Reviewed by Oliver.
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2007 02:40:00 +0000 (02:40 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2007 02:40:00 +0000 (02:40 +0000)
        Patch for http://bugs.webkit.org/show_bug.cgi?id=14109
        Cleanup JSEvent and JSClipboard in preperation for autogeneration

        * bindings/js/kjs_events.cpp:
        (KJS::DOMEvent::DOMEvent):
        (KJS::DOMEvent::getValueProperty):
        (KJS::DOMEvent::put):
        (KJS::DOMEvent::putValueProperty):
        (KJS::DOMEventPrototypeFunction::callAsFunction):
        (KJS::toJS):
        (KJS::toEvent):
        (KJS::):
        (KJS::JSClipboard::JSClipboard):
        (KJS::JSClipboard::~JSClipboard):
        (KJS::JSClipboard::getOwnPropertySlot):
        (KJS::JSClipboard::getValueProperty):
        (KJS::JSClipboard::put):
        (KJS::JSClipboard::putValueProperty):
        (KJS::JSClipboardPrototypeFunction::callAsFunction):
        (KJS::toClipboard):
        * bindings/js/kjs_events.h:
        (KJS::DOMEvent::):
        (KJS::DOMEvent::impl):
        (KJS::JSClipboard::impl):
        * dom/ClipboardEvent.h:
        * dom/Event.h:
        (WebCore::Event::srcElement):
        (WebCore::Event::returnValue):
        (WebCore::Event::clipboardData):
        (WebCore::Event::dataTransfer):
        (WebCore::Event::clipboard):
        * dom/MouseEvent.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23471 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bindings/js/kjs_events.cpp
WebCore/bindings/js/kjs_events.h
WebCore/dom/ClipboardEvent.h
WebCore/dom/Event.h
WebCore/dom/MouseEvent.h

index 281888c5384a03b6d38581cbd8ce4564ea7a2986..6ee4f4891b675339f5c994aad851a11a8e636921 100644 (file)
@@ -1,3 +1,40 @@
+2007-06-12  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        Patch for http://bugs.webkit.org/show_bug.cgi?id=14109
+        Cleanup JSEvent and JSClipboard in preperation for autogeneration
+
+        * bindings/js/kjs_events.cpp:
+        (KJS::DOMEvent::DOMEvent):
+        (KJS::DOMEvent::getValueProperty):
+        (KJS::DOMEvent::put):
+        (KJS::DOMEvent::putValueProperty):
+        (KJS::DOMEventPrototypeFunction::callAsFunction):
+        (KJS::toJS):
+        (KJS::toEvent):
+        (KJS::):
+        (KJS::JSClipboard::JSClipboard):
+        (KJS::JSClipboard::~JSClipboard):
+        (KJS::JSClipboard::getOwnPropertySlot):
+        (KJS::JSClipboard::getValueProperty):
+        (KJS::JSClipboard::put):
+        (KJS::JSClipboard::putValueProperty):
+        (KJS::JSClipboardPrototypeFunction::callAsFunction):
+        (KJS::toClipboard):
+        * bindings/js/kjs_events.h:
+        (KJS::DOMEvent::):
+        (KJS::DOMEvent::impl):
+        (KJS::JSClipboard::impl):
+        * dom/ClipboardEvent.h:
+        * dom/Event.h:
+        (WebCore::Event::srcElement):
+        (WebCore::Event::returnValue):
+        (WebCore::Event::clipboardData):
+        (WebCore::Event::dataTransfer):
+        (WebCore::Event::clipboard):
+        * dom/MouseEvent.h:
+
 2007-06-13  Lars Knoll <lars@trolltech.com>
 
         Reviewed by Niko.
index 0584bd6df330f89819927c63a209480662d3ec7d..39912ec0a90149fc4d293eaa774260923472b22b 100644 (file)
@@ -387,8 +387,8 @@ const ClassInfo DOMEvent::info = { "Event", 0, &DOMEventTable, 0 };
 KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMEventPrototypeFunction)
 KJS_IMPLEMENT_PROTOTYPE("DOMEvent", DOMEventPrototype, DOMEventPrototypeFunction)
 
-DOMEvent::DOMEvent(ExecState *exec, Event *e)
-  : m_impl(e), clipboard(0) 
+DOMEvent::DOMEvent(ExecState* exec, Event* event)
+    : m_impl(event)
 {
     setPrototype(DOMEventPrototype::self(exec));
 }
