Changeset 52882 in webkit
- Timestamp:
- Jan 6, 2010 4:47:00 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52880 r52882 1 2010-01-06 Adam Barth <abarth@webkit.org> 2 3 No review, rolling out r52877. 4 http://trac.webkit.org/changeset/52877 5 https://bugs.webkit.org/show_bug.cgi?id=33243 6 7 I screwedd up landing this patch and only partially applied the patch I 8 was trying to land. 9 10 * bindings/ScriptControllerBase.cpp: 11 * bindings/js/ScriptController.cpp: 12 (WebCore::ScriptController::executeScriptInWorld): 13 * bindings/v8/ScriptController.cpp: 14 (WebCore::ScriptController::ScriptController): 15 (WebCore::ScriptController::~ScriptController): 16 (WebCore::ScriptController::updateSecurityOrigin): 17 (WebCore::ScriptController::evaluateInIsolatedWorld): 18 (WebCore::ScriptController::haveInterpreter): 19 (WebCore::ScriptController::mainWorldWindowShell): 20 (WebCore::ScriptController::clearWindowShell): 21 (WebCore::ScriptController::clearForClose): 22 (WebCore::ScriptController::destroyWindowShell): 23 (WebCore::ScriptController::updateDocument): 24 * bindings/v8/ScriptController.h: 25 (WebCore::ScriptController::proxy): 26 (WebCore::ScriptController::windowShell): 27 (WebCore::ScriptController::existingWindowShell): 28 (WebCore::ScriptController::evaluateInWorld): 29 * bindings/v8/V8DOMWindowShell.cpp: 30 (WebCore::V8DOMWindowShell::create): 31 (WebCore::V8DOMWindowShell::V8DOMWindowShell): 32 (WebCore::V8DOMWindowShell::initContextIfNeeded): 33 1 34 2010-01-06 Eric Seidel <eric@webkit.org> 2 35 -
trunk/WebCore/bindings/ScriptControllerBase.cpp
r52877 r52882 54 54 } 55 55 56 ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)57 {58 ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());59 60 if (!isEnabled() || isPaused())61 return ScriptValue();62 63 bool wasInExecuteScript = m_inExecuteScript;64 m_inExecuteScript = true;65 66 ScriptValue result = evaluateInWorld(sourceCode, world);67 68 if (!wasInExecuteScript) {69 m_inExecuteScript = false;70 Document::updateStyleForAllDocuments();71 }72 73 return result;74 }75 56 76 57 bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument) -
trunk/WebCore/bindings/js/ScriptController.cpp
r52877 r52882 447 447 } 448 448 449 ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture) 450 { 451 ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url()); 452 453 if (!isEnabled() || isPaused()) 454 return ScriptValue(); 455 456 bool wasInExecuteScript = m_inExecuteScript; 457 m_inExecuteScript = true; 458 459 ScriptValue result = evaluateInWorld(sourceCode, world); 460 461 if (!wasInExecuteScript) { 462 m_inExecuteScript = false; 463 Document::updateStyleForAllDocuments(); 464 } 465 466 return result; 467 } 468 449 469 } // namespace WebCore -
trunk/WebCore/bindings/v8/ScriptController.cpp
r52877 r52882 61 61 namespace WebCore { 62 62 63 PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()64 {65 return IsolatedWorld::create();66 }67 68 V8DOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)69 {70 ASSERT(!m_windowShells.contains(world));71 72 RefPtr<V8DOMWindowShell> windowShell = V8DOMWindowShell::create(m_frame, world);73 m_windowShells.add(world, windowShell);74 windowShell->initContextIfNeeded();75 windowShell->updateDocument();76 77 m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);78 79 return windowShell.get();80 }81 82 63 void ScriptController::initializeThreading() 83 64 { … … 126 107 , m_paused(false) 127 108 , m_proxy(new V8Proxy(frame)) 109 , m_windowShell(V8DOMWindowShell::create(frame)) 128 110 #if ENABLE(NETSCAPE_PLUGIN_API) 129 111 , m_windowScriptNPObject(0) … … 136 118 { 137 119 m_proxy->disconnectFrame(); 138 139 if (!m_windowShells.isEmpty()) { 140 m_windowShells.clear(); 141 m_mainWorldWindowShell = 0; 142 // JSC triggers a GC here, but we haven't historically. 143 } 120 m_windowShell.clear(); 144 121 } 145 122 … … 166 143 void ScriptController::updateSecurityOrigin() 167 144 { 168 for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) 169 iter->second->updateSecurityOrigin(); 145 m_windowShell->updateSecurityOrigin(); 170 146 } 171 147 … … 233 209 { 234 210 // FIXME: This will need to get reorganized once we have a windowShell for the isolated world. 235 236 // Force the mainWindowShell to exist. 237 windowShell(mainThreadNormalWorld()); 211 m_windowShell->initContextIfNeeded(); 238 212 m_proxy->evaluateInIsolatedWorld(worldID, sources, 0); 239 213 } … … 275 249 } 276 250 277 ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*)278 {279 // FIXME: Move isolated world execution to here!280 notImplemented();281 return ScriptValue();282 }283 284 251 void ScriptController::setEventHandlerLineNumber(int lineNumber) 285 252 { … … 325 292 { 326 293 v8::V8::LowMemoryNotification(); 294 } 295 296 bool ScriptController::haveInterpreter() const 297 { 298 return m_windowShell->isContextInitialized(); 327 299 } 328 300 … … 468 440 } 469 441 470 V8DOMWindowShell* ScriptController::mainWorldWindowShell() 471 { 472 if (!m_mainWorldWindowShell) 473 m_mainWorldWindowShell = windowShell(mainThreadNormalWorld()); 474 return m_mainWorldWindowShell.get(); 442 V8DOMWindowShell* ScriptController::mainWorldWindowShell() const 443 { 444 m_windowShell->initContextIfNeeded(); 445 return m_windowShell.get(); 475 446 } 476 447 … … 483 454 // when a frame is loading a new page. V8DOMWindowShell::clearForNavigation 484 455 // creates a new context for the new page. 485 for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) 486 iter->second->clearForNavigation(); 456 m_windowShell->clearForNavigation(); 487 457 } 488 458 489 459 void ScriptController::clearForClose() 490 460 { 491 for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) 492 iter->second->clearForClose(); 461 m_windowShell->clearForClose(); 493 462 } 494 463 495 464 void ScriptController::destroyWindowShell() 496 465 { 497 m_windowShell s.clear();498 m_ mainWorldWindowShell = 0;466 m_windowShell->clearForClose(); 467 m_windowShell->destroyGlobal(); 499 468 } 500 469 … … 506 475 void ScriptController::updateDocument() 507 476 { 508 // This seems redudant, but JSC does it. 509 if (!m_frame->document()) 510 return; 511 512 for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) 513 iter->second->updateDocument(); 477 m_windowShell->updateDocument(); 514 478 } 515 479 -
trunk/WebCore/bindings/v8/ScriptController.h
r52877 r52882 52 52 class ScriptState; 53 53 class String; 54 class V8DOMWindow;55 54 class Widget; 56 55 class XSSAuditor; 57 56 58 57 class ScriptController { 59 typedef WTF::HashMap< RefPtr<DOMWrapperWorld>, RefPtr<V8DOMWindowShell> > ShellMap;60 61 58 public: 62 59 ScriptController(Frame*); 63 60 ~ScriptController(); 64 61 65 static PassRefPtr<DOMWrapperWorld> createWorld();66 67 V8DOMWindowShell* windowShell(DOMWrapperWorld* world)68 {69 ShellMap::iterator iter = m_windowShells.find(world);70 return (iter != m_windowShells.end()) ? iter->second.get() : initScript(world);71 }72 V8DOMWindowShell* existingWindowShell(DOMWrapperWorld* world) const73 {74 ShellMap::const_iterator iter = m_windowShells.find(world);75 return (iter != m_windowShells.end()) ? iter->second.get() : 0;76 }77 V8DOMWindow* globalObject(DOMWrapperWorld* world)78 {79 notImplemented();80 return 0;81 }82 83 static void getAllWorlds(Vector<DOMWrapperWorld*>&);84 85 ScriptValue executeScript(const ScriptSourceCode&);86 ScriptValue executeScript(const String& script, bool forceUserGesture = false);87 ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);88 89 // Returns true if argument is a JavaScript URL.90 bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);91 92 // This function must be called from the main thread. It is safe to call it repeatedly.93 static void initializeThreading();94 95 ScriptValue evaluate(const ScriptSourceCode&);96 ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);97 98 // ==== End identical match with JSC's ScriptController === //99 100 62 // FIXME: V8Proxy should either be folded into ScriptController 101 63 // or this accessor should be made JSProxy* 102 64 V8Proxy* proxy() { return m_proxy.get(); } 103 65 104 // FIXME: We should eventually remove all clients of this method. The 105 // problem is that some of them are in very hot code paths. 106 V8DOMWindowShell* mainWorldWindowShell(); 66 V8DOMWindowShell* mainWorldWindowShell() const; 67 68 ScriptValue executeScript(const ScriptSourceCode&); 69 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 70 71 // Returns true if argument is a JavaScript URL. 72 bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true); 73 74 // This function must be called from the main thread. It is safe to call it repeatedly. 75 static void initializeThreading(); 76 77 // Evaluate a script file in the environment of this proxy. 78 // If succeeded, 'succ' is set to true and result is returned 79 // as a string. 80 ScriptValue evaluate(const ScriptSourceCode&); 107 81 108 82 void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&); … … 120 94 void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&, int extensionGroup); 121 95 96 // Masquerade 'this' as the windowShell. 97 // This is a bit of a hack, but provides reasonable compatibility 98 // with what JSC does as well. 99 ScriptController* windowShell(DOMWrapperWorld*) { return this; } 100 ScriptController* existingWindowShell(DOMWrapperWorld*) { return this; } 101 122 102 XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); } 123 103 … … 131 111 132 112 PassScriptInstance createScriptInstanceForWidget(Widget*); 113 114 // Check if the javascript engine has been initialized. 115 bool haveInterpreter() const; 133 116 134 117 bool isEnabled() const; … … 188 171 #endif 189 172 173 // Dummy method to avoid a bunch of ifdef's in WebCore. 174 void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*) { } 175 static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); 176 190 177 // Script state for the main world context. 191 178 ScriptState* mainWorldScriptState(); … … 195 182 196 183 private: 197 V8DOMWindowShell* initScript(DOMWrapperWorld*);198 199 ShellMap m_windowShells;200 184 Frame* m_frame; 201 202 // This is a cache of the main world's windowShell. We have this203 // because we need access to it during some wrapper operations that204 // are performance sensitive. Those call sites are wrong, but I'm205 // waiting to remove them until the next patch.206 RefPtr<V8DOMWindowShell> m_mainWorldWindowShell;207 208 185 const String* m_sourceURL; 209 186 … … 215 192 // FIXME: V8Proxy should eventually be removed. 216 193 OwnPtr<V8Proxy> m_proxy; 194 195 // For the moment, we have one of these. Soon we will have one per DOMWrapperWorld. 196 RefPtr<V8DOMWindowShell> m_windowShell; 217 197 218 198 typedef HashMap<Widget*, NPObject*> PluginObjectMap; -
trunk/WebCore/bindings/v8/V8DOMWindowShell.cpp
r52877 r52882 37 37 #include "DocumentLoader.h" 38 38 #include "DOMObjectsInclude.h" 39 #include "DOMWrapperWorld.h"40 39 #include "Frame.h" 41 40 #include "FrameLoaderClient.h" … … 124 123 } 125 124 126 PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame , DOMWrapperWorld* world)127 { 128 return adoptRef(new V8DOMWindowShell(frame , world));129 } 130 131 V8DOMWindowShell::V8DOMWindowShell(Frame* frame , DOMWrapperWorld* world)125 PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame) 126 { 127 return adoptRef(new V8DOMWindowShell(frame)); 128 } 129 130 V8DOMWindowShell::V8DOMWindowShell(Frame* frame) 132 131 : m_frame(frame) 133 , m_world(world)134 132 { 135 133 } … … 314 312 setSecurityToken(); 315 313 316 // FIXME: JSC doesn't seem to make this callback.317 314 m_frame->loader()->client()->didCreateScriptContextForFrame(); 315 316 // FIXME: This is wrong. We should actually do this for the proper world once 317 // we do isolated worlds the WebCore way. 318 m_frame->loader()->dispatchDidClearWindowObjectInWorld(0); 318 319 } 319 320
Note: See TracChangeset
for help on using the changeset viewer.