2009-07-13 Drew Wilson <atwilson@google.com>
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jul 2009 08:58:48 +0000 (08:58 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jul 2009 08:58:48 +0000 (08:58 +0000)
        Reviewed by David Levin.

        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
        https://bugs.webkit.org/show_bug.cgi?id=26932

.:

        Added ENABLE(SHARED_WORKERS) flag.

       * configure.ac:

JavaScriptCore:

        Added ENABLE(SHARED_WORKERS) flag (off by default).

        * Configurations/FeatureDefines.xcconfig:

WebCore:

        Initial IDL definition and bindings for SharedWorkers.

        * Configurations/FeatureDefines.xcconfig:
        Added new files for SharedWorker support.
        * DerivedSources.make:
        Added new files for SharedWorker support.
        * GNUmakefile.am:
        Added new files for SharedWorker support.
        * WebCore.gypi:
        Added new files for SharedWorker support.
        * WebCore.pro:
        Added new files for SharedWorker support.
        * WebCore.xcodeproj/project.pbxproj:
        Added new files for SharedWorker support.
        * bindings/js/JSAbstractWorkerCustom.cpp: Added.
        (WebCore::JSAbstractWorker::mark):
        Custom mark handler that marks the event listeners.
        (WebCore::JSAbstractWorker::addEventListener):
        (WebCore::JSAbstractWorker::removeEventListener):
        (WebCore::JSAbstractWorker::toJS):
        Custom toJS handler which differentiates between various subclasses.
        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::JSDOMWindow::sharedWorker):
        SharedWorker constructor (only enabled when SHARED_WORKERS is
        enabled).
        * bindings/js/JSEventTarget.cpp:
        (WebCore::toJS):
        (WebCore::toEventTarget):
        Added support for converting to/from SharedWorkers.
        * bindings/js/JSSharedWorkerConstructor.cpp: Added.
        (WebCore::JSSharedWorkerConstructor::JSSharedWorkerConstructor):
        (WebCore::constructSharedWorker):
        (WebCore::JSSharedWorkerConstructor::getConstructData):
        * bindings/js/JSSharedWorkerConstructor.h: Added.
        (WebCore::JSSharedWorkerConstructor::classInfo):
        * bindings/js/JSSharedWorkerCustom.cpp: Added.
        (WebCore::JSSharedWorker::mark):
        Custom mark function that marks the internal MessagePort.
        * bindings/v8/DOMObjectsInclude.h:
        Updated to include new header files.
        * bindings/v8/V8Index.cpp:
        * bindings/v8/V8Index.h:
        * bindings/v8/custom/V8AbstractWorkerCustom.cpp: Added.
        (WebCore::getEventListener):
        (WebCore::ACCESSOR_GETTER):
        (WebCore::ACCESSOR_SETTER):
        (WebCore::CALLBACK_FUNC_DECL):
        V8 handlers for add/removeEventListener().
        * bindings/v8/custom/V8CustomBinding.h:
        * bindings/v8/custom/V8SharedWorkerCustom.cpp: Added.
        (WebCore::CALLBACK_FUNC_DECL):
        Custom constructor for SharedWorker.
        * dom/EventTarget.cpp:
        (WebCore::EventTarget::toSharedWorker):
        * dom/EventTarget.h:
        * page/DOMWindow.idl:
        * workers/AbstractWorker.cpp: Added.
        (WebCore::AbstractWorker::AbstractWorker):
        Common base class for SharedWorker and (soon) Worker. The functions below were copied from Worker.cpp.
        This is the first step in refactoring Worker to derive from AbstractWorker to enable code sharing.
        (WebCore::AbstractWorker::~AbstractWorker):
        (WebCore::AbstractWorker::addEventListener):
        (WebCore::AbstractWorker::removeEventListener):
        (WebCore::AbstractWorker::dispatchEvent):
        (WebCore::AbstractWorker::dispatchLoadErrorEvent):
        (WebCore::AbstractWorker::dispatchScriptErrorEvent):
        * workers/AbstractWorker.h: Added.
        Definitions of functionality shared by Worker.h and SharedWorker.h. In a future patch, Worker will derive from AbstractWorker.
        (WebCore::AbstractWorker::scriptExecutionContext):
        (WebCore::AbstractWorker::setOnerror):
        (WebCore::AbstractWorker::onerror):
        (WebCore::AbstractWorker::eventListeners):
        (WebCore::AbstractWorker::refEventTarget):
        (WebCore::AbstractWorker::derefEventTarget):
        * workers/AbstractWorker.idl: Added.
        * workers/SharedWorker.cpp: Added.
        (WebCore::SharedWorker::SharedWorker):
        (WebCore::SharedWorker::~SharedWorker):
        * workers/SharedWorker.h: Added.
        (WebCore::SharedWorker::create):
        (WebCore::SharedWorker::port):
        (WebCore::SharedWorker::toSharedWorker):
        * workers/SharedWorker.idl: Added.

WebKit/mac:

        Added ENABLE(SHARED_WORKERS) flag (disabled by default).

        * Configurations/FeatureDefines.xcconfig:

WebKitTools:

        Added support for --shared-workers (turned off by default)

        * Scripts/build-webkit:

LayoutTests:

        Unit tests for new SharedWorker APIs (disabled by default).

        * fast/workers/shared-worker-constructor-expected.txt: Added.
        * fast/workers/shared-worker-constructor.html-disabled: Added.
        * fast/workers/shared-worker-event-listener-expected.txt: Added.
        * fast/workers/shared-worker-event-listener.html-disabled: Added.

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

41 files changed:
ChangeLog
JavaScriptCore/ChangeLog
JavaScriptCore/Configurations/FeatureDefines.xcconfig
LayoutTests/ChangeLog
LayoutTests/fast/workers/shared-worker-constructor-expected.txt [new file with mode: 0644]
LayoutTests/fast/workers/shared-worker-constructor.html-disabled [new file with mode: 0644]
LayoutTests/fast/workers/shared-worker-event-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/workers/shared-worker-event-listener.html-disabled [new file with mode: 0644]
WebCore/ChangeLog
WebCore/Configurations/FeatureDefines.xcconfig
WebCore/DerivedSources.make
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSAbstractWorkerCustom.cpp [new file with mode: 0644]
WebCore/bindings/js/JSDOMWindowCustom.cpp
WebCore/bindings/js/JSEventTarget.cpp
WebCore/bindings/js/JSSharedWorkerConstructor.cpp [new file with mode: 0644]
WebCore/bindings/js/JSSharedWorkerConstructor.h [new file with mode: 0644]
WebCore/bindings/js/JSSharedWorkerCustom.cpp [new file with mode: 0644]
WebCore/bindings/v8/DOMObjectsInclude.h
WebCore/bindings/v8/V8Index.cpp
WebCore/bindings/v8/V8Index.h
WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp [new file with mode: 0644]
WebCore/bindings/v8/custom/V8CustomBinding.h
WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp [new file with mode: 0644]
WebCore/dom/EventTarget.cpp
WebCore/dom/EventTarget.h
WebCore/page/DOMWindow.idl
WebCore/workers/AbstractWorker.cpp [new file with mode: 0644]
WebCore/workers/AbstractWorker.h [new file with mode: 0644]
WebCore/workers/AbstractWorker.idl [new file with mode: 0644]
WebCore/workers/SharedWorker.cpp [new file with mode: 0644]
WebCore/workers/SharedWorker.h [new file with mode: 0644]
WebCore/workers/SharedWorker.idl [new file with mode: 0644]
WebKit/mac/ChangeLog
WebKit/mac/Configurations/FeatureDefines.xcconfig
WebKitTools/ChangeLog
WebKitTools/Scripts/build-webkit
configure.ac

index 069c90ff4b44ba71da20b9ba6e253c0edd838b36..b0c0b7a6fc6da84343e7b2771e5109636517e1dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Added ENABLE(SHARED_WORKERS) flag.
+
+       * configure.ac:
+
 2009-07-12  Xan Lopez  <xlopez@igalia.com>
 
         Reviewed by Gustavo Noronha.
index 8d795e28783548782f177f54e69d42b2db1c63e5..1370becf42e8d1caec15ccdbb544b51e8aeb61d0 100644 (file)
@@ -1,3 +1,14 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Added ENABLE(SHARED_WORKERS) flag (off by default).
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2009-07-07  Norbert Leser  <norbert.leser@nokia.com>
 
         Reviewed by Maciej Stachoviak.