@@ -398,183 +398,170 @@ DOMEvent::~DOMEvent()
     ScriptInterpreter::forgetDOMObject(m_impl.get());
 }
 
-// pass marks through to JS objects we hold during garbage collection
-void DOMEvent::mark()
+bool DOMEvent::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 {
-    DOMObject::mark();
-    if (clipboard && !clipboard->marked())
-        clipboard->mark();
+    return getStaticValueSlot<DOMEvent, DOMObject>(exec, &DOMEventTable, this, propertyName, slot);
 }
 
-bool DOMEvent::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+JSValue* DOMEvent::getValueProperty(ExecState* exec, int token) const
 {
-    return getStaticValueSlot<DOMEvent, DOMObject>(exec, &DOMEventTable, this, propertyName, slot);
+    Event* event = impl();
+    switch (token) {
+        case Type:
+            return jsString(event->type());
+        case Target:
+            return toJS(exec, event->target());
+        case SrcElement:
+            return toJS(exec, event->srcElement());
+        case CurrentTarget:
+            return toJS(exec, event->currentTarget());
+        case EventPhase:
+            return jsNumber(event->eventPhase());
+        case Bubbles:
+            return jsBoolean(event->bubbles());
+        case CancelBubble:
+            return jsBoolean(event->cancelBubble());
+        case ReturnValue:
+            return jsBoolean(event->returnValue());
+        case Cancelable:
+            return jsBoolean(event->cancelable());
+        case TimeStamp:
+            return jsNumber(event->timeStamp());
+        case ClipboardData:
+            if (event->isClipboardEvent())
+                return toJS(exec, event->clipboardData());
+            return jsUndefined();
+        case DataTransfer:
+            if (event->isDragEvent())
+                return toJS(exec, event->dataTransfer());
+            return jsUndefined();
+        default:
+            return 0;
+    }
 }
 
-JSValue *DOMEvent::getValueProperty(ExecState *exec, int token) const
-{
-  Event &event = *m_impl;
-  switch (token) {
-  case Type:
-    return jsString(event.type());
-  case Target:
-  case SrcElement: /*MSIE extension - "the object that fired the event"*/
-    return toJS(exec, event.target());
-  case CurrentTarget:
-    return toJS(exec, event.currentTarget());
-  case EventPhase:
-    return jsNumber(event.eventPhase());
-  case Bubbles:
-    return jsBoolean(event.bubbles());
-  case CancelBubble:
-    return jsBoolean(event.cancelBubble());
-  case ReturnValue:
-    return jsBoolean(!event.defaultPrevented());
-  case Cancelable:
-    return jsBoolean(event.cancelable());
-  case TimeStamp:
-    return jsNumber(event.timeStamp());
-  case ClipboardData:
-  {
-    if (event.isClipboardEvent()) {
-      ClipboardEvent *impl = static_cast<ClipboardEvent *>(&event);
-      if (!clipboard)
-        clipboard = new Clipboard(exec, impl->clipboard());
-      return clipboard;
-    } else
-      return jsUndefined();
-  }
-  case DataTransfer:
-  {
-    if (event.isDragEvent()) {
-      MouseEvent *impl = static_cast<MouseEvent *>(&event);
-      if (!clipboard)
-        clipboard = new Clipboard(exec, impl->clipboard());
-      return clipboard;
-    } else
-      return jsUndefined();
-  }
-  default:
-    return 0;
-  }
-}
-
-void DOMEvent::put(ExecState *exec, const Identifier &propertyName,
-                      JSValue *value, int attr)
+void DOMEvent::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
 {
     lookupPut<DOMEvent, DOMObject>(exec, propertyName, value, attr, &DOMEventTable, this);
 }
 
