Changeset 23471 in webkit


Ignore:
Timestamp:
Jun 12, 2007 7:40:00 PM (17 years ago)
Author:
weinig
Message:

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:
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r23469 r23471  
     12007-06-12  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Oliver.
     4
     5        Patch for http://bugs.webkit.org/show_bug.cgi?id=14109
     6        Cleanup JSEvent and JSClipboard in preperation for autogeneration
     7
     8        * bindings/js/kjs_events.cpp:
     9        (KJS::DOMEvent::DOMEvent):
     10        (KJS::DOMEvent::getValueProperty):
     11        (KJS::DOMEvent::put):
     12        (KJS::DOMEvent::putValueProperty):
     13        (KJS::DOMEventPrototypeFunction::callAsFunction):
     14        (KJS::toJS):
     15        (KJS::toEvent):
     16        (KJS::):
     17        (KJS::JSClipboard::JSClipboard):
     18        (KJS::JSClipboard::~JSClipboard):
     19        (KJS::JSClipboard::getOwnPropertySlot):
     20        (KJS::JSClipboard::getValueProperty):
     21        (KJS::JSClipboard::put):
     22        (KJS::JSClipboard::putValueProperty):
     23        (KJS::JSClipboardPrototypeFunction::callAsFunction):
     24        (KJS::toClipboard):
     25        * bindings/js/kjs_events.h:
     26        (KJS::DOMEvent::):
     27        (KJS::DOMEvent::impl):
     28        (KJS::JSClipboard::impl):
     29        * dom/ClipboardEvent.h:
     30        * dom/Event.h:
     31        (WebCore::Event::srcElement):
     32        (WebCore::Event::returnValue):
     33        (WebCore::Event::clipboardData):
     34        (WebCore::Event::dataTransfer):
     35        (WebCore::Event::clipboard):
     36        * dom/MouseEvent.h:
     37
    1382007-06-13  Lars Knoll <lars@trolltech.com>
    239
  • trunk/WebCore/bindings/js/kjs_events.cpp

    r22039 r23471  
    388388KJS_IMPLEMENT_PROTOTYPE("DOMEvent", DOMEventPrototype, DOMEventPrototypeFunction)
    389389
    390 DOMEvent::DOMEvent(ExecState *exec, Event *e)
    391   : m_impl(e), clipboard(0)
     390DOMEvent::DOMEvent(ExecState* exec, Event* event)
     391    : m_impl(event)
    392392{
    393393    setPrototype(DOMEventPrototype::self(exec));
     
    399399}
    400400
    401 // pass marks through to JS objects we hold during garbage collection
    402 void DOMEvent::mark()
    403 {
    404     DOMObject::mark();
    405     if (clipboard && !clipboard->marked())
    406         clipboard->mark();
    407 }
    408 
    409401bool DOMEvent::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    410402{
     
    412404}
    413405
    414 JSValue *DOMEvent::getValueProperty(ExecState *exec, int token) const
    415 {
    416   Event &event = *m_impl;
    417   switch (token) {
    418   case Type:
    419     return jsString(event.type());
    420   case Target:
    421   case SrcElement: /*MSIE extension - "the object that fired the event"*/
    422     return toJS(exec, event.target());
    423   case CurrentTarget:
    424     return toJS(exec, event.currentTarget());
    425   case EventPhase:
    426     return jsNumber(event.eventPhase());
    427   case Bubbles:
    428     return jsBoolean(event.bubbles());
    429   case CancelBubble:
    430     return jsBoolean(event.cancelBubble());
    431   case ReturnValue:
    432     return jsBoolean(!event.defaultPrevented());
    433   case Cancelable:
    434     return jsBoolean(event.cancelable());
    435   case TimeStamp:
    436     return jsNumber(event.timeStamp());
    437   case ClipboardData:
    438   {
    439     if (event.isClipboardEvent()) {
    440       ClipboardEvent *impl = static_cast<ClipboardEvent *>(&event);
    441       if (!clipboard)
    442         clipboard = new Clipboard(exec, impl->clipboard());
    443       return clipboard;
    444     } else
    445       return jsUndefined();
    446   }
    447   case DataTransfer:
    448   {
    449     if (event.isDragEvent()) {
    450       MouseEvent *impl = static_cast<MouseEvent *>(&event);
    451       if (!clipboard)
    452         clipboard = new Clipboard(exec, impl->clipboard());
    453       return clipboard;
    454     } else
    455       return jsUndefined();
    456   }
    457   default:
    458     return 0;
    459   }
    460 }
    461 
    462 void DOMEvent::put(ExecState *exec, const Identifier &propertyName,
    463                       JSValue *value, int attr)
     406JSValue* DOMEvent::getValueProperty(ExecState* exec, int token) const
     407{
     408    Event* event = impl();
     409    switch (token) {
     410        case Type:
     411            return jsString(event->type());
     412        case Target:
     413            return toJS(exec, event->target());
     414        case SrcElement:
     415            return toJS(exec, event->srcElement());
     416        case CurrentTarget:
     417            return toJS(exec, event->currentTarget());
     418        case EventPhase:
     419            return jsNumber(event->eventPhase());
     420        case Bubbles:
     421            return jsBoolean(event->bubbles());
     422        case CancelBubble:
     423            return jsBoolean(event->cancelBubble());
     424        case ReturnValue:
     425            return jsBoolean(event->returnValue());
     426        case Cancelable:
     427            return jsBoolean(event->cancelable());
     428        case TimeStamp:
     429            return jsNumber(event->timeStamp());
     430        case ClipboardData:
     431            if (event->isClipboardEvent())
     432                return toJS(exec, event->clipboardData());
     433            return jsUndefined();
     434        case DataTransfer:
     435            if (event->isDragEvent())
     436                return toJS(exec, event->dataTransfer());
     437            return jsUndefined();
     438        default:
     439            return 0;
     440    }
     441}
     442
     443void DOMEvent::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
    464444{
    465445    lookupPut<DOMEvent, DOMObject>(exec, propertyName, value, attr, &DOMEventTable, this);
    466446}
    467447
    468 void DOMEvent::putValueProperty(ExecState *exec, int token, JSValue *value, int)
    469 {
    470   Event &event = *m_impl;
    471   switch (token) {
    472   case ReturnValue:
    473     event.setDefaultPrevented(!value->toBoolean(exec));
    474     break;
    475   case CancelBubble:
    476     event.setCancelBubble(value->toBoolean(exec));
    477     break;
    478   default:
    479     break;
    480   }
    481 }
    482 
    483 JSValue *DOMEventPrototypeFunction::callAsFunction(ExecState *exec, JSObject * thisObj, const List &args)
    484 {
    485   if (!thisObj->inherits(&DOMEvent::info))
    486     return throwError(exec, TypeError);
    487   Event &event = *static_cast<DOMEvent *>( thisObj )->impl();
    488   switch (id) {
    489     case DOMEvent::StopPropagation:
    490       event.stopPropagation();
    491       return jsUndefined();
    492     case DOMEvent::PreventDefault:
    493       event.preventDefault();
    494       return jsUndefined();
    495     case DOMEvent::InitEvent:
    496       event.initEvent(AtomicString(args[0]->toString(exec)), args[1]->toBoolean(exec), args[2]->toBoolean(exec));
    497       return jsUndefined();
     448void DOMEvent::putValueProperty(ExecState* exec, int token, JSValue* value, int)
     449{
     450    Event* event = m_impl.get();
     451    switch (token) {
     452        case ReturnValue:
     453            event->setDefaultPrevented(!value->toBoolean(exec));
     454            break;
     455        case CancelBubble:
     456            event->setCancelBubble(value->toBoolean(exec));
     457            break;
     458        default:
     459            break;
     460    }
     461}
     462
     463JSValue* DOMEventPrototypeFunction::callAsFunction(ExecState *exec, JSObject * thisObj, const List &args)
     464{
     465    if (!thisObj->inherits(&DOMEvent::info))
     466        return throwError(exec, TypeError);
     467
     468    Event* event = static_cast<DOMEvent*>(thisObj)->impl();
     469    switch (id) {
     470        case DOMEvent::StopPropagation:
     471            event->stopPropagation();
     472            return jsUndefined();
     473        case DOMEvent::PreventDefault:
     474            event->preventDefault();
     475            return jsUndefined();
     476        case DOMEvent::InitEvent:
     477            event->initEvent(AtomicString(args[0]->toString(exec)), args[1]->toBoolean(exec), args[2]->toBoolean(exec));
     478            return jsUndefined();
    498479  };
    499480  return jsUndefined();
    500481}
    501482
    502 JSValue* toJS(ExecState* exec, Event* e)
    503 {
    504   if (!e)
    505     return jsNull();
    506 
    507   ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter());
    508 
    509   JSLock lock;
    510 
    511   DOMObject* ret = interp->getDOMObject(e);
    512   if (!ret) {
    513     if (e->isKeyboardEvent())
    514       ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent*>(e));
    515     else if (e->isTextEvent())
    516       ret = new JSTextEvent(exec, static_cast<TextEvent*>(e));
    517     else if (e->isMouseEvent())
    518       ret = new JSMouseEvent(exec, static_cast<MouseEvent*>(e));
    519     else if (e->isWheelEvent())
    520       ret = new JSWheelEvent(exec, static_cast<WheelEvent*>(e));
    521     else if (e->isUIEvent())
    522       ret = new JSUIEvent(exec, static_cast<UIEvent*>(e));
    523     else if (e->isMutationEvent())
    524       ret = new JSMutationEvent(exec, static_cast<MutationEvent*>(e));
    525     else if (e->isOverflowEvent())
    526       ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(e));
     483JSValue* toJS(ExecState* exec, Event* event)
     484{
     485    if (!event)
     486        return jsNull();
     487
     488    ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter());
     489
     490    JSLock lock;
     491
     492    DOMObject* ret = interp->getDOMObject(event);
     493    if (ret)
     494        return ret;
     495
     496    if (event->isKeyboardEvent())
     497        ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent*>(event));
     498    else if (event->isTextEvent())
     499        ret = new JSTextEvent(exec, static_cast<TextEvent*>(event));
     500    else if (event->isMouseEvent())
     501        ret = new JSMouseEvent(exec, static_cast<MouseEvent*>(event));
     502    else if (event->isWheelEvent())
     503        ret = new JSWheelEvent(exec, static_cast<WheelEvent*>(event));
     504    else if (event->isUIEvent())
     505        ret = new JSUIEvent(exec, static_cast<UIEvent*>(event));
     506    else if (event->isMutationEvent())
     507        ret = new JSMutationEvent(exec, static_cast<MutationEvent*>(event));
     508    else if (event->isOverflowEvent())
     509        ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(event));
    527510    else
    528       ret = new JSEvent(exec, e);
    529 
    530     interp->putDOMObject(e, ret);
    531   }
    532 
    533   return ret;
    534 }
    535 
    536 Event *toEvent(JSValue *val)
     511        ret = new JSEvent(exec, event);
     512
     513    interp->putDOMObject(event, ret);
     514    return ret;
     515}
     516
     517Event* toEvent(JSValue* val)
    537518{
    538519    if (!val || !val->isObject(&DOMEvent::info))
    539520        return 0;
    540     return static_cast<DOMEvent *>(val)->impl();
     521    return static_cast<DOMEvent*>(val)->impl();
    541522}
    542523
    543524// -------------------------------------------------------------------------
    544525
    545 const ClassInfo Clipboard::info = { "Clipboard", 0, &ClipboardTable, 0 };
    546 
    547 /* Source for ClipboardTable. Use "make hashtables" to regenerate.
    548 @begin ClipboardTable 3
    549   dropEffect    Clipboard::DropEffect   DontDelete
    550   effectAllowed Clipboard::EffectAllowed        DontDelete
    551   types         Clipboard::Types        DontDelete|ReadOnly
     526const ClassInfo JSClipboard::info = { "Clipboard", 0, &JSClipboardTable, 0 };
     527
     528/* Source for JSClipboardTable. Use "make hashtables" to regenerate.
     529@begin JSClipboardTable 3
     530  dropEffect    JSClipboard::DropEffect   DontDelete
     531  effectAllowed JSClipboard::EffectAllowed        DontDelete
     532  types         JSClipboard::Types        DontDelete|ReadOnly
    552533@end
    553 @begin ClipboardPrototypeTable 4
    554   clearData     Clipboard::ClearData    DontDelete|Function 0
    555   getData       Clipboard::GetData      DontDelete|Function 1
    556   setData       Clipboard::SetData      DontDelete|Function 2
    557   setDragImage  Clipboard::SetDragImage DontDelete|Function 3
     534@begin JSClipboardPrototypeTable 4
     535  clearData     JSClipboard::ClearData    DontDelete|Function 0
     536  getData       JSClipboard::GetData      DontDelete|Function 1
     537  setData       JSClipboard::SetData      DontDelete|Function 2
     538  setDragImage  JSClipboard::SetDragImage DontDelete|Function 3
    558539@end
    559540*/
    560541
    561 KJS_DEFINE_PROTOTYPE(ClipboardPrototype)
    562 KJS_IMPLEMENT_PROTOTYPE_FUNCTION(ClipboardPrototypeFunction)
    563 KJS_IMPLEMENT_PROTOTYPE("Clipboard", ClipboardPrototype, ClipboardPrototypeFunction)
    564 
    565 Clipboard::Clipboard(ExecState *exec, WebCore::Clipboard *cb)
    566   : clipboard(cb)
    567 {
    568     setPrototype(ClipboardPrototype::self(exec));
    569 }
    570 
    571 bool Clipboard::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    572 {
    573     return getStaticValueSlot<Clipboard, DOMObject>(exec, &ClipboardTable, this, propertyName, slot);
    574 }
    575 
    576 JSValue *Clipboard::getValueProperty(ExecState *exec, int token) const
    577 {
     542KJS_DEFINE_PROTOTYPE(JSClipboardPrototype)
     543KJS_IMPLEMENT_PROTOTYPE_FUNCTION(JSClipboardPrototypeFunction)
     544KJS_IMPLEMENT_PROTOTYPE("Clipboard", JSClipboardPrototype, JSClipboardPrototypeFunction)
     545
     546JSClipboard::JSClipboard(ExecState* exec, WebCore::Clipboard* cb)
     547    : m_impl(cb)
     548{
     549    setPrototype(JSClipboardPrototype::self(exec));
     550}
     551
     552JSClipboard::~JSClipboard()
     553{
     554    ScriptInterpreter::forgetDOMObject(m_impl.get());
     555}
     556
     557bool JSClipboard::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     558{
     559    return getStaticValueSlot<JSClipboard, DOMObject>(exec, &JSClipboardTable, this, propertyName, slot);
     560}
     561
     562JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const
     563{
     564    WebCore::Clipboard* clipboard = impl();
    578565    switch (token) {
    579566        case DropEffect:
     
    587574            HashSet<String> types = clipboard->types();
    588575            if (types.isEmpty())
    589                 return jsNull(); 
     576                return jsNull();
    590577            else {
    591578                List list;
    592579                HashSet<String>::const_iterator end = types.end();
    593                 for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it) 
     580                for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
    594581                    list.append(jsString(UString(*it)));
    595582                return exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
     
    597584        }
    598585        default:
    599             return NULL;
    600     }
    601 }
    602 
    603 void Clipboard::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
    604 {
    605     lookupPut<Clipboard,DOMObject>(exec, propertyName, value, attr, &ClipboardTable, this );
    606 }
    607 
    608 void Clipboard::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
    609 {
     586            return 0;
     587    }
     588}
     589
     590void JSClipboard::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
     591{
     592    lookupPut<JSClipboard, DOMObject>(exec, propertyName, value, attr, &JSClipboardTable, this );
     593}
     594
     595void JSClipboard::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
     596{
     597    WebCore::Clipboard* clipboard = impl();
    610598    switch (token) {
    611599        case DropEffect:
     
    622610}
    623611
    624 JSValue *ClipboardPrototypeFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
    625 {
    626     if (!thisObj->inherits(&Clipboard::info))
     612JSValue* JSClipboardPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     613{
     614    if (!thisObj->inherits(&JSClipboard::info))
    627615        return throwError(exec, TypeError);
    628616
    629     Clipboard *cb = static_cast<Clipboard *>(thisObj);
     617    WebCore::Clipboard* clipboard = static_cast<JSClipboard*>(thisObj)->impl();
    630618    switch (id) {
    631         case Clipboard::ClearData:
     619        case JSClipboard::ClearData:
    632620            if (args.size() == 0) {
    633                 cb->clipboard->clearAllData();
     621                clipboard->clearAllData();
    634622                return jsUndefined();
    635623            } else if (args.size() == 1) {
    636                 cb->clipboard->clearData(args[0]->toString(exec));
     624                clipboard->clearData(args[0]->toString(exec));
    637625                return jsUndefined();
    638626            } else
    639627                return throwError(exec, SyntaxError, "clearData: Invalid number of arguments");
    640         case Clipboard::GetData:
     628        case JSClipboard::GetData:
    641629        {
    642630            if (args.size() == 1) {
    643631                bool success;
    644                 String result = cb->clipboard->getData(args[0]->toString(exec), success);
     632                String result = clipboard->getData(args[0]->toString(exec), success);
    645633                if (success)
    646634                    return jsString(result);
    647                 else
    648                     return jsUndefined();
     635                return jsUndefined();
    649636            } else
    650637                return throwError(exec, SyntaxError, "getData: Invalid number of arguments");
    651638        }
    652         case Clipboard::SetData:
     639        case JSClipboard::SetData:
    653640            if (args.size() == 2)
    654                 return jsBoolean(cb->clipboard->setData(args[0]->toString(exec), args[1]->toString(exec)));
    655             else
    656                 return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
    657         case Clipboard::SetDragImage:
     641                return jsBoolean(clipboard->setData(args[0]->toString(exec), args[1]->toString(exec)));
     642            return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
     643        case JSClipboard::SetDragImage:
    658644        {
    659             if (!cb->clipboard->isForDragging())
     645            if (!clipboard->isForDragging())
    660646                return jsUndefined();
    661647
     
    663649                return throwError(exec, SyntaxError, "setDragImage: Invalid number of arguments");
    664650
    665             int x = (int)args[1]->toNumber(exec);
    666             int y = (int)args[2]->toNumber(exec);
     651            int x = static_cast<int>(args[1]->toNumber(exec));
     652            int y = static_cast<int>(args[2]->toNumber(exec));
    667653
    668654            // See if they passed us a node
    669             Node *node = toNode(args[0]);
     655            Node* node = toNode(args[0]);
    670656            if (!node)
    671657                return throwError(exec, TypeError);
     
    676662            if (static_cast<Element*>(node)->hasLocalName(imgTag) &&
    677663                !node->inDocument())
    678                 cb->clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
     664                clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
    679665            else
    680                 cb->clipboard->setDragImageElement(node, IntPoint(x, y));                   
     666                clipboard->setDragImageElement(node, IntPoint(x, y));                   
    681667               
    682668            return jsUndefined();
     
    686672}
    687673
    688 }
     674JSValue* toJS(ExecState* exec, WebCore::Clipboard* obj)
     675{
     676    return cacheDOMObject<WebCore::Clipboard, JSClipboard>(exec, obj);
     677}
     678
     679WebCore::Clipboard* toClipboard(JSValue* val)
     680{
     681    return val->isObject(&JSClipboard::info) ? static_cast<JSClipboard*>(val)->impl() : 0;
     682}
     683
     684}
  • trunk/WebCore/bindings/js/kjs_events.h

    r18912 r23471  
    3939
    4040    class Window;
    41     class Clipboard;
     41    class JSClipboard;
    4242   
    4343    class JSAbstractEventListener : public WebCore::EventListener {
     
    9999        DOMEvent(ExecState*, WebCore::Event*);
    100100        virtual ~DOMEvent();
     101
    101102        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    102103        JSValue* getValueProperty(ExecState*, int token) const;
    103104        virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
    104         void putValueProperty(ExecState*, int token, JSValue*, int);
     105        void putValueProperty(ExecState*, int token, JSValue*, int attr);
     106
    105107        virtual const ClassInfo* classInfo() const { return &info; }
    106108        static const ClassInfo info;
    107         enum { Type, Target, CurrentTarget, EventPhase, Bubbles,
    108                Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
    109                // MS IE equivalents
    110                SrcElement, ReturnValue, CancelBubble, ClipboardData, DataTransfer };
    111         WebCore::Event *impl() const { return m_impl.get(); }
    112         virtual void mark();
     109
     110        enum {
     111            Type, Target, CurrentTarget, EventPhase,
     112            Bubbles, Cancelable, TimeStamp, StopPropagation,
     113            PreventDefault, InitEvent,
     114
     115            // MS IE equivalents
     116            SrcElement, ReturnValue, CancelBubble, ClipboardData,
     117            DataTransfer
     118        };
     119
     120        WebCore::Event* impl() const { return m_impl.get(); }
     121
    113122    protected:
    114123        RefPtr<WebCore::Event> m_impl;
    115         mutable Clipboard* clipboard;
    116124    };
    117125
    118126    JSValue* toJS(ExecState*, WebCore::Event*);
    119 
    120127    WebCore::Event* toEvent(JSValue*); // returns 0 if value is not a DOMEvent object
    121128
    122129    KJS_DEFINE_PROTOTYPE(DOMEventPrototype)
    123130
    124     class Clipboard : public DOMObject {
    125     friend class ClipboardPrototypeFunction;
     131    class JSClipboard : public DOMObject {
     132        friend class JSClipboardPrototypeFunction;
    126133    public:
    127         Clipboard(ExecState*, WebCore::Clipboard *ds);
     134        JSClipboard(ExecState*, WebCore::Clipboard* ds);
     135        virtual ~JSClipboard();
     136
    128137        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    129138        JSValue* getValueProperty(ExecState*, int token) const;
    130139        virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None);
    131140        void putValueProperty(ExecState*, int token, JSValue*, int attr);
    132         virtual bool toBoolean(ExecState*) const { return true; }
     141
    133142        virtual const ClassInfo* classInfo() const { return &info; }
    134143        static const ClassInfo info;
     144
    135145        enum { ClearData, GetData, SetData, Types, SetDragImage, DropEffect, EffectAllowed };
     146
     147        WebCore::Clipboard* impl() const { return m_impl.get(); }
     148
    136149    private:
    137         RefPtr<WebCore::Clipboard> clipboard;
     150        RefPtr<WebCore::Clipboard> m_impl;
    138151    };
     152
     153    JSValue* toJS(ExecState*, WebCore::Clipboard*);
     154    WebCore::Clipboard* toClipboard(JSValue*);
    139155
    140156} // namespace
  • trunk/WebCore/dom/ClipboardEvent.h

    r14916 r23471  
    55 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
    66 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
    7  * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
     7 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    88 *
    99 * This library is free software; you can redistribute it and/or
     
    3838
    3939        Clipboard* clipboard() const { return m_clipboard.get(); }
     40
    4041        virtual bool isClipboardEvent() const;
     42
    4143    private:
    4244        RefPtr<Clipboard> m_clipboard;
  • trunk/WebCore/dom/Event.h

    r19855 r23471  
    55 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
    66 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
    7  * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
     7 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    88 *
    99 * This library is free software; you can redistribute it and/or
     
    3232
    3333namespace WebCore {
     34
     35    class Clipboard;
    3436
    3537    // FIXME: this should probably defined elsewhere.
     
    9092        void stopPropagation() { m_propagationStopped = true; }
    9193
     94        // IE Extensions
     95        EventTarget* srcElement() const { return target(); } // MSIE extension - "the object that fired the event"
     96        bool returnValue() const { return !m_defaultPrevented; }
     97        Clipboard* clipboardData() const { return isClipboardEvent() ? clipboard() : 0; }
     98        Clipboard* dataTransfer() const { return isMouseEvent() ? clipboard() : 0; }
     99
    92100        virtual bool isUIEvent() const;
    93101        virtual bool isMouseEvent() const;
     
    122130        virtual void storeResult(const String&);
    123131
     132        virtual Clipboard* clipboard() const { return 0; }
     133
    124134    protected:
    125135        virtual void receivedTarget();
  • trunk/WebCore/dom/MouseEvent.h

    r20780 r23471  
    5353        bool buttonDown() const { return m_buttonDown; }
    5454        EventTargetNode* relatedTarget() const { return m_relatedTarget.get(); }
     55
    5556        Clipboard* clipboard() const { return m_clipboard.get(); }
    56        
     57
    5758        Node* toElement() const;
    5859        Node* fromElement() const;
Note: See TracChangeset for help on using the changeset viewer.