Reviewed by Sam Weinig, Anders Carlsson, and (unofficially) Adam Barth.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Sep 2008 10:15:11 +0000 (10:15 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Sep 2008 10:15:11 +0000 (10:15 +0000)
commit76b281c83ae969725e9a6796a7bb0ca682f7b1ee
tree39408de3fba45d734e8c402bbfb0a46d23ee22c1
parentbd40e77224b6320bef1588e73519057c407056af
    Reviewed by Sam Weinig, Anders Carlsson, and (unofficially) Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=20879
        Implement HTML5 channel messaging

        Tests: fast/events/message-channel-gc.html
               fast/events/message-port-deleted-document.html
               fast/events/message-port-deleted-frame.html
               fast/events/message-port-inactive-document.html
               fast/events/message-port.html
               http/tests/security/MessagePort/event-listener-context.html

        * Configurations/WebCore.xcconfig:
        Removed unused  ENABLE_CROSS_DOCUMENT_MESSAGING macro.

        * DerivedSources.make:
        Added MessageChannel and MessagePort.

        * WebCore.pro: Made MessageEvent compilation unconditional, as it could not possibly be
        turmed off anyway. Added new files.

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        Added new files.

        * bindings/js/JSDOMWindowBase.h:
        * bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::getValueProperty):
        Added suport for window.MessageChannel constructor.

        * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::postMessage):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::postMessage):
        * page/DOMWindow.h:
        * page/DOMWindow.idl:
        Added support for three-argument postMessage (that posts a MessagePort).

        * dom/EventTarget.cpp:
        (WebCore::EventTarget::toMessagePort):
        * dom/EventTarget.h:
        * bindings/js/JSEventTargetBase.cpp: (WebCore::toJS): Added MessagePort as yet another
        EventTarget variant.

        * bindings/js/JSMessageChannelConstructor.h:
        * bindings/js/JSMessageChannelConstructor.cpp: Added a custom constructor, so that it could
        take a browsing context (document) parameter.

        * bindings/js/JSMessageChannelCustom.cpp: Added.
        (WebCore::JSMessageChannel::mark): JSMessageChannel uses a custom mark function to mark
        port1 and port2 that it owns.

        * bindings/js/JSMessagePortCustom.cpp: Added.
        (WebCore::JSMessagePort::startConversation):
        (WebCore::JSMessagePort::addEventListener):
        (WebCore::JSMessagePort::removeEventListener):
        (WebCore::JSMessagePort::dispatchEvent):
        (WebCore::JSMessagePort::setOnmessage):
        (WebCore::JSMessagePort::onmessage):
        (WebCore::JSMessagePort::setOnclose):
        (WebCore::JSMessagePort::onclose):
        (WebCore::JSMessagePort::mark):
        * dom/MessagePort.cpp: Added.
        * dom/MessagePort.h: Added.
        * dom/MessagePort.idl: Added.
        Added a MessagePort implementation. Currently, it is not thread-safe at all, and only works
        with Documents as contexts, but in the future, it will be used for communication with worker
        threads.

        * bindings/objc/DOMInternal.h: Include "DOMMessagePortInternal.h". The new APIs do not
        really have Obj-C bindings, as they are far from being final, but a MessagePort stub is
        needed for MessageEvent.

        * bindings/scripts/CodeGeneratorJS.pm: Include PlatformString.h for MessagePort happiness.

        * dom/Document.cpp:
        (WebCore::MessagePortTimer::MessagePortTimer):
        (WebCore::MessagePortTimer::fired):
        (WebCore::Document::processMessagePortMessagesSoon):
        (WebCore::Document::~Document):
        (WebCore::Document::dispatchMessagePortEvents):
        (WebCore::Document::createdMessagePort):
        (WebCore::Document::destroyedMessagePort):
        * dom/Document.h:
        Document keeps track of all MessagePort objects that were created when it was fully active
        in its context.

        * dom/EventNames.h: Added closeEvent.

        * dom/MessageChannel.cpp: Added.
        (WebCore::MessageChannel::MessageChannel):
        (WebCore::MessageChannel::~MessageChannel):
        * dom/MessageChannel.h: Added.
        (WebCore::MessageChannel::create):
        (WebCore::MessageChannel::port1):
        (WebCore::MessageChannel::port2):
        * dom/MessageChannel.idl: Added.
        Addded JSMessageChannel implementation.

        * dom/MessageEvent.cpp:
        (WebCore::MessageEvent::MessageEvent):
        (WebCore::MessageEvent::initMessageEvent):
        * dom/MessageEvent.h:
        (WebCore::MessageEvent::create):
        (WebCore::MessageEvent::messagePort):
        * dom/MessageEvent.idl:
        MessageEvent has a MessagePort member now, making it possible to pass ports across
        documents.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@36891 268f45cc-cd09-0410-ab3c-d52691b4dbfc
53 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/fast/events/message-channel-gc-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-channel-gc.html [new file with mode: 0644]
LayoutTests/fast/events/message-port-deleted-document-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-port-deleted-document.html [new file with mode: 0644]
LayoutTests/fast/events/message-port-deleted-frame-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-port-deleted-frame.html [new file with mode: 0644]
LayoutTests/fast/events/message-port-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-port-inactive-document-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-port-inactive-document.html [new file with mode: 0644]
LayoutTests/fast/events/message-port.html [new file with mode: 0644]
LayoutTests/fast/events/resources/message-port-iframe.html [new file with mode: 0644]
LayoutTests/http/tests/security/MessagePort/event-listener-context-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/security/MessagePort/event-listener-context.html [new file with mode: 0644]
LayoutTests/http/tests/security/MessagePort/resources/attacker-frame.html [new file with mode: 0644]
LayoutTests/http/tests/security/MessagePort/resources/banking-site.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/Configurations/WebCore.xcconfig
WebCore/DerivedSources.cpp
WebCore/DerivedSources.make
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/bindings/js/JSDOMWindowBase.cpp
WebCore/bindings/js/JSDOMWindowBase.h
WebCore/bindings/js/JSDOMWindowCustom.cpp
WebCore/bindings/js/JSEventTargetBase.cpp
WebCore/bindings/js/JSMessageChannelConstructor.cpp [new file with mode: 0644]
WebCore/bindings/js/JSMessageChannelConstructor.h [new file with mode: 0644]
WebCore/bindings/js/JSMessageChannelCustom.cpp [new file with mode: 0644]
WebCore/bindings/js/JSMessagePortCustom.cpp [new file with mode: 0644]
WebCore/bindings/objc/DOMInternal.h
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/EventNames.h
WebCore/dom/EventTarget.cpp
WebCore/dom/EventTarget.h
WebCore/dom/MessageChannel.cpp [new file with mode: 0644]
WebCore/dom/MessageChannel.h [new file with mode: 0644]
WebCore/dom/MessageChannel.idl [new file with mode: 0644]
WebCore/dom/MessageEvent.cpp
WebCore/dom/MessageEvent.h
WebCore/dom/MessageEvent.idl
WebCore/dom/MessagePort.cpp [new file with mode: 0644]
WebCore/dom/MessagePort.h [new file with mode: 0644]
WebCore/dom/MessagePort.idl [new file with mode: 0644]
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/DOMWindow.idl