[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 11:45:25 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit c17a28e41fdd6f84003142c191be33cb446aaabc
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 5 21:32:14 2010 +0000

    Add script world API for injected bundles
    https://bugs.webkit.org/show_bug.cgi?id=43577
    
    Reviewed by Gavin Barraclough.
    
    * Shared/APIObject.h:
    (WebKit::APIObject::):
    * WebKit2.xcodeproj/project.pbxproj:
    * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
    (WebKit::):
    * WebProcess/InjectedBundle/API/c/WKBundleBase.h:
    * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp: Added.
    (WKBundleScriptWorldGetTypeID):
    (WKBundleScriptWorldCreateWorld):
    (WKBundleScriptWorldNormalWorld):
    (WKBundleScriptWorldRetain):
    (WKBundleScriptWorldRelease):
    * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h: Added.
    * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
    * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp: Added.
    (WebKit::allWorlds):
    (WebKit::InjectedBundleScriptWorld::create):
    (WebKit::InjectedBundleScriptWorld::getOrCreate):
    (WebKit::InjectedBundleScriptWorld::normalWorld):
    (WebKit::InjectedBundleScriptWorld::InjectedBundleScriptWorld):
    (WebKit::InjectedBundleScriptWorld::~InjectedBundleScriptWorld):
    * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h: Added.
    (WebKit::InjectedBundleScriptWorld::type):
    * win/WebKit2.vcproj:
    * win/WebKit2Generated.make:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64788 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 099fe6d..dffc2b2 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,38 @@
 2010-08-05  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Gavin Barraclough.
+
+        Add script world API for injected bundles
+        https://bugs.webkit.org/show_bug.cgi?id=43577
+
+        * Shared/APIObject.h:
+        (WebKit::APIObject::):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
+        (WebKit::):
+        * WebProcess/InjectedBundle/API/c/WKBundleBase.h:
+        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp: Added.
+        (WKBundleScriptWorldGetTypeID):
+        (WKBundleScriptWorldCreateWorld):
+        (WKBundleScriptWorldNormalWorld):
+        (WKBundleScriptWorldRetain):
+        (WKBundleScriptWorldRelease):
+        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h: Added.
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp: Added.
+        (WebKit::allWorlds):
+        (WebKit::InjectedBundleScriptWorld::create):
+        (WebKit::InjectedBundleScriptWorld::getOrCreate):
+        (WebKit::InjectedBundleScriptWorld::normalWorld):
+        (WebKit::InjectedBundleScriptWorld::InjectedBundleScriptWorld):
+        (WebKit::InjectedBundleScriptWorld::~InjectedBundleScriptWorld):
+        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h: Added.
+        (WebKit::InjectedBundleScriptWorld::type):
+        * win/WebKit2.vcproj:
+        * win/WebKit2Generated.make:
+
+2010-08-05  Sam Weinig  <sam at webkit.org>
+
         Reviewed Anders Carlsson.
 
         Add DOM Node wrapper class for injected bundle
diff --git a/WebKit2/Shared/APIObject.h b/WebKit2/Shared/APIObject.h
index fa1b498..eb89f5a 100644
--- a/WebKit2/Shared/APIObject.h
+++ b/WebKit2/Shared/APIObject.h
@@ -55,6 +55,7 @@ public:
         TypeBundle,
         TypeBundleFrame,
         TypeBundlePage,
+        TypeBundleScriptWorld,
         TypeBundleNodeHandle,
 
         // Platform specific
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 97fe9c1..f4ca62f 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -151,6 +151,10 @@
 		BC111B64112F638300337BAB /* WebPageProxyMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BC111B61112F638300337BAB /* WebPageProxyMessageKinds.h */; };
 		BC111B65112F638300337BAB /* WebProcessMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BC111B62112F638300337BAB /* WebProcessMessageKinds.h */; };
 		BC131BC911726C2800B69727 /* CoreIPCMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BC131BC811726C2800B69727 /* CoreIPCMessageKinds.h */; };
+		BC14DF77120B5B7900826C0C /* InjectedBundleScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */; };
+		BC14DF78120B5B7900826C0C /* InjectedBundleScriptWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */; };
+		BC14DF9E120B635F00826C0C /* WKBundleScriptWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */; };
+		BC14DF9F120B635F00826C0C /* WKBundleScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = BC14DF9D120B635F00826C0C /* WKBundleScriptWorld.h */; };
 		BC177465118B9FF4007D9E9A /* WKPagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC177464118B9FF4007D9E9A /* WKPagePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		BC17753F118BABF0007D9E9A /* GenericCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = BC17753E118BABF0007D9E9A /* GenericCallback.h */; };
 		BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A7C571136E19C00FB7167 /* ProcessLauncher.h */; };