index 5ab06ef224d8bafded2e4e241eeeec4efc851515..a6d57cffed02e3b4dddedb40cc4a0475f3ca07f3 100644 (file)
@@ -39,6 +39,7 @@ ENABLE_GEOLOCATION = ;
 ENABLE_ICONDATABASE = ENABLE_ICONDATABASE;
 ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER;
 ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS;
+ENABLE_SHARED_WORKERS = ;
 ENABLE_SVG = ENABLE_SVG;
 ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION;
 ENABLE_SVG_AS_IMAGE = ENABLE_SVG_AS_IMAGE;
@@ -52,4 +53,4 @@ ENABLE_WORKERS = ENABLE_WORKERS;
 ENABLE_XPATH = ENABLE_XPATH;
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
index c32e947fbbfa6ba8710061f73ef24519116edbd0..1e793b6c63ad61f9f9dbfc344e158fed8c553bb1 100644 (file)
@@ -1,3 +1,17 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Unit tests for new SharedWorker APIs (disabled by default).
+
+        * fast/workers/shared-worker-constructor-expected.txt: Added.
+        * fast/workers/shared-worker-constructor.html-disabled: Added.
+        * fast/workers/shared-worker-event-listener-expected.txt: Added.
+        * fast/workers/shared-worker-event-listener.html-disabled: Added.
+
 2009-07-12  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/fast/workers/shared-worker-constructor-expected.txt b/LayoutTests/fast/workers/shared-worker-constructor-expected.txt
new file mode 100644 (file)
index 0000000..224c1c3
--- /dev/null
@@ -0,0 +1,9 @@
+Test SharedWorker constructor functionality. Should print a series of PASS messages, followed with DONE.
+
+PASS: toString exception propagated correctly.
+PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded.)
+PASS: invoking SharedWorker constructor without arguments resulted in an exception (SyntaxError: Not enough arguments)
+PASS: invoking SharedWorker constructor without name resulted in an exception (SyntaxError: Not enough arguments)
+PASS: SharedWorker constructor succeeded: [object SharedWorker]
+DONE
+
diff --git a/LayoutTests/fast/workers/shared-worker-constructor.html-disabled b/LayoutTests/fast/workers/shared-worker-constructor.html-disabled
new file mode 100644 (file)
index 0000000..5547e6d
--- /dev/null
@@ -0,0 +1,59 @@
+<body>
+<p>Test SharedWorker constructor functionality. Should print a series of PASS messages, followed with DONE.</p>
+<div id=result></div>
+<script>
+function log(message)
+{
+    document.getElementById("result").innerHTML += message + "<br>";
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+try {
+    new SharedWorker({toString:function(){throw "exception"}}, "name")
+    log("FAIL: toString exception not propagated.");
+} catch (ex) {
+    if (ex == "exception")
+        log("PASS: toString exception propagated correctly.");
+    else
+        log("FAIL: unexpected exception (" + ex + ") received instead of one propagated from toString.");
+}
+
+try {
+    var foo = {toString:function(){new Worker(foo)}}
+    new SharedWorker(foo, name);
+    log("FAIL: no exception when trying to create workers recursively");
+} catch (ex) {
+    log("PASS: trying to create workers recursively resulted in an exception (" + ex + ")");
+}
+
+try {
+    new SharedWorker();
+    log("FAIL: invoking SharedWorker constructor without arguments did not result in an exception");
+} catch (ex) {
+    log("PASS: invoking SharedWorker constructor without arguments resulted in an exception (" + ex + ")");
+}
+
+try {
+    var worker = new SharedWorker("resources/worker-common.js");
+    log("FAIL: Constructor succeeded when no name is passed");
+} catch (ex) {
+    log("PASS: invoking SharedWorker constructor without name resulted in an exception (" + ex + ")");
+}
+
+try {
+    var worker = new SharedWorker("resources/worker-common.js", "name");
+    log ("PASS: SharedWorker constructor succeeded: " + worker);
+} catch (ex) {
+    log("FAIL: invoking SharedWorker constructor resulted in an exception (" + ex + ")");
+}
+
+log("DONE");
+if (window.layoutTestController)
+    layoutTestController.notifyDone();
+
+</script>
+</body>
diff --git a/LayoutTests/fast/workers/shared-worker-event-listener-expected.txt b/LayoutTests/fast/workers/shared-worker-event-listener-expected.txt
new file mode 100644 (file)
index 0000000..f8704aa
--- /dev/null
@@ -0,0 +1,7 @@
+Test SharedWorker event listener. Should print a series of PASS messages, followed with DONE.
+
+SUCCESS: Listener was called.
+SUCCESS: Listener was not called after removal.
+SUCCESS: Listener was called after GC.
+DONE
+
diff --git a/LayoutTests/fast/workers/shared-worker-event-listener.html-disabled b/LayoutTests/fast/workers/shared-worker-event-listener.html-disabled
new file mode 100644 (file)
index 0000000..ea33fe7
--- /dev/null
@@ -0,0 +1,73 @@
+<body>
+<p>Test SharedWorker event listener. Should print a series of PASS messages, followed with DONE.</p>
+<div id=result></div>
+<script>
+function log(message)
+{
+    document.getElementById("result").innerHTML += message + "<br>";
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var worker = new SharedWorker("resources/worker-common.js", "foobar");
+var numListenerCalls = 0;
+function countListenerCallbacks(event)
+{
+    if (event.type != "foo")
+        log("FAIL: Received unexpected event: " + event.type);
+    numListenerCalls++;
+}
+worker.addEventListener("foo", countListenerCallbacks, false);
+var event = document.createEvent("Events");
+event.initEvent("foo", false, false);
+worker.dispatchEvent(event);
+if (numListenerCalls == 1) {
+    log("SUCCESS: Listener was called.");
+} else {
+    log("FAIL: Listener was not called.");
+}
+
+worker.removeEventListener("foo", countListenerCallbacks, false);
+worker.dispatchEvent(event);
+if (numListenerCalls == 1) {
+    log("SUCCESS: Listener was not called after removal.");
+} else {
+    log("FAIL: Listener was called after removal.");
+}
+
+// Test to make sure that event listeners survive GC.
+worker.addEventListener("foo", createNewListener(countListenerCallbacks), false);
+gc();
+worker.dispatchEvent(event);
+if (numListenerCalls == 2) {
+    log("SUCCESS: Listener was called after GC.");
+} else {
+    log("FAIL: Listener was not called after GC.");
+}
+
+
+log("DONE");
+if (window.layoutTestController)
+    layoutTestController.notifyDone();
+
+function createNewListener(func)
+{
+  return function(event) { func(event); };
+}
+
+function gc()
+{
+    if (window.GCController)
+        return GCController.collect();
+
+    for (var i = 0; i < 10000; i++) { // force garbage collection (FF requires about 9K allocations before a collect).
+        var s = new String("abc");
+    }
+}
+
+
+</script>
+</body>
index 17f72f097c23cb2f49a08eec3ed3898dfe1747a4..f5f017f9e7e67f973697f85e16ae40bbfd87ba8f 100644 (file)
@@ -1,3 +1,94 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Initial IDL definition and bindings for SharedWorkers.
+
+        * Configurations/FeatureDefines.xcconfig:
+        Added new files for SharedWorker support.
+        * DerivedSources.make:
+        Added new files for SharedWorker support.
+        * GNUmakefile.am:
+        Added new files for SharedWorker support.
+        * WebCore.gypi:
+        Added new files for SharedWorker support.
+        * WebCore.pro:
+        Added new files for SharedWorker support.
+        * WebCore.xcodeproj/project.pbxproj:
+        Added new files for SharedWorker support.
+        * bindings/js/JSAbstractWorkerCustom.cpp: Added.
+        (WebCore::JSAbstractWorker::mark):
+        Custom mark handler that marks the event listeners.
+        (WebCore::JSAbstractWorker::addEventListener):
+        (WebCore::JSAbstractWorker::removeEventListener):
+        (WebCore::JSAbstractWorker::toJS):
+        Custom toJS handler which differentiates between various subclasses.
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::sharedWorker):
+        SharedWorker constructor (only enabled when SHARED_WORKERS is
+        enabled).
+        * bindings/js/JSEventTarget.cpp:
+        (WebCore::toJS):
+        (WebCore::toEventTarget):
+        Added support for converting to/from SharedWorkers.
+        * bindings/js/JSSharedWorkerConstructor.cpp: Added.
+        (WebCore::JSSharedWorkerConstructor::JSSharedWorkerConstructor):
+        (WebCore::constructSharedWorker):
+        (WebCore::JSSharedWorkerConstructor::getConstructData):
+        * bindings/js/JSSharedWorkerConstructor.h: Added.
+        (WebCore::JSSharedWorkerConstructor::classInfo):
+        * bindings/js/JSSharedWorkerCustom.cpp: Added.
+        (WebCore::JSSharedWorker::mark):
+        Custom mark function that marks the internal MessagePort.
+        * bindings/v8/DOMObjectsInclude.h:
+        Updated to include new header files.
+        * bindings/v8/V8Index.cpp:
+        * bindings/v8/V8Index.h:
+        * bindings/v8/custom/V8AbstractWorkerCustom.cpp: Added.
+        (WebCore::getEventListener):
+        (WebCore::ACCESSOR_GETTER):
+        (WebCore::ACCESSOR_SETTER):
+        (WebCore::CALLBACK_FUNC_DECL):
+        V8 handlers for add/removeEventListener().
+        * bindings/v8/custom/V8CustomBinding.h:
+        * bindings/v8/custom/V8SharedWorkerCustom.cpp: Added.
+        (WebCore::CALLBACK_FUNC_DECL):
+        Custom constructor for SharedWorker.
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::toSharedWorker):
+        * dom/EventTarget.h:
+        * page/DOMWindow.idl:
+        * workers/AbstractWorker.cpp: Added.
+        (WebCore::AbstractWorker::AbstractWorker):
+        Common base class for SharedWorker and (soon) Worker. The functions below were copied from Worker.cpp.
+        This is the first step in refactoring Worker to derive from AbstractWorker to enable code sharing.
+        (WebCore::AbstractWorker::~AbstractWorker):
+        (WebCore::AbstractWorker::addEventListener):
+        (WebCore::AbstractWorker::removeEventListener):
+        (WebCore::AbstractWorker::dispatchEvent):
+        (WebCore::AbstractWorker::dispatchLoadErrorEvent):
+        (WebCore::AbstractWorker::dispatchScriptErrorEvent):
+        * workers/AbstractWorker.h: Added.
+        Definitions of functionality shared by Worker.h and SharedWorker.h. In a future patch, Worker will derive from AbstractWorker.
+        (WebCore::AbstractWorker::scriptExecutionContext):
+        (WebCore::AbstractWorker::setOnerror):
+        (WebCore::AbstractWorker::onerror):
+        (WebCore::AbstractWorker::eventListeners):
+        (WebCore::AbstractWorker::refEventTarget):
+        (WebCore::AbstractWorker::derefEventTarget):
+        * workers/AbstractWorker.idl: Added.
+        * workers/SharedWorker.cpp: Added.
+        (WebCore::SharedWorker::SharedWorker):
+        (WebCore::SharedWorker::~SharedWorker):
+        * workers/SharedWorker.h: Added.
+        (WebCore::SharedWorker::create):
+        (WebCore::SharedWorker::port):
+        (WebCore::SharedWorker::toSharedWorker):
+        * workers/SharedWorker.idl: Added.
+
 2009-07-13  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by Simon Hausmann.
