Changeset 50907 in webkit
- Timestamp:
- Nov 12, 2009, 2:41:15 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r50905 r50907 1 2009-11-12 Adam Roben <aroben@apple.com> 2 3 Replace worldIDs with world objects 4 5 Part of <http://webkit.org/b/31414> Implement new SPI for dealing with 6 user scripts/stylesheets and isolated worlds 7 8 Reviewed by Sam Weinig. 9 10 Covered by existing tests. 11 12 * WebCore.base.exp: Update exported symbols to match what now exists 13 and is needed by WebKit. 14 15 * bindings/js/ScheduledAction.cpp: 16 (WebCore::ScheduledAction::execute): Updated for function rename. 17 18 * bindings/js/ScriptController.cpp: Removed code that dealt with 19 worldIDs. 20 (WebCore::ScriptController::createWorld): Added. Returns a new world 21 suitable for use on the main thread. 22 (WebCore::ScriptController::executeScriptInWorld): Renamed from 23 executeScriptInIsolatedWorld, since this works just fine with a 24 "normal" world. 25 26 * bindings/js/ScriptController.h: Added createWorld, removed functions 27 that took worldIDs, renamed executeScriptInIsolatedWorld to 28 executeScriptInWorld. 29 30 * page/Frame.cpp: 31 (WebCore::Frame::injectUserScripts): 32 (WebCore::Frame::injectUserScriptsForWorld): 33 Updated for changes to UserScriptMap and ScriptController. 34 35 * page/Frame.h: Changed injectUserScriptsForWorld to take a 36 DOMWrapperWorld* instead of a worldID. 37 38 * page/PageGroup.cpp: 39 (WebCore::PageGroup::addUserScriptToWorld): 40 (WebCore::PageGroup::addUserStyleSheetToWorld): 41 (WebCore::PageGroup::removeUserScriptFromWorld): 42 (WebCore::PageGroup::removeUserStyleSheetFromWorld): 43 (WebCore::PageGroup::removeUserScriptsFromWorld): 44 (WebCore::PageGroup::removeUserStyleSheetsFromWorld): 45 * page/PageGroup.h: 46 Changed these functions to take a DOMWrapperWorld* instead of a 47 worldID. Also updated for changes to UserScript and UserStyleSheet. 48 49 * page/UserScript.h: 50 * page/UserStyleSheet.h: Changed not to hold a worldID, since it was 51 never used. 52 53 * page/UserScriptTypes.h: 54 * page/UserStyleSheetTypes.h: Changed UserScriptMap and 55 UserStyleSheetMap to use a RefPtr<DOMWrapperWorld> instead of a 56 worldID as their key type. 57 58 1 59 2009-11-12 Brian Weinstein <bweinstein@apple.com> 2 60 -
trunk/WebCore/WebCore.base.exp
r50792 r50907 327 327 __ZN7WebCore15BackForwardListC1EPNS_4PageE 328 328 __ZN7WebCore15BackForwardListD1Ev 329 __ZN7WebCore15DOMWrapperWorldD1Ev 329 330 __ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE 330 331 __ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKNS_6StringE … … 339 340 __ZN7WebCore15DatabaseTracker8setQuotaEPNS_14SecurityOriginEy 340 341 __ZN7WebCore15DatabaseTracker9setClientEPNS_21DatabaseTrackerClientE 341 __ZN7WebCore15DOMWrapperWorldD1Ev342 342 __ZN7WebCore15FocusController10setFocusedEb 343 343 __ZN7WebCore15FocusController15setFocusedFrameEN3WTF10PassRefPtrINS_5FrameEEE … … 374 374 __ZN7WebCore16NavigationActionC1Ev 375 375 __ZN7WebCore16ScriptController10initScriptEPNS_15DOMWrapperWorldE 376 __ZN7WebCore16ScriptController1 2globalObjectEj376 __ZN7WebCore16ScriptController11createWorldEv 377 377 __ZN7WebCore16ScriptController13executeScriptERKNS_6StringEb 378 378 __ZN7WebCore16ScriptController18windowScriptObjectEv 379 __ZN7WebCore16ScriptController2 8executeScriptInIsolatedWorldEjRKNS_6StringEb379 __ZN7WebCore16ScriptController20executeScriptInWorldEPNS_15DOMWrapperWorldERKNS_6StringEb 380 380 __ZN7WebCore16VisibleSelectionC1EPKNS_5RangeENS_9EAffinityE 381 381 __ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionES3_ … … 734 734 __ZN7WebCore9PageGroup14addVisitedLinkEPKtm 735 735 __ZN7WebCore9PageGroup17closeLocalStorageEv 736 __ZN7WebCore9PageGroup20addUserScriptToWorldE jRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_NS_23UserScriptInjectionTimeE736 __ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_23UserScriptInjectionTimeE 737 737 __ZN7WebCore9PageGroup20removeAllUserContentEv 738 738 __ZN7WebCore9PageGroup21removeAllVisitedLinksEv 739 __ZN7WebCore9PageGroup24addUserStyleSheetToWorldE jRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_740 __ZN7WebCore9PageGroup25removeUserScriptFromWorldE jRKNS_4KURLE741 __ZN7WebCore9PageGroup26removeUserScriptsFromWorldE j739 __ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_ 740 __ZN7WebCore9PageGroup25removeUserScriptFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE 741 __ZN7WebCore9PageGroup26removeUserScriptsFromWorldEPNS_15DOMWrapperWorldE 742 742 __ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb 743 __ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldE jRKNS_4KURLE744 __ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldE j743 __ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE 744 __ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE 745 745 __ZN7WebCore9PageGroup9pageGroupERKNS_6StringE 746 746 __ZN7WebCore9TimerBase4stopEv -
trunk/WebCore/bindings/js/ScheduledAction.cpp
r49963 r50907 127 127 Document::updateStyleForAllDocuments(); 128 128 } else 129 frame->script()->executeScriptIn IsolatedWorld(m_isolatedWorld.get(), m_code);129 frame->script()->executeScriptInWorld(m_isolatedWorld.get(), m_code); 130 130 131 131 frame->script()->setProcessingTimerCallback(false); -
trunk/WebCore/bindings/js/ScriptController.cpp
r50792 r50907 166 166 }; 167 167 168 static PassRefPtr<IsolatedWorld> findWorld(unsigned worldID) 169 { 170 if (!worldID) 171 return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData()); 172 173 typedef HashMap<unsigned, RefPtr<IsolatedWorld> > WorldMap; 174 DEFINE_STATIC_LOCAL(WorldMap, isolatedWorlds, ()); 175 176 WorldMap::iterator iter = isolatedWorlds.find(worldID); 177 if (iter != isolatedWorlds.end()) 178 return iter->second; 179 180 RefPtr<IsolatedWorld> newWorld = IsolatedWorld::create(JSDOMWindow::commonJSGlobalData()); 181 isolatedWorlds.add(worldID, newWorld); 182 return newWorld; 183 } 184 185 JSDOMWindow* ScriptController::globalObject(unsigned worldID) 186 { 187 RefPtr<DOMWrapperWorld> world = findWorld(worldID); 188 return windowShell(world.get())->window(); 189 } 190 191 ScriptValue ScriptController::evaluateInIsolatedWorld(unsigned worldID, const ScriptSourceCode& sourceCode) 192 { 193 RefPtr<DOMWrapperWorld> world = findWorld(worldID); 194 return evaluateInWorld(sourceCode, world.get()); 195 } 196 197 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sourceCode) 198 { 199 RefPtr<DOMWrapperWorld> world = findWorld(worldID); 200 201 unsigned size = sourceCode.size(); 202 for (unsigned i = 0; i < size; ++i) 203 evaluateInWorld(sourceCode[i], world.get()); 168 PassRefPtr<DOMWrapperWorld> ScriptController::createWorld() 169 { 170 return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData()); 204 171 } 205 172 … … 477 444 } 478 445 479 ScriptValue ScriptController::executeScriptIn IsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture)446 ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture) 480 447 { 481 448 ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url()); … … 487 454 m_inExecuteScript = true; 488 455 489 ScriptValue result = evaluateIn IsolatedWorld(worldID, sourceCode);456 ScriptValue result = evaluateInWorld(sourceCode, world); 490 457 491 458 if (!wasInExecuteScript) { … … 497 464 } 498 465 499 ScriptValue ScriptController::executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)500 {501 ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());502 503 if (!isEnabled() || isPaused())504 return ScriptValue();505 506 bool wasInExecuteScript = m_inExecuteScript;507 m_inExecuteScript = true;508 509 ScriptValue result = evaluateInWorld(sourceCode, world);510 511 if (!wasInExecuteScript) {512 m_inExecuteScript = false;513 Document::updateStyleForAllDocuments();514 }515 516 return result;517 }518 519 466 } // namespace WebCore -
trunk/WebCore/bindings/js/ScriptController.h
r50792 r50907 71 71 ~ScriptController(); 72 72 73 static PassRefPtr<DOMWrapperWorld> createWorld(); 74 73 75 JSDOMWindowShell* windowShell(DOMWrapperWorld* world) 74 76 { … … 85 87 return windowShell(world)->window(); 86 88 } 87 JSDOMWindow* globalObject(unsigned worldID);88 89 89 90 ScriptValue executeScript(const ScriptSourceCode&); 90 91 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 91 ScriptValue executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture = false); 92 ScriptValue executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false); 92 ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false); 93 93 94 94 // Returns true if argument is a JavaScript URL. … … 101 101 ScriptValue evaluate(const ScriptSourceCode&); 102 102 ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); 103 ScriptValue evaluateInIsolatedWorld(unsigned /*worldID*/, const ScriptSourceCode&);104 void evaluateInIsolatedWorld(unsigned /*worldID*/, const Vector<ScriptSourceCode>&);105 103 106 104 void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; } -
trunk/WebCore/page/Frame.cpp
r50672 r50907 875 875 UserScriptMap::const_iterator end = userScripts->end(); 876 876 for (UserScriptMap::const_iterator it = userScripts->begin(); it != end; ++it) 877 injectUserScriptsForWorld(it->first , *it->second, injectionTime);878 } 879 880 void Frame::injectUserScriptsForWorld( unsigned worldID, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime)877 injectUserScriptsForWorld(it->first.get(), *it->second, injectionTime); 878 } 879 880 void Frame::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime) 881 881 { 882 882 if (userScripts.isEmpty()) … … 892 892 UserScript* script = userScripts[i].get(); 893 893 if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->whitelist(), script->blacklist())) 894 sourceCode.append(ScriptSourceCode(script->source(), script->url())); 895 } 896 script()->evaluateInIsolatedWorld(worldID, sourceCode); 894 m_script.evaluateInWorld(ScriptSourceCode(script->source(), script->url()), world); 895 } 897 896 } 898 897 -
trunk/WebCore/page/Frame.h
r48958 r50907 132 132 133 133 private: 134 void injectUserScriptsForWorld( unsigned worldID, const UserScriptVector&, UserScriptInjectionTime);134 void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime); 135 135 136 136 private: -
trunk/WebCore/page/PageGroup.cpp
r49541 r50907 201 201 #endif 202 202 203 void PageGroup::addUserScriptToWorld( unsigned worldID, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,203 void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist, 204 204 PassOwnPtr<Vector<String> > blacklist, UserScriptInjectionTime injectionTime) 205 205 { 206 if (worldID == UINT_MAX)207 return; 208 OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, worldID,injectionTime));206 ASSERT_ARG(world, world); 207 208 OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, injectionTime)); 209 209 if (!m_userScripts) 210 210 m_userScripts.set(new UserScriptMap); 211 UserScriptVector*& scriptsInWorld = m_userScripts->add(world ID, 0).first->second;211 UserScriptVector*& scriptsInWorld = m_userScripts->add(world, 0).first->second; 212 212 if (!scriptsInWorld) 213 213 scriptsInWorld = new UserScriptVector; … … 215 215 } 216 216 217 void PageGroup::addUserStyleSheetToWorld( unsigned worldID, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,217 void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist, 218 218 PassOwnPtr<Vector<String> > blacklist) 219 219 { 220 if (worldID == UINT_MAX)221 return; 222 OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist , worldID));220 ASSERT_ARG(world, world); 221 222 OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist)); 223 223 if (!m_userStyleSheets) 224 224 m_userStyleSheets.set(new UserStyleSheetMap); 225 UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(world ID, 0).first->second;225 UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(world, 0).first->second; 226 226 if (!styleSheetsInWorld) 227 227 styleSheetsInWorld = new UserStyleSheetVector; … … 236 236 } 237 237 238 void PageGroup::removeUserScriptFromWorld(unsigned worldID, const KURL& url) 239 { 238 void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const KURL& url) 239 { 240 ASSERT_ARG(world, world); 241 240 242 if (!m_userScripts) 241 243 return; 242 244 243 UserScriptMap::iterator it = m_userScripts->find(world ID);245 UserScriptMap::iterator it = m_userScripts->find(world); 244 246 if (it == m_userScripts->end()) 245 247 return; … … 258 260 } 259 261 260 void PageGroup::removeUserStyleSheetFromWorld(unsigned worldID, const KURL& url) 261 { 262 void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const KURL& url) 263 { 264 ASSERT_ARG(world, world); 265 262 266 if (!m_userStyleSheets) 263 267 return; 264 268 265 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world ID);269 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); 266 270 bool sheetsChanged = false; 267 271 if (it == m_userStyleSheets->end()) … … 292 296 } 293 297 294 void PageGroup::removeUserScriptsFromWorld(unsigned worldID) 295 { 298 void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld* world) 299 { 300 ASSERT_ARG(world, world); 301 296 302 if (!m_userScripts) 297 303 return; 298 304 299 UserScriptMap::iterator it = m_userScripts->find(world ID);305 UserScriptMap::iterator it = m_userScripts->find(world); 300 306 if (it == m_userScripts->end()) 301 307 return; … … 305 311 } 306 312 307 void PageGroup::removeUserStyleSheetsFromWorld(unsigned worldID) 308 { 313 void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world) 314 { 315 ASSERT_ARG(world, world); 316 309 317 if (!m_userStyleSheets) 310 318 return; 311 319 312 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world ID);320 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); 313 321 if (it == m_userStyleSheets->end()) 314 322 return; -
trunk/WebCore/page/PageGroup.h
r49541 r50907 71 71 #endif 72 72 73 void addUserScriptToWorld( unsigned worldID, const String& source, const KURL&,73 void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&, 74 74 PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist, 75 75 UserScriptInjectionTime); 76 void addUserStyleSheetToWorld( unsigned worldID, const String& source, const KURL&,76 void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&, 77 77 PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist); 78 78 79 void removeUserScriptFromWorld( unsigned, const KURL&);80 void removeUserStyleSheetFromWorld( unsigned, const KURL&);79 void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&); 80 void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&); 81 81 82 void removeUserScriptsFromWorld( unsigned);83 void removeUserStyleSheetsFromWorld( unsigned);82 void removeUserScriptsFromWorld(DOMWrapperWorld*); 83 void removeUserStyleSheetsFromWorld(DOMWrapperWorld*); 84 84 85 85 void removeAllUserContent(); -
trunk/WebCore/page/UserScript.h
r50810 r50907 39 39 UserScript(const String& source, const KURL& url, 40 40 PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist, 41 unsigned worldID,UserScriptInjectionTime injectionTime)41 UserScriptInjectionTime injectionTime) 42 42 : m_source(source) 43 43 , m_url(url) 44 44 , m_whitelist(whitelist) 45 45 , m_blacklist(blacklist) 46 , m_worldID(worldID)47 46 , m_injectionTime(injectionTime) 48 47 { … … 53 52 const Vector<String>* whitelist() const { return m_whitelist.get(); } 54 53 const Vector<String>* blacklist() const { return m_blacklist.get(); } 55 unsigned worldID() const { return m_worldID; }56 54 UserScriptInjectionTime injectionTime() const { return m_injectionTime; } 57 55 … … 61 59 OwnPtr<Vector<String> > m_whitelist; 62 60 OwnPtr<Vector<String> > m_blacklist; 63 unsigned m_worldID;64 61 UserScriptInjectionTime m_injectionTime; 65 62 }; -
trunk/WebCore/page/UserScriptTypes.h
r48225 r50907 34 34 enum UserScriptInjectionTime { InjectAtDocumentStart, InjectAtDocumentEnd }; 35 35 36 class DOMWrapperWorld; 36 37 class UserScript; 37 38 38 39 typedef Vector<OwnPtr<UserScript> > UserScriptVector; 39 typedef HashMap< unsigned, UserScriptVector*> UserScriptMap;40 typedef HashMap<RefPtr<DOMWrapperWorld>, UserScriptVector*> UserScriptMap; 40 41 41 42 } // namespace WebCore -
trunk/WebCore/page/UserStyleSheet.h
r50810 r50907 38 38 public: 39 39 UserStyleSheet(const String& source, const KURL& url, 40 PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist, 41 unsigned worldID) 40 PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist) 42 41 : m_source(source) 43 42 , m_url(url) 44 43 , m_whitelist(whitelist) 45 44 , m_blacklist(blacklist) 46 , m_worldID(worldID)47 45 { 48 46 } … … 52 50 const Vector<String>* whitelist() const { return m_whitelist.get(); } 53 51 const Vector<String>* blacklist() const { return m_blacklist.get(); } 54 unsigned worldID() const { return m_worldID; }55 52 56 53 private: … … 59 56 OwnPtr<Vector<String> > m_whitelist; 60 57 OwnPtr<Vector<String> > m_blacklist; 61 unsigned m_worldID;62 58 }; 63 59 -
trunk/WebCore/page/UserStyleSheetTypes.h
r48225 r50907 32 32 namespace WebCore { 33 33 34 class DOMWrapperWorld; 34 35 class UserStyleSheet; 35 36 36 37 typedef Vector<OwnPtr<UserStyleSheet> > UserStyleSheetVector; 37 typedef HashMap< unsigned, UserStyleSheetVector*> UserStyleSheetMap;38 typedef HashMap<RefPtr<DOMWrapperWorld>, UserStyleSheetVector*> UserStyleSheetMap; 38 39 39 40 } // namespace WebCore -
trunk/WebKit/ChangeLog
r50883 r50907 1 2009-11-12 Adam Roben <aroben@apple.com> 2 3 Replace worldIDs with world objects 4 5 Part of <http://webkit.org/b/31414> Implement new SPI for dealing with 6 user scripts/stylesheets and isolated worlds 7 8 Reviewed by Sam Weinig. 9 10 * WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project. 11 1 12 2009-11-12 Chris Fleizach <cfleizach@apple.com> 2 13 -
trunk/WebKit/WebKit.xcodeproj/project.pbxproj
r50106 r50907 334 334 C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */; }; 335 335 C0167BF90D7F5DD00028696E /* WebScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */; }; 336 C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */; settings = {ATTRIBUTES = (Private, ); }; }; 337 C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; }; 338 C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; }; 336 339 DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; }; 337 340 DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; }; … … 622 625 C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugger.h; sourceTree = "<group>"; }; 623 626 C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptDebugger.mm; sourceTree = "<group>"; }; 627 C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorld.h; sourceTree = "<group>"; }; 628 C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; }; 629 C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; }; 624 630 DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; }; 625 631 DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; … … 1131 1137 C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */, 1132 1138 C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */, 1139 C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */, 1140 C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */, 1141 C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */, 1133 1142 936A2DE90FD2D08400D312DB /* WebTextCompletionController.h */, 1134 1143 936A2DE70FD2D08000D312DB /* WebTextCompletionController.mm */, … … 1514 1523 0FD3B0F81076C3F700039B96 /* WebWindowAnimation.h in Headers */, 1515 1524 0A2D87FD107AF52B00CDDEE3 /* WebPluginHalterClient.h in Headers */, 1525 C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */, 1526 C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */, 1516 1527 ); 1517 1528 runOnlyForDeploymentPostprocessing = 0; … … 1854 1865 0A2D87FE107AF52B00CDDEE3 /* WebPluginHalterClient.mm in Sources */, 1855 1866 BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */, 1867 C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */, 1856 1868 ); 1857 1869 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebKit/mac/ChangeLog
r50883 r50907 1 2009-11-12 Adam Roben <aroben@apple.com> 2 3 Replace worldIDs with world objects 4 5 WebScriptWorld is the new object that represents a world. The only 6 place worldID is still used is in -[WebFrame 7 _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:], 8 but that will change soon. 9 10 Part of <http://webkit.org/b/31414> Implement new SPI for dealing with 11 user scripts/stylesheets and isolated worlds 12 13 Reviewed by Sam Weinig. 14 15 * WebKit.exp: Export WebScriptWorld. 16 17 * WebView/WebFrame.mm: 18 (-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]): 19 Moved the bizarre world caching/creation logic that DRT depends on 20 here from the findWorld function in ScriptController.cpp. Updated to 21 use ScriptController::executeScriptInWorld instead of 22 ScriptController::executeScriptInIsolatedWorld. 23 (-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now 24 takes a WebScriptWorld. 25 26 * WebView/WebFramePrivate.h: Replaced contextForWorldID: with 27 _contextForWorld:. 28 29 * WebView/WebScriptWorld.h: Added. 30 * WebView/WebScriptWorld.mm: Added. 31 (-[WebScriptWorld initWithWorld:]): Store the passed-in world in our 32 _private member. 33 (-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to 34 -initWithWorld:. 35 (-[WebScriptWorld dealloc]): Release _private. 36 (+[WebScriptWorld standardWorld]): Returns a shared instance that 37 represents WebCore's mainThreadNormalWorld(). 38 (+[WebScriptWorld world]): Returns a new instance. 39 (core): Returns the DOMWrapperWorld for this WebScriptWorld. 40 41 * WebView/WebScriptWorldInternal.h: Added. 42 43 * WebView/WebView.mm: 44 (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]): 45 (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]): 46 (+[WebView _removeUserScriptFromGroup:world:url:]): 47 (+[WebView _removeUserStyleSheetFromGroup:world:url:]): 48 (+[WebView _removeUserScriptsFromGroup:world:]): 49 (+[WebView _removeUserStyleSheetsFromGroup:world:]): 50 * WebView/WebViewPrivate.h: 51 Changed these functions to take a WebScriptWorld instead of a worldID. 52 1 53 2009-11-12 Chris Fleizach <cfleizach@apple.com> 2 54 -
trunk/WebKit/mac/WebKit.exp
r48144 r50907 29 29 .objc_class_name_WebResource 30 30 .objc_class_name_WebScriptCallFrame 31 .objc_class_name_WebScriptWorld 31 32 .objc_class_name_WebSecurityOrigin 32 33 .objc_class_name_WebStringTruncator -
trunk/WebKit/mac/WebView/WebFrame.mm
r50786 r50907 50 50 #import "WebNSURLExtras.h" 51 51 #import "WebScriptDebugger.h" 52 #import "WebScriptWorldInternal.h" 52 53 #import "WebViewInternal.h" 53 54 #import <JavaScriptCore/APICast.h> … … 1204 1205 Frame* frame = anyWorldGlobalObject->impl()->frame(); 1205 1206 ASSERT(frame->document()); 1206 JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue(); 1207 1208 // Get the world to execute in based on the worldID. DRT expects that a 1209 // worldID of 0 always corresponds to a newly-created world, while any 1210 // other worldID corresponds to a world that is created once and then 1211 // cached forever. 1212 RefPtr<DOMWrapperWorld> world; 1213 if (!worldID) 1214 world = ScriptController::createWorld(); 1215 else { 1216 static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >; 1217 RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second; 1218 if (!worldSlot) 1219 worldSlot = ScriptController::createWorld(); 1220 world = worldSlot; 1221 } 1222 JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue(); 1207 1223 1208 1224 if (!frame) // In case the script removed our frame from the page. … … 1219 1235 } 1220 1236 1221 - (JSGlobalContextRef) contextForWorldID:(unsigned)worldID;1237 - (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world 1222 1238 { 1223 1239 Frame* coreFrame = _private->coreFrame; 1224 1240 if (!coreFrame) 1225 1241 return 0; 1226 return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec()); 1242 DOMWrapperWorld* coreWorld = core(world); 1243 if (!coreWorld) 1244 return 0; 1245 return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec()); 1227 1246 } 1228 1247 -
trunk/WebKit/mac/WebView/WebFramePrivate.h
r50012 r50907 40 40 @class WebIconFetcher; 41 41 @class WebScriptObject; 42 @class WebScriptWorld; 42 43 43 44 // Keys for accessing the values in the page cache dictionary. … … 98 99 99 100 - (NSString *)_stringByEvaluatingJavaScriptInIsolatedWorld:(unsigned)worldID WithGlobalObject:(JSObjectRef)globalObject FromString:(NSString *)string; 100 - (JSGlobalContextRef) contextForWorldID:(unsigned)worldID;101 - (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world; 101 102 102 103 // Pause a given CSS animation or transition on the target node at a specific time. -
trunk/WebKit/mac/WebView/WebView.mm
r50242 r50907 91 91 #import "WebPreferencesPrivate.h" 92 92 #import "WebScriptDebugDelegate.h" 93 #import "WebScriptWorldInternal.h" 93 94 #import "WebSystemInterface.h" 94 95 #import "WebTextCompletionController.h" … … 2176 2177 } 2177 2178 2178 + (void)_addUserScriptToGroup:(NSString *)groupName world ID:(unsigned)worldIDsource:(NSString *)source url:(NSURL *)url2179 + (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url 2179 2180 whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime 2180 2181 { 2181 2182 String group(groupName); 2182 if (group.isEmpty() || worldID == UINT_MAX)2183 if (group.isEmpty()) 2183 2184 return; 2184 2185 … … 2187 2188 return; 2188 2189 2189 pageGroup->addUserScriptToWorld( worldID, source, url, toStringVector(whitelist), toStringVector(blacklist),2190 pageGroup->addUserScriptToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist), 2190 2191 injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd); 2191 2192 } 2192 2193 2193 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world ID:(unsigned)worldIDsource:(NSString *)source url:(NSURL *)url2194 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url 2194 2195 whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist 2195 2196 { 2196 2197 String group(groupName); 2197 if (group.isEmpty() || worldID == UINT_MAX)2198 if (group.isEmpty()) 2198 2199 return; 2199 2200 … … 2202 2203 return; 2203 2204 2204 pageGroup->addUserStyleSheetToWorld( worldID, source, url, toStringVector(whitelist), toStringVector(blacklist));2205 } 2206 2207 + (void)_removeUserScriptFromGroup:(NSString *)groupName world ID:(unsigned)worldIDurl:(NSURL *)url2205 pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist)); 2206 } 2207 2208 + (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url 2208 2209 { 2209 2210 String group(groupName); … … 2215 2216 return; 2216 2217 2217 pageGroup->removeUserScriptFromWorld( worldID, url);2218 } 2219 2220 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world ID:(unsigned)worldIDurl:(NSURL *)url2218 pageGroup->removeUserScriptFromWorld(core(world), url); 2219 } 2220 2221 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url 2221 2222 { 2222 2223 String group(groupName); … … 2228 2229 return; 2229 2230 2230 pageGroup->removeUserStyleSheetFromWorld( worldID, url);2231 } 2232 2233 + (void)_removeUserScriptsFromGroup:(NSString *)groupName world ID:(unsigned)worldID2231 pageGroup->removeUserStyleSheetFromWorld(core(world), url); 2232 } 2233 2234 + (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world 2234 2235 { 2235 2236 String group(groupName); … … 2241 2242 return; 2242 2243 2243 pageGroup->removeUserScriptsFromWorld( worldID);2244 } 2245 2246 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world ID:(unsigned)worldID2244 pageGroup->removeUserScriptsFromWorld(core(world)); 2245 } 2246 2247 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world 2247 2248 { 2248 2249 String group(groupName); … … 2254 2255 return; 2255 2256 2256 pageGroup->removeUserStyleSheetsFromWorld( worldID);2257 pageGroup->removeUserStyleSheetsFromWorld(core(world)); 2257 2258 } 2258 2259 -
trunk/WebKit/mac/WebView/WebViewPrivate.h
r49733 r50907 46 46 @class WebInspector; 47 47 @class WebPreferences; 48 @class WebScriptWorld; 48 49 @class WebTextIterator; 49 50 … … 480 481 + (void)_resetOriginAccessWhiteLists; 481 482 482 + (void)_addUserScriptToGroup:(NSString *)groupName world ID:(unsigned)worldIDsource:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;483 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world ID:(unsigned)worldIDsource:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;484 + (void)_removeUserScriptFromGroup:(NSString *)groupName world ID:(unsigned)worldIDurl:(NSURL *)url;485 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world ID:(unsigned)worldIDurl:(NSURL *)url;486 + (void)_removeUserScriptsFromGroup:(NSString *)groupName world ID:(unsigned)worldID;487 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world ID:(unsigned)worldID;483 + (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime; 484 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist; 485 + (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url; 486 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url; 487 + (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world; 488 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world; 488 489 + (void)_removeAllUserContentFromGroup:(NSString *)groupName; 489 490 -
trunk/WebKit/win/ChangeLog
r50906 r50907 1 2009-11-12 Adam Roben <aroben@apple.com> 2 3 Replace worldIDs with world objects 4 5 WebScriptWorld is the new object that represents a world. The only 6 place worldID is still used is in 7 IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but 8 that will change soon. 9 10 Part of <http://webkit.org/b/31414> Implement new SPI for dealing with 11 user scripts/stylesheets and isolated worlds 12 13 Reviewed by Sam Weinig. 14 15 * ForEachCoClass.h: Added WebScriptWorld. 16 17 * Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with 18 contextForWorld. 19 20 * Interfaces/IWebScriptWorld.idl: Added. 21 22 * Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet 23 functions to take an IWebScriptWorld instead of a worldID. 24 25 * Interfaces/WebKit.idl: Added WebScriptWorld. 26 27 * WebFrame.cpp: 28 (WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes 29 an IWebScriptWorld. 30 (WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the 31 bizarre world caching/creation logic that DRT depends on here from the 32 findWorld function in ScriptController.cpp. Updated to use 33 ScriptController::executeScriptInWorld instead of 34 ScriptController::executeScriptInIsolatedWorld. 35 36 * WebFrame.h: Replaced contextForWorldID with contextForWorld. 37 38 * WebScriptWorld.cpp: Added. 39 (WebScriptWorld::WebScriptWorld): 40 (WebScriptWorld::~WebScriptWorld): 41 (WebScriptWorld::createInstance): 42 (WebScriptWorld::AddRef): 43 (WebScriptWorld::Release): 44 (WebScriptWorld::QueryInterface): 45 Standard COM class implementations. 46 47 (WebScriptWorld::standardWorld): Returns a shared instance that represents 48 WebCore's mainThreadNormalWorld(). 49 50 * WebScriptWorld.h: Added. 51 (WebScriptWorld::world): Simple getter. 52 53 * WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl. 54 55 * WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld. 56 57 * WebKitClassFactory.cpp: Added WebScriptWorld. 58 59 * WebView.cpp: 60 (WebView::addUserScriptToGroup): 61 (WebView::addUserStyleSheetToGroup): 62 (WebView::removeUserScriptFromGroup): 63 (WebView::removeUserStyleSheetFromGroup): 64 (WebView::removeUserScriptsFromGroup): 65 (WebView::removeUserStyleSheetsFromGroup): 66 * WebView.h: 67 Changed these functions to take an IWebScriptWorld instead of a worldID. 68 1 69 2009-11-12 Adam Roben <aroben@apple.com> 2 70 -
trunk/WebKit/win/ForEachCoClass.h
r47429 r50907 64 64 macro(WebCookieManager) \ 65 65 macro(WebWorkersPrivate) \ 66 macro(WebScriptWorld) \ 66 67 // end of macro 67 68 -
trunk/WebKit/win/Interfaces/IWebFramePrivate.idl
r50316 r50907 33 33 interface IWebIconFetcher; 34 34 interface IWebIconFetcherDelegate; 35 interface IWebScriptWorld; 35 36 36 37 typedef enum { … … 97 98 HRESULT stringByEvaluatingJavaScriptInIsolatedWorld([in] unsigned worldID, [in] OLE_HANDLE jsGlobalObject, [in] BSTR script, [out, retval] BSTR* result); 98 99 99 [local] JSGlobalContextRef contextForWorldID([in] unsigned worldID);100 [local] JSGlobalContextRef globalContextForScriptWorld([in] IWebScriptWorld*); 100 101 101 102 HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result); -
trunk/WebKit/win/Interfaces/IWebViewPrivate.idl
r49732 r50907 185 185 HRESULT MIMETypeForExtension([in] BSTR extension, [out, retval] BSTR* mimeType); 186 186 187 // For the following functions, 0 < worldID < UINT_MAX. 188 HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, 187 HRESULT addUserScriptToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url, 189 188 [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist, 190 189 [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist, 191 190 [in] WebUserScriptInjectionTime injectionTime); 192 HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,191 HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url, 193 192 [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist, 194 193 [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist); 195 HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);196 HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);197 HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] unsigned worldID);198 HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] unsigned worldID);194 HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url); 195 HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url); 196 HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*); 197 HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*); 199 198 HRESULT removeAllUserContentFromGroup([in] BSTR groupName); 200 199 -
trunk/WebKit/win/Interfaces/WebKit.idl
r50484 r50907 114 114 #include "IWebResourceLoadDelegate.idl" 115 115 #include "IWebResourceLoadDelegatePrivate.idl" 116 #include "IWebScriptWorld.idl" 116 117 #include "IWebScrollBarDelegatePrivate.idl" 117 118 #include "IWebScrollBarPrivate.idl" … … 272 273 [default] interface IWebWorkersPrivate; 273 274 } 275 276 [uuid(D3C301EE-D59A-49c0-A43A-9EA01CDB1590)] 277 coclass WebScriptWorld { 278 [default] interface IWebScriptWorld; 279 } 274 280 } -
trunk/WebKit/win/WebFrame.cpp
r50567 r50907 30 30 31 31 #include "CFDictionaryPropertyBag.h" 32 #include "COMPropertyBag.h" 32 33 #include "COMPtr.h" 33 #include " COMPropertyBag.h"34 #include "DOMCoreClasses.h" 34 35 #include "DefaultPolicyDelegate.h" 35 #include "DOMCoreClasses.h"36 36 #include "HTMLFrameOwnerElement.h" 37 37 #include "MarshallingHelpers.h" 38 38 #include "WebActionPropertyBag.h" 39 39 #include "WebChromeClient.h" 40 #include "WebDataSource.h" 40 41 #include "WebDocumentLoader.h" 41 42 #include "WebDownload.h" 43 #include "WebEditorClient.h" 42 44 #include "WebError.h" 43 #include "WebMutableURLRequest.h"44 #include "WebEditorClient.h"45 45 #include "WebFramePolicyListener.h" 46 46 #include "WebHistory.h" 47 #include "WebHistoryItem.h" 47 48 #include "WebIconFetcher.h" 48 49 #include "WebKit.h" 49 50 #include "WebKitStatisticsPrivate.h" 51 #include "WebMutableURLRequest.h" 50 52 #include "WebNotificationCenter.h" 53 #include "WebScriptWorld.h" 54 #include "WebURLResponse.h" 51 55 #include "WebView.h" 52 #include "WebDataSource.h"53 #include "WebHistoryItem.h"54 #include "WebURLResponse.h"55 56 #pragma warning( push, 0 ) 56 57 #include <WebCore/BString.h> … … 491 492 } 492 493 493 JSGlobalContextRef STDMETHODCALLTYPE WebFrame::contextForWorldID( 494 /* [in] */ unsigned worldID) 494 JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld) 495 495 { 496 496 Frame* coreFrame = core(this); … … 498 498 return 0; 499 499 500 return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec()); 500 COMPtr<WebScriptWorld> world(Query, iWorld); 501 if (!world) 502 return 0; 503 504 return toGlobalRef(coreFrame->script()->globalObject(world->world())->globalExec()); 501 505 } 502 506 … … 2195 2199 Frame* frame = anyWorldGlobalObject->impl()->frame(); 2196 2200 ASSERT(frame->document()); 2197 JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue(); 2201 2202 // Get the world to execute in based on the worldID. DRT expects that a 2203 // worldID of 0 always corresponds to a newly-created world, while any 2204 // other worldID corresponds to a world that is created once and then 2205 // cached forever. 2206 RefPtr<DOMWrapperWorld> world; 2207 if (!worldID) 2208 world = ScriptController::createWorld(); 2209 else { 2210 static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >; 2211 RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second; 2212 if (!worldSlot) 2213 worldSlot = ScriptController::createWorld(); 2214 world = worldSlot; 2215 } 2216 JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue(); 2198 2217 2199 2218 if (!frame) // In case the script removed our frame from the page. -
trunk/WebKit/win/WebFrame.h
r50233 r50907 255 255 /* [retval][out] */ BSTR* evaluationResult); 256 256 257 virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE contextForWorldID( 258 /* [in] */ unsigned worldID); 257 virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*); 259 258 260 259 // IWebDocumentText -
trunk/WebKit/win/WebKit.vcproj/Interfaces.vcproj
r49566 r50907 1325 1325 </File> 1326 1326 <File 1327 RelativePath="..\Interfaces\IWebScriptWorld.idl" 1328 > 1329 <FileConfiguration 1330 Name="Debug|Win32" 1331 ExcludedFromBuild="true" 1332 > 1333 <Tool 1334 Name="VCMIDLTool" 1335 /> 1336 </FileConfiguration> 1337 <FileConfiguration 1338 Name="Release|Win32" 1339 ExcludedFromBuild="true" 1340 > 1341 <Tool 1342 Name="VCMIDLTool" 1343 /> 1344 </FileConfiguration> 1345 </File> 1346 <File 1327 1347 RelativePath="..\Interfaces\IWebScrollBarDelegatePrivate.idl" 1328 1348 > -
trunk/WebKit/win/WebKit.vcproj/WebKit.vcproj
r50322 r50907 723 723 </File> 724 724 <File 725 RelativePath="..\WebScriptWorld.h" 726 > 727 </File> 728 <File 725 729 RelativePath="..\WebKitStatistics.h" 726 730 > … … 1088 1092 <File 1089 1093 RelativePath="..\WebKitLogging.cpp" 1094 > 1095 </File> 1096 <File 1097 RelativePath="..\WebScriptWorld.cpp" 1090 1098 > 1091 1099 </File> -
trunk/WebKit/win/WebKitClassFactory.cpp
r50567 r50907 28 28 #include "WebKitClassFactory.h" 29 29 30 #include "CFDictionaryPropertyBag.h" 30 31 #include "ForEachCoClass.h" 31 #include "CFDictionaryPropertyBag.h"32 32 #include "WebArchive.h" 33 33 #include "WebCache.h" … … 43 43 #include "WebJavaScriptCollector.h" 44 44 #include "WebKit.h" 45 #include "WebScrollBar.h"46 45 #include "WebKitStatistics.h" 47 46 #include "WebMutableURLRequest.h" 48 47 #include "WebNotificationCenter.h" 49 48 #include "WebPreferences.h" 49 #include "WebScriptWorld.h" 50 #include "WebScrollBar.h" 50 51 #include "WebTextRenderer.h" 51 52 #include "WebURLCredential.h" -
trunk/WebKit/win/WebView.cpp
r50906 r50907 32 32 #include "MarshallingHelpers.h" 33 33 #include "SoftLinking.h" 34 #include "WebDatabaseManager.h"35 #include "WebDocumentLoader.h"36 #include "WebDownload.h"37 #include "WebEditorClient.h"38 #include "WebElementPropertyBag.h"39 #include "WebFrame.h"40 34 #include "WebBackForwardList.h" 41 35 #include "WebChromeClient.h" 42 36 #include "WebContextMenuClient.h" 43 37 #include "WebCoreTextRenderer.h" 38 #include "WebDatabaseManager.h" 39 #include "WebDocumentLoader.h" 40 #include "WebDownload.h" 44 41 #include "WebDragClient.h" 42 #include "WebEditorClient.h" 43 #include "WebElementPropertyBag.h" 44 #include "WebFrame.h" 45 45 #include "WebIconDatabase.h" 46 46 #include "WebInspector.h" … … 53 53 #include "WebPluginHalterClient.h" 54 54 #include "WebPreferences.h" 55 #include "WebScriptWorld.h" 55 56 #include "WindowsTouch.h" 56 57 #pragma warning( push, 0 ) … … 5491 5492 } 5492 5493 5493 HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,5494 HRESULT WebView::addUserScriptToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url, 5494 5495 unsigned whitelistCount, BSTR* whitelist, 5495 5496 unsigned blacklistCount, BSTR* blacklist, 5496 5497 WebUserScriptInjectionTime injectionTime) 5497 5498 { 5499 COMPtr<WebScriptWorld> world(Query, iWorld); 5500 if (!world) 5501 return E_POINTER; 5502 5498 5503 String group = toString(groupName); 5499 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5504 if (group.isEmpty()) 5500 5505 return E_INVALIDARG; 5501 5506 … … 5505 5510 return E_FAIL; 5506 5511 5507 pageGroup->addUserScriptToWorld(world ID, toString(source), toKURL(url),5512 pageGroup->addUserScriptToWorld(world->world(), toString(source), toKURL(url), 5508 5513 toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist), 5509 5514 injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd); … … 5512 5517 } 5513 5518 5514 HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,5519 HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url, 5515 5520 unsigned whitelistCount, BSTR* whitelist, 5516 5521 unsigned blacklistCount, BSTR* blacklist) 5517 5522 { 5523 COMPtr<WebScriptWorld> world(Query, iWorld); 5524 if (!world) 5525 return E_POINTER; 5526 5518 5527 String group = toString(groupName); 5519 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5528 if (group.isEmpty()) 5520 5529 return E_INVALIDARG; 5521 5530 … … 5525 5534 return E_FAIL; 5526 5535 5527 pageGroup->addUserStyleSheetToWorld(world ID, toString(source), toKURL(url),5536 pageGroup->addUserStyleSheetToWorld(world->world(), toString(source), toKURL(url), 5528 5537 toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist)); 5529 5538 … … 5531 5540 } 5532 5541 5533 HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url) 5534 { 5542 HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url) 5543 { 5544 COMPtr<WebScriptWorld> world(Query, iWorld); 5545 if (!world) 5546 return E_POINTER; 5547 5535 5548 String group = toString(groupName); 5536 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5549 if (group.isEmpty()) 5537 5550 return E_INVALIDARG; 5538 5551 … … 5542 5555 return E_FAIL; 5543 5556 5544 pageGroup->removeUserScriptFromWorld(worldID, toKURL(url)); 5545 5546 return S_OK; 5547 } 5548 5549 HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url) 5550 { 5557 pageGroup->removeUserScriptFromWorld(world->world(), toKURL(url)); 5558 5559 return S_OK; 5560 } 5561 5562 HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url) 5563 { 5564 COMPtr<WebScriptWorld> world(Query, iWorld); 5565 if (!world) 5566 return E_POINTER; 5567 5551 5568 String group = toString(groupName); 5552 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5569 if (group.isEmpty()) 5553 5570 return E_INVALIDARG; 5554 5571 … … 5558 5575 return E_FAIL; 5559 5576 5560 pageGroup->removeUserStyleSheetFromWorld(worldID, toKURL(url)); 5561 5562 return S_OK; 5563 } 5564 5565 HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID) 5566 { 5577 pageGroup->removeUserStyleSheetFromWorld(world->world(), toKURL(url)); 5578 5579 return S_OK; 5580 } 5581 5582 HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld* iWorld) 5583 { 5584 COMPtr<WebScriptWorld> world(Query, iWorld); 5585 if (!world) 5586 return E_POINTER; 5587 5567 5588 String group = toString(groupName); 5568 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5589 if (group.isEmpty()) 5569 5590 return E_INVALIDARG; 5570 5591 … … 5574 5595 return E_FAIL; 5575 5596 5576 pageGroup->removeUserScriptsFromWorld(worldID); 5577 return S_OK; 5578 } 5579 5580 HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID) 5581 { 5597 pageGroup->removeUserScriptsFromWorld(world->world()); 5598 return S_OK; 5599 } 5600 5601 HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld* iWorld) 5602 { 5603 COMPtr<WebScriptWorld> world(Query, iWorld); 5604 if (!world) 5605 return E_POINTER; 5606 5582 5607 String group = toString(groupName); 5583 if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())5608 if (group.isEmpty()) 5584 5609 return E_INVALIDARG; 5585 5610 … … 5589 5614 return E_FAIL; 5590 5615 5591 pageGroup->removeUserStyleSheetsFromWorld(world ID);5616 pageGroup->removeUserStyleSheetsFromWorld(world->world()); 5592 5617 return S_OK; 5593 5618 } -
trunk/WebKit/win/WebView.h
r49732 r50907 741 741 /* [in] */ BOOL canStartPlugins); 742 742 743 virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,743 virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url, 744 744 unsigned whitelistCount, BSTR* whitelist, 745 745 unsigned blacklistCount, BSTR* blacklist, 746 746 WebUserScriptInjectionTime); 747 virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,747 virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url, 748 748 unsigned whitelistCount, BSTR* whitelist, 749 749 unsigned blacklistCount, BSTR* blacklist); 750 virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url);751 virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url);752 virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, unsigned worldID);753 virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID);750 virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url); 751 virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url); 752 virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld*); 753 virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld*); 754 754 virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName); 755 755 -
trunk/WebKitTools/ChangeLog
r50865 r50907 1 2009-11-12 Adam Roben <aroben@apple.com> 2 3 Replace worldIDs with world objects 4 5 Part of <http://webkit.org/b/31414> Implement new SPI for dealing with 6 user scripts/stylesheets and isolated worlds 7 8 Reviewed by Sam Weinig. 9 10 * DumpRenderTree/mac/LayoutTestControllerMac.mm: 11 (LayoutTestController::addUserScript): 12 (LayoutTestController::addUserStyleSheet): 13 * DumpRenderTree/win/LayoutTestControllerWin.cpp: 14 (LayoutTestController::addUserScript): 15 (LayoutTestController::addUserStyleSheet): 16 Changed these functions to create a new WebJSWorld each time they're 17 called and to pass that world to WebKit. 18 1 19 2009-11-11 Chris Fleizach <cfleizach@apple.com> 2 20 -
trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
r50233 r50907 44 44 #import <WebKit/WebBackForwardList.h> 45 45 #import <WebKit/WebCoreStatistics.h> 46 #import <WebKit/WebDataSource.h> 46 47 #import <WebKit/WebDatabaseManagerPrivate.h> 47 #import <WebKit/WebDataSource.h>48 48 #import <WebKit/WebFrame.h> 49 49 #import <WebKit/WebFrameViewPrivate.h> 50 #import <WebKit/Web IconDatabasePrivate.h>50 #import <WebKit/WebGeolocationMockPrivate.h> 51 51 #import <WebKit/WebHTMLRepresentation.h> 52 52 #import <WebKit/WebHTMLViewPrivate.h> 53 53 #import <WebKit/WebHistory.h> 54 54 #import <WebKit/WebHistoryPrivate.h> 55 #import <WebKit/WebIconDatabasePrivate.h> 55 56 #import <WebKit/WebInspectorPrivate.h> 56 #import <WebKit/WebGeolocationMockPrivate.h>57 57 #import <WebKit/WebNSURLExtras.h> 58 58 #import <WebKit/WebPreferences.h> 59 59 #import <WebKit/WebPreferencesPrivate.h> 60 #import <WebKit/WebScriptWorld.h> 60 61 #import <WebKit/WebSecurityOriginPrivate.h> 61 62 #import <WebKit/WebTypesInternal.h> … … 502 503 RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source)); 503 504 NSString *sourceNS = (NSString *)sourceCF.get(); 504 [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world ID:1source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];505 [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)]; 505 506 } 506 507 … … 509 510 RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source)); 510 511 NSString *sourceNS = (NSString *)sourceCF.get(); 511 [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world ID:1source:sourceNS url:nil whitelist:nil blacklist:nil];512 [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil]; 512 513 } 513 514 -
trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
r50233 r50907 660 660 { 661 661 m_waitToDump = waitUntilDone; 662 if ( m_waitToDump && !waitToDumpWatchdog)662 if (false && m_waitToDump && !waitToDumpWatchdog) 663 663 waitToDumpWatchdog = SetTimer(0, 0, waitToDumpWatchdogInterval * 1000, waitUntilDoneWatchdogFired); 664 664 } … … 862 862 return; 863 863 864 webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd); 864 COMPtr<IWebScriptWorld> world; 865 if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world)))) 866 return; 867 868 webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd); 865 869 } 866 870 … … 872 876 return; 873 877 874 webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0); 878 COMPtr<IWebScriptWorld> world; 879 if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world)))) 880 return; 881 882 webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0); 875 883 } 876 884
Note:
See TracChangeset
for help on using the changeset viewer.