@@ -472,6 +476,10 @@
 		BC111B61112F638300337BAB /* WebPageProxyMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageProxyMessageKinds.h; sourceTree = "<group>"; };
 		BC111B62112F638300337BAB /* WebProcessMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessMessageKinds.h; sourceTree = "<group>"; };
 		BC131BC811726C2800B69727 /* CoreIPCMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreIPCMessageKinds.h; sourceTree = "<group>"; };
+		BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleScriptWorld.h; sourceTree = "<group>"; };
+		BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleScriptWorld.cpp; sourceTree = "<group>"; };
+		BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleScriptWorld.cpp; sourceTree = "<group>"; };
+		BC14DF9D120B635F00826C0C /* WKBundleScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleScriptWorld.h; sourceTree = "<group>"; };
 		BC177464118B9FF4007D9E9A /* WKPagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPagePrivate.h; sourceTree = "<group>"; };
 		BC17753E118BABF0007D9E9A /* GenericCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericCallback.h; sourceTree = "<group>"; };
 		BC1A7C571136E19C00FB7167 /* ProcessLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessLauncher.h; sourceTree = "<group>"; };
@@ -1133,6 +1141,8 @@
 				BCA8C6A711E3BA5F00812FB7 /* InjectedBundlePageLoaderClient.h */,
 				BCA8C6AD11E3C08700812FB7 /* InjectedBundlePageUIClient.cpp */,
 				BCA8C6AE11E3C08700812FB7 /* InjectedBundlePageUIClient.h */,
+				BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */,
+				BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */,
 			);
 			path = InjectedBundle;
 			sourceTree = "<group>";
@@ -1174,6 +1184,8 @@
 				BCF049E511FE20F600F86A58 /* WKBundlePrivate.h */,
 				E1EE55F711F8F1BC00CCBEE4 /* WKBundleRange.cpp */,
 				E1EE55F311F8F18900CCBEE4 /* WKBundleRange.h */,
+				BC14DF9C120B635F00826C0C /* WKBundleScriptWorld.cpp */,
+				BC14DF9D120B635F00826C0C /* WKBundleScriptWorld.h */,
 			);
 			path = c;
 			sourceTree = "<group>";
@@ -1418,6 +1430,8 @@
 				1A0F29E4120B44420053D1B9 /* VisitedLinkProvider.h in Headers */,
 				BC4BEEAB120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.h in Headers */,
 				BC4BEFE1120A1A4C00FBA0C7 /* WKBundleNodeHandle.h in Headers */,
+				BC14DF77120B5B7900826C0C /* InjectedBundleScriptWorld.h in Headers */,
+				BC14DF9F120B635F00826C0C /* WKBundleScriptWorld.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1630,6 +1644,8 @@
 				1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */,
 				BC4BEEAC120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp in Sources */,
 				BC4BEFE2120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp in Sources */,