-void DOMEvent::putValueProperty(ExecState *exec, int token, JSValue *value, int)
-{
-  Event &event = *m_impl;
-  switch (token) {
-  case ReturnValue:
-    event.setDefaultPrevented(!value->toBoolean(exec));
-    break;
-  case CancelBubble:
-    event.setCancelBubble(value->toBoolean(exec));
-    break;
-  default:
-    break;
-  }
-}
-
-JSValue *DOMEventPrototypeFunction::callAsFunction(ExecState *exec, JSObject * thisObj, const List &args)
-{
-  if (!thisObj->inherits(&DOMEvent::info))
-    return throwError(exec, TypeError);
-  Event &event = *static_cast<DOMEvent *>( thisObj )->impl();
-  switch (id) {
-    case DOMEvent::StopPropagation:
-      event.stopPropagation();
-      return jsUndefined();
-    case DOMEvent::PreventDefault:
-      event.preventDefault();
-      return jsUndefined();
-    case DOMEvent::InitEvent:
-      event.initEvent(AtomicString(args[0]->toString(exec)), args[1]->toBoolean(exec), args[2]->toBoolean(exec));
-      return jsUndefined();
+void DOMEvent::putValueProperty(ExecState* exec, int token, JSValue* value, int)
+{
+    Event* event = m_impl.get();
+    switch (token) {
+        case ReturnValue:
+            event->setDefaultPrevented(!value->toBoolean(exec));
+            break;
+        case CancelBubble:
+            event->setCancelBubble(value->toBoolean(exec));
+            break;
+        default:
+            break;
+    }
+}
+
+JSValue* DOMEventPrototypeFunction::callAsFunction(ExecState *exec, JSObject * thisObj, const List &args)
+{
+    if (!thisObj->inherits(&DOMEvent::info))
+        return throwError(exec, TypeError);
+
+    Event* event = static_cast<DOMEvent*>(thisObj)->impl();
+    switch (id) {
+        case DOMEvent::StopPropagation:
+            event->stopPropagation();
+            return jsUndefined();
+        case DOMEvent::PreventDefault:
+            event->preventDefault();
+            return jsUndefined();
+        case DOMEvent::InitEvent:
+            event->initEvent(AtomicString(args[0]->toString(exec)), args[1]->toBoolean(exec), args[2]->toBoolean(exec));
+            return jsUndefined();
   };
   return jsUndefined();
 }
 
-JSValue* toJS(ExecState* exec, Event* e)
+JSValue* toJS(ExecState* exec, Event* event)
 {
-  if (!e)
-    return jsNull();
+    if (!event)
+        return jsNull();
 
-  ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter());
-
-  JSLock lock;
-
-  DOMObject* ret = interp->getDOMObject(e);
-  if (!ret) {
-    if (e->isKeyboardEvent())
-      ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent*>(e));
-    else if (e->isTextEvent())
-      ret = new JSTextEvent(exec, static_cast<TextEvent*>(e));
-    else if (e->isMouseEvent())
-      ret = new JSMouseEvent(exec, static_cast<MouseEvent*>(e));
-    else if (e->isWheelEvent())
-      ret = new JSWheelEvent(exec, static_cast<WheelEvent*>(e));
-    else if (e->isUIEvent())
-      ret = new JSUIEvent(exec, static_cast<UIEvent*>(e));
-    else if (e->isMutationEvent())
-      ret = new JSMutationEvent(exec, static_cast<MutationEvent*>(e));
-    else if (e->isOverflowEvent())
-      ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(e));
-    else
-      ret = new JSEvent(exec, e);
+    ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter());
 
-    interp->putDOMObject(e, ret);
-  }
+    JSLock lock;
+
+    DOMObject* ret = interp->getDOMObject(event);
+    if (ret)
+        return ret;
+
+    if (event->isKeyboardEvent())
+        ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent*>(event));
+    else if (event->isTextEvent())
+        ret = new JSTextEvent(exec, static_cast<TextEvent*>(event));
+    else if (event->isMouseEvent())
+        ret = new JSMouseEvent(exec, static_cast<MouseEvent*>(event));
+    else if (event->isWheelEvent())
+        ret = new JSWheelEvent(exec, static_cast<WheelEvent*>(event));
+    else if (event->isUIEvent())
+        ret = new JSUIEvent(exec, static_cast<UIEvent*>(event));
+    else if (event->isMutationEvent())
+        ret = new JSMutationEvent(exec, static_cast<MutationEvent*>(event));
+    else if (event->isOverflowEvent())
+        ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(event));
+    else
+        ret = new JSEvent(exec, event);
 
-  return ret;
+    interp->putDOMObject(event, ret);
+    return ret;
 }
 
-Event *toEvent(JSValue *val)
+Event* toEvent(JSValue* val)
 {
     if (!val || !val->isObject(&DOMEvent::info))
         return 0;
-    return static_cast<DOMEvent *>(val)->impl();
+    return static_cast<DOMEvent*>(val)->impl();
 }
 
 // -------------------------------------------------------------------------
 
-const ClassInfo Clipboard::info = { "Clipboard", 0, &ClipboardTable, 0 };
+const ClassInfo JSClipboard::info = { "Clipboard", 0, &JSClipboardTable, 0 };
 
