[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:09:42 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 79bfb1fa35957239b9185f90dfe965a13d2842b8
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 6 06:26:16 2003 +0000

            Reviewed by Maciej.
    
            - fixed 3475109 -- support keyboard event object properties of altkey, ctrlKey, shiftKey
    
            We had the DOM Level 3 KeyboardEvent class already; I just had to add JavaScript bindings.
    
            * khtml/ecma/kjs_events.h: Added DOMKeyboardEvent class.
            * khtml/ecma/kjs_events.cpp:
            (KJS::getDOMEvent): Added code to make a DOMKeyboardEvent if the event is a DOM::KeyboardEvent.
            (DOMKeyboardEvent::~DOMKeyboardEvent): Added.
            (DOMKeyboardEvent::classInfo): Added.
            (DOMKeyboardEvent::tryGet): Added.
            (DOMKeyboardEvent::getValueProperty): Added.
            (DOMKeyboardEventProtoFunc::tryCall): Added.
    
            * khtml/dom/dom2_events.cpp:
            (KeyboardEvent::keyIdentifier): Added.
            (KeyboardEvent::keyLocation): Added.
    
            * khtml/ecma/kjs_events.lut.h: Regenerated.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5402 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 69f4a80..08041b0 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,26 @@
+2003-11-05  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed 3475109 -- support keyboard event object properties of altkey, ctrlKey, shiftKey
+
+        We had the DOM Level 3 KeyboardEvent class already; I just had to add JavaScript bindings.
+
+        * khtml/ecma/kjs_events.h: Added DOMKeyboardEvent class.
+        * khtml/ecma/kjs_events.cpp:
+        (KJS::getDOMEvent): Added code to make a DOMKeyboardEvent if the event is a DOM::KeyboardEvent.
+        (DOMKeyboardEvent::~DOMKeyboardEvent): Added.
+        (DOMKeyboardEvent::classInfo): Added.
+        (DOMKeyboardEvent::tryGet): Added.
+        (DOMKeyboardEvent::getValueProperty): Added.
+        (DOMKeyboardEventProtoFunc::tryCall): Added.
+
+        * khtml/dom/dom2_events.cpp:
+        (KeyboardEvent::keyIdentifier): Added.
+        (KeyboardEvent::keyLocation): Added.
+
+        * khtml/ecma/kjs_events.lut.h: Regenerated.
+
 2003-11-05  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/khtml/dom/dom2_events.cpp b/WebCore/khtml/dom/dom2_events.cpp
index acc2de3..240b622 100644
--- a/WebCore/khtml/dom/dom2_events.cpp
+++ b/WebCore/khtml/dom/dom2_events.cpp
@@ -633,7 +633,7 @@ void MutationEvent::initMutationEvent(const DOMString &typeArg,
 
 // -----------------------------------------------------------------------------
 
-KeyboardEvent::KeyboardEvent() : UIEvent()
+KeyboardEvent::KeyboardEvent()
 {
 }
 
@@ -641,9 +641,9 @@ KeyboardEvent::KeyboardEvent(const KeyboardEvent &other) : UIEvent(other)
 {
 }
 
-KeyboardEvent::KeyboardEvent(const Event &other) : UIEvent()
+KeyboardEvent::KeyboardEvent(const Event &other)
 {
-    (*this)=other;
+    *this = other;
 }
 
 KeyboardEvent::KeyboardEvent(KeyboardEventImpl *impl) : UIEvent(impl)
@@ -672,6 +672,22 @@ KeyboardEvent::~KeyboardEvent()
 {
 }
 
+DOMString KeyboardEvent::keyIdentifier() const
+{
+    if (!impl)
+	throw DOMException(DOMException::INVALID_STATE_ERR);
+
+    return static_cast<KeyboardEventImpl*>(impl)->keyIdentifier();
+}
+
+unsigned long KeyboardEvent::keyLocation() const
+{
+    if (!impl)
+	throw DOMException(DOMException::INVALID_STATE_ERR);
+
+    return static_cast<KeyboardEventImpl*>(impl)->keyLocation();
+}
+
 bool KeyboardEvent::ctrlKey() const
 {
     if (!impl)
diff --git a/WebCore/khtml/ecma/kjs_events.cpp b/WebCore/khtml/ecma/kjs_events.cpp
index 04aaf20..2bf7f7c 100644
--- a/WebCore/khtml/ecma/kjs_events.cpp
+++ b/WebCore/khtml/ecma/kjs_events.cpp
@@ -33,6 +33,8 @@
 
 using namespace KJS;
 
+using DOM::KeyboardEvent;
+
 // -------------------------------------------------------------------------
 
 JSEventListener::JSEventListener(Object _listener, const Object &_win, bool _html)
@@ -304,7 +306,9 @@ Value KJS::getDOMEvent(ExecState *exec, DOM::Event e)
     return Value(ret);
 
   DOM::DOMString module = e.eventModuleName();
-  if (module == "UIEvents")
+  if (e.handle()->isKeyboardEvent())
+    ret = new DOMKeyboardEvent(exec, static_cast<DOM::KeyboardEvent>(e));
+  else if (module == "UIEvents")
     ret = new DOMUIEvent(exec, static_cast<DOM::UIEvent>(e));
   else if (module == "MouseEvents")
     ret = new DOMMouseEvent(exec, static_cast<DOM::MouseEvent>(e));
@@ -571,6 +575,94 @@ Value DOMMouseEventProtoFunc::tryCall(ExecState *exec, Object &thisObj, const Li
 
 // -------------------------------------------------------------------------
 
+const ClassInfo DOMKeyboardEvent::info = { "KeyboardEvent", &DOMUIEvent::info, &DOMKeyboardEventTable, 0 };
+
+/*
+ at begin DOMKeyboardEventTable 5
+  keyIdentifier	DOMKeyboardEvent::KeyIdentifier	DontDelete|ReadOnly
+  keyLocation	DOMKeyboardEvent::KeyLocation	DontDelete|ReadOnly
+  ctrlKey	DOMKeyboardEvent::CtrlKey	DontDelete|ReadOnly
+  shiftKey	DOMKeyboardEvent::ShiftKey	DontDelete|ReadOnly
+  altKey	DOMKeyboardEvent::AltKey	DontDelete|ReadOnly
+  metaKey	DOMKeyboardEvent::MetaKey	DontDelete|ReadOnly
+  altGraphKey	DOMKeyboardEvent::AltGraphKey	DontDelete|ReadOnly
+ at end
+ at begin DOMKeyboardEventProtoTable 1
+  initKeyboardEvent	DOMKeyboardEvent::InitKeyboardEvent	DontDelete|Function 11
+ at end
+*/
+DEFINE_PROTOTYPE("DOMKeyboardEvent", DOMKeyboardEventProto)
+IMPLEMENT_PROTOFUNC(DOMKeyboardEventProtoFunc)
+IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMKeyboardEventProto, DOMKeyboardEventProtoFunc, DOMUIEventProto)
+
+DOMKeyboardEvent::~DOMKeyboardEvent()
+{
+}
+
+const ClassInfo* DOMKeyboardEvent::classInfo() const
+{
+    return &info;
+}
+
+Value DOMKeyboardEvent::tryGet(ExecState *exec, const Identifier &p) const
+{
+#ifdef KJS_VERBOSE
+  kdDebug(6070) << "DOMKeyboardEvent::tryGet " << p.qstring() << endl;
+#endif
+  return DOMObjectLookupGetValue<DOMKeyboardEvent, DOMUIEvent>(exec, p, &DOMKeyboardEventTable, this);
+}
+
+Value DOMKeyboardEvent::getValueProperty(ExecState *exec, int token) const
+{
+  switch (token) {
+  case KeyIdentifier:
+    return String(static_cast<KeyboardEvent>(event).keyIdentifier());
+  case KeyLocation:
+    return Number(static_cast<KeyboardEvent>(event).keyLocation());
+  case CtrlKey:
+    return Boolean(static_cast<KeyboardEvent>(event).ctrlKey());
+  case ShiftKey:
+    return Boolean(static_cast<KeyboardEvent>(event).shiftKey());
+  case AltKey:
+    return Boolean(static_cast<KeyboardEvent>(event).altKey());
+  case MetaKey:
+    return Boolean(static_cast<KeyboardEvent>(event).metaKey());
+  case AltGraphKey:
+    return Boolean(static_cast<KeyboardEvent>(event).altGraphKey());
+  default:
+    kdWarning() << "Unhandled token in DOMKeyboardEvent::getValueProperty : " << token << endl;
+    return Value();
+  }
+}
+
+Value DOMKeyboardEventProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
+{
+  if (!thisObj.inherits(&DOMKeyboardEvent::info)) {
+    Object err = Error::create(exec,TypeError);
+    exec->setException(err);
+    return err;
+  }
+  KeyboardEvent event = static_cast<DOMKeyboardEvent *>(thisObj.imp())->toKeyboardEvent();
+  switch (id) {
+    case DOMKeyboardEvent::InitKeyboardEvent:
+      event.initKeyboardEvent(args[0].toString(exec).string(), // typeArg
+                              args[1].toBoolean(exec), // canBubbleArg
+                              args[2].toBoolean(exec), // cancelableArg
+                              toAbstractView(args[3]), // viewArg
+                              args[4].toString(exec).string(), // keyIdentifier
+                              args[5].toInteger(exec), // keyLocationArg
+                              args[6].toBoolean(exec), // ctrlKeyArg
+                              args[7].toBoolean(exec), // altKeyArg
+                              args[8].toBoolean(exec), // shiftKeyArg
+                              args[9].toBoolean(exec), // metaKeyArg
+                              args[10].toBoolean(exec)); // altGraphKeyArg
+      return Undefined();
+  }
+  return Undefined();
+}
+
+// -------------------------------------------------------------------------
+
 const ClassInfo MutationEventConstructor::info = { "MutationEventConstructor", 0, &MutationEventConstructorTable, 0 };
 /*
 @begin MutationEventConstructorTable 3
diff --git a/WebCore/khtml/ecma/kjs_events.h b/WebCore/khtml/ecma/kjs_events.h
index 3ce499e..3d59868 100644
--- a/WebCore/khtml/ecma/kjs_events.h
+++ b/WebCore/khtml/ecma/kjs_events.h
@@ -128,6 +128,19 @@ namespace KJS {
     DOM::MouseEvent toMouseEvent() const { return static_cast<DOM::MouseEvent>(event); }
   };
 
+  class DOMKeyboardEvent : public DOMUIEvent {
+  public:
+    DOMKeyboardEvent(ExecState *exec, DOM::KeyboardEvent ke) : DOMUIEvent(exec, ke) {}
+    ~DOMKeyboardEvent();
+    virtual Value tryGet(ExecState *exec, const Identifier &p) const;
+    Value getValueProperty(ExecState *, int token) const;
+    // no put - all read-only
+    virtual const ClassInfo* classInfo() const;
+    static const ClassInfo info;
+    enum { KeyIdentifier, KeyLocation, CtrlKey, ShiftKey, AltKey, MetaKey, AltGraphKey, InitKeyboardEvent};
+    DOM::KeyboardEvent toKeyboardEvent() const { return event; }
+  };
+
   // Constructor object MutationEvent
   class MutationEventConstructor : public DOMObject {
   public:
diff --git a/WebCore/khtml/ecma/kjs_events.lut.h b/WebCore/khtml/ecma/kjs_events.lut.h
index db9a201..4ddcd52 100644
--- a/WebCore/khtml/ecma/kjs_events.lut.h
+++ b/WebCore/khtml/ecma/kjs_events.lut.h
@@ -141,6 +141,33 @@ const struct HashTable DOMMouseEventProtoTable = { 2, 1, DOMMouseEventProtoTable
 
 namespace KJS {
 
+const struct HashEntry DOMKeyboardEventTableEntries[] = {
+   { "metaKey", DOMKeyboardEvent::MetaKey, DontDelete|ReadOnly, 0, 0 },
+   { "keyIdentifier", DOMKeyboardEvent::KeyIdentifier, DontDelete|ReadOnly, 0, &DOMKeyboardEventTableEntries[7] },
+   { 0, 0, 0, 0, 0 },
+   { "altKey", DOMKeyboardEvent::AltKey, DontDelete|ReadOnly, 0, 0 },
+   { "keyLocation", DOMKeyboardEvent::KeyLocation, DontDelete|ReadOnly, 0, &DOMKeyboardEventTableEntries[5] },
+   { "ctrlKey", DOMKeyboardEvent::CtrlKey, DontDelete|ReadOnly, 0, &DOMKeyboardEventTableEntries[6] },
+   { "shiftKey", DOMKeyboardEvent::ShiftKey, DontDelete|ReadOnly, 0, 0 },
+   { "altGraphKey", DOMKeyboardEvent::AltGraphKey, DontDelete|ReadOnly, 0, 0 }
+};
+
+const struct HashTable DOMKeyboardEventTable = { 2, 8, DOMKeyboardEventTableEntries, 5 };
+
+} // namespace
+
+namespace KJS {
+
+const struct HashEntry DOMKeyboardEventProtoTableEntries[] = {
+   { "initKeyboardEvent", DOMKeyboardEvent::InitKeyboardEvent, DontDelete|Function, 11, 0 }
+};
+
+const struct HashTable DOMKeyboardEventProtoTable = { 2, 1, DOMKeyboardEventProtoTableEntries, 1 };
+
+} // namespace
+
+namespace KJS {
+
 const struct HashEntry MutationEventConstructorTableEntries[] = {
    { "ADDITION", DOM::MutationEvent::ADDITION, DontDelete|ReadOnly, 0, &MutationEventConstructorTableEntries[3] },
    { "MODIFICATION", DOM::MutationEvent::MODIFICATION, DontDelete|ReadOnly, 0, 0 },

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list