Changeset 101591 in webkit


Ignore:
Timestamp:
Nov 30, 2011 7:23:05 PM (12 years ago)
Author:
haraken@chromium.org
Message:

Implement the StorageEvent constructor
https://bugs.webkit.org/show_bug.cgi?id=71685

Reviewed by Adam Barth.

Source/WebCore:

This patch makes StorageEvent constractable.
The spec: http://www.whatwg.org/specs/web-apps/current-work/#storageevent

Test: fast/events/constructors/storage-event-constructor.html

  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::tryGetProperty):
(WebCore::JSDictionary::convertValue): Returns a Storage object corresponding to a given key.

  • bindings/js/JSDictionary.h:

(WebCore::JSDictionary::tryGetProperty):

  • bindings/v8/OptionsObject.cpp:

(WebCore::OptionsObject::get): Ditto.

  • bindings/v8/OptionsObject.h:
  • storage/StorageEvent.cpp: Added an implementation of the StorageEvent constructor.

(WebCore::StorageEventInit::StorageEventInit):
(WebCore::StorageEvent::create):
(WebCore::StorageEvent::StorageEvent):

  • storage/StorageEvent.h: Added a definition of StorageEventInit.

(WebCore::StorageEvent::key):
(WebCore::StorageEvent::oldValue):
(WebCore::StorageEvent::newValue):
(WebCore::StorageEvent::url):
(WebCore::StorageEvent::storageArea):

  • storage/StorageEvent.idl: Added [ConstructorTemplate=Event] IDL.

LayoutTests:

storage-event-constructor.html checks the behavior of the StorageEvent constructor.

  • fast/dom/constructed-objects-prototypes-expected.txt: Added window.StorageEvent.
  • fast/events/constructors/storage-event-constructor-expected.txt: Added.
  • fast/events/constructors/storage-event-constructor.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r101590 r101591  
     12011-11-30  Kentaro Hara  <haraken@chromium.org>
     2
     3        Implement the StorageEvent constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=71685
     5
     6        Reviewed by Adam Barth.
     7
     8        storage-event-constructor.html checks the behavior of the StorageEvent constructor.
     9
     10        * fast/dom/constructed-objects-prototypes-expected.txt: Added window.StorageEvent.
     11        * fast/events/constructors/storage-event-constructor-expected.txt: Added.
     12        * fast/events/constructors/storage-event-constructor.html: Added.
     13
    1142011-11-30  Hayato Ito  <hayato@chromium.org>
    215
  • trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt

    r101183 r101591  
    4040PASS (new inner.ProgressEvent()).isInner is true
    4141PASS (new inner.ProgressEvent()).constructor.isInner is true
     42PASS (new inner.StorageEvent()).isInner is true
     43PASS (new inner.StorageEvent()).constructor.isInner is true
    4244PASS (new inner.WebGLContextEvent()).isInner is true
    4345PASS (new inner.WebGLContextEvent()).constructor.isInner is true
  • trunk/Source/WebCore/ChangeLog

    r101587 r101591  
     12011-11-30  Kentaro Hara  <haraken@chromium.org>
     2
     3        Implement the StorageEvent constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=71685
     5
     6        Reviewed by Adam Barth.
     7
     8        This patch makes StorageEvent constractable.
     9        The spec: http://www.whatwg.org/specs/web-apps/current-work/#storageevent
     10
     11        Test: fast/events/constructors/storage-event-constructor.html
     12
     13        * bindings/js/JSDictionary.cpp:
     14        (WebCore::JSDictionary::tryGetProperty):
     15        (WebCore::JSDictionary::convertValue): Returns a Storage object corresponding to a given key.
     16        * bindings/js/JSDictionary.h:
     17        (WebCore::JSDictionary::tryGetProperty):
     18        * bindings/v8/OptionsObject.cpp:
     19        (WebCore::OptionsObject::get): Ditto.
     20        * bindings/v8/OptionsObject.h:
     21        * storage/StorageEvent.cpp: Added an implementation of the StorageEvent constructor.
     22        (WebCore::StorageEventInit::StorageEventInit):
     23        (WebCore::StorageEvent::create):
     24        (WebCore::StorageEvent::StorageEvent):
     25        * storage/StorageEvent.h: Added a definition of StorageEventInit.
     26        (WebCore::StorageEvent::key):
     27        (WebCore::StorageEvent::oldValue):
     28        (WebCore::StorageEvent::newValue):
     29        (WebCore::StorageEvent::url):
     30        (WebCore::StorageEvent::storageArea):
     31        * storage/StorageEvent.idl: Added [ConstructorTemplate=Event] IDL.
     32
    1332011-11-30  Naveen Bobbili  <qghc36@motorola.com>
    234
  • trunk/Source/WebCore/bindings/js/JSDictionary.cpp

    r99261 r101591  
    3131#include "JSMessagePortCustom.h"
    3232#include "JSNode.h"
     33#include "JSStorage.h"
    3334#include "JSTrackCustom.h"
    3435#include "SerializedScriptValue.h"
     
    4445    Identifier identifier(m_exec, propertyName);
    4546    PropertySlot slot(m_initializerObject);
    46    
     47
    4748    if (!m_initializerObject->getPropertySlot(m_exec, identifier, slot))
    4849        return NoPropertyFound;
     
    119120}
    120121
     122void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Storage>& result)
     123{
     124    result = toStorage(value);
     125}
     126
    121127void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result)
    122128{
  • trunk/Source/WebCore/bindings/js/JSDictionary.h

    r100628 r101591  
    3838class ScriptValue;
    3939class SerializedScriptValue;
     40class Storage;
    4041class TrackBase;
    4142
     
    8283    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
    8384    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
     85    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
    8486    static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
    8587#if ENABLE(VIDEO_TRACK)
     
    105107        if (m_exec->hadException())
    106108            return false;
    107    
     109
    108110        setter(context, result);
    109111        break;
  • trunk/Source/WebCore/bindings/v8/OptionsObject.cpp

    r101118 r101591  
    3030#include "V8Binding.h"
    3131#include "V8DOMWindow.h"
     32#include "V8Storage.h"
    3233#include "V8Utilities.h"
    3334#include <wtf/MathExtras.h>
     
    207208}
    208209
     210bool OptionsObject::get(const String& key, RefPtr<Storage>& value) const
     211{
     212    v8::Local<v8::Value> v8Value;
     213    if (!getKey(key, v8Value))
     214        return false;
     215
     216    Storage* source = 0;
     217    if (v8Value->IsObject()) {
     218        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
     219        v8::Handle<v8::Object> storage = V8DOMWrapper::lookupDOMWrapper(V8Storage::GetTemplate(), wrapper);
     220        if (!storage.IsEmpty())
     221            source = V8Storage::toNative(storage);
     222    }
     223    value = source;
     224    return true;
     225}
     226
    209227bool OptionsObject::get(const String& key, MessagePortArray& value) const
    210228{
  • trunk/Source/WebCore/bindings/v8/OptionsObject.h

    r99992 r101591  
    3939class DOMWindow;
    4040class IDBKeyRange;
     41class Storage;
    4142class TrackBase;
    4243
     
    6061    bool get(const String&, unsigned long long&) const;
    6162    bool get(const String&, RefPtr<DOMWindow>&) const;
     63    bool get(const String&, RefPtr<Storage>&) const;
    6264    bool get(const String&, MessagePortArray&) const;
    6365#if ENABLE(VIDEO_TRACK)
  • trunk/Source/WebCore/storage/StorageEvent.cpp

    r98044 r101591  
    3232namespace WebCore {
    3333
     34StorageEventInit::StorageEventInit()
     35{
     36}
     37
    3438PassRefPtr<StorageEvent> StorageEvent::create()
    3539{
     
    5054}
    5155
     56PassRefPtr<StorageEvent> StorageEvent::create(const AtomicString& type, const StorageEventInit& initializer)
     57{
     58    return adoptRef(new StorageEvent(type, initializer));
     59}
     60
    5261StorageEvent::StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea)
    5362    : Event(type, false, false)
     
    5766    , m_url(url)
    5867    , m_storageArea(storageArea)
     68{
     69}
     70
     71StorageEvent::StorageEvent(const AtomicString& type, const StorageEventInit& initializer)
     72    : Event(type, initializer)
     73    , m_key(initializer.key)
     74    , m_oldValue(initializer.oldValue)
     75    , m_newValue(initializer.newValue)
     76    , m_url(initializer.url)
     77    , m_storageArea(initializer.storageArea)
    5978{
    6079}
  • trunk/Source/WebCore/storage/StorageEvent.h

    r98044 r101591  
    3232namespace WebCore {
    3333
    34     class Storage;
     34class Storage;
    3535
    36     class StorageEvent : public Event {
    37     public:
    38         static PassRefPtr<StorageEvent> create();
    39         static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
    40         virtual ~StorageEvent();
     36struct StorageEventInit : public EventInit {
     37    StorageEventInit();
    4138
    42         const String& key() const { return m_key; }
    43         const String& oldValue() const { return m_oldValue; }
    44         const String& newValue() const { return m_newValue; }
    45         const String& url() const { return m_url; }
    46         Storage* storageArea() const { return m_storageArea.get(); }
     39    String key;
     40    String oldValue;
     41    String newValue;
     42    String url;
     43    RefPtr<Storage> storageArea;
     44};
    4745
    48         void initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
     46class StorageEvent : public Event {
     47public:
     48    static PassRefPtr<StorageEvent> create();
     49    static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
     50    static PassRefPtr<StorageEvent> create(const AtomicString&, const StorageEventInit&);
     51    virtual ~StorageEvent();
    4952
    50         // Needed once we support init<blank>EventNS
    51         // void initStorageEventNS(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, Storage storageAreaArg);
     53    const String& key() const { return m_key; }
     54    const String& oldValue() const { return m_oldValue; }
     55    const String& newValue() const { return m_newValue; }
     56    const String& url() const { return m_url; }
     57    Storage* storageArea() const { return m_storageArea.get(); }
    5258
    53         virtual const AtomicString& interfaceName() const;
     59    void initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
    5460
    55     private:
    56         StorageEvent();
    57         StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
     61    // Needed once we support init<blank>EventNS
     62    // void initStorageEventNS(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, Storage storageAreaArg);
    5863
    59         String m_key;
    60         String m_oldValue;
    61         String m_newValue;
    62         String m_url;
    63         RefPtr<Storage> m_storageArea;
    64     };
     64    virtual const AtomicString& interfaceName() const;
     65
     66private:
     67    StorageEvent();
     68    StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
     69    StorageEvent(const AtomicString&, const StorageEventInit&);
     70
     71    String m_key;
     72    String m_oldValue;
     73    String m_newValue;
     74    String m_url;
     75    RefPtr<Storage> m_storageArea;
     76};
    6577
    6678} // namespace WebCore
  • trunk/Source/WebCore/storage/StorageEvent.idl

    r101453 r101591  
    2626module storage {
    2727
    28     interface StorageEvent : Event {
    29         readonly attribute DOMString key;
    30         readonly attribute [ConvertNullStringTo=Null] DOMString oldValue;
    31         readonly attribute [ConvertNullStringTo=Null] DOMString newValue;
    32         readonly attribute DOMString url;
    33         readonly attribute Storage storageArea;
     28    interface [
     29        ConstructorTemplate=Event
     30    ] StorageEvent : Event {
     31        readonly attribute [InitializedByConstructor] DOMString key;
     32        readonly attribute [InitializedByConstructor, ConvertNullStringTo=Null] DOMString oldValue;
     33        readonly attribute [InitializedByConstructor, ConvertNullStringTo=Null] DOMString newValue;
     34        readonly attribute [InitializedByConstructor] DOMString url;
     35        readonly attribute [InitializedByConstructor] Storage storageArea;
     36
    3437        void initStorageEvent(in [Optional=CallWithDefaultValue] DOMString typeArg,
    3538                              in [Optional=CallWithDefaultValue] boolean canBubbleArg,
Note: See TracChangeset for help on using the changeset viewer.