[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:29:30 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 9780a4cb82f71c87f75aae4115459199ec8b15f8
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 27 14:41:42 2010 +0000

    2010-01-27  Marcus Bulach  <bulach at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Adds EventSource bindings for V8
            https://bugs.webkit.org/show_bug.cgi?id=33695
    
            No new tests (existing layout tests for EventSource should pass).
    
            * Android.v8bindings.mk:
            * WebCore.gypi:
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/v8/DOMObjectsInclude.h:
            * bindings/v8/DerivedSourcesAllInOne.cpp:
            * bindings/v8/V8DOMWrapper.cpp:
            * bindings/v8/V8DOMWrapper.h:
            * bindings/v8/V8Index.cpp:
            * bindings/v8/V8Index.h:
            * bindings/v8/WorkerContextExecutionProxy.cpp:
            * bindings/v8/custom/V8CustomBinding.h:
            * bindings/v8/custom/V8EventSourceConstructor.cpp: Added.
            * bindings/v8/custom/V8EventSourceCustom.cpp: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk
index 7aa21c5..2c2bc44 100644
--- a/WebCore/Android.v8bindings.mk
+++ b/WebCore/Android.v8bindings.mk
@@ -110,6 +110,8 @@ LOCAL_SRC_FILES += \
 	bindings/v8/custom/V8DocumentLocationCustom.cpp \
 	bindings/v8/custom/V8ElementCustom.cpp \
 	bindings/v8/custom/V8EventCustom.cpp \
+	bindings/v8/custom/V8EventSourceConstructor.cpp \
+	bindings/v8/custom/V8EventSourceCustom.cpp \
 	bindings/v8/custom/V8FileListCustom.cpp \
 	bindings/v8/custom/V8GeolocationCustom.cpp \
 	bindings/v8/custom/V8HTMLAllCollectionCustom.cpp \
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 09746db..67371ea 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-01-27  Marcus Bulach  <bulach at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Adds EventSource bindings for V8
+        https://bugs.webkit.org/show_bug.cgi?id=33695
+
+        No new tests (existing layout tests for EventSource should pass).
+
+        * Android.v8bindings.mk:
+        * WebCore.gypi:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/DOMObjectsInclude.h:
+        * bindings/v8/DerivedSourcesAllInOne.cpp:
+        * bindings/v8/V8DOMWrapper.cpp:
+        * bindings/v8/V8DOMWrapper.h:
+        * bindings/v8/V8Index.cpp:
+        * bindings/v8/V8Index.h:
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        * bindings/v8/custom/V8CustomBinding.h:
+        * bindings/v8/custom/V8EventSourceConstructor.cpp: Added.
+        * bindings/v8/custom/V8EventSourceCustom.cpp: Added.
+
 2010-01-27  Kent Hansen  <kent.hansen at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 3e565ee..dfc34e7 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -196,6 +196,7 @@
             'page/Coordinates.idl',
             'page/DOMSelection.idl',
             'page/DOMWindow.idl',
+            'page/EventSource.idl',
             'page/Geolocation.idl',
             'page/Geoposition.idl',
             'page/History.idl',
@@ -693,6 +694,8 @@
             'bindings/v8/custom/V8DocumentCustom.cpp',
             'bindings/v8/custom/V8ElementCustom.cpp',
             'bindings/v8/custom/V8EventCustom.cpp',
+            'bindings/v8/custom/V8EventSourceConstructor.cpp',
+            'bindings/v8/custom/V8EventSourceCustom.cpp',
             'bindings/v8/custom/V8GeolocationCustom.cpp',
             'bindings/v8/custom/V8HistoryCustom.cpp',
             'bindings/v8/custom/V8HTMLAudioElementConstructor.cpp',
@@ -1796,6 +1799,8 @@
             'page/EditorClient.h',
             'page/EventHandler.cpp',
             'page/EventHandler.h',
+            'page/EventSource.cpp',
+            'page/EventSource.h',
             'page/FocusController.cpp',
             'page/FocusController.h',
             'page/FocusDirection.h',
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index eda0497..a7bb4b5 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -357,6 +357,7 @@ sub GetInternalFields
     return ("cacheIndex", "implementationIndex") if ($name eq "Document") || ($name eq "SVGDocument");
     return ("cacheIndex", "implementationIndex", "markerIndex", "shadowIndex") if $name eq "HTMLDocument";
     return ("cacheIndex") if IsNodeSubType($dataNode);
+    return ("cacheIndex") if $name eq "EventSource";
     return ("cacheIndex") if $name eq "XMLHttpRequest";
     return ("cacheIndex") if $name eq "XMLHttpRequestUpload";
     return ("cacheIndex") if $name eq "MessagePort";
diff --git a/WebCore/bindings/v8/DOMObjectsInclude.h b/WebCore/bindings/v8/DOMObjectsInclude.h
index afefe13..3cb8e17 100644
--- a/WebCore/bindings/v8/DOMObjectsInclude.h
+++ b/WebCore/bindings/v8/DOMObjectsInclude.h
@@ -188,6 +188,10 @@
 #include "StorageEvent.h"
 #endif // DOM_STORAGE
 
+#if ENABLE(EVENTSOURCE)
+#include "EventSource.h"
+#endif // EVENTSOURCE
+
 // GEOLOCATION
 #include "Coordinates.h"
 #include "Geolocation.h"
diff --git a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
index 56a3fda..291c616 100644
--- a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
+++ b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
@@ -424,3 +424,7 @@
 #include "bindings/V8InspectorBackend.cpp"
 #include "bindings/V8InspectorFrontendHost.cpp"
 #endif
+
+#if ENABLE(EVENTSOURCE)
+#include "bindings/V8EventSource.cpp"
+#endif
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index d5d01cd..111f148 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -259,6 +259,13 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
         break;
     }
 
