-
aroben@apple.com authored
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
f6cbb76a