index 1f196ea7d99d8902466879ca6d93abc284007be7..69177153f7ce24771bd58dda4e5d10284e724ab0 100644 (file)
@@ -40,6 +40,7 @@ ENABLE_GEOLOCATION = ;
 ENABLE_ICONDATABASE = ENABLE_ICONDATABASE;
 ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER;
 ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS;
+ENABLE_SHARED_WORKERS = ;
 ENABLE_SVG = ENABLE_SVG;
 ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION;
 ENABLE_SVG_AS_IMAGE = ENABLE_SVG_AS_IMAGE;
@@ -53,4 +54,4 @@ ENABLE_WORKERS = ENABLE_WORKERS;
 ENABLE_XPATH = ENABLE_XPATH;
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
index 2da23c8fb8c3e2aeef7fc16874c0cc482bf117e7..aa263126e136b2e4a33f920692c43e9b37c5e400 100644 (file)
@@ -45,6 +45,7 @@ VPATH = \
 
 DOM_CLASSES = \
     AbstractView \
+    AbstractWorker \
     Attr \
     BarInfo \
     CDATASection \
@@ -200,6 +201,7 @@ DOM_CLASSES = \
     Range \
     RangeException \
     Rect \
+    SharedWorker \
     SQLError \
     SQLResultSet \
     SQLResultSetRowList \
index 66263ea06d0261fb2b784718cdc84313346bd598..5af7f4a5fa4c72bea57dca05b7073847f1facfbf 100644 (file)
@@ -250,6 +250,8 @@ IDL_BINDINGS += \
        WebCore/plugins/MimeTypeArray.idl \
        WebCore/plugins/Plugin.idl \
        WebCore/plugins/PluginArray.idl \
+       WebCore/workers/AbstractWorker.idl \
+       WebCore/workers/SharedWorker.idl \
        WebCore/workers/Worker.idl \
        WebCore/workers/WorkerContext.idl \
        WebCore/workers/WorkerLocation.idl \
@@ -2341,6 +2343,27 @@ webcore_sources += \
        WebCore/workers/WorkerThread.h
 endif
 
+# ---
+# SharedWorker support
+# ---
+if ENABLE_SHARED_WORKERS
+FEATURE_DEFINES_JAVASCRIPT += ENABLE_SHARED_WORKERS=1
+
+webcore_cppflags += \
+       -DENABLE_SHARED_WORKERS=1
+
+webcore_built_sources += \
+       WebCore/bindings/js/JSAbstractWorkerCustom.cpp \
+       WebCore/bindings/js/JSSharedWorkerConstructor.cpp \
+       WebCore/bindings/js/JSSharedWorkerConstructor.h \
+       WebCore/bindings/js/JSSharedWorkerCustom.cpp \
+       WebCore/workers/AbstractWorker.cpp \
+       WebCore/workers/AbstractWorker.h \
+       WebCore/workers/SharedWorker.cpp \
+       WebCore/workers/SharedWorker.h
+
+endif
+
 # ----
 # WML Support
 # ----
index 810f891c3218b9114abe717cb3d4b3addce7a7e8..d96da8671caaa0c99542af26aa63e678ec859b33 100644 (file)
             'svg/SVGViewSpec.idl',
             'svg/SVGZoomAndPan.idl',
             'svg/SVGZoomEvent.idl',
+            'workers/AbstractWorker.idl',
+            'workers/SharedWorker.idl',
             'workers/Worker.idl',
             'workers/WorkerContext.idl',
             'workers/WorkerLocation.idl',
             'bindings/js/StringSourceProvider.h',
             'bindings/js/WorkerScriptController.cpp',
             'bindings/js/WorkerScriptController.h',
+            'bindings/v8/custom/V8AbstractWorkerCustom.cpp',
             'bindings/v8/custom/V8AttrCustom.cpp',
             'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
             'bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp',
             'bindings/v8/custom/V8SVGElementInstanceCustom.cpp',
             'bindings/v8/custom/V8SVGLengthCustom.cpp',
             'bindings/v8/custom/V8SVGMatrixCustom.cpp',
+            'bindings/v8/custom/V8SharedWorkerCustom.cpp',
             'bindings/v8/custom/V8StyleSheetListCustom.cpp',
             'bindings/v8/custom/V8TreeWalkerCustom.cpp',
             'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp',
             'svg/SVGZoomEvent.cpp',
             'svg/SVGZoomEvent.h',
             'svg/SynchronizableTypeWrapper.h',
+            'workers/AbstractWorker.cpp',
+            'workers/AbstractWorker.h',
             'workers/GenericWorkerTask.h',
+            'workers/SharedWorker.cpp',
+            'workers/SharedWorker.h',
             'workers/Worker.cpp',
             'workers/Worker.h',
             'workers/WorkerContext.cpp',
index 0086d02b97431eb48b88879c997fe72020ea483b..b76cad1c4435b863578b5408b9ef90fa75d00807 100644 (file)
@@ -123,6 +123,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
 !contains(DEFINES, ENABLE_XSLT=.): DEFINES += ENABLE_XSLT=0
 #!contains(DEFINES, ENABLE_XBL=.): DEFINES += ENABLE_XBL=1
 !contains(DEFINES, ENABLE_WML=.): DEFINES += ENABLE_WML=0
+!contains(DEFINES, ENABLE_SHARED_WORKERS=.): DEFINES += ENABLE_SHARED_WORKERS=0
 !contains(DEFINES, ENABLE_WORKERS=.): DEFINES += ENABLE_WORKERS=1
 !contains(DEFINES, ENABLE_XHTMLMP=.): DEFINES += ENABLE_XHTMLMP=0
 
@@ -1443,6 +1444,21 @@ contains(DEFINES, ENABLE_WORKERS=1) {
         workers/WorkerScriptLoader.cpp
 }
 