-/* Source for ClipboardTable. Use "make hashtables" to regenerate.
-@begin ClipboardTable 3
-  dropEffect    Clipboard::DropEffect   DontDelete
-  effectAllowed Clipboard::EffectAllowed        DontDelete
-  types         Clipboard::Types        DontDelete|ReadOnly
+/* Source for JSClipboardTable. Use "make hashtables" to regenerate.
+@begin JSClipboardTable 3
+  dropEffect    JSClipboard::DropEffect   DontDelete
+  effectAllowed JSClipboard::EffectAllowed        DontDelete
+  types         JSClipboard::Types        DontDelete|ReadOnly
 @end
-@begin ClipboardPrototypeTable 4
-  clearData     Clipboard::ClearData    DontDelete|Function 0
-  getData       Clipboard::GetData      DontDelete|Function 1
-  setData       Clipboard::SetData      DontDelete|Function 2
-  setDragImage  Clipboard::SetDragImage DontDelete|Function 3
+@begin JSClipboardPrototypeTable 4
+  clearData     JSClipboard::ClearData    DontDelete|Function 0
+  getData       JSClipboard::GetData      DontDelete|Function 1
+  setData       JSClipboard::SetData      DontDelete|Function 2
+  setDragImage  JSClipboard::SetDragImage DontDelete|Function 3
 @end
 */
 
-KJS_DEFINE_PROTOTYPE(ClipboardPrototype)
-KJS_IMPLEMENT_PROTOTYPE_FUNCTION(ClipboardPrototypeFunction)
-KJS_IMPLEMENT_PROTOTYPE("Clipboard", ClipboardPrototype, ClipboardPrototypeFunction)
+KJS_DEFINE_PROTOTYPE(JSClipboardPrototype)
+KJS_IMPLEMENT_PROTOTYPE_FUNCTION(JSClipboardPrototypeFunction)
+KJS_IMPLEMENT_PROTOTYPE("Clipboard", JSClipboardPrototype, JSClipboardPrototypeFunction)
 
-Clipboard::Clipboard(ExecState *exec, WebCore::Clipboard *cb)
-  : clipboard(cb)
+JSClipboard::JSClipboard(ExecState* exec, WebCore::Clipboard* cb)
+    : m_impl(cb)
 {
-    setPrototype(ClipboardPrototype::self(exec));
+    setPrototype(JSClipboardPrototype::self(exec));
 }
 
-bool Clipboard::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+JSClipboard::~JSClipboard()
 {
-    return getStaticValueSlot<Clipboard, DOMObject>(exec, &ClipboardTable, this, propertyName, slot);
+    ScriptInterpreter::forgetDOMObject(m_impl.get());
 }
 
-JSValue *Clipboard::getValueProperty(ExecState *exec, int token) const
+bool JSClipboard::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
+    return getStaticValueSlot<JSClipboard, DOMObject>(exec, &JSClipboardTable, this, propertyName, slot);
+}
+
+JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const
+{
+    WebCore::Clipboard* clipboard = impl();
     switch (token) {
         case DropEffect:
             ASSERT(clipboard->isForDragging() || clipboard->dropEffect().isNull());
@@ -586,27 +573,28 @@ JSValue *Clipboard::getValueProperty(ExecState *exec, int token) const
         {
             HashSet<String> types = clipboard->types();
             if (types.isEmpty())
-                return jsNull(); 
+                return jsNull();
             else {
                 List list;
                 HashSet<String>::const_iterator end = types.end();
-                for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it) 
+                for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
                     list.append(jsString(UString(*it)));
                 return exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
             }
         }
         default:
-            return NULL;
+            return 0;
     }
 }
 
-void Clipboard::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void JSClipboard::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
 {
-    lookupPut<Clipboard,DOMObject>(exec, propertyName, value, attr, &ClipboardTable, this );
+    lookupPut<JSClipboard, DOMObject>(exec, propertyName, value, attr, &JSClipboardTable, this );
 }
 
