WebCore:
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Apr 2008 23:11:29 +0000 (23:11 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Apr 2008 23:11:29 +0000 (23:11 +0000)
commita92490735f9a0cd6d4b85de85c7ce55f3c019194
treee455049d887c6e7b3d8ae7dffbdcb8724b70e322
parentd8532a893a630ec11f37ab193e6eace416d3a2ac
WebCore:

2008-04-07  Brady Eidson  <beidson@apple.com>

        Lovingly reviewed by Sam Weinig

        <rdar://problem/5797684> - HTML5 SessionStorage and underpinnings for LocalStorage

        Tests: storage/domstorage/sessionstorage/iframe-events.html
               storage/domstorage/sessionstorage/index-get-and-set.html
               storage/domstorage/sessionstorage/simple-events.html
               storage/domstorage/sessionstorage/simple-usage.html
               storage/domstorage/sessionstorage/window-open.html
               storage/domstorage/window-attributes-exist.html

        * Configurations/WebCore.xcconfig: Define to enable DOM_STORAGE

        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::JSDOMWindow::mark): Add optionalSessionStorage case

        * bindings/js/JSEventCustom.cpp:
        (WebCore::toJS): Add StorageEvent case

        * bindings/js/JSStorageCustom.cpp:
        (WebCore::JSStorage::canGetItemsForName):
        (WebCore::JSStorage::nameGetter): If the property doesn't exist on the object, call through to getItem()
        (WebCore::JSStorage::customPut): If the property doesn't exist on the object, call through to setItem()

        * dom/Event.cpp:
        (WebCore::Event::isStorageEvent):
        * dom/Event.h:

        * dom/EventNames.h: Add "storage"

        * dom/EventTargetNode.cpp:
        (WebCore::EventTargetNode::dispatchStorageEvent):
        * dom/EventTargetNode.h:

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::createWindow): After a new page has been created, set its SessionStorage object
          to a copy of the previous Page's

        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::sessionStorage): Accessor to pull the appropriate OriginStorage out of the Page's
          SessionStorage.
        (WebCore::DOMWindow::localStorage): To be filled in later
        * page/DOMWindow.h:
        (WebCore::DOMWindow::optionalSessionStorage): Return the session Storage object for this window to mark,
          if any exists
        * page/DOMWindow.idl:

        * page/Page.cpp:
        (WebCore::Page::sessionStorage):  Create and/or return the SessionStorage for this Page.
        (WebCore::Page::setSessionStorage): Set the SessionStorage for this Page - used in FrameLoader after a
          Window.open();
        * page/Page.h:

        * storage/OriginStorage.cpp: Intermediate layer between individual Storage objects, and shared StorageMap
          objects.  There is one OriginStorage object per SecurityOrigin in each "unique set of storage areas", such
          as the SessionStorage.  This layer forwards DOM-level calls down to the backing StorageMap, handles
          copy-on-write along with the StorageMap, fires StorageEvents to the DOM when a value is changed, and will
          eventually handle quota enforcement.
        (WebCore::OriginStorage::create):
        (WebCore::OriginStorage::OriginStorage):
        (WebCore::OriginStorage::~OriginStorage):
        (WebCore::OriginStorage::copy):
        (WebCore::OriginStorage::length):
        (WebCore::OriginStorage::key):
        (WebCore::OriginStorage::getItem):
        (WebCore::OriginStorage::setItem):
        (WebCore::OriginStorage::removeItem):
        (WebCore::OriginStorage::contains):
        (WebCore::OriginStorage::dispatchStorageEvent):
        * storage/OriginStorage.h:

        * storage/SessionStorage.cpp: From the HTML5 spec:
          "Each top-level browsing context has a unique set of session storage areas, one for each origin."
          This object represents that "unique set of session storage areas", and creates or returns the Storage
          object for the requested SecurityOrigin
        (WebCore::SessionStorage::create):
        (WebCore::SessionStorage::SessionStorage):
        (WebCore::SessionStorage::copy):
        (WebCore::SessionStorage::originStorage):
        * storage/SessionStorage.h:
        (WebCore::SessionStorage::page):

        * storage/Storage.cpp: Representation of the DOM-level object, wrapped by JSStorage.  There is a unique
          Storage object per Window (per-Frame) that wraps a specific shared OriginStorage object.
        (WebCore::Storage::create):
        (WebCore::Storage::Storage):
        (WebCore::Storage::length):
        (WebCore::Storage::key):
        (WebCore::Storage::getItem):
        (WebCore::Storage::setItem):
        (WebCore::Storage::removeItem):
        (WebCore::Storage::contains):
        * storage/Storage.h:
        * storage/Storage.idl:

        * storage/StorageEvent.cpp:
        (WebCore::StorageEvent::StorageEvent):
        (WebCore::StorageEvent::initStorageEvent):
        * storage/StorageEvent.h:
        (WebCore::StorageEvent::isStorageEvent):

        * storage/StorageMap.cpp: The physical map of key/value pairs that is shared between OriginStorage objects,
          and implements copy-on-write semantics whenever a value is changed
        (WebCore::StorageMap::create):
        (WebCore::StorageMap::StorageMap):
        (WebCore::StorageMap::copy):
        (WebCore::StorageMap::invalidateIterator): Used to support the key(unsigned i) part of the API
        (WebCore::StorageMap::setIteratorToIndex): Ditto
        (WebCore::StorageMap::length):
        (WebCore::StorageMap::key):
        (WebCore::StorageMap::getItem):
        (WebCore::StorageMap::setItem):
        (WebCore::StorageMap::removeItem):
        (WebCore::StorageMap::contains):
        * storage/StorageMap.h:

LayoutTests:

2008-04-07  Brady Eidson  <beidson@apple.com>

        Begrudgingly reviewed by Sam Weinig

        Initial suite of layout tests for HTML5 key/value SessionStorage (<rdar://problem/5797684>)

        * fast/dom/Window/window-properties-expected.txt:
        * storage/domstorage: Added.
        * storage/domstorage/localstorage: Added.
        * storage/domstorage/sessionstorage: Added.
        * storage/domstorage/sessionstorage/iframe-events-expected.txt: Added.
        * storage/domstorage/sessionstorage/iframe-events.html: Added.
        * storage/domstorage/sessionstorage/index-get-and-set-expected.txt: Added.
        * storage/domstorage/sessionstorage/index-get-and-set.html: Added.
        * storage/domstorage/sessionstorage/resources: Added.
        * storage/domstorage/sessionstorage/resources/clearSessionStorage.js: Added.
        * storage/domstorage/sessionstorage/resources/iframe-events-second.html: Added.
        * storage/domstorage/sessionstorage/resources/window-open-second.html: Added.
        * storage/domstorage/sessionstorage/simple-events-expected.txt: Added.
        * storage/domstorage/sessionstorage/simple-events.html: Added.
        * storage/domstorage/sessionstorage/simple-usage-expected.txt: Added.
        * storage/domstorage/sessionstorage/simple-usage.html: Added.
        * storage/domstorage/sessionstorage/window-open-expected.txt: Added.
        * storage/domstorage/sessionstorage/window-open.html: Added.
        * storage/domstorage/window-attributes-exist-expected.txt: Added.
        * storage/domstorage/window-attributes-exist.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/storage/domstorage/sessionstorage/iframe-events-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/iframe-events.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/index-get-and-set-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/index-get-and-set.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/resources/clearSessionStorage.js [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/resources/iframe-events-second.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/resources/window-open-second.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/simple-events-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/simple-events.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/simple-usage-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/simple-usage.html [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/window-open-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/window-open.html [new file with mode: 0644]
LayoutTests/storage/domstorage/window-attributes-exist-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/window-attributes-exist.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/Configurations/WebCore.xcconfig
WebCore/bindings/js/JSDOMWindowCustom.cpp
WebCore/bindings/js/JSEventCustom.cpp
WebCore/bindings/js/JSStorageCustom.cpp
WebCore/dom/Event.cpp
WebCore/dom/Event.h
WebCore/dom/EventNames.h
WebCore/dom/EventTargetNode.cpp
WebCore/dom/EventTargetNode.h
WebCore/loader/FrameLoader.cpp
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/DOMWindow.idl
WebCore/page/Page.cpp
WebCore/page/Page.h
WebCore/storage/OriginStorage.cpp
WebCore/storage/OriginStorage.h
WebCore/storage/SessionStorage.cpp
WebCore/storage/SessionStorage.h
WebCore/storage/Storage.cpp
WebCore/storage/Storage.h
WebCore/storage/Storage.idl
WebCore/storage/StorageEvent.cpp
WebCore/storage/StorageEvent.h
WebCore/storage/StorageMap.cpp
WebCore/storage/StorageMap.h