+				BC14DF78120B5B7900826C0C /* InjectedBundleScriptWorld.cpp in Sources */,
+				BC14DF9E120B635F00826C0C /* WKBundleScriptWorld.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
index 6248d2d..fbc1a05 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
@@ -41,6 +41,7 @@ namespace WebKit {
 
 class InjectedBundle;
 class InjectedBundleNodeHandle;
+class InjectedBundleScriptWorld;
 class WebFrame;
 class WebPage;
 
@@ -49,6 +50,7 @@ template<> struct BundleAPITypeInfo<WKBundleFrameRef>                   { typede
 template<> struct BundleAPITypeInfo<WKBundlePageRef>                    { typedef WebPage* ImplType; };
 template<> struct BundleAPITypeInfo<WKBundleRef>                        { typedef InjectedBundle* ImplType; };
 template<> struct BundleAPITypeInfo<WKBundleNodeHandleRef>              { typedef InjectedBundleNodeHandle* ImplType; };
+template<> struct BundleAPITypeInfo<WKBundleScriptWorldRef>             { typedef InjectedBundleScriptWorld* ImplType; };
 template<> struct BundleAPITypeInfo<WKBundleNodeRef>                    { typedef WebCore::Node* ImplType; };
 template<> struct BundleAPITypeInfo<WKBundleRangeRef>                   { typedef WebCore::Range* ImplType; };
 template<> struct BundleAPITypeInfo<WKBundleCSSStyleDeclarationRef>     { typedef WebCore::CSSStyleDeclaration* ImplType; };
@@ -56,6 +58,7 @@ template<> struct BundleAPITypeInfo<WKBundleCSSStyleDeclarationRef>     { typede
 template<typename ImplType> struct BundleImplTypeInfo { };
 template<> struct BundleImplTypeInfo<InjectedBundle*>                   { typedef WKBundleRef APIType; };
 template<> struct BundleImplTypeInfo<InjectedBundleNodeHandle*>         { typedef WKBundleNodeHandleRef APIType; };
+template<> struct BundleImplTypeInfo<InjectedBundleScriptWorld*>        { typedef WKBundleScriptWorldRef APIType; };
 template<> struct BundleImplTypeInfo<WebFrame*>                         { typedef WKBundleFrameRef APIType; };
 template<> struct BundleImplTypeInfo<WebPage*>                          { typedef WKBundlePageRef APIType; };
 template<> struct BundleImplTypeInfo<WebCore::CSSStyleDeclaration*>     { typedef WKBundleCSSStyleDeclarationRef APIType; };
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBase.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBase.h
index be5fda9..194c3c2 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBase.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBase.h
@@ -30,6 +30,7 @@ typedef struct OpaqueWKBundle* WKBundleRef;
 typedef struct OpaqueWKBundleFrame* WKBundleFrameRef;
 typedef struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
 typedef struct OpaqueWKBundlePage* WKBundlePageRef;
+typedef struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef;
 
 typedef struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
 typedef struct OpaqueWKBundleNode* WKBundleNodeRef;
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp
new file mode 100644
index 0000000..e4eb94c
--- /dev/null
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "WKBundleScriptWorld.h"
+
+#include "InjectedBundleScriptWorld.h"
+#include "WKAPICast.h"
+#include "WKBundleAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKBundleScriptWorldGetTypeID()
+{
+    return toRef(InjectedBundleScriptWorld::APIType);
+}
+
+WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld()
+{
+    RefPtr<InjectedBundleScriptWorld> world = InjectedBundleScriptWorld::create();
+    return toRef(world.release().releaseRef());
+}
+
+WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld()
+{
+    return toRef(InjectedBundleScriptWorld::normalWorld());
+}
+
+WKBundleScriptWorldRef WKBundleScriptWorldRetain(WKBundleScriptWorldRef scriptWorldRef)
+{
+    toWK(scriptWorldRef)->ref();
+    return scriptWorldRef;
+}
+
+void WKBundleScriptWorldRelease(WKBundleScriptWorldRef scriptWorldRef)
+{
+    toWK(scriptWorldRef)->deref();
+}
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h
new file mode 100644
index 0000000..dd22a00
--- /dev/null
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WKBundleScriptWorld_h
+#define WKBundleScriptWorld_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKBundleBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBundleScriptWorldGetTypeID();
+
+WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld();
+WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld();
+
+WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldRetain(WKBundleScriptWorldRef scriptWorld);
+WK_EXPORT void WKBundleScriptWorldRelease(WKBundleScriptWorldRef scriptWorld);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKBundleScriptWorld_h */
diff --git a/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
index 35fcb8e..de69f15 100644
--- a/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
@@ -40,21 +40,6 @@ static DOMHandleCache& domHandleCache()
     return cache;
 }
 
