[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
aroben at apple.com
aroben at apple.com
Wed Apr 7 23:35:26 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit f6cbb76a36fea497be2ccf573ba1f80424870586
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Nov 12 22:41:15 2009 +0000
Replace worldIDs with world objects
Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
user scripts/stylesheets and isolated worlds
Reviewed by Sam Weinig.
WebCore:
Covered by existing tests.
* WebCore.base.exp: Update exported symbols to match what now exists
and is needed by WebKit.
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute): Updated for function rename.
* bindings/js/ScriptController.cpp: Removed code that dealt with
worldIDs.
(WebCore::ScriptController::createWorld): Added. Returns a new world
suitable for use on the main thread.
(WebCore::ScriptController::executeScriptInWorld): Renamed from
executeScriptInIsolatedWorld, since this works just fine with a
"normal" world.
* bindings/js/ScriptController.h: Added createWorld, removed functions
that took worldIDs, renamed executeScriptInIsolatedWorld to
executeScriptInWorld.
* page/Frame.cpp:
(WebCore::Frame::injectUserScripts):
(WebCore::Frame::injectUserScriptsForWorld):
Updated for changes to UserScriptMap and ScriptController.
* page/Frame.h: Changed injectUserScriptsForWorld to take a
DOMWrapperWorld* instead of a worldID.
* page/PageGroup.cpp:
(WebCore::PageGroup::addUserScriptToWorld):
(WebCore::PageGroup::addUserStyleSheetToWorld):
(WebCore::PageGroup::removeUserScriptFromWorld):
(WebCore::PageGroup::removeUserStyleSheetFromWorld):
(WebCore::PageGroup::removeUserScriptsFromWorld):
(WebCore::PageGroup::removeUserStyleSheetsFromWorld):
* page/PageGroup.h:
Changed these functions to take a DOMWrapperWorld* instead of a
worldID. Also updated for changes to UserScript and UserStyleSheet.
* page/UserScript.h:
* page/UserStyleSheet.h: Changed not to hold a worldID, since it was
never used.
* page/UserScriptTypes.h:
* page/UserStyleSheetTypes.h: Changed UserScriptMap and
UserStyleSheetMap to use a RefPtr<DOMWrapperWorld> instead of a
worldID as their key type.
WebKit:
* WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project.
WebKit/mac:
WebScriptWorld is the new object that represents a world. The only
place worldID is still used is in -[WebFrame
_stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:],
but that will change soon.
* WebKit.exp: Export WebScriptWorld.
* WebView/WebFrame.mm:
(-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]):
Moved the bizarre world caching/creation logic that DRT depends on
here from the findWorld function in ScriptController.cpp. Updated to
use ScriptController::executeScriptInWorld instead of
ScriptController::executeScriptInIsolatedWorld.
(-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now
takes a WebScriptWorld.
* WebView/WebFramePrivate.h: Replaced contextForWorldID: with
_contextForWorld:.
* WebView/WebScriptWorld.h: Added.
* WebView/WebScriptWorld.mm: Added.
(-[WebScriptWorld initWithWorld:]): Store the passed-in world in our
_private member.
(-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to
-initWithWorld:.
(-[WebScriptWorld dealloc]): Release _private.
(+[WebScriptWorld standardWorld]): Returns a shared instance that
represents WebCore's mainThreadNormalWorld().
(+[WebScriptWorld world]): Returns a new instance.
(core): Returns the DOMWrapperWorld for this WebScriptWorld.
* WebView/WebScriptWorldInternal.h: Added.
* WebView/WebView.mm:
(+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
(+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
(+[WebView _removeUserScriptFromGroup:world:url:]):
(+[WebView _removeUserStyleSheetFromGroup:world:url:]):
(+[WebView _removeUserScriptsFromGroup:world:]):
(+[WebView _removeUserStyleSheetsFromGroup:world:]):
* WebView/WebViewPrivate.h:
Changed these functions to take a WebScriptWorld instead of a worldID.
WebKit/win:
WebScriptWorld is the new object that represents a world. The only
place worldID is still used is in
IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but
that will change soon.
* ForEachCoClass.h: Added WebScriptWorld.
* Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with
contextForWorld.
* Interfaces/IWebScriptWorld.idl: Added.
* Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet
functions to take an IWebScriptWorld instead of a worldID.
* Interfaces/WebKit.idl: Added WebScriptWorld.
* WebFrame.cpp:
(WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes
an IWebScriptWorld.
(WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the
bizarre world caching/creation logic that DRT depends on here from the
findWorld function in ScriptController.cpp. Updated to use
ScriptController::executeScriptInWorld instead of
ScriptController::executeScriptInIsolatedWorld.
* WebFrame.h: Replaced contextForWorldID with contextForWorld.
* WebScriptWorld.cpp: Added.
(WebScriptWorld::WebScriptWorld):
(WebScriptWorld::~WebScriptWorld):
(WebScriptWorld::createInstance):
(WebScriptWorld::AddRef):
(WebScriptWorld::Release):
(WebScriptWorld::QueryInterface):
Standard COM class implementations.
(WebScriptWorld::standardWorld): Returns a shared instance that represents
WebCore's mainThreadNormalWorld().
* WebScriptWorld.h: Added.
(WebScriptWorld::world): Simple getter.
* WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl.
* WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld.
* WebKitClassFactory.cpp: Added WebScriptWorld.
* WebView.cpp:
(WebView::addUserScriptToGroup):
(WebView::addUserStyleSheetToGroup):
(WebView::removeUserScriptFromGroup):
(WebView::removeUserStyleSheetFromGroup):
(WebView::removeUserScriptsFromGroup):
(WebView::removeUserStyleSheetsFromGroup):
* WebView.h:
Changed these functions to take an IWebScriptWorld instead of a worldID.
WebKitTools:
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::addUserScript):
(LayoutTestController::addUserStyleSheet):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::addUserScript):
(LayoutTestController::addUserStyleSheet):
Changed these functions to create a new WebJSWorld each time they're
called and to pass that world to WebKit.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50907 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index aea4b6d..b837830 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,61 @@
+2009-11-12 Adam Roben <aroben at apple.com>
+
+ Replace worldIDs with world objects
+
+ Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
+ user scripts/stylesheets and isolated worlds
+
+ Reviewed by Sam Weinig.
+
+ Covered by existing tests.
+
+ * WebCore.base.exp: Update exported symbols to match what now exists
+ and is needed by WebKit.
+
+ * bindings/js/ScheduledAction.cpp:
+ (WebCore::ScheduledAction::execute): Updated for function rename.
+
+ * bindings/js/ScriptController.cpp: Removed code that dealt with
+ worldIDs.
+ (WebCore::ScriptController::createWorld): Added. Returns a new world
+ suitable for use on the main thread.
+ (WebCore::ScriptController::executeScriptInWorld): Renamed from
+ executeScriptInIsolatedWorld, since this works just fine with a
+ "normal" world.
+
+ * bindings/js/ScriptController.h: Added createWorld, removed functions
+ that took worldIDs, renamed executeScriptInIsolatedWorld to
+ executeScriptInWorld.
+
+ * page/Frame.cpp:
+ (WebCore::Frame::injectUserScripts):
+ (WebCore::Frame::injectUserScriptsForWorld):
+ Updated for changes to UserScriptMap and ScriptController.
+
+ * page/Frame.h: Changed injectUserScriptsForWorld to take a
+ DOMWrapperWorld* instead of a worldID.
+
+ * page/PageGroup.cpp:
+ (WebCore::PageGroup::addUserScriptToWorld):
+ (WebCore::PageGroup::addUserStyleSheetToWorld):
+ (WebCore::PageGroup::removeUserScriptFromWorld):
+ (WebCore::PageGroup::removeUserStyleSheetFromWorld):
+ (WebCore::PageGroup::removeUserScriptsFromWorld):
+ (WebCore::PageGroup::removeUserStyleSheetsFromWorld):
+ * page/PageGroup.h:
+ Changed these functions to take a DOMWrapperWorld* instead of a
+ worldID. Also updated for changes to UserScript and UserStyleSheet.
+
+ * page/UserScript.h:
+ * page/UserStyleSheet.h: Changed not to hold a worldID, since it was
+ never used.
+
+ * page/UserScriptTypes.h:
+ * page/UserStyleSheetTypes.h: Changed UserScriptMap and
+ UserStyleSheetMap to use a RefPtr<DOMWrapperWorld> instead of a
+ worldID as their key type.
+
+
2009-11-12 Brian Weinstein <bweinstein at apple.com>
Reviewed by Tim Hatcher.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 9769f46..90516c1 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -326,6 +326,7 @@ __ZN7WebCore15BackForwardList8goToItemEPNS_11HistoryItemE
__ZN7WebCore15BackForwardList9goForwardEv
__ZN7WebCore15BackForwardListC1EPNS_4PageE
__ZN7WebCore15BackForwardListD1Ev
+__ZN7WebCore15DOMWrapperWorldD1Ev
__ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKNS_6StringE
__ZN7WebCore15DatabaseTracker14quotaForOriginEPNS_14SecurityOriginE
@@ -338,7 +339,6 @@ __ZN7WebCore15DatabaseTracker7originsERN3WTF6VectorINS1_6RefPtrINS_14SecurityOri
__ZN7WebCore15DatabaseTracker7trackerEv
__ZN7WebCore15DatabaseTracker8setQuotaEPNS_14SecurityOriginEy
__ZN7WebCore15DatabaseTracker9setClientEPNS_21DatabaseTrackerClientE
-__ZN7WebCore15DOMWrapperWorldD1Ev
__ZN7WebCore15FocusController10setFocusedEb
__ZN7WebCore15FocusController15setFocusedFrameEN3WTF10PassRefPtrINS_5FrameEEE
__ZN7WebCore15FocusController15setInitialFocusENS_14FocusDirectionEPNS_13KeyboardEventE
@@ -373,10 +373,10 @@ __ZN7WebCore16NavigationActionC1ERKNS_4KURLENS_13FrameLoadTypeEb
__ZN7WebCore16NavigationActionC1ERKNS_4KURLENS_14NavigationTypeE
__ZN7WebCore16NavigationActionC1Ev
__ZN7WebCore16ScriptController10initScriptEPNS_15DOMWrapperWorldE
-__ZN7WebCore16ScriptController12globalObjectEj
+__ZN7WebCore16ScriptController11createWorldEv
__ZN7WebCore16ScriptController13executeScriptERKNS_6StringEb
__ZN7WebCore16ScriptController18windowScriptObjectEv
-__ZN7WebCore16ScriptController28executeScriptInIsolatedWorldEjRKNS_6StringEb
+__ZN7WebCore16ScriptController20executeScriptInWorldEPNS_15DOMWrapperWorldERKNS_6StringEb
__ZN7WebCore16VisibleSelectionC1EPKNS_5RangeENS_9EAffinityE
__ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionES3_
__ZN7WebCore16colorFromNSColorEP7NSColor
@@ -733,15 +733,15 @@ __ZN7WebCore9PageCache11setCapacityEi
__ZN7WebCore9PageCache27releaseAutoreleasedPagesNowEv
__ZN7WebCore9PageGroup14addVisitedLinkEPKtm
__ZN7WebCore9PageGroup17closeLocalStorageEv
-__ZN7WebCore9PageGroup20addUserScriptToWorldEjRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_NS_23UserScriptInjectionTimeE
+__ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_23UserScriptInjectionTimeE
__ZN7WebCore9PageGroup20removeAllUserContentEv
__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
-__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEjRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_
-__ZN7WebCore9PageGroup25removeUserScriptFromWorldEjRKNS_4KURLE
-__ZN7WebCore9PageGroup26removeUserScriptsFromWorldEj
+__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_
+__ZN7WebCore9PageGroup25removeUserScriptFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
+__ZN7WebCore9PageGroup26removeUserScriptsFromWorldEPNS_15DOMWrapperWorldE
__ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
-__ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEjRKNS_4KURLE
-__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEj
+__ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
+__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
__ZN7WebCore9PageGroup9pageGroupERKNS_6StringE
__ZN7WebCore9TimerBase4stopEv
__ZN7WebCore9TimerBase5startEdd
diff --git a/WebCore/bindings/js/ScheduledAction.cpp b/WebCore/bindings/js/ScheduledAction.cpp
index 9a21b6b..f3b32b0 100644
--- a/WebCore/bindings/js/ScheduledAction.cpp
+++ b/WebCore/bindings/js/ScheduledAction.cpp
@@ -126,7 +126,7 @@ void ScheduledAction::execute(Document* document)
executeFunctionInContext(window, window->shell());
Document::updateStyleForAllDocuments();
} else
- frame->script()->executeScriptInIsolatedWorld(m_isolatedWorld.get(), m_code);
+ frame->script()->executeScriptInWorld(m_isolatedWorld.get(), m_code);
frame->script()->setProcessingTimerCallback(false);
}
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index ec39eef..c5f17d9 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -165,42 +165,9 @@ public:
static PassRefPtr<IsolatedWorld> create(JSGlobalData* globalData) { return adoptRef(new IsolatedWorld(globalData)); }
};
-static PassRefPtr<IsolatedWorld> findWorld(unsigned worldID)
+PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
{
- if (!worldID)
- return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
-
- typedef HashMap<unsigned, RefPtr<IsolatedWorld> > WorldMap;
- DEFINE_STATIC_LOCAL(WorldMap, isolatedWorlds, ());
-
- WorldMap::iterator iter = isolatedWorlds.find(worldID);
- if (iter != isolatedWorlds.end())
- return iter->second;
-
- RefPtr<IsolatedWorld> newWorld = IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
- isolatedWorlds.add(worldID, newWorld);
- return newWorld;
-}
-
-JSDOMWindow* ScriptController::globalObject(unsigned worldID)
-{
- RefPtr<DOMWrapperWorld> world = findWorld(worldID);
- return windowShell(world.get())->window();
-}
-
-ScriptValue ScriptController::evaluateInIsolatedWorld(unsigned worldID, const ScriptSourceCode& sourceCode)
-{
- RefPtr<DOMWrapperWorld> world = findWorld(worldID);
- return evaluateInWorld(sourceCode, world.get());
-}
-
-void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sourceCode)
-{
- RefPtr<DOMWrapperWorld> world = findWorld(worldID);
-
- unsigned size = sourceCode.size();
- for (unsigned i = 0; i < size; ++i)
- evaluateInWorld(sourceCode[i], world.get());
+ return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
}
void ScriptController::clearWindowShell()
@@ -476,27 +443,7 @@ void ScriptController::clearScriptObjects()
#endif
}
-ScriptValue ScriptController::executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture)
-{
- ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
-
- if (!isEnabled() || isPaused())
- return ScriptValue();
-
- bool wasInExecuteScript = m_inExecuteScript;
- m_inExecuteScript = true;
-
- ScriptValue result = evaluateInIsolatedWorld(worldID, sourceCode);
-
- if (!wasInExecuteScript) {
- m_inExecuteScript = false;
- Document::updateStyleForAllDocuments();
- }
-
- return result;
-}
-
-ScriptValue ScriptController::executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
+ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
{
ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h
index 3344458..fc6b553 100644
--- a/WebCore/bindings/js/ScriptController.h
+++ b/WebCore/bindings/js/ScriptController.h
@@ -70,6 +70,8 @@ public:
ScriptController(Frame*);
~ScriptController();
+ static PassRefPtr<DOMWrapperWorld> createWorld();
+
JSDOMWindowShell* windowShell(DOMWrapperWorld* world)
{
ShellMap::iterator iter = m_windowShells.find(world);
@@ -84,12 +86,10 @@ public:
{
return windowShell(world)->window();
}
- JSDOMWindow* globalObject(unsigned worldID);
ScriptValue executeScript(const ScriptSourceCode&);
ScriptValue executeScript(const String& script, bool forceUserGesture = false);
- ScriptValue executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture = false);
- ScriptValue executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
+ ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
// Returns true if argument is a JavaScript URL.
bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
@@ -100,8 +100,6 @@ public:
ScriptValue evaluate(const ScriptSourceCode&);
ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
- ScriptValue evaluateInIsolatedWorld(unsigned /*worldID*/, const ScriptSourceCode&);
- void evaluateInIsolatedWorld(unsigned /*worldID*/, const Vector<ScriptSourceCode>&);
void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; }
int eventHandlerLineNumber() { return m_handlerLineNumber; }
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index 6a76ade..d73b56f 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -874,10 +874,10 @@ void Frame::injectUserScripts(UserScriptInjectionTime injectionTime)
return;
UserScriptMap::const_iterator end = userScripts->end();
for (UserScriptMap::const_iterator it = userScripts->begin(); it != end; ++it)
- injectUserScriptsForWorld(it->first, *it->second, injectionTime);
+ injectUserScriptsForWorld(it->first.get(), *it->second, injectionTime);
}
-void Frame::injectUserScriptsForWorld(unsigned worldID, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime)
+void Frame::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime)
{
if (userScripts.isEmpty())
return;
@@ -891,9 +891,8 @@ void Frame::injectUserScriptsForWorld(unsigned worldID, const UserScriptVector&
for (unsigned i = 0; i < count; ++i) {
UserScript* script = userScripts[i].get();
if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->whitelist(), script->blacklist()))
- sourceCode.append(ScriptSourceCode(script->source(), script->url()));
+ m_script.evaluateInWorld(ScriptSourceCode(script->source(), script->url()), world);
}
- script()->evaluateInIsolatedWorld(worldID, sourceCode);
}
bool Frame::shouldChangeSelection(const VisibleSelection& newSelection) const
diff --git a/WebCore/page/Frame.h b/WebCore/page/Frame.h
index 6208bbd..fc52af9 100644
--- a/WebCore/page/Frame.h
+++ b/WebCore/page/Frame.h
@@ -131,7 +131,7 @@ namespace WebCore {
void injectUserScripts(UserScriptInjectionTime);
private:
- void injectUserScriptsForWorld(unsigned worldID, const UserScriptVector&, UserScriptInjectionTime);
+ void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
private:
Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
diff --git a/WebCore/page/PageGroup.cpp b/WebCore/page/PageGroup.cpp
index 427c240..558c5cb 100644
--- a/WebCore/page/PageGroup.cpp
+++ b/WebCore/page/PageGroup.cpp
@@ -200,29 +200,29 @@ StorageNamespace* PageGroup::localStorage()
}
#endif
-void PageGroup::addUserScriptToWorld(unsigned worldID, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
+void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
PassOwnPtr<Vector<String> > blacklist, UserScriptInjectionTime injectionTime)
{
- if (worldID == UINT_MAX)
- return;
- OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, worldID, injectionTime));
+ ASSERT_ARG(world, world);
+
+ OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, injectionTime));
if (!m_userScripts)
m_userScripts.set(new UserScriptMap);
- UserScriptVector*& scriptsInWorld = m_userScripts->add(worldID, 0).first->second;
+ UserScriptVector*& scriptsInWorld = m_userScripts->add(world, 0).first->second;
if (!scriptsInWorld)
scriptsInWorld = new UserScriptVector;
scriptsInWorld->append(userScript.release());
}
-void PageGroup::addUserStyleSheetToWorld(unsigned worldID, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
+void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
PassOwnPtr<Vector<String> > blacklist)
{
- if (worldID == UINT_MAX)
- return;
- OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist, worldID));
+ ASSERT_ARG(world, world);
+
+ OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist));
if (!m_userStyleSheets)
m_userStyleSheets.set(new UserStyleSheetMap);
- UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(worldID, 0).first->second;
+ UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(world, 0).first->second;
if (!styleSheetsInWorld)
styleSheetsInWorld = new UserStyleSheetVector;
styleSheetsInWorld->append(userStyleSheet.release());
@@ -235,12 +235,14 @@ void PageGroup::addUserStyleSheetToWorld(unsigned worldID, const String& source,
}
}
-void PageGroup::removeUserScriptFromWorld(unsigned worldID, const KURL& url)
+void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const KURL& url)
{
+ ASSERT_ARG(world, world);
+
if (!m_userScripts)
return;
- UserScriptMap::iterator it = m_userScripts->find(worldID);
+ UserScriptMap::iterator it = m_userScripts->find(world);
if (it == m_userScripts->end())
return;
@@ -257,12 +259,14 @@ void PageGroup::removeUserScriptFromWorld(unsigned worldID, const KURL& url)
m_userScripts->remove(it);
}
-void PageGroup::removeUserStyleSheetFromWorld(unsigned worldID, const KURL& url)
+void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const KURL& url)
{
+ ASSERT_ARG(world, world);
+
if (!m_userStyleSheets)
return;
- UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
+ UserStyleSheetMap::iterator it = m_userStyleSheets->find(world);
bool sheetsChanged = false;
if (it == m_userStyleSheets->end())
return;
@@ -291,12 +295,14 @@ void PageGroup::removeUserStyleSheetFromWorld(unsigned worldID, const KURL& url)
}
}
-void PageGroup::removeUserScriptsFromWorld(unsigned worldID)
+void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld* world)
{
+ ASSERT_ARG(world, world);
+
if (!m_userScripts)
return;
- UserScriptMap::iterator it = m_userScripts->find(worldID);
+ UserScriptMap::iterator it = m_userScripts->find(world);
if (it == m_userScripts->end())
return;
@@ -304,12 +310,14 @@ void PageGroup::removeUserScriptsFromWorld(unsigned worldID)
m_userScripts->remove(it);
}
-void PageGroup::removeUserStyleSheetsFromWorld(unsigned worldID)
+void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world)
{
+ ASSERT_ARG(world, world);
+
if (!m_userStyleSheets)
return;
- UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
+ UserStyleSheetMap::iterator it = m_userStyleSheets->find(world);
if (it == m_userStyleSheets->end())
return;
diff --git a/WebCore/page/PageGroup.h b/WebCore/page/PageGroup.h
index c233cd1..446f0c7 100644
--- a/WebCore/page/PageGroup.h
+++ b/WebCore/page/PageGroup.h
@@ -70,17 +70,17 @@ namespace WebCore {
bool hasLocalStorage() { return m_localStorage; }
#endif
- void addUserScriptToWorld(unsigned worldID, const String& source, const KURL&,
+ void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
UserScriptInjectionTime);
- void addUserStyleSheetToWorld(unsigned worldID, const String& source, const KURL&,
+ void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist);
- void removeUserScriptFromWorld(unsigned, const KURL&);
- void removeUserStyleSheetFromWorld(unsigned, const KURL&);
+ void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&);
+ void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&);
- void removeUserScriptsFromWorld(unsigned);
- void removeUserStyleSheetsFromWorld(unsigned);
+ void removeUserScriptsFromWorld(DOMWrapperWorld*);
+ void removeUserStyleSheetsFromWorld(DOMWrapperWorld*);
void removeAllUserContent();
diff --git a/WebCore/page/UserScript.h b/WebCore/page/UserScript.h
index 57a0c5d..8b3703f 100644
--- a/WebCore/page/UserScript.h
+++ b/WebCore/page/UserScript.h
@@ -38,12 +38,11 @@ class UserScript : public Noncopyable {
public:
UserScript(const String& source, const KURL& url,
PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
- unsigned worldID, UserScriptInjectionTime injectionTime)
+ UserScriptInjectionTime injectionTime)
: m_source(source)
, m_url(url)
, m_whitelist(whitelist)
, m_blacklist(blacklist)
- , m_worldID(worldID)
, m_injectionTime(injectionTime)
{
}
@@ -52,7 +51,6 @@ public:
const KURL& url() const { return m_url; }
const Vector<String>* whitelist() const { return m_whitelist.get(); }
const Vector<String>* blacklist() const { return m_blacklist.get(); }
- unsigned worldID() const { return m_worldID; }
UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
private:
@@ -60,7 +58,6 @@ private:
KURL m_url;
OwnPtr<Vector<String> > m_whitelist;
OwnPtr<Vector<String> > m_blacklist;
- unsigned m_worldID;
UserScriptInjectionTime m_injectionTime;
};
diff --git a/WebCore/page/UserScriptTypes.h b/WebCore/page/UserScriptTypes.h
index ac37662..ad27e79 100644
--- a/WebCore/page/UserScriptTypes.h
+++ b/WebCore/page/UserScriptTypes.h
@@ -33,10 +33,11 @@ namespace WebCore {
enum UserScriptInjectionTime { InjectAtDocumentStart, InjectAtDocumentEnd };
+class DOMWrapperWorld;
class UserScript;
typedef Vector<OwnPtr<UserScript> > UserScriptVector;
-typedef HashMap<unsigned, UserScriptVector*> UserScriptMap;
+typedef HashMap<RefPtr<DOMWrapperWorld>, UserScriptVector*> UserScriptMap;
} // namespace WebCore
diff --git a/WebCore/page/UserStyleSheet.h b/WebCore/page/UserStyleSheet.h
index 2f51ed4..610778f 100644
--- a/WebCore/page/UserStyleSheet.h
+++ b/WebCore/page/UserStyleSheet.h
@@ -37,13 +37,11 @@ namespace WebCore {
class UserStyleSheet : public Noncopyable {
public:
UserStyleSheet(const String& source, const KURL& url,
- PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
- unsigned worldID)
+ PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist)
: m_source(source)
, m_url(url)
, m_whitelist(whitelist)
, m_blacklist(blacklist)
- , m_worldID(worldID)
{
}
@@ -51,14 +49,12 @@ public:
const KURL& url() const { return m_url; }
const Vector<String>* whitelist() const { return m_whitelist.get(); }
const Vector<String>* blacklist() const { return m_blacklist.get(); }
- unsigned worldID() const { return m_worldID; }
private:
String m_source;
KURL m_url;
OwnPtr<Vector<String> > m_whitelist;
OwnPtr<Vector<String> > m_blacklist;
- unsigned m_worldID;
};
} // namespace WebCore
diff --git a/WebCore/page/UserStyleSheetTypes.h b/WebCore/page/UserStyleSheetTypes.h
index 094b2cf..ef662f2 100644
--- a/WebCore/page/UserStyleSheetTypes.h
+++ b/WebCore/page/UserStyleSheetTypes.h
@@ -31,10 +31,11 @@
namespace WebCore {
+class DOMWrapperWorld;
class UserStyleSheet;
typedef Vector<OwnPtr<UserStyleSheet> > UserStyleSheetVector;
-typedef HashMap<unsigned, UserStyleSheetVector*> UserStyleSheetMap;
+typedef HashMap<RefPtr<DOMWrapperWorld>, UserStyleSheetVector*> UserStyleSheetMap;
} // namespace WebCore
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 0325fd2..242d44e 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-12 Adam Roben <aroben at apple.com>
+
+ Replace worldIDs with world objects
+
+ Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
+ user scripts/stylesheets and isolated worlds
+
+ Reviewed by Sam Weinig.
+
+ * WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project.
+
2009-11-12 Chris Fleizach <cfleizach at apple.com>
Reviewed by Darin Adler.
diff --git a/WebKit/WebKit.xcodeproj/project.pbxproj b/WebKit/WebKit.xcodeproj/project.pbxproj
index a5a2e39..a36ea6c 100644
--- a/WebKit/WebKit.xcodeproj/project.pbxproj
+++ b/WebKit/WebKit.xcodeproj/project.pbxproj
@@ -333,6 +333,9 @@
BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC97E7E110963D260010D361 /* WebViewEventHandling.mm */; };
C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */; };
C0167BF90D7F5DD00028696E /* WebScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */; };
+ C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; };
+ C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; };
DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; };
DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
DD89682109AA87240097E7F0 /* WebElementDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */; };
@@ -621,6 +624,9 @@
BEE52D4B0473032500CA289C /* WebKitSystemBits.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitSystemBits.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugger.h; sourceTree = "<group>"; };
C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptDebugger.mm; sourceTree = "<group>"; };
+ C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorld.h; sourceTree = "<group>"; };
+ C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; };
+ C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; };
DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; };
DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebElementDictionary.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -1130,6 +1136,9 @@
7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.mm */,
C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */,
C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */,
+ C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */,
+ C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */,
+ C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */,
936A2DE90FD2D08400D312DB /* WebTextCompletionController.h */,
936A2DE70FD2D08000D312DB /* WebTextCompletionController.mm */,
F834AAD50E64B1C700E2737C /* WebTextIterator.h */,
@@ -1513,6 +1522,8 @@
0FD3B0F41076C3E900039B96 /* WebVideoFullscreenHUDWindowController.h in Headers */,
0FD3B0F81076C3F700039B96 /* WebWindowAnimation.h in Headers */,
0A2D87FD107AF52B00CDDEE3 /* WebPluginHalterClient.h in Headers */,
+ C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
+ C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1853,6 +1864,7 @@
0FD3B0F91076C3F700039B96 /* WebWindowAnimation.m in Sources */,
0A2D87FE107AF52B00CDDEE3 /* WebPluginHalterClient.mm in Sources */,
BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */,
+ C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 866819c..a68a4ff 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,55 @@
+2009-11-12 Adam Roben <aroben at apple.com>
+
+ Replace worldIDs with world objects
+
+ WebScriptWorld is the new object that represents a world. The only
+ place worldID is still used is in -[WebFrame
+ _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:],
+ but that will change soon.
+
+ Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
+ user scripts/stylesheets and isolated worlds
+
+ Reviewed by Sam Weinig.
+
+ * WebKit.exp: Export WebScriptWorld.
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]):
+ Moved the bizarre world caching/creation logic that DRT depends on
+ here from the findWorld function in ScriptController.cpp. Updated to
+ use ScriptController::executeScriptInWorld instead of
+ ScriptController::executeScriptInIsolatedWorld.
+ (-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now
+ takes a WebScriptWorld.
+
+ * WebView/WebFramePrivate.h: Replaced contextForWorldID: with
+ _contextForWorld:.
+
+ * WebView/WebScriptWorld.h: Added.
+ * WebView/WebScriptWorld.mm: Added.
+ (-[WebScriptWorld initWithWorld:]): Store the passed-in world in our
+ _private member.
+ (-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to
+ -initWithWorld:.
+ (-[WebScriptWorld dealloc]): Release _private.
+ (+[WebScriptWorld standardWorld]): Returns a shared instance that
+ represents WebCore's mainThreadNormalWorld().
+ (+[WebScriptWorld world]): Returns a new instance.
+ (core): Returns the DOMWrapperWorld for this WebScriptWorld.
+
+ * WebView/WebScriptWorldInternal.h: Added.
+
+ * WebView/WebView.mm:
+ (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
+ (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
+ (+[WebView _removeUserScriptFromGroup:world:url:]):
+ (+[WebView _removeUserStyleSheetFromGroup:world:url:]):
+ (+[WebView _removeUserScriptsFromGroup:world:]):
+ (+[WebView _removeUserStyleSheetsFromGroup:world:]):
+ * WebView/WebViewPrivate.h:
+ Changed these functions to take a WebScriptWorld instead of a worldID.
+
2009-11-12 Chris Fleizach <cfleizach at apple.com>
Reviewed by Darin Adler.
diff --git a/WebKit/mac/WebKit.exp b/WebKit/mac/WebKit.exp
index 12507d0..f4280da 100644
--- a/WebKit/mac/WebKit.exp
+++ b/WebKit/mac/WebKit.exp
@@ -28,6 +28,7 @@
.objc_class_name_WebRenderNode
.objc_class_name_WebResource
.objc_class_name_WebScriptCallFrame
+.objc_class_name_WebScriptWorld
.objc_class_name_WebSecurityOrigin
.objc_class_name_WebStringTruncator
.objc_class_name_WebTextIterator
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 6715d45..b8a5be7 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -49,6 +49,7 @@
#import "WebNSObjectExtras.h"
#import "WebNSURLExtras.h"
#import "WebScriptDebugger.h"
+#import "WebScriptWorldInternal.h"
#import "WebViewInternal.h"
#import <JavaScriptCore/APICast.h>
#import <WebCore/AXObjectCache.h>
@@ -1203,7 +1204,22 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
// Get the frame frome the global object we've settled on.
Frame* frame = anyWorldGlobalObject->impl()->frame();
ASSERT(frame->document());
- JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue();
+
+ // Get the world to execute in based on the worldID. DRT expects that a
+ // worldID of 0 always corresponds to a newly-created world, while any
+ // other worldID corresponds to a world that is created once and then
+ // cached forever.
+ RefPtr<DOMWrapperWorld> world;
+ if (!worldID)
+ world = ScriptController::createWorld();
+ else {
+ static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >;
+ RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second;
+ if (!worldSlot)
+ worldSlot = ScriptController::createWorld();
+ world = worldSlot;
+ }
+ JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue();
if (!frame) // In case the script removed our frame from the page.
return @"";
@@ -1218,12 +1234,15 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return String(result.toString(anyWorldGlobalObject->globalExec()));
}
-- (JSGlobalContextRef)contextForWorldID:(unsigned)worldID;
+- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world
{
Frame* coreFrame = _private->coreFrame;
if (!coreFrame)
return 0;
- return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec());
+ DOMWrapperWorld* coreWorld = core(world);
+ if (!coreWorld)
+ return 0;
+ return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec());
}
@end
diff --git a/WebKit/mac/WebView/WebFramePrivate.h b/WebKit/mac/WebView/WebFramePrivate.h
index be13430..cc12775 100644
--- a/WebKit/mac/WebView/WebFramePrivate.h
+++ b/WebKit/mac/WebView/WebFramePrivate.h
@@ -39,6 +39,7 @@
@class DOMNode;
@class WebIconFetcher;
@class WebScriptObject;
+ at class WebScriptWorld;
// Keys for accessing the values in the page cache dictionary.
extern NSString *WebPageCacheEntryDateKey;
@@ -97,7 +98,7 @@ typedef enum {
#endif
- (NSString *)_stringByEvaluatingJavaScriptInIsolatedWorld:(unsigned)worldID WithGlobalObject:(JSObjectRef)globalObject FromString:(NSString *)string;
-- (JSGlobalContextRef)contextForWorldID:(unsigned)worldID;
+- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world;
// Pause a given CSS animation or transition on the target node at a specific time.
// If the animation or transition is already paused, it will update its pause time.
diff --git a/WebKit/mac/WebView/WebScriptWorld.h b/WebKit/mac/WebView/WebScriptWorld.h
new file mode 100644
index 0000000..9204975
--- /dev/null
+++ b/WebKit/mac/WebView/WebScriptWorld.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+ at class WebScriptWorldPrivate;
+
+ at interface WebScriptWorld : NSObject {
+ at private
+ WebScriptWorldPrivate *_private;
+}
+
++ (WebScriptWorld *)standardWorld;
++ (WebScriptWorld *)world;
+ at end
diff --git a/WebKit/mac/WebView/WebScriptWorld.mm b/WebKit/mac/WebView/WebScriptWorld.mm
new file mode 100644
index 0000000..8e954cd
--- /dev/null
+++ b/WebKit/mac/WebView/WebScriptWorld.mm
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+#import "WebScriptWorld.h"
+
+#import "WebScriptWorldInternal.h"
+#import <WebCore/JSDOMBinding.h>
+#import <WebCore/ScriptController.h>
+#import <wtf/RefPtr.h>
+
+using namespace WebCore;
+
+ at interface WebScriptWorldPrivate : NSObject {
+ at public
+ RefPtr<DOMWrapperWorld> world;
+}
+ at end
+
+ at implementation WebScriptWorldPrivate
+ at end
+
+ at implementation WebScriptWorld
+
+- (id)initWithWorld:(PassRefPtr<DOMWrapperWorld>)world
+{
+ ASSERT_ARG(world, world);
+ if (!world)
+ return nil;
+
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _private = [[WebScriptWorldPrivate alloc] init];
+ _private->world = world;
+
+ return self;
+}
+
+- (id)init
+{
+ return [self initWithWorld:ScriptController::createWorld()];
+}
+
+- (void)dealloc
+{
+ [_private release];
+ _private = nil;
+ [super dealloc];
+}
+
++ (WebScriptWorld *)standardWorld
+{
+ static WebScriptWorld *world = [[WebScriptWorld alloc] initWithWorld:mainThreadNormalWorld()];
+ return world;
+}
+
++ (WebScriptWorld *)world
+{
+ return [[[self alloc] init] autorelease];
+}
+
+DOMWrapperWorld* core(WebScriptWorld *world)
+{
+ return world ? world->_private->world.get() : 0;
+}
+
+ at end
diff --git a/WebKit/mac/WebView/WebScriptWorldInternal.h b/WebKit/mac/WebView/WebScriptWorldInternal.h
new file mode 100644
index 0000000..bff808e
--- /dev/null
+++ b/WebKit/mac/WebView/WebScriptWorldInternal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+#import "WebScriptWorld.h"
+
+namespace WebCore {
+ class DOMWrapperWorld;
+}
+
+WebCore::DOMWrapperWorld* core(WebScriptWorld *);
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 25da631..38332f7 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -90,6 +90,7 @@
#import "WebPreferenceKeysPrivate.h"
#import "WebPreferencesPrivate.h"
#import "WebScriptDebugDelegate.h"
+#import "WebScriptWorldInternal.h"
#import "WebSystemInterface.h"
#import "WebTextCompletionController.h"
#import "WebTextIterator.h"
@@ -2175,36 +2176,36 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
return patternsVector;
}
-+ (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url
++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime
{
String group(groupName);
- if (group.isEmpty() || worldID == UINT_MAX)
+ if (group.isEmpty())
return;
PageGroup* pageGroup = PageGroup::pageGroup(group);
if (!pageGroup)
return;
- pageGroup->addUserScriptToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist),
+ pageGroup->addUserScriptToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist),
injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
}
-+ (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
{
String group(groupName);
- if (group.isEmpty() || worldID == UINT_MAX)
+ if (group.isEmpty())
return;
PageGroup* pageGroup = PageGroup::pageGroup(group);
if (!pageGroup)
return;
- pageGroup->addUserStyleSheetToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist));
+ pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist));
}
-+ (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url
++ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url
{
String group(groupName);
if (group.isEmpty())
@@ -2214,10 +2215,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
if (!pageGroup)
return;
- pageGroup->removeUserScriptFromWorld(worldID, url);
+ pageGroup->removeUserScriptFromWorld(core(world), url);
}
-+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url
++ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url
{
String group(groupName);
if (group.isEmpty())
@@ -2227,10 +2228,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
if (!pageGroup)
return;
- pageGroup->removeUserStyleSheetFromWorld(worldID, url);
+ pageGroup->removeUserStyleSheetFromWorld(core(world), url);
}
-+ (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID
++ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world
{
String group(groupName);
if (group.isEmpty())
@@ -2240,10 +2241,10 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
if (!pageGroup)
return;
- pageGroup->removeUserScriptsFromWorld(worldID);
+ pageGroup->removeUserScriptsFromWorld(core(world));
}
-+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID
++ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world
{
String group(groupName);
if (group.isEmpty())
@@ -2253,7 +2254,7 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
if (!pageGroup)
return;
- pageGroup->removeUserStyleSheetsFromWorld(worldID);
+ pageGroup->removeUserStyleSheetsFromWorld(core(world));
}
+ (void)_removeAllUserContentFromGroup:(NSString *)groupName
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
index 99bd5fa..e17cec0 100644
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ b/WebKit/mac/WebView/WebViewPrivate.h
@@ -45,6 +45,7 @@
@class WebFrame;
@class WebInspector;
@class WebPreferences;
+ at class WebScriptWorld;
@class WebTextIterator;
@protocol WebFormDelegate;
@@ -479,12 +480,12 @@ Could be worth adding to the API.
// Removes all white list entries created with _whiteListAccessFromOrigin.
+ (void)_resetOriginAccessWhiteLists;
-+ (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
-+ (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
-+ (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url;
-+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url;
-+ (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
-+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
++ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
++ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
++ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
++ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
+ (void)_removeAllUserContentFromGroup:(NSString *)groupName;
/*!
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 2b97b35..a7c29e0 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,5 +1,73 @@
2009-11-12 Adam Roben <aroben at apple.com>
+ Replace worldIDs with world objects
+
+ WebScriptWorld is the new object that represents a world. The only
+ place worldID is still used is in
+ IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but
+ that will change soon.
+
+ Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
+ user scripts/stylesheets and isolated worlds
+
+ Reviewed by Sam Weinig.
+
+ * ForEachCoClass.h: Added WebScriptWorld.
+
+ * Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with
+ contextForWorld.
+
+ * Interfaces/IWebScriptWorld.idl: Added.
+
+ * Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet
+ functions to take an IWebScriptWorld instead of a worldID.
+
+ * Interfaces/WebKit.idl: Added WebScriptWorld.
+
+ * WebFrame.cpp:
+ (WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes
+ an IWebScriptWorld.
+ (WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the
+ bizarre world caching/creation logic that DRT depends on here from the
+ findWorld function in ScriptController.cpp. Updated to use
+ ScriptController::executeScriptInWorld instead of
+ ScriptController::executeScriptInIsolatedWorld.
+
+ * WebFrame.h: Replaced contextForWorldID with contextForWorld.
+
+ * WebScriptWorld.cpp: Added.
+ (WebScriptWorld::WebScriptWorld):
+ (WebScriptWorld::~WebScriptWorld):
+ (WebScriptWorld::createInstance):
+ (WebScriptWorld::AddRef):
+ (WebScriptWorld::Release):
+ (WebScriptWorld::QueryInterface):
+ Standard COM class implementations.
+
+ (WebScriptWorld::standardWorld): Returns a shared instance that represents
+ WebCore's mainThreadNormalWorld().
+
+ * WebScriptWorld.h: Added.
+ (WebScriptWorld::world): Simple getter.
+
+ * WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl.
+
+ * WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld.
+
+ * WebKitClassFactory.cpp: Added WebScriptWorld.
+
+ * WebView.cpp:
+ (WebView::addUserScriptToGroup):
+ (WebView::addUserStyleSheetToGroup):
+ (WebView::removeUserScriptFromGroup):
+ (WebView::removeUserStyleSheetFromGroup):
+ (WebView::removeUserScriptsFromGroup):
+ (WebView::removeUserStyleSheetsFromGroup):
+ * WebView.h:
+ Changed these functions to take an IWebScriptWorld instead of a worldID.
+
+2009-11-12 Adam Roben <aroben at apple.com>
+
Small clean-up in WebView's user content functions
Preparation for <http://webkit.org/b/31414> Implement new SPI for
diff --git a/WebKit/win/ForEachCoClass.h b/WebKit/win/ForEachCoClass.h
index 26f4a6c..39f8e32 100644
--- a/WebKit/win/ForEachCoClass.h
+++ b/WebKit/win/ForEachCoClass.h
@@ -63,6 +63,7 @@
macro(WebCoreStatistics) \
macro(WebCookieManager) \
macro(WebWorkersPrivate) \
+ macro(WebScriptWorld) \
// end of macro
// Everything below this point is deprecated. Please do not use.
diff --git a/WebKit/win/Interfaces/IWebFramePrivate.idl b/WebKit/win/Interfaces/IWebFramePrivate.idl
index 15a8dc3..c97ed5a 100644
--- a/WebKit/win/Interfaces/IWebFramePrivate.idl
+++ b/WebKit/win/Interfaces/IWebFramePrivate.idl
@@ -32,6 +32,7 @@ import "IWebFrame.idl";
interface IWebFrame;
interface IWebIconFetcher;
interface IWebIconFetcherDelegate;
+interface IWebScriptWorld;
typedef enum {
WebFrameLoadTypeStandard,
@@ -96,7 +97,7 @@ interface IWebFramePrivate : IUnknown
HRESULT stringByEvaluatingJavaScriptInIsolatedWorld([in] unsigned worldID, [in] OLE_HANDLE jsGlobalObject, [in] BSTR script, [out, retval] BSTR* result);
- [local] JSGlobalContextRef contextForWorldID([in] unsigned worldID);
+ [local] JSGlobalContextRef globalContextForScriptWorld([in] IWebScriptWorld*);
HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result);
}
diff --git a/WebKit/win/Interfaces/IWebScriptWorld.idl b/WebKit/win/Interfaces/IWebScriptWorld.idl
new file mode 100644
index 0000000..255255c
--- /dev/null
+++ b/WebKit/win/Interfaces/IWebScriptWorld.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 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 DO_NO_IMPORTS
+import "oaidl.idl";
+import "ocidl.idl";
+#endif
+
+[
+ object,
+ oleautomation,
+ uuid(EBD45575-8184-4f22-B849-A5FE88336055),
+ pointer_default(unique)
+]
+interface IWebScriptWorld : IUnknown {
+ HRESULT standardWorld([out, retval] IWebScriptWorld**);
+}
diff --git a/WebKit/win/Interfaces/IWebViewPrivate.idl b/WebKit/win/Interfaces/IWebViewPrivate.idl
index d95f92b..1c8cea2 100644
--- a/WebKit/win/Interfaces/IWebViewPrivate.idl
+++ b/WebKit/win/Interfaces/IWebViewPrivate.idl
@@ -184,18 +184,17 @@ interface IWebViewPrivate : IUnknown
*/
HRESULT MIMETypeForExtension([in] BSTR extension, [out, retval] BSTR* mimeType);
- // For the following functions, 0 < worldID < UINT_MAX.
- HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
+ HRESULT addUserScriptToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url,
[in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
[in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist,
[in] WebUserScriptInjectionTime injectionTime);
- HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
+ HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url,
[in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
[in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist);
- HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
- HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
- HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] unsigned worldID);
- HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] unsigned worldID);
+ HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url);
+ HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url);
+ HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*);
+ HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*);
HRESULT removeAllUserContentFromGroup([in] BSTR groupName);
HRESULT setPluginHalterDelegate([in] IWebPluginHalterDelegate* d);
diff --git a/WebKit/win/Interfaces/WebKit.idl b/WebKit/win/Interfaces/WebKit.idl
index cdd24b3..bbdbb2c 100644
--- a/WebKit/win/Interfaces/WebKit.idl
+++ b/WebKit/win/Interfaces/WebKit.idl
@@ -113,6 +113,7 @@ import "ocidl.idl";
#include "IWebResource.idl"
#include "IWebResourceLoadDelegate.idl"
#include "IWebResourceLoadDelegatePrivate.idl"
+#include "IWebScriptWorld.idl"
#include "IWebScrollBarDelegatePrivate.idl"
#include "IWebScrollBarPrivate.idl"
#include "IWebSecurityOrigin.idl"
@@ -271,4 +272,9 @@ library WebKit
coclass WebWorkersPrivate{
[default] interface IWebWorkersPrivate;
}
+
+ [uuid(D3C301EE-D59A-49c0-A43A-9EA01CDB1590)]
+ coclass WebScriptWorld {
+ [default] interface IWebScriptWorld;
+ }
}
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index 1e64d1a..4f9c353 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -29,29 +29,30 @@
#include "WebFrame.h"
#include "CFDictionaryPropertyBag.h"
-#include "COMPtr.h"
#include "COMPropertyBag.h"
-#include "DefaultPolicyDelegate.h"
+#include "COMPtr.h"
#include "DOMCoreClasses.h"
+#include "DefaultPolicyDelegate.h"
#include "HTMLFrameOwnerElement.h"
#include "MarshallingHelpers.h"
#include "WebActionPropertyBag.h"
#include "WebChromeClient.h"
+#include "WebDataSource.h"
#include "WebDocumentLoader.h"
#include "WebDownload.h"
-#include "WebError.h"
-#include "WebMutableURLRequest.h"
#include "WebEditorClient.h"
+#include "WebError.h"
#include "WebFramePolicyListener.h"
#include "WebHistory.h"
+#include "WebHistoryItem.h"
#include "WebIconFetcher.h"
#include "WebKit.h"
#include "WebKitStatisticsPrivate.h"
+#include "WebMutableURLRequest.h"
#include "WebNotificationCenter.h"
-#include "WebView.h"
-#include "WebDataSource.h"
-#include "WebHistoryItem.h"
+#include "WebScriptWorld.h"
#include "WebURLResponse.h"
+#include "WebView.h"
#pragma warning( push, 0 )
#include <WebCore/BString.h>
#include <WebCore/Cache.h>
@@ -490,14 +491,17 @@ JSGlobalContextRef STDMETHODCALLTYPE WebFrame::globalContext()
return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
}
-JSGlobalContextRef STDMETHODCALLTYPE WebFrame::contextForWorldID(
- /* [in] */ unsigned worldID)
+JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld)
{
Frame* coreFrame = core(this);
if (!coreFrame)
return 0;
- return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec());
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return 0;
+
+ return toGlobalRef(coreFrame->script()->globalObject(world->world())->globalExec());
}
HRESULT STDMETHODCALLTYPE WebFrame::loadRequest(
@@ -2194,7 +2198,22 @@ HRESULT STDMETHODCALLTYPE WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld(
// Get the frame frome the global object we've settled on.
Frame* frame = anyWorldGlobalObject->impl()->frame();
ASSERT(frame->document());
- JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue();
+
+ // Get the world to execute in based on the worldID. DRT expects that a
+ // worldID of 0 always corresponds to a newly-created world, while any
+ // other worldID corresponds to a world that is created once and then
+ // cached forever.
+ RefPtr<DOMWrapperWorld> world;
+ if (!worldID)
+ world = ScriptController::createWorld();
+ else {
+ static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >;
+ RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second;
+ if (!worldSlot)
+ worldSlot = ScriptController::createWorld();
+ world = worldSlot;
+ }
+ JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue();
if (!frame) // In case the script removed our frame from the page.
return S_OK;
diff --git a/WebKit/win/WebFrame.h b/WebKit/win/WebFrame.h
index d0f6adf..5788bd5 100644
--- a/WebKit/win/WebFrame.h
+++ b/WebKit/win/WebFrame.h
@@ -254,8 +254,7 @@ public:
/* [in] */ BSTR script,
/* [retval][out] */ BSTR* evaluationResult);
- virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE contextForWorldID(
- /* [in] */ unsigned worldID);
+ virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*);
// IWebDocumentText
virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding(
diff --git a/WebKit/win/WebKit.vcproj/Interfaces.vcproj b/WebKit/win/WebKit.vcproj/Interfaces.vcproj
index 75c7c11..ad82d94 100644
--- a/WebKit/win/WebKit.vcproj/Interfaces.vcproj
+++ b/WebKit/win/WebKit.vcproj/Interfaces.vcproj
@@ -1324,6 +1324,26 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\Interfaces\IWebScriptWorld.idl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\Interfaces\IWebScrollBarDelegatePrivate.idl"
>
<FileConfiguration
diff --git a/WebKit/win/WebKit.vcproj/WebKit.vcproj b/WebKit/win/WebKit.vcproj/WebKit.vcproj
index 22c4c55..f426539 100644
--- a/WebKit/win/WebKit.vcproj/WebKit.vcproj
+++ b/WebKit/win/WebKit.vcproj/WebKit.vcproj
@@ -722,6 +722,10 @@
>
</File>
<File
+ RelativePath="..\WebScriptWorld.h"
+ >
+ </File>
+ <File
RelativePath="..\WebKitStatistics.h"
>
</File>
@@ -1090,6 +1094,10 @@
>
</File>
<File
+ RelativePath="..\WebScriptWorld.cpp"
+ >
+ </File>
+ <File
RelativePath="..\WebKitStatistics.cpp"
>
</File>
diff --git a/WebKit/win/WebKitClassFactory.cpp b/WebKit/win/WebKitClassFactory.cpp
index 27b053d..b233a5c 100644
--- a/WebKit/win/WebKitClassFactory.cpp
+++ b/WebKit/win/WebKitClassFactory.cpp
@@ -27,8 +27,8 @@
#include "WebKitDLL.h"
#include "WebKitClassFactory.h"
-#include "ForEachCoClass.h"
#include "CFDictionaryPropertyBag.h"
+#include "ForEachCoClass.h"
#include "WebArchive.h"
#include "WebCache.h"
#include "WebCookieManager.h"
@@ -42,11 +42,12 @@
#include "WebIconDatabase.h"
#include "WebJavaScriptCollector.h"
#include "WebKit.h"
-#include "WebScrollBar.h"
#include "WebKitStatistics.h"
#include "WebMutableURLRequest.h"
#include "WebNotificationCenter.h"
#include "WebPreferences.h"
+#include "WebScriptWorld.h"
+#include "WebScrollBar.h"
#include "WebTextRenderer.h"
#include "WebURLCredential.h"
#include "WebURLProtectionSpace.h"
diff --git a/WebKit/win/WebScriptWorld.cpp b/WebKit/win/WebScriptWorld.cpp
new file mode 100644
index 0000000..5f1cffa
--- /dev/null
+++ b/WebKit/win/WebScriptWorld.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2009 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 "config.h"
+#include "WebKitDLL.h"
+#include "WebScriptWorld.h"
+
+#include <WebCore/JSDOMBinding.h>
+#include <WebCore/ScriptController.h>
+
+using namespace WebCore;
+
+inline WebScriptWorld::WebScriptWorld(PassRefPtr<DOMWrapperWorld> world)
+ : m_refCount(0)
+ , m_world(world)
+{
+ ASSERT_ARG(world, m_world);
+
+ ++gClassCount;
+ gClassNameCount.add("WebScriptWorld");
+}
+
+WebScriptWorld::~WebScriptWorld()
+{
+ --gClassCount;
+ gClassNameCount.remove("WebScriptWorld");
+}
+
+COMPtr<WebScriptWorld> WebScriptWorld::createInstance()
+{
+ return createInstance(ScriptController::createWorld());
+}
+
+COMPtr<WebScriptWorld> WebScriptWorld::createInstance(PassRefPtr<DOMWrapperWorld> world)
+{
+ return new WebScriptWorld(world);
+}
+
+ULONG WebScriptWorld::AddRef()
+{
+ return ++m_refCount;
+}
+
+ULONG WebScriptWorld::Release()
+{
+ ULONG newRefCount = --m_refCount;
+ if (!newRefCount)
+ delete this;
+ return newRefCount;
+}
+
+HRESULT WebScriptWorld::QueryInterface(REFIID riid, void** ppvObject)
+{
+ if (!ppvObject)
+ return E_POINTER;
+ *ppvObject = 0;
+
+ if (IsEqualIID(riid, __uuidof(WebScriptWorld)))
+ *ppvObject = this;
+ else if (IsEqualIID(riid, __uuidof(IWebScriptWorld)))
+ *ppvObject = static_cast<IWebScriptWorld*>(this);
+ else if (IsEqualIID(riid, IID_IUnknown))
+ *ppvObject = static_cast<IUnknown*>(this);
+ else
+ return E_NOINTERFACE;
+
+ AddRef();
+ return S_OK;
+}
+
+HRESULT WebScriptWorld::standardWorld(IWebScriptWorld** outWorld)
+{
+ if (!outWorld)
+ return E_POINTER;
+
+ static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef();
+
+ *outWorld = standardWorld;
+ standardWorld->AddRef();
+ return S_OK;
+}
diff --git a/WebKit/win/WebScriptWorld.h b/WebKit/win/WebScriptWorld.h
new file mode 100644
index 0000000..b5b288f
--- /dev/null
+++ b/WebKit/win/WebScriptWorld.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 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 WebScriptWorld_h
+#define WebScriptWorld_h
+
+#include <WebCore/COMPtr.h>
+
+namespace WebCore {
+ class DOMWrapperWorld;
+}
+
+class WebScriptWorld : public Noncopyable, public IWebScriptWorld {
+public:
+ static COMPtr<WebScriptWorld> createInstance();
+ static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release();
+
+ WebCore::DOMWrapperWorld* world() const { return m_world.get(); }
+
+private:
+ WebScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
+ ~WebScriptWorld();
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void** ppvObject);
+ virtual HRESULT STDMETHODCALLTYPE standardWorld(IWebScriptWorld**);
+
+ ULONG m_refCount;
+ RefPtr<WebCore::DOMWrapperWorld> m_world;
+};
+
+#endif // WebScriptWorld_h
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index b3b6c35..0c39618 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -31,17 +31,17 @@
#include "DOMCoreClasses.h"
#include "MarshallingHelpers.h"
#include "SoftLinking.h"
+#include "WebBackForwardList.h"
+#include "WebChromeClient.h"
+#include "WebContextMenuClient.h"
+#include "WebCoreTextRenderer.h"
#include "WebDatabaseManager.h"
#include "WebDocumentLoader.h"
#include "WebDownload.h"
+#include "WebDragClient.h"
#include "WebEditorClient.h"
#include "WebElementPropertyBag.h"
#include "WebFrame.h"
-#include "WebBackForwardList.h"
-#include "WebChromeClient.h"
-#include "WebContextMenuClient.h"
-#include "WebCoreTextRenderer.h"
-#include "WebDragClient.h"
#include "WebIconDatabase.h"
#include "WebInspector.h"
#include "WebInspectorClient.h"
@@ -52,6 +52,7 @@
#include "WebNotificationCenter.h"
#include "WebPluginHalterClient.h"
#include "WebPreferences.h"
+#include "WebScriptWorld.h"
#include "WindowsTouch.h"
#pragma warning( push, 0 )
#include <WebCore/ApplicationCacheStorage.h>
@@ -5490,13 +5491,17 @@ static PassOwnPtr<Vector<String> > toStringVector(unsigned patternsCount, BSTR*
return patternsVector;
}
-HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+HRESULT WebView::addUserScriptToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url,
unsigned whitelistCount, BSTR* whitelist,
unsigned blacklistCount, BSTR* blacklist,
WebUserScriptInjectionTime injectionTime)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5504,19 +5509,23 @@ HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR sou
if (!pageGroup)
return E_FAIL;
- pageGroup->addUserScriptToWorld(worldID, toString(source), toKURL(url),
+ pageGroup->addUserScriptToWorld(world->world(), toString(source), toKURL(url),
toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist),
injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
return S_OK;
}
-HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url,
unsigned whitelistCount, BSTR* whitelist,
unsigned blacklistCount, BSTR* blacklist)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5524,16 +5533,20 @@ HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR
if (!pageGroup)
return E_FAIL;
- pageGroup->addUserStyleSheetToWorld(worldID, toString(source), toKURL(url),
+ pageGroup->addUserStyleSheetToWorld(world->world(), toString(source), toKURL(url),
toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist));
return S_OK;
}
-HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url)
+HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5541,15 +5554,19 @@ HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BST
if (!pageGroup)
return E_FAIL;
- pageGroup->removeUserScriptFromWorld(worldID, toKURL(url));
+ pageGroup->removeUserScriptFromWorld(world->world(), toKURL(url));
return S_OK;
}
-HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url)
+HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5557,15 +5574,19 @@ HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID,
if (!pageGroup)
return E_FAIL;
- pageGroup->removeUserStyleSheetFromWorld(worldID, toKURL(url));
+ pageGroup->removeUserStyleSheetFromWorld(world->world(), toKURL(url));
return S_OK;
}
-HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID)
+HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld* iWorld)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5573,14 +5594,18 @@ HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID)
if (!pageGroup)
return E_FAIL;
- pageGroup->removeUserScriptsFromWorld(worldID);
+ pageGroup->removeUserScriptsFromWorld(world->world());
return S_OK;
}
-HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID)
+HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld* iWorld)
{
+ COMPtr<WebScriptWorld> world(Query, iWorld);
+ if (!world)
+ return E_POINTER;
+
String group = toString(groupName);
- if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
+ if (group.isEmpty())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
@@ -5588,7 +5613,7 @@ HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID
if (!pageGroup)
return E_FAIL;
- pageGroup->removeUserStyleSheetsFromWorld(worldID);
+ pageGroup->removeUserStyleSheetsFromWorld(world->world());
return S_OK;
}
diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h
index b4c1239..ea86dd7 100644
--- a/WebKit/win/WebView.h
+++ b/WebKit/win/WebView.h
@@ -740,17 +740,17 @@ public:
virtual HRESULT STDMETHODCALLTYPE setCanStartPlugins(
/* [in] */ BOOL canStartPlugins);
- virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+ virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url,
unsigned whitelistCount, BSTR* whitelist,
unsigned blacklistCount, BSTR* blacklist,
WebUserScriptInjectionTime);
- virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+ virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url,
unsigned whitelistCount, BSTR* whitelist,
unsigned blacklistCount, BSTR* blacklist);
- virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url);
- virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url);
- virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, unsigned worldID);
- virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID);
+ virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url);
+ virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url);
+ virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld*);
+ virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld*);
virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName);
virtual HRESULT STDMETHODCALLTYPE setPluginHalterDelegate(IWebPluginHalterDelegate*);
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index b849e00..02bd387 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,21 @@
+2009-11-12 Adam Roben <aroben at apple.com>
+
+ Replace worldIDs with world objects
+
+ Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
+ user scripts/stylesheets and isolated worlds
+
+ Reviewed by Sam Weinig.
+
+ * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+ (LayoutTestController::addUserScript):
+ (LayoutTestController::addUserStyleSheet):
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::addUserScript):
+ (LayoutTestController::addUserStyleSheet):
+ Changed these functions to create a new WebJSWorld each time they're
+ called and to pass that world to WebKit.
+
2009-11-11 Chris Fleizach <cfleizach at apple.com>
Reviewed by Oliver Hunt.
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 4d6a609..15bc0d4 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -43,20 +43,21 @@
#import <WebKit/WebApplicationCache.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebCoreStatistics.h>
-#import <WebKit/WebDatabaseManagerPrivate.h>
#import <WebKit/WebDataSource.h>
+#import <WebKit/WebDatabaseManagerPrivate.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebFrameViewPrivate.h>
-#import <WebKit/WebIconDatabasePrivate.h>
+#import <WebKit/WebGeolocationMockPrivate.h>
#import <WebKit/WebHTMLRepresentation.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebHistory.h>
#import <WebKit/WebHistoryPrivate.h>
+#import <WebKit/WebIconDatabasePrivate.h>
#import <WebKit/WebInspectorPrivate.h>
-#import <WebKit/WebGeolocationMockPrivate.h>
#import <WebKit/WebNSURLExtras.h>
#import <WebKit/WebPreferences.h>
#import <WebKit/WebPreferencesPrivate.h>
+#import <WebKit/WebScriptWorld.h>
#import <WebKit/WebSecurityOriginPrivate.h>
#import <WebKit/WebTypesInternal.h>
#import <WebKit/WebView.h>
@@ -501,14 +502,14 @@ void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
{
RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
NSString *sourceNS = (NSString *)sourceCF.get();
- [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
+ [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
}
void LayoutTestController::addUserStyleSheet(JSStringRef source)
{
RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
NSString *sourceNS = (NSString *)sourceCF.get();
- [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil];
+ [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil];
}
void LayoutTestController::showWebInspector()
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index d3cac7a..4158233 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -659,7 +659,7 @@ static void CALLBACK waitUntilDoneWatchdogFired(HWND, UINT, UINT_PTR, DWORD)
void LayoutTestController::setWaitToDump(bool waitUntilDone)
{
m_waitToDump = waitUntilDone;
- if (m_waitToDump && !waitToDumpWatchdog)
+ if (false && m_waitToDump && !waitToDumpWatchdog)
waitToDumpWatchdog = SetTimer(0, 0, waitToDumpWatchdogInterval * 1000, waitUntilDoneWatchdogFired);
}
@@ -861,7 +861,11 @@ void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView))))
return;
- webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd);
+ COMPtr<IWebScriptWorld> world;
+ if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
+ return;
+
+ webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd);
}
@@ -871,7 +875,11 @@ void LayoutTestController::addUserStyleSheet(JSStringRef source)
if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView))))
return;
- webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0);
+ COMPtr<IWebScriptWorld> world;
+ if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
+ return;
+
+ webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0);
}
void LayoutTestController::showWebInspector()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list