-void Clipboard::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
+void JSClipboard::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
 {
+    WebCore::Clipboard* clipboard = impl();
     switch (token) {
         case DropEffect:
             // can never set this when not for dragging, thus getting always returns NULL string
@@ -621,52 +609,50 @@ void Clipboard::putValueProperty(ExecState *exec, int token, JSValue *value, int
     }
 }
 
-JSValue *ClipboardPrototypeFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
+JSValue* JSClipboardPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
 {
-    if (!thisObj->inherits(&Clipboard::info))
+    if (!thisObj->inherits(&JSClipboard::info))
         return throwError(exec, TypeError);
 
-    Clipboard *cb = static_cast<Clipboard *>(thisObj);
+    WebCore::Clipboard* clipboard = static_cast<JSClipboard*>(thisObj)->impl();
     switch (id) {
-        case Clipboard::ClearData:
+        case JSClipboard::ClearData:
             if (args.size() == 0) {
-                cb->clipboard->clearAllData();
+                clipboard->clearAllData();
                 return jsUndefined();
             } else if (args.size() == 1) {
-                cb->clipboard->clearData(args[0]->toString(exec));
+                clipboard->clearData(args[0]->toString(exec));
                 return jsUndefined();
             } else
                 return throwError(exec, SyntaxError, "clearData: Invalid number of arguments");
-        case Clipboard::GetData:
+        case JSClipboard::GetData:
         {
             if (args.size() == 1) {
                 bool success;
-                String result = cb->clipboard->getData(args[0]->toString(exec), success);
+                String result = clipboard->getData(args[0]->toString(exec), success);
                 if (success)
                     return jsString(result);
-                else
-                    return jsUndefined();
+                return jsUndefined();
             } else
                 return throwError(exec, SyntaxError, "getData: Invalid number of arguments");
         }
-        case Clipboard::SetData:
+        case JSClipboard::SetData:
             if (args.size() == 2)
-                return jsBoolean(cb->clipboard->setData(args[0]->toString(exec), args[1]->toString(exec)));
-            else
-                return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
-        case Clipboard::SetDragImage:
+                return jsBoolean(clipboard->setData(args[0]->toString(exec), args[1]->toString(exec)));
+            return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
+        case JSClipboard::SetDragImage:
         {
-            if (!cb->clipboard->isForDragging())
+            if (!clipboard->isForDragging())
                 return jsUndefined();
 
             if (args.size() != 3)
                 return throwError(exec, SyntaxError, "setDragImage: Invalid number of arguments");
 
-            int x = (int)args[1]->toNumber(exec);
-            int y = (int)args[2]->toNumber(exec);
+            int x = static_cast<int>(args[1]->toNumber(exec));
+            int y = static_cast<int>(args[2]->toNumber(exec));
 
             // See if they passed us a node
-            Node *node = toNode(args[0]);
+            Nodenode = toNode(args[0]);
             if (!node)
                 return throwError(exec, TypeError);
             
@@ -675,9 +661,9 @@ JSValue *ClipboardPrototypeFunction::callAsFunction(ExecState *exec, JSObject *t
 
             if (static_cast<Element*>(node)->hasLocalName(imgTag) && 
                 !node->inDocument())
-                cb->clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
+                clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
             else
-                cb->clipboard->setDragImageElement(node, IntPoint(x, y));                    
+                clipboard->setDragImageElement(node, IntPoint(x, y));                    
                 
             return jsUndefined();
         }
@@ -685,4 +671,14 @@ JSValue *ClipboardPrototypeFunction::callAsFunction(ExecState *exec, JSObject *t
     return jsUndefined();
 }
 
+JSValue* toJS(ExecState* exec, WebCore::Clipboard* obj)
+{
+    return cacheDOMObject<WebCore::Clipboard, JSClipboard>(exec, obj);
+}
+
+WebCore::Clipboard* toClipboard(JSValue* val)
+{
+    return val->isObject(&JSClipboard::info) ? static_cast<JSClipboard*>(val)->impl() : 0;
+}
+
 }
index 7ecb5e919a69ce770ff55270d8c5fbf73ed2c2f4..13d0f0c3e4931f49f93bb6fe8dc67885d11205df 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 namespace KJS {
 
     class Window;
-    class Clipboard;
+    class JSClipboard;
     
     class JSAbstractEventListener : public WebCore::EventListener {
     public:
@@ -98,45 +98,61 @@ namespace KJS {
     public:
         DOMEvent(ExecState*, WebCore::Event*);
         virtual ~DOMEvent();
+
         virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
         JSValue* getValueProperty(ExecState*, int token) const;
         virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
-        void putValueProperty(ExecState*, int token, JSValue*, int);
+        void putValueProperty(ExecState*, int token, JSValue*, int attr);
+
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
-        enum { Type, Target, CurrentTarget, EventPhase, Bubbles,
-               Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
-               // MS IE equivalents
-               SrcElement, ReturnValue, CancelBubble, ClipboardData, DataTransfer };
-        WebCore::Event *impl() const { return m_impl.get(); }
-        virtual void mark();
+
+        enum { 
+            Type, Target, CurrentTarget, EventPhase,
+            Bubbles, Cancelable, TimeStamp, StopPropagation,
+            PreventDefault, InitEvent,
+
+            // MS IE equivalents
+            SrcElement, ReturnValue, CancelBubble, ClipboardData,
+            DataTransfer
+        };
+
+        WebCore::Event* impl() const { return m_impl.get(); }
+
     protected:
         RefPtr<WebCore::Event> m_impl;
-        mutable Clipboard* clipboard;
     };
 
     JSValue* toJS(ExecState*, WebCore::Event*);
-
     WebCore::Event* toEvent(JSValue*); // returns 0 if value is not a DOMEvent object
 
     KJS_DEFINE_PROTOTYPE(DOMEventPrototype)
 
-    class Clipboard : public DOMObject {
-    friend class ClipboardPrototypeFunction;
+    class JSClipboard : public DOMObject {
+        friend class JSClipboardPrototypeFunction;
     public:
-        Clipboard(ExecState*, WebCore::Clipboard *ds);
+        JSClipboard(ExecState*, WebCore::Clipboard* ds);
+        virtual ~JSClipboard();
+
         virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
         JSValue* getValueProperty(ExecState*, int token) const;
         virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
         void putValueProperty(ExecState*, int token, JSValue*, int attr);
-        virtual bool toBoolean(ExecState*) const { return true; }
+
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
+
         enum { ClearData, GetData, SetData, Types, SetDragImage, DropEffect, EffectAllowed };
+
+        WebCore::Clipboard* impl() const { return m_impl.get(); }
+
     private:
-        RefPtr<WebCore::Clipboard> clipboard;
+        RefPtr<WebCore::Clipboard> m_impl;
     };
 
+    JSValue* toJS(ExecState*, WebCore::Clipboard*);
+    WebCore::Clipboard* toClipboard(JSValue*);
+
 } // namespace
 
 #endif
index 1999cac4fb5162ded36e426177d3dd4699d1f886..9d27a5e39152cfb71d94bcd3142ad61199b1ad31 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -37,7 +37,9 @@ namespace WebCore {
         ClipboardEvent(const AtomicString& type, bool canBubbleArg, bool cancelableArg, Clipboard* clipboardArg);
 
         Clipboard* clipboard() const { return m_clipboard.get(); }
+
         virtual bool isClipboardEvent() const;
+
     private:
         RefPtr<Clipboard> m_clipboard;
     };
index d6a28e83c6d734862843fdab84d08decbb791599..5f1fb100fcb0c007367f47f5968c58f8399c9ec5 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -32,6 +32,8 @@
 
 namespace WebCore {
 
+    class Clipboard;
+
     // FIXME: this should probably defined elsewhere.
     typedef unsigned long long DOMTimeStamp;
 
@@ -89,6 +91,12 @@ namespace WebCore {
         DOMTimeStamp timeStamp() { return m_createTime; }
         void stopPropagation() { m_propagationStopped = true; }
 
+        // IE Extensions
+        EventTarget* srcElement() const { return target(); } // MSIE extension - "the object that fired the event"
+        bool returnValue() const { return !m_defaultPrevented; }
+        Clipboard* clipboardData() const { return isClipboardEvent() ? clipboard() : 0; }
+        Clipboard* dataTransfer() const { return isMouseEvent() ? clipboard() : 0; }
+
         virtual bool isUIEvent() const;
         virtual bool isMouseEvent() const;
         virtual bool isMutationEvent() const;
@@ -121,6 +129,8 @@ namespace WebCore {
         virtual bool storesResultAsString() const;
         virtual void storeResult(const String&);
 
+        virtual Clipboard* clipboard() const { return 0; }
+
     protected:
         virtual void receivedTarget();
         bool dispatched() const { return m_target; }
index 84bb0e1ad01371da4f9e77995226b37246f8c6a4..8cf07614516aa532d58dff332e6765712353d147 100644 (file)
@@ -52,8 +52,9 @@ namespace WebCore {
         unsigned short button() const { return m_button; }
         bool buttonDown() const { return m_buttonDown; }
         EventTargetNode* relatedTarget() const { return m_relatedTarget.get(); }
+
         Clipboard* clipboard() const { return m_clipboard.get(); }
-        
+
         Node* toElement() const;
         Node* fromElement() const;