+#if ENABLE(EVENTSOURCE)
+    case V8ClassIndex::EVENTSOURCE: {
+        descriptor->SetCallHandler(USE_CALLBACK(EventSourceConstructor));
+        break;
+    }
+#endif
+
 #if ENABLE(WORKERS)
     case V8ClassIndex::WORKER: {
         descriptor->SetCallHandler(USE_CALLBACK(WorkerConstructor));
@@ -1226,6 +1233,12 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta
         return convertToV8Object(V8ClassIndex::DOMAPPLICATIONCACHE, domAppCache);
 #endif
 
+#if ENABLE(EVENTSOURCE)
+    EventSource* eventSource = target->toEventSource();
+    if (eventSource)
+        return convertToV8Object(V8ClassIndex::EVENTSOURCE, eventSource);
+#endif
+
     ASSERT(0);
     return notHandledByInterceptor();
 }
@@ -1290,6 +1303,22 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(XMLHttpRequestUpload* u
     return getEventListener(upload->associatedXMLHttpRequest(), value, isAttribute, lookup);
 }
 
+#if ENABLE(EVENTSOURCE)
+PassRefPtr<EventListener> V8DOMWrapper::getEventListener(EventSource* eventSource, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
+{
+    if (V8Proxy::retrieve(eventSource->scriptExecutionContext()))
+        return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
+
+#if ENABLE(WORKERS)
+    WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve();
+    if (workerContextProxy)
+        return workerContextProxy->findOrCreateEventListener(value, isAttribute, lookup == ListenerFindOnly);
+#endif
+
+    return 0;
+}
+#endif
+
 PassRefPtr<EventListener> V8DOMWrapper::getEventListener(EventTarget* eventTarget, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
 {
     if (V8Proxy::retrieve(eventTarget->scriptExecutionContext()))
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index bdf6547..16f5913 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -190,6 +190,10 @@ namespace WebCore {
 
         static PassRefPtr<EventListener> getEventListener(XMLHttpRequestUpload* upload, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
 
+#if ENABLE(EVENTSOURCE)
+        static PassRefPtr<EventListener> getEventListener(EventSource* eventTarget, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
+#endif
+
         static PassRefPtr<EventListener> getEventListener(EventTarget* eventTarget, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
 
         static PassRefPtr<EventListener> getEventListener(V8Proxy* proxy, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp
index c1050fe..8ba0ef7 100644
--- a/WebCore/bindings/v8/V8Index.cpp
+++ b/WebCore/bindings/v8/V8Index.cpp
@@ -445,6 +445,10 @@
 #include "V8InspectorFrontendHost.h"
 #endif
 
+#if ENABLE(EVENTSOURCE)
+#include "V8EventSource.h"
+#endif
+
 // Geolocation
 #include "V8Coordinates.h"
 #include "V8Geolocation.h"
diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h
index 6904456..d291809 100644
--- a/WebCore/bindings/v8/V8Index.h
+++ b/WebCore/bindings/v8/V8Index.h
@@ -85,6 +85,13 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
 #define WORKER_NONNODE_WRAPPER_TYPES(V)
 #endif
 
+#if ENABLE(EVENTSOURCE)
+#define EVENTSOURCE_ACTIVE_OBJECT_WRAPPER_TYPES(V)                      \
+    V(EVENTSOURCE, EventSource)
+#else
+#define EVENTSOURCE_ACTIVE_OBJECT_WRAPPER_TYPES(V)
+#endif
+
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
 #define APPLICATIONCACHE_NONNODE_WRAPPER_TYPES(V)                       \
   V(DOMAPPLICATIONCACHE, DOMApplicationCache)
@@ -321,7 +328,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
     V(XMLHTTPREQUEST, XMLHttpRequest)                                   \
     WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)                               \
     SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V)                        \
-    WEBSOCKET_ACTIVE_OBJECT_WRAPPER_TYPES(V)
+    WEBSOCKET_ACTIVE_OBJECT_WRAPPER_TYPES(V)                            \
+    EVENTSOURCE_ACTIVE_OBJECT_WRAPPER_TYPES(V)
 
 // NOTE: DOM_OBJECT_TYPES is split into two halves because
 //       Visual Studio's Intellinonsense crashes when macros get
diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
index 57d612f..ac677a2 100644
--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
@@ -38,6 +38,7 @@
 #include "DOMCoreException.h"
 #include "DedicatedWorkerContext.h"
 #include "Event.h"
+#include "EventSource.h"
 #include "Notification.h"
 #include "NotificationCenter.h"
 #include "EventException.h"
@@ -326,6 +327,12 @@ v8::Handle<v8::Value> WorkerContextExecutionProxy::convertEventTargetToV8Object(
         return convertToV8Object(V8ClassIndex::WEBSOCKET, webSocket);
 #endif
 
+#if ENABLE(EVENTSOURCE)
+    EventSource* eventSource = target->toEventSource();
+    if (eventSource)
+        return convertToV8Object(V8ClassIndex::EVENTSOURCE, eventSource);
+#endif
+
     ASSERT_NOT_REACHED();
     return v8::Handle<v8::Value>();
 }
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index 82ff825..801c3d2 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -75,6 +75,10 @@ namespace WebCore {
         DECLARE_CALLBACK(WebSocketConstructor);
 #endif
 
+#if ENABLE(EVENTSOURCE)
+        DECLARE_CALLBACK(EventSourceConstructor);
+#endif
+
 #undef DECLARE_CALLBACK
     };
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8EventSourceConstructor.cpp b/WebCore/bindings/v8/custom/V8EventSourceConstructor.cpp
new file mode 100644
index 0000000..8c3e015
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8EventSourceConstructor.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2010 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(EVENTSOURCE)
+#include "V8EventSource.h"
+
+#include "EventSource.h"
+#include "Frame.h"
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
+#include "WorkerContext.h"
+#include "WorkerContextExecutionProxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8Custom::v8EventSourceConstructorCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.EventSource.Constructor");
+
+    if (!args.IsConstructCall())
+        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+
+    // Expect one parameter.
+    // Allocate an EventSource object as its internal field.
+    ScriptExecutionContext* context = getScriptExecutionContext();
+    if (!context)
+        return throwError("EventSource constructor's associated context is not available", V8Proxy::ReferenceError);
+    if (args.Length() != 1)
+        return throwError("EventSource constructor wrong number of parameters", V8Proxy::TypeError);
+
+    ExceptionCode ec = 0;
+    String url = toWebCoreString(args[0]);
+
+    RefPtr<EventSource> eventSource = EventSource::create(url, context, ec);
+    
+    if (ec)
+        return throwError(ec);
+
+    V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::EVENTSOURCE), eventSource.get());
+
+    // Add object to the wrapper map.
+    eventSource->ref();
+    V8DOMWrapper::setJSWrapperForActiveDOMObject(eventSource.get(), v8::Persistent<v8::Object>::New(args.Holder()));
+    return args.Holder();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(EVENTSOURCE)
diff --git a/WebCore/bindings/v8/custom/V8EventSourceCustom.cpp b/WebCore/bindings/v8/custom/V8EventSourceCustom.cpp
new file mode 100644
index 0000000..e603549
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8EventSourceCustom.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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(EVENTSOURCE)
+#include "V8EventSource.h"
+
+#include "EventSource.h"
+
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8EventSource::addEventListenerCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.EventSource.addEventListener()");
+    EventSource* eventSource = V8EventSource::toNative(args.Holder());
+
+    RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(eventSource, args[1], false, ListenerFindOrCreate);
+    if (listener) {
+        String type = toWebCoreString(args[0]);
+        bool useCapture = args[2]->BooleanValue();
+        eventSource->addEventListener(type, listener, useCapture);
+
+        createHiddenDependency(args.Holder(), args[1], cacheIndex);
+    }
+    return v8::Undefined();
+}
+
+v8::Handle<v8::Value> V8EventSource::removeEventListenerCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.EventSource.removeEventListener()");
+    EventSource* eventSource = V8EventSource::toNative(args.Holder());
+
+    RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(eventSource, args[1], false, ListenerFindOnly);
+    if (listener) {
+        String type = toWebCoreString(args[0]);
+        bool useCapture = args[2]->BooleanValue();
+        eventSource->removeEventListener(type, listener.get(), useCapture);
+
+        removeHiddenDependency(args.Holder(), args[1], cacheIndex);
+    }
+
+    return v8::Undefined();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(EVENTSOURCE)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list