+contains(DEFINES, SHARED_WORKERS=1) {
+    FEATURE_DEFINES_JAVASCRIPT += ENABLE_SHARED_WORKERS=1
+
+    IDL_BINDINGS += \
+        workers/AbstractWorker.idl \
+        workers/SharedWorker.idl
+
+    SOURCES += \
+        bindings/js/JSAbstractWorkerCustom.cpp \
+        bindings/js/JSSharedWorkerConstructor.cpp \
+        bindings/js/JSSharedWorkerCustom.cpp \
+        workers/AbstractWorker.cpp \
+        workers/SharedWorker.cpp
+}
+
 contains(DEFINES, ENABLE_VIDEO=1) {
     FEATURE_DEFINES_JAVASCRIPT += ENABLE_VIDEO=1
 
index 1d4c6d6b5a63d2831705f88e1a6775978e474100..62b54f3bc8502e9e6ae8499c80b8bbe1b30f70f4 100644 (file)
                411046420FA222A600BA436A /* ScriptEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 411046400FA222A600BA436A /* ScriptEventListener.cpp */; };
                4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
                412A68470F6B03DD000EA66E /* ScriptObjectQuarantine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 412A68460F6B03DD000EA66E /* ScriptObjectQuarantine.cpp */; };
+               415B7C570FF598E6006770F7 /* JSAbstractWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415B7C540FF598E6006770F7 /* JSAbstractWorkerCustom.cpp */; };
+               415B7C580FF598E6006770F7 /* JSSharedWorkerConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415B7C550FF598E6006770F7 /* JSSharedWorkerConstructor.cpp */; };
+               415B7C590FF598E6006770F7 /* JSSharedWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415B7C560FF598E6006770F7 /* JSSharedWorkerCustom.cpp */; };
+               415B7C630FF5A767006770F7 /* JSSharedWorkerConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 415B7C620FF5A767006770F7 /* JSSharedWorkerConstructor.h */; };
                416E75BE0EDF8FD700360E1D /* ScriptCallStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */; };
                416E75BF0EDF8FD700360E1D /* ScriptCallStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */; };
                416E75CB0EDF90C700360E1D /* ScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */; };
                416E75CC0EDF90C700360E1D /* ScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */; };
                416F45F00ED7B311008215B6 /* ScriptString.h in Headers */ = {isa = PBXBuildFile; fileRef = 416F45EF0ED7B311008215B6 /* ScriptString.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */; };
+               418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 418F88030FF957AE0080F045 /* JSAbstractWorker.h */; };
                419536510F68222400D0C679 /* ScriptObjectQuarantine.h in Headers */ = {isa = PBXBuildFile; fileRef = 419536500F68222400D0C679 /* ScriptObjectQuarantine.h */; };
                41BF700B0FE86F49005E8DEC /* MessagePortChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41BF70090FE86F49005E8DEC /* MessagePortChannel.cpp */; };
                41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */; };
                41C760B10EDE03D300C1655F /* ScriptState.h in Headers */ = {isa = PBXBuildFile; fileRef = 41C760B00EDE03D300C1655F /* ScriptState.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; };
                41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
+               41D07A7E0FF935CA0095EDCE /* JSSharedWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D07A7C0FF935CA0095EDCE /* JSSharedWorker.cpp */; };
+               41D07A7F0FF935CA0095EDCE /* JSSharedWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D07A7D0FF935CA0095EDCE /* JSSharedWorker.h */; };
+               41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */; };
+               41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E1B1CB0FF5986900576B3B /* AbstractWorker.h */; };
+               41E1B1D20FF5986900576B3B /* AbstractWorker.idl in Resources */ = {isa = PBXBuildFile; fileRef = 41E1B1CC0FF5986900576B3B /* AbstractWorker.idl */; };
+               41E1B1D30FF5986900576B3B /* SharedWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CD0FF5986900576B3B /* SharedWorker.cpp */; };
+               41E1B1D40FF5986900576B3B /* SharedWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E1B1CE0FF5986900576B3B /* SharedWorker.h */; };
+               41E1B1D50FF5986900576B3B /* SharedWorker.idl in Resources */ = {isa = PBXBuildFile; fileRef = 41E1B1CF0FF5986900576B3B /* SharedWorker.idl */; };
                41F060CD0F5EEB2B00A07EAC /* JSInspectorController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F060CB0F5EEB2B00A07EAC /* JSInspectorController.cpp */; };
                41F060CE0F5EEB2B00A07EAC /* JSInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F060CC0F5EEB2B00A07EAC /* JSInspectorController.h */; };
                41F0616A0F5EFBDD00A07EAC /* JSInspectorControllerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F061690F5EFBDD00A07EAC /* JSInspectorControllerCustom.cpp */; };
                411046400FA222A600BA436A /* ScriptEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEventListener.cpp; sourceTree = "<group>"; };
                4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
                412A68460F6B03DD000EA66E /* ScriptObjectQuarantine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptObjectQuarantine.cpp; sourceTree = "<group>"; };
+               415B7C540FF598E6006770F7 /* JSAbstractWorkerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorkerCustom.cpp; sourceTree = "<group>"; };
+               415B7C550FF598E6006770F7 /* JSSharedWorkerConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSharedWorkerConstructor.cpp; sourceTree = "<group>"; };
+               415B7C560FF598E6006770F7 /* JSSharedWorkerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSharedWorkerCustom.cpp; sourceTree = "<group>"; };
+               415B7C620FF5A767006770F7 /* JSSharedWorkerConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSharedWorkerConstructor.h; sourceTree = "<group>"; };
                416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStack.h; sourceTree = "<group>"; };
                416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStack.cpp; sourceTree = "<group>"; };
                416E75C90EDF90C700360E1D /* ScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallFrame.h; sourceTree = "<group>"; };
                416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallFrame.cpp; sourceTree = "<group>"; };
                416F45EF0ED7B311008215B6 /* ScriptString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptString.h; sourceTree = "<group>"; };
+               418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = "<group>"; };
+               418F88030FF957AE0080F045 /* JSAbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAbstractWorker.h; sourceTree = "<group>"; };
                419536500F68222400D0C679 /* ScriptObjectQuarantine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptObjectQuarantine.h; sourceTree = "<group>"; };
                41BF70090FE86F49005E8DEC /* MessagePortChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessagePortChannel.cpp; sourceTree = "<group>"; };
                41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagePortChannel.h; sourceTree = "<group>"; };
                41C760B00EDE03D300C1655F /* ScriptState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptState.h; sourceTree = "<group>"; };
                41D015C80F4B5C71004A662F /* ContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentType.h; sourceTree = "<group>"; };
                41D015C90F4B5C71004A662F /* ContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentType.cpp; sourceTree = "<group>"; };
+               41D07A7C0FF935CA0095EDCE /* JSSharedWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSharedWorker.cpp; sourceTree = "<group>"; };
+               41D07A7D0FF935CA0095EDCE /* JSSharedWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSharedWorker.h; sourceTree = "<group>"; };
+               41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AbstractWorker.cpp; path = workers/AbstractWorker.cpp; sourceTree = "<group>"; };
+               41E1B1CB0FF5986900576B3B /* AbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AbstractWorker.h; path = workers/AbstractWorker.h; sourceTree = "<group>"; };
+               41E1B1CC0FF5986900576B3B /* AbstractWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AbstractWorker.idl; path = workers/AbstractWorker.idl; sourceTree = "<group>"; };
+               41E1B1CD0FF5986900576B3B /* SharedWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharedWorker.cpp; path = workers/SharedWorker.cpp; sourceTree = "<group>"; };
+               41E1B1CE0FF5986900576B3B /* SharedWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharedWorker.h; path = workers/SharedWorker.h; sourceTree = "<group>"; };
+               41E1B1CF0FF5986900576B3B /* SharedWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = SharedWorker.idl; path = workers/SharedWorker.idl; sourceTree = "<group>"; };
                41F060AA0F5EE8BB00A07EAC /* InspectorController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = InspectorController.idl; sourceTree = "<group>"; };
                41F060CB0F5EEB2B00A07EAC /* JSInspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorController.cpp; sourceTree = "<group>"; };
                41F060CC0F5EEB2B00A07EAC /* JSInspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorController.h; sourceTree = "<group>"; };
                2E4346310F546A6800B0F1BA /* workers */ = {
                        isa = PBXGroup;
                        children = (
+                               41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */,
+                               41E1B1CB0FF5986900576B3B /* AbstractWorker.h */,
+                               41E1B1CC0FF5986900576B3B /* AbstractWorker.idl */,
                                2E4346320F546A8200B0F1BA /* GenericWorkerTask.h */,
+                               41E1B1CD0FF5986900576B3B /* SharedWorker.cpp */,
+                               41E1B1CE0FF5986900576B3B /* SharedWorker.h */,
+                               41E1B1CF0FF5986900576B3B /* SharedWorker.idl */,
                                2E4346330F546A8200B0F1BA /* Worker.cpp */,
                                2E4346340F546A8200B0F1BA /* Worker.h */,
                                2E4346350F546A8200B0F1BA /* Worker.idl */,
                BC1A3793097C6FB10019F3D8 /* js */ = {
                        isa = PBXGroup;
                        children = (
+                               415B7C620FF5A767006770F7 /* JSSharedWorkerConstructor.h */,
+                               415B7C540FF598E6006770F7 /* JSAbstractWorkerCustom.cpp */,
+                               415B7C550FF598E6006770F7 /* JSSharedWorkerConstructor.cpp */,
+                               415B7C560FF598E6006770F7 /* JSSharedWorkerCustom.cpp */,
                                BC4EDEF70C08F414007EDD49 /* Custom */,
                                14DFB33F0A7DF7630018F769 /* Derived Sources */,
                                BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
                E1C8BE4B0E8BD0D10064CB7D /* Threads */ = {
                        isa = PBXGroup;
                        children = (
+                               418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */,
+                               418F88030FF957AE0080F045 /* JSAbstractWorker.h */,
+                               41D07A7C0FF935CA0095EDCE /* JSSharedWorker.cpp */,
+                               41D07A7D0FF935CA0095EDCE /* JSSharedWorker.h */,
                                E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */,
                                E1CAA5C50E8BD23600A73ECA /* JSWorker.h */,
                                E182568D0EF2B02D00933242 /* JSWorkerContext.cpp */,
                                93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
+                               41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
+                               41E1B1D40FF5986900576B3B /* SharedWorker.h in Headers */,
+                               415B7C630FF5A767006770F7 /* JSSharedWorkerConstructor.h in Headers */,
+                               41D07A7F0FF935CA0095EDCE /* JSSharedWorker.h in Headers */,
+                               418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */,
                                1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */,
                                1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
+                               41E1B1D20FF5986900576B3B /* AbstractWorker.idl in Resources */,
+                               41E1B1D50FF5986900576B3B /* SharedWorker.idl in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                93F19B0408245E59001E9ABC /* XSLTProcessor.cpp in Sources */,
                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
+                               41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
+                               41E1B1D30FF5986900576B3B /* SharedWorker.cpp in Sources */,
+                               415B7C570FF598E6006770F7 /* JSAbstractWorkerCustom.cpp in Sources */,
+                               415B7C580FF598E6006770F7 /* JSSharedWorkerConstructor.cpp in Sources */,
+                               415B7C590FF598E6006770F7 /* JSSharedWorkerCustom.cpp in Sources */,
+                               41D07A7E0FF935CA0095EDCE /* JSSharedWorker.cpp in Sources */,
+                               418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/bindings/js/JSAbstractWorkerCustom.cpp b/WebCore/bindings/js/JSAbstractWorkerCustom.cpp
new file mode 100644 (file)
index 0000000..82e06e3
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "JSAbstractWorker.h"
+
+#include "AbstractWorker.h"
+#include "JSDOMGlobalObject.h"
+#include "JSEventListener.h"
+#include "JSEventTarget.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSAbstractWorker::mark()
+{
+    DOMObject::mark();
+
+    markIfNotNull(m_impl->onerror());
+
+    typedef AbstractWorker::EventListenersMap EventListenersMap;
+    typedef AbstractWorker::ListenerVector ListenerVector;
+    EventListenersMap& eventListeners = m_impl->eventListeners();
+    for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter != eventListeners.end(); ++mapIter) {
+        for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter != mapIter->second.end(); ++vecIter)
+            (*vecIter)->markJSFunction();
+    }
+}
+
+JSValue JSAbstractWorker::addEventListener(ExecState* exec, const ArgList& args)
+{
+    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
+    if (!globalObject)
+        return jsUndefined();
+    RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1));
+    if (!listener)
+        return jsUndefined();
+    impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec));
+    return jsUndefined();
+}
+
+JSValue JSAbstractWorker::removeEventListener(ExecState* exec, const ArgList& args)
+{
+    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
+    if (!globalObject)
+        return jsUndefined();
+    JSEventListener* listener = globalObject->findJSEventListener(args.at(1));
+    if (!listener)
+        return jsUndefined();
+    impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec));
+    return jsUndefined();
+}
+
+JSValue toJS(ExecState* exec, AbstractWorker* baseObject)
+{
+    // Just call the JSEventTarget implementation of toJS(), which already differentiates between the different implementations.
+    return toJS(exec, static_cast<EventTarget*>(baseObject));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
index 22013eb5c7f6f1a0285d7f02f34d46ea8ed1c8ac..c095bf2f1d3bb2214b8b0cca68f02438f931452f 100644 (file)
@@ -45,6 +45,7 @@
 #include "JSMessageChannelConstructor.h"
 #include "JSMessagePort.h"
 #include "JSOptionConstructor.h"
+#include "JSSharedWorkerConstructor.h"
 #include "JSWebKitCSSMatrixConstructor.h"
 #include "JSWebKitPointConstructor.h"
 #include "JSWorkerConstructor.h"
@@ -476,6 +477,13 @@ JSValue JSDOMWindow::worker(ExecState* exec) const
 }
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+JSValue JSDOMWindow::sharedWorker(ExecState* exec) const
+{
+    return getDOMConstructor<JSSharedWorkerConstructor>(exec, this);
+}
+#endif
+
 // Custom functions
 
 // Helper for window.open() and window.showModalDialog()
index 20580982dd89154cbf8c28f7c5e5ac2da2fe423d..875e904ad6d7279ce3deed48bd6bedb7d791110c 100644 (file)
 #include "WorkerContext.h"
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+#include "JSSharedWorker.h"
+#include "SharedWorker.h"
+#endif
+
 using namespace JSC;
 
 namespace WebCore {
@@ -101,6 +106,11 @@ JSValue toJS(ExecState* exec, EventTarget* target)
         return toJSDOMGlobalObject(workerContext);
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+    if (SharedWorker* sharedWorker = target->toSharedWorker())
+        return toJS(exec, sharedWorker);
+#endif
+
     ASSERT_NOT_REACHED();
     return jsNull();
 }
@@ -132,6 +142,10 @@ EventTarget* toEventTarget(JSC::JSValue value)
     CONVERT_TO_EVENT_TARGET(WorkerContext)
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+    CONVERT_TO_EVENT_TARGET(SharedWorker)
+#endif
+
     return 0;
 }
 
diff --git a/WebCore/bindings/js/JSSharedWorkerConstructor.cpp b/WebCore/bindings/js/JSSharedWorkerConstructor.cpp
new file mode 100644 (file)
index 0000000..ead17dd
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "JSSharedWorkerConstructor.h"
+
+#include "JSDOMWindowCustom.h"
+#include "JSSharedWorker.h"
+#include "SharedWorker.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+const ClassInfo JSSharedWorkerConstructor::s_info = { "SharedWorkerConstructor", 0, 0, 0 };
+
+JSSharedWorkerConstructor::JSSharedWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
+    : DOMObject(JSSharedWorkerConstructor::createStructure(globalObject->objectPrototype()))
+{
+    putDirect(exec->propertyNames().prototype, JSSharedWorkerPrototype::self(exec, globalObject), None);
+    // Host functions have a length property describing the number of expected arguments.
+    putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum);
+}
+
+static JSObject* constructSharedWorker(ExecState* exec, JSObject*, const ArgList& args)
+{
+    if (args.size() < 2)
+        return throwError(exec, SyntaxError, "Not enough arguments");
+
+    UString scriptURL = args.at(0).toString(exec);
+    UString name = args.at(1).toString(exec);
+    if (exec->hadException())
+        return 0;
+
+    ScriptExecutionContext* context = static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())->scriptExecutionContext();
+    ExceptionCode ec = 0;
+    RefPtr<SharedWorker> worker = SharedWorker::create(scriptURL, name, context, ec);
+    setDOMException(exec, ec);
+
+    // FIXME: toJS() creates an object whose prototype is derived from lexicalGlobalScope, which is incorrect (Bug 27088)
+    return asObject(toJS(exec, worker.release()));
+}
+
+ConstructType JSSharedWorkerConstructor::getConstructData(ConstructData& constructData)
+{
+    constructData.native.function = constructSharedWorker;
+    return ConstructTypeHost;
+}
+
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
diff --git a/WebCore/bindings/js/JSSharedWorkerConstructor.h b/WebCore/bindings/js/JSSharedWorkerConstructor.h
new file mode 100644 (file)
index 0000000..be8b2b4
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSSharedWorkerConstructor_h
+#define JSSharedWorkerConstructor_h
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "JSDOMBinding.h"
+
+namespace WebCore {
+
+    class JSSharedWorkerConstructor : public DOMObject {
+    public:
+        JSSharedWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*);
+
+        static const JSC::ClassInfo s_info;
+
+    private:
+        virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+
+        virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
+    };
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
+
+#endif // JSSharedWorkerConstructor_h
diff --git a/WebCore/bindings/js/JSSharedWorkerCustom.cpp b/WebCore/bindings/js/JSSharedWorkerCustom.cpp
new file mode 100644 (file)
index 0000000..8553298
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "JSSharedWorker.h"
+
+#include "JSDOMGlobalObject.h"
+#include "SharedWorker.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSSharedWorker::mark()
+{
+    Base::mark();
+
+    if (MessagePort* port = impl()->port()) {
+        DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), port);
+        if (wrapper && !wrapper->marked())
+            wrapper->mark();
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
index 2d5ee6fbf6d05c3e940dde905aff4258f0309fd5..11596c5bcfc72793fd0319aa1b0113c8c015cbcb 100644 (file)
 #include "WorkerNavigator.h"
 #endif // WORKERS
 