-static inline InjectedBundleNodeHandle* getDOMHandle(Node* domObject)
-{
-    return domHandleCache().get(domObject);
-}
-
-static inline void setDOMHandle(Node* domObject, InjectedBundleNodeHandle* handle)
-{
-    domHandleCache().set(domObject, handle);
-}
-
-static inline void removeDOMHandle(Node* domObject)
-{
-    domHandleCache().remove(domObject);
-}
-
 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* node)
 {
     std::pair<DOMHandleCache::iterator, bool> result = domHandleCache().add(node, 0);
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp b/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp
new file mode 100644
index 0000000..ce02390
--- /dev/null
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "InjectedBundleScriptWorld.h"
+
+#include <WebCore/DOMWrapperWorld.h>
+#include <WebCore/ScriptController.h>
+#include <wtf/HashMap.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef HashMap<DOMWrapperWorld*, InjectedBundleScriptWorld*> WorldMap;
+
+static WorldMap& allWorlds()
+{
+    DEFINE_STATIC_LOCAL(WorldMap, map, ());
+    return map;
+}
+
+PassRefPtr<InjectedBundleScriptWorld> InjectedBundleScriptWorld::create()
+{
+    return adoptRef(new InjectedBundleScriptWorld(ScriptController::createWorld()));
+}
+
+PassRefPtr<InjectedBundleScriptWorld> InjectedBundleScriptWorld::getOrCreate(DOMWrapperWorld* world)
+{
+    if (world == mainThreadNormalWorld())
+        return normalWorld();
+
+    if (InjectedBundleScriptWorld* existingWorld = allWorlds().get(world))
+        return existingWorld;
+
+    return adoptRef(new InjectedBundleScriptWorld(world));
+}
+
+InjectedBundleScriptWorld* InjectedBundleScriptWorld::normalWorld()
+{
+    static InjectedBundleScriptWorld* world = adoptRef(new InjectedBundleScriptWorld(mainThreadNormalWorld())).leakRef();
+    return world;
+}
+
+InjectedBundleScriptWorld::InjectedBundleScriptWorld(PassRefPtr<DOMWrapperWorld> world)
+    : m_world(world)
+{
+    ASSERT(!allWorlds().contains(m_world.get()));
+    allWorlds().add(m_world.get(), this);
+}
+
+InjectedBundleScriptWorld::~InjectedBundleScriptWorld()
+{
+    ASSERT(allWorlds().contains(m_world.get()));
+    allWorlds().remove(m_world.get());
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h b/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h
new file mode 100644
index 0000000..0f6e6fa
--- /dev/null
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 InjectedBundleScriptWorld_h
+#define InjectedBundleScriptWorld_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+    class DOMWrapperWorld;
+}
+
+namespace WebKit {
+
+class InjectedBundleScriptWorld : public APIObject {
+public:
+    static const Type APIType = TypeBundleScriptWorld;
+
+    static PassRefPtr<InjectedBundleScriptWorld> create();
+    static PassRefPtr<InjectedBundleScriptWorld> getOrCreate(WebCore::DOMWrapperWorld*);
+    static InjectedBundleScriptWorld* normalWorld();
+
+    ~InjectedBundleScriptWorld();
+
+private:
+    InjectedBundleScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
+
+    virtual Type type() const { return APIType; }
+
+    RefPtr<WebCore::DOMWrapperWorld> m_world;
+};
+
+} // namespace WebKit
+
+#endif // InjectedBundleScriptWorld_h
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index 22daaae..e6a4b48 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -731,6 +731,14 @@
 					RelativePath="..\WebProcess\InjectedBundle\InjectedBundlePageUIClient.h"
 					>
 				</File>
+				<File
+					RelativePath="..\WebProcess\InjectedBundle\InjectedBundleScriptWorld.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\WebProcess\InjectedBundle\InjectedBundleScriptWorld.h"
+					>
+				</File>
 				<Filter
 					Name="API"
 					>
@@ -809,6 +817,14 @@
 							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleRange.h"
 							>
 						</File>
+						<File
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleScriptWorld.cpp"
+							>
+						</File>
+						<File
+							RelativePath="..\WebProcess\InjectedBundle\API\c\WKBundleScriptWorld.h"
+							>
+						</File>
 					</Filter>
 				</Filter>
 				<Filter
diff --git a/WebKit2/win/WebKit2Generated.make b/WebKit2/win/WebKit2Generated.make
index 97c8c51..8e7201c 100644
--- a/WebKit2/win/WebKit2Generated.make
+++ b/WebKit2/win/WebKit2Generated.make
@@ -35,6 +35,7 @@ all:
     xcopy /y /d "..\WebProcess\InjectedBundle\API\c\WKBundlePagePrivate.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\WebProcess\InjectedBundle\API\c\WKBundlePrivate.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     xcopy /y /d "..\WebProcess\InjectedBundle\API\c\WKBundleRange.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
+    xcopy /y /d "..\WebProcess\InjectedBundle\API\c\WKBundleScriptWorld.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
     -del "$(WEBKITOUTPUTDIR)\buildfailed"
 
 clean:

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list