+#if ENABLE(SHARED_WORKERS)
+#include "AbstractWorker.h"
+#include "SharedWorker.h"
+#endif // SHARED_WORKERS
+
 #if ENABLE(XPATH)
 #include "XPathEvaluator.h"
 #endif // XPATH
index 93740b6a786fd21a76bd512d2ffb1f08bae35b39..f238421dd0edc5c706f2245998f2aa63c3369689 100644 (file)
 #include "V8WorkerNavigator.h"
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+#include "V8AbstractWorker.h"
+#include "V8SharedWorker.h"
+#endif
+
 namespace WebCore {
 
 FunctionTemplateFactory V8ClassIndex::GetFactory(V8WrapperType type)
index a890ff86983d1c103baf7b7744e3a0f1d2175d54..a4d78dd66449b27fcff9dea77fb618493f6c9057 100644 (file)
@@ -65,6 +65,17 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
 #define WORKER_NONNODE_WRAPPER_TYPES(V)
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+#define SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)                    \
+    V(SHAREDWORKER, SharedWorker)
+
+#define SHARED_WORKER_NONNODE_WRAPPER_TYPES(V)                          \
+    V(ABSTRACTWORKER, AbstractWorker)
+#else
+#define SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)
+#define SHARED_WORKER_NONNODE_WRAPPER_TYPES(V)
+#endif
+
 #define DOM_NODE_TYPES(V)                                               \
     V(ATTR, Attr)                                                       \
     V(CHARACTERDATA, CharacterData)                                     \
@@ -267,7 +278,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
 #define ACTIVE_DOM_OBJECT_TYPES(V)                                      \
     V(MESSAGEPORT, MessagePort)                                         \
     V(XMLHTTPREQUEST, XMLHttpRequest)                                   \
-    WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)
+    WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)                               \
+    SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)
 
 // NOTE: DOM_OBJECT_TYPES is split into two halves because
 //       Visual Studio's Intellinonsense crashes when macros get
@@ -365,6 +377,7 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
     V(XSLTPROCESSOR, XSLTProcessor)                                     \
     ACTIVE_DOM_OBJECT_TYPES(V)                                          \
     VIDEO_NONNODE_TYPES(V)                                              \
+    SHARED_WORKER_NONNODE_WRAPPER_TYPES(V)                              \
     WORKER_NONNODE_WRAPPER_TYPES(V)
 
 #if ENABLE(DATABASE)
diff --git a/WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp b/WebCore/bindings/v8/custom/V8AbstractWorkerCustom.cpp
new file mode 100644 (file)
index 0000000..2860db9
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "AbstractWorker.h"
+
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8ObjectEventListener.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
+#include "WorkerContextExecutionProxy.h"
+
+namespace WebCore {
+
+PassRefPtr<EventListener> getEventListener(AbstractWorker* worker, v8::Local<v8::Value> value, bool findOnly)
+{
+    if (worker->scriptExecutionContext()->isWorkerContext()) {
+        WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve();
+        ASSERT(workerContextProxy);
+        return workerContextProxy->findOrCreateObjectEventListener(value, false, findOnly);
+    }
+
+    V8Proxy* proxy = V8Proxy::retrieve(worker->scriptExecutionContext());
+    if (proxy)
+        return findOnly ? proxy->findObjectEventListener(value, false) : proxy->findOrCreateObjectEventListener(value, false);
+
+    return 0;
+}
+
+ACCESSOR_GETTER(AbstractWorkerOnerror)
+{
+    INC_STATS(L"DOM.AbstractWorker.onerror._get");
+    AbstractWorker* worker = V8Proxy::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, info.Holder());
+    if (worker->onerror()) {
+        V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(worker->onerror());
+        v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+        return v8Listener;
+    }
+    return v8::Undefined();
+}
+
+ACCESSOR_SETTER(AbstractWorkerOnerror)
+{
+    INC_STATS(L"DOM.AbstractWorker.onerror._set");
+    AbstractWorker* worker = V8Proxy::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, info.Holder());
+    V8ObjectEventListener* oldListener = static_cast<V8ObjectEventListener*>(worker->onerror());
+    if (value->IsNull()) {
+        if (oldListener) {
+            v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
+            removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kAbstractWorkerRequestCacheIndex);
+        }
+
+        // Clear the listener.
+        worker->setOnerror(0);
+    } else {
+        RefPtr<EventListener> listener = getEventListener(worker, value, false);
+        if (listener) {
+            if (oldListener) {
+                v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
+                removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kAbstractWorkerRequestCacheIndex);
+            }
+
+            worker->setOnerror(listener);
+            createHiddenDependency(info.Holder(), value, V8Custom::kAbstractWorkerRequestCacheIndex);
+        }
+    }
+}
+
+CALLBACK_FUNC_DECL(AbstractWorkerAddEventListener)
+{
+    INC_STATS(L"DOM.AbstractWorker.addEventListener()");
+    AbstractWorker* worker = V8Proxy::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, args.Holder());
+
+    RefPtr<EventListener> listener = getEventListener(worker, args[1], false);
+    if (listener) {
+        String type = toWebCoreString(args[0]);
+        bool useCapture = args[2]->BooleanValue();
+        worker->addEventListener(type, listener, useCapture);
+
+        createHiddenDependency(args.Holder(), args[1], V8Custom::kAbstractWorkerRequestCacheIndex);
+    }
+    return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(AbstractWorkerRemoveEventListener)
+{
+    INC_STATS(L"DOM.AbstractWorker.removeEventListener()");
+    AbstractWorker* worker = V8Proxy::convertToNativeObject<AbstractWorker>(V8ClassIndex::ABSTRACTWORKER, args.Holder());
+
+    RefPtr<EventListener> listener = getEventListener(worker, args[1], true);
+    if (listener) {
+        String type = toWebCoreString(args[0]);
+        bool useCapture = args[2]->BooleanValue();
+        worker->removeEventListener(type, listener.get(), useCapture);
+
+        removeHiddenDependency(args.Holder(), args[1], V8Custom::kAbstractWorkerRequestCacheIndex);
+    }
+
+    return v8::Undefined();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
index 6083ac5114b73ca051f2f143a0f3bf668ed87a5d..760952406db3d03d1aac1adfd24b92f72319d06d 100644 (file)
@@ -126,6 +126,11 @@ namespace WebCore {
         static const int kWorkerContextInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+        static const int kAbstractWorkerRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
+        static const int kAbstractWorkerInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
+#endif
+
         static const int kDOMWindowConsoleIndex = kDefaultWrapperInternalFieldCount + 0;
         static const int kDOMWindowHistoryIndex = kDefaultWrapperInternalFieldCount + 1;
         static const int kDOMWindowLocationbarIndex = kDefaultWrapperInternalFieldCount + 2;
@@ -487,6 +492,13 @@ namespace WebCore {
         DECLARE_CALLBACK(WorkerContextRemoveEventListener);
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+        DECLARE_PROPERTY_ACCESSOR(AbstractWorkerOnerror);
+        DECLARE_CALLBACK(AbstractWorkerAddEventListener);
+        DECLARE_CALLBACK(AbstractWorkerRemoveEventListener);
+        DECLARE_CALLBACK(SharedWorkerConstructor);
+#endif
+
 #undef DECLARE_INDEXED_ACCESS_CHECK
 #undef DECLARE_NAMED_ACCESS_CHECK
 
diff --git a/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp b/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp
new file mode 100644 (file)
index 0000000..3ab2f8e
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "SharedWorker.h"
+
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8ObjectEventListener.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
+#include "WorkerContext.h"
+#include "WorkerContextExecutionProxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(SharedWorkerConstructor)
+{
+    INC_STATS(L"DOM.SharedWorker.Constructor");
+
+    if (!args.IsConstructCall())
+        return throwError("DOM object constructor cannot be called as a function.");
+
+    if (args.Length() < 2)
+        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+
+    v8::TryCatch tryCatch;
+    v8::Handle<v8::String> scriptUrl = args[0]->ToString();
+    v8::Handle<v8::String> name = args[1]->ToString();
+    if (tryCatch.HasCaught())
+        return throwError(tryCatch.Exception());
+
+    if (scriptUrl.IsEmpty())
+        return v8::Undefined();
+
+    // Get the script execution context.
+    ScriptExecutionContext* context = 0;
+    WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
+    if (proxy)
+        context = proxy->workerContext();
+    else {
+        Frame* frame = V8Proxy::retrieveFrame();
+        if (!frame)
+            return v8::Undefined();
+        context = frame->document();
+    }
+
+    // Create the worker object.
+    // Note: it's OK to let this RefPtr go out of scope because we also call SetDOMWrapper(), which effectively holds a reference to obj.
+    ExceptionCode ec = 0;
+    RefPtr<SharedWorker> obj = SharedWorker::create(toWebCoreString(scriptUrl), toWebCoreString(name), context, ec);
+
+    // Setup the standard wrapper object internal fields.
+    v8::Handle<v8::Object> wrapperObject = args.Holder();
+    V8Proxy::setDOMWrapper(wrapperObject, V8ClassIndex::SHAREDWORKER, obj.get());
+
+    obj->ref();
+    V8Proxy::setJSWrapperForActiveDOMObject(obj.get(), v8::Persistent<v8::Object>::New(wrapperObject));
+
+    return wrapperObject;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
index 06cea07fc175e9b2b90d11dffb59ddd1d7a043d2..437f5ba2fd6e73b838c109bfa1e031f2039711d6 100644 (file)
@@ -95,6 +95,13 @@ WorkerContext* EventTarget::toWorkerContext()
 }
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+SharedWorker* EventTarget::toSharedWorker()
+{
+    return 0;
+}
+#endif
+
 #ifndef NDEBUG
 void forbidEventDispatch()
 {
index 662902e45f02fcbb4c2ab6a9bff0be3e02b7720f..73a32e3f9feb5c362d0c6bab51d76647e780a722 100644 (file)
@@ -36,6 +36,7 @@
 
 namespace WebCore {
 
+    class AbstractWorker;
     class AtomicString;
     class DOMApplicationCache;
     class DOMWindow;
@@ -45,6 +46,7 @@ namespace WebCore {
     class Node;
     class SVGElementInstance;
     class ScriptExecutionContext;
+    class SharedWorker;
     class Worker;
     class WorkerContext;
     class XMLHttpRequest;
@@ -70,6 +72,10 @@ namespace WebCore {
         virtual WorkerContext* toWorkerContext();
 #endif
 
+#if ENABLE(SHARED_WORKERS)
+        virtual SharedWorker* toSharedWorker();
+#endif
+
         virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
 
         virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) = 0;
index a23d7080018a60f03f7116cf3193e9770bf89045..bfdebd4a39f834f7e58017150369aff5f54d8a96 100644 (file)
@@ -461,6 +461,10 @@ module window {
         attribute [JSCCustomGetter] WorkerConstructor Worker; // Usable with the new operator
 #endif
 
+#if defined(ENABLE_SHARED_WORKERS) && ENABLE_SHARED_WORKERS
+        attribute [JSCCustomGetter] SharedWorkerConstructor SharedWorker; // Usable with the new operator
+#endif
+
         attribute PluginConstructor Plugin;
         attribute PluginArrayConstructor PluginArray;
 
diff --git a/WebCore/workers/AbstractWorker.cpp b/WebCore/workers/AbstractWorker.cpp
new file mode 100644 (file)
index 0000000..120f78a
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "AbstractWorker.h"
+
+#include "Event.h"
+#include "EventException.h"
+#include "EventNames.h"
+
+namespace WebCore {
+
+AbstractWorker::AbstractWorker(ScriptExecutionContext* context)
+    : ActiveDOMObject(context, this)
+{
+}
+
+AbstractWorker::~AbstractWorker()
+{
+}
+
+void AbstractWorker::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool)
+{
+    EventListenersMap::iterator iter = m_eventListeners.find(eventType);
+    if (iter == m_eventListeners.end()) {
+        ListenerVector listeners;
+        listeners.append(eventListener);
+        m_eventListeners.add(eventType, listeners);
+    } else {
+        ListenerVector& listeners = iter->second;
+        for (ListenerVector::iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter) {
+            if (*listenerIter == eventListener)
+                return;
+        }
+
+        listeners.append(eventListener);
+        m_eventListeners.add(eventType, listeners);
+    }
+}
+
+void AbstractWorker::removeEventListener(const AtomicString& eventType, EventListener* eventListener, bool)
+{
+    EventListenersMap::iterator iter = m_eventListeners.find(eventType);
+    if (iter == m_eventListeners.end())
+        return;
+
+    ListenerVector& listeners = iter->second;
+    for (ListenerVector::const_iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter) {
+        if (*listenerIter == eventListener) {
+            listeners.remove(listenerIter - listeners.begin());
+            return;
+        }
+    }
+}
+
+bool AbstractWorker::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec)
+{
+    if (!event || event->type().isEmpty()) {
+        ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR;
+        return true;
+    }
+
+    ListenerVector listenersCopy = m_eventListeners.get(event->type());
+    for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) {
+        event->setTarget(this);
+        event->setCurrentTarget(this);
+        listenerIter->get()->handleEvent(event.get(), false);
+    }
+
+    return !event->defaultPrevented();
+}
+
+void AbstractWorker::dispatchLoadErrorEvent()
+{
+    RefPtr<Event> evt = Event::create(eventNames().errorEvent, false, true);
+    if (m_onErrorListener) {
+        evt->setTarget(this);
+        evt->setCurrentTarget(this);
+        m_onErrorListener->handleEvent(evt.get(), true);
+    }
+
+    ExceptionCode ec = 0;
+    dispatchEvent(evt.release(), ec);
+    ASSERT(!ec);
+}
+
+void AbstractWorker::dispatchScriptErrorEvent(const String&, const String&, int)
+{
+    //FIXME: Generate an ErrorEvent instead of a simple event
+    dispatchLoadErrorEvent();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
diff --git a/WebCore/workers/AbstractWorker.h b/WebCore/workers/AbstractWorker.h
new file mode 100644 (file)
index 0000000..89e4258
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AbstractWorker_h
+#define AbstractWorker_h
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "ActiveDOMObject.h"
+#include "AtomicStringHash.h"
+#include "EventListener.h"
+#include "EventTarget.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+    class ScriptExecutionContext;
+
+    class AbstractWorker : public RefCounted<AbstractWorker>, public ActiveDOMObject, public EventTarget {
+    public:
+        // EventTarget APIs
+        virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
+
+        virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
+        virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
+        virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
+
+        // Utility routines to generate appropriate error events for loading and script exceptions.
+        void dispatchLoadErrorEvent();
+        void dispatchScriptErrorEvent(const String& errorMessage, const String& sourceURL, int);
+
+        void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; }
+        EventListener* onerror() const { return m_onErrorListener.get(); }
+        typedef Vector<RefPtr<EventListener> > ListenerVector;
+        typedef HashMap<AtomicString, ListenerVector> EventListenersMap;
+        EventListenersMap& eventListeners() { return m_eventListeners; }
+
+        using RefCounted<AbstractWorker>::ref;
+        using RefCounted<AbstractWorker>::deref;
+
+        AbstractWorker(ScriptExecutionContext*);
+        virtual ~AbstractWorker();
+
+    private:
+
+        virtual void refEventTarget() { ref(); }
+        virtual void derefEventTarget() { deref(); }
+
+        RefPtr<EventListener> m_onErrorListener;
+        EventListenersMap m_eventListeners;
+    };
+
+} // namespace WebCore
+
+#endif // ENABLE(SHARED_WORKERS)
+
+#endif // AbstractWorker_h
diff --git a/WebCore/workers/AbstractWorker.idl b/WebCore/workers/AbstractWorker.idl
new file mode 100644 (file)
index 0000000..1234c0d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module threads {
+
+    interface [
+        Conditional=SHARED_WORKERS,
+        CustomMarkFunction,
+        CustomToJS,
+        GenerateConstructor
+    ] AbstractWorker {
+
+        attribute EventListener onerror;
+
+        [Custom] void addEventListener(in DOMString type,
+                                       in EventListener listener,
+                                       in boolean useCapture);
+        [Custom] void removeEventListener(in DOMString type,
+                                          in EventListener listener,
+                                          in boolean useCapture);
+        boolean dispatchEvent(in Event evt)
+            raises(EventException);
+    };
+
+}
diff --git a/WebCore/workers/SharedWorker.cpp b/WebCore/workers/SharedWorker.cpp
new file mode 100644 (file)
index 0000000..e1d30d3
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+
+#if ENABLE(SHARED_WORKERS)
+
+#include "SharedWorker.h"
+
+#include "MessagePort.h"
+
+namespace WebCore {
+
+SharedWorker::SharedWorker(const String&, const String&, ScriptExecutionContext* context, ExceptionCode&)
+    : AbstractWorker(context)
+{
+    // Placeholder - ultimately we'll look up the worker in the SharedWorkerRepository.
+}
+
+SharedWorker::~SharedWorker()
+{
+}
+
+} // namespace WebCore
+
+#endif  // ENABLE(SHARED_WORKERS)
diff --git a/WebCore/workers/SharedWorker.h b/WebCore/workers/SharedWorker.h
new file mode 100644 (file)
index 0000000..36c7d85
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SharedWorker_h
+#define SharedWorker_h
+
+#include "AbstractWorker.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+
+namespace WebCore {
+
+    class SharedWorker : public AbstractWorker {
+    public:
+        static PassRefPtr<SharedWorker> create(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
+        {
+            return adoptRef(new SharedWorker(url, name, context, ec));
+        }
+        ~SharedWorker();
+        MessagePort* port() const { return m_port.get(); }
+
+        virtual SharedWorker* toSharedWorker() { return this; }
+
+    private:
+        SharedWorker(const String& url, const String& name, ScriptExecutionContext*, ExceptionCode&);
+
+        RefPtr<MessagePort> m_port;
+    };
+
+} // namespace WebCore
+
+#endif // SharedWorker_h
diff --git a/WebCore/workers/SharedWorker.idl b/WebCore/workers/SharedWorker.idl
new file mode 100644 (file)
index 0000000..09475f7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module threads {
+
+    interface [
+        Conditional=SHARED_WORKERS,
+        CustomMarkFunction,
+        GenerateNativeConverter,
+        GenerateToJS
+    ] SharedWorker : AbstractWorker {
+        readonly attribute MessagePort port;
+    };
+
+}
index b5fee2316c6d8eaede2ae71c02a369d92abd8a87..33a9c4501b1cfcdbde8ddfcde1bdbdb71097f455 100644 (file)
@@ -1,3 +1,14 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Added ENABLE(SHARED_WORKERS) flag (disabled by default).
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2009-07-12  Keishi Hattori  <casey.hattori@gmail.com>
 
         Reviewed by Timothy Hatcher.
index 1f196ea7d99d8902466879ca6d93abc284007be7..69177153f7ce24771bd58dda4e5d10284e724ab0 100644 (file)
@@ -40,6 +40,7 @@ ENABLE_GEOLOCATION = ;
 ENABLE_ICONDATABASE = ENABLE_ICONDATABASE;
 ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER;
 ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS;
+ENABLE_SHARED_WORKERS = ;
 ENABLE_SVG = ENABLE_SVG;
 ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION;
 ENABLE_SVG_AS_IMAGE = ENABLE_SVG_AS_IMAGE;
@@ -53,4 +54,4 @@ ENABLE_WORKERS = ENABLE_WORKERS;
 ENABLE_XPATH = ENABLE_XPATH;
 ENABLE_XSLT = ENABLE_XSLT;
 
-FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT);
index dd4e37fb9e9ad1efce5a19e045076d8504eabe74..fb40511a7550c7726f1bef5734587615d7badae7 100644 (file)
@@ -1,3 +1,14 @@
+2009-07-13  Drew Wilson  <atwilson@google.com>
+
+        Reviewed by David Levin.
+
+        Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs
+        https://bugs.webkit.org/show_bug.cgi?id=26932
+
+        Added support for --shared-workers (turned off by default)
+
+        * Scripts/build-webkit:
+
 2009-07-12  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 9e2f41c33edd590d9bafea79472038fb99094c21..2a551cacb644c937a05a55fe67a69bc921cf7c0d 100755 (executable)
@@ -46,10 +46,10 @@ my $makeArgs;
 
 my ($threeDRenderingSupport, $channelMessagingSupport, $databaseSupport, $domStorageSupport,
     $filtersSupport, $geolocationSupport, $gnomeKeyringSupport, $iconDatabaseSupport,
-    $javaScriptDebuggerSupport, $offlineWebApplicationSupport, $svgSupport, $svgAnimationSupport,
-    $svgAsImageSupport, $svgDOMObjCBindingsSupport, $svgFontsSupport, $svgForeignObjectSupport,
-    $svgUseSupport, $videoSupport, $wmlSupport, $workersSupport, $xpathSupport, $xsltSupport,
-    $coverageSupport);
+    $javaScriptDebuggerSupport, $offlineWebApplicationSupport, $sharedWorkersSupport, $svgSupport,
+    $svgAnimationSupport, $svgAsImageSupport, $svgDOMObjCBindingsSupport, $svgFontsSupport,
+    $svgForeignObjectSupport, $svgUseSupport, $videoSupport, $wmlSupport, $workersSupport,
+    $xpathSupport, $xsltSupport, $coverageSupport);
 
 my @features = (
     { option => "3d-rendering", desc => "Toggle 3D rendering support",
@@ -85,6 +85,9 @@ my @features = (
     { option => "offline-web-applications", desc => "Toggle Offline Web Application Support",
       define => "ENABLE_OFFLINE_WEB_APPLICATIONS", default => 1, value => \$offlineWebApplicationSupport },
 
+    { option => "shared-workers", desc => "Toggle SharedWorkers support",
+      define => "ENABLE_SHARED_WORKERS", default => 0, value => \$sharedWorkersSupport },
+
     { option => "svg", desc => "Toggle SVG support",
       define => "ENABLE_SVG", default => 1, value => \$svgSupport },
 
index 5abe9f32f922eb808e3bd3415bc85c5a58252ec4..f347a26057b86b17dc619fde6aa57714422dd1c6 100644 (file)
@@ -409,6 +409,14 @@ AC_ARG_ENABLE(wml,
               [],[enable_wml="no"])
 AC_MSG_RESULT([$enable_wml])
 
+# check whether to enable SharedWorkers support
+AC_MSG_CHECKING([whether to enable SharedWorkers support])
+AC_ARG_ENABLE(shared_workers,
+              AC_HELP_STRING([--enable-shared-workers],
+                             [enable support for SharedWorkers [default=no]]),
+              [],[enable_shared_workers="no"])
+AC_MSG_RESULT([$enable_shared_workers])
+
 # check whether to enable Web Workers support
 AC_MSG_CHECKING([whether to enable Web Workers support])
 AC_ARG_ENABLE(workers,
@@ -691,6 +699,7 @@ AM_CONDITIONAL([ENABLE_COVERAGE],[test "$enable_coverage" = "yes"])
 AM_CONDITIONAL([ENABLE_FAST_MALLOC],[test "$enable_fast_malloc" = "yes"])
 AM_CONDITIONAL([ENABLE_WML],[test "$enable_wml" = "yes"])
 AM_CONDITIONAL([ENABLE_WORKERS],[test "$enable_workers" = "yes"])
+AM_CONDITIONAL([ENABLE_SHARED_WORKERS],[test "$enable_shared_workers" = "yes"])
 AM_CONDITIONAL([SVG_FLAGS],[test "$svg_flags" = "yes"])
 AM_CONDITIONAL([HTML_FLAGS],[test "$html_flags" = "yes"])
 
@@ -729,6 +738,7 @@ Features:
  HTML5 client-side database storage support               : $enable_database
  HTML5 video element support                              : $enable_video
  Icon database support                                    : $enable_icon_database
+ SharedWorkers support                                    : $enable_shared_workers
  SVG support                                              : $enable_svg
  SVG animation support                                    : $enable_svg_animation
  SVG fonts support                                        : $enable_svg_fonts