Changeset 52847 in webkit
- Timestamp:
- Jan 5, 2010 7:09:24 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52846 r52847 1 2010-01-05 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 [v8] Move V8DOMWindowShell to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=33232 7 8 This patch moves V8DOMWindow shell to ScriptController, where the 9 window shells live in JSC land. The next step will be to allow for 10 more than one window shell per script controller. 11 12 * bindings/v8/ScriptController.cpp: 13 (WebCore::ScriptController::ScriptController): 14 (WebCore::ScriptController::~ScriptController): 15 (WebCore::ScriptController::updateSecurityOrigin): 16 (WebCore::ScriptController::evaluateInIsolatedWorld): 17 (WebCore::ScriptController::haveInterpreter): 18 (WebCore::ScriptController::mainWorldWindowShell): 19 (WebCore::ScriptController::clearWindowShell): 20 (WebCore::ScriptController::clearForClose): 21 (WebCore::ScriptController::destroyWindowShell): 22 (WebCore::ScriptController::updateDocument): 23 * bindings/v8/ScriptController.h: 24 * bindings/v8/V8DOMWindowShell.cpp: 25 (WebCore::V8DOMWindowShell::~V8DOMWindowShell): 26 * bindings/v8/V8DOMWindowShell.h: 27 (WebCore::V8DOMWindowShell::localHandleForContext): 28 * bindings/v8/V8DOMWrapper.cpp: 29 (WebCore::V8DOMWrapper::instantiateV8Object): 30 (WebCore::V8DOMWrapper::convertDocumentToV8Object): 31 (WebCore::V8DOMWrapper::convertNewNodeToV8Object): 32 * bindings/v8/V8IsolatedContext.cpp: 33 (WebCore::V8IsolatedContext::V8IsolatedContext): 34 * bindings/v8/V8Proxy.cpp: 35 (WebCore::V8Proxy::V8Proxy): 36 (WebCore::V8Proxy::~V8Proxy): 37 (WebCore::V8Proxy::handleOutOfMemory): 38 (WebCore::V8Proxy::evaluateInIsolatedWorld): 39 (WebCore::V8Proxy::setInjectedScriptContextDebugId): 40 (WebCore::V8Proxy::context): 41 (WebCore::V8Proxy::mainWorldContext): 42 (WebCore::V8Proxy::currentContext): 43 (WebCore::V8Proxy::setContextDebugId): 44 * bindings/v8/V8Proxy.h: 45 * bindings/v8/WorldContextHandle.cpp: 46 (WebCore::WorldContextHandle::adjustedContext): 47 1 48 2010-01-05 Kent Tamura <tkent@chromium.org> 2 49 -
trunk/WebCore/bindings/v8/ScriptController.cpp
r52811 r52847 107 107 , m_paused(false) 108 108 , m_proxy(new V8Proxy(frame)) 109 , m_windowShell(V8DOMWindowShell::create(frame)) 109 110 #if ENABLE(NETSCAPE_PLUGIN_API) 110 111 , m_windowScriptNPObject(0) … … 117 118 { 118 119 m_proxy->disconnectFrame(); 120 m_windowShell.clear(); 119 121 } 120 122 … … 141 143 void ScriptController::updateSecurityOrigin() 142 144 { 143 m_ proxy->windowShell()->updateSecurityOrigin();145 m_windowShell->updateSecurityOrigin(); 144 146 } 145 147 … … 206 208 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources) 207 209 { 210 // FIXME: This will need to get reorganized once we have a windowShell for the isolated world. 211 m_windowShell->initContextIfNeeded(); 208 212 m_proxy->evaluateInIsolatedWorld(worldID, sources, 0); 209 213 } … … 292 296 bool ScriptController::haveInterpreter() const 293 297 { 294 return m_ proxy->windowShell()->isContextInitialized();298 return m_windowShell->isContextInitialized(); 295 299 } 296 300 … … 436 440 } 437 441 442 V8DOMWindowShell* ScriptController::mainWorldWindowShell() const 443 { 444 m_windowShell->initContextIfNeeded(); 445 return m_windowShell.get(); 446 } 438 447 439 448 void ScriptController::clearWindowShell() 440 449 { 441 450 m_mainWorldScriptState.clear(); 451 m_proxy->resetIsolatedWorlds(); 442 452 443 453 // V8 binding expects ScriptController::clearWindowShell only be called 444 // when a frame is loading a new page. V8 Proxy::clearForNavigation454 // when a frame is loading a new page. V8DOMWindowShell::clearForNavigation 445 455 // creates a new context for the new page. 446 m_proxy->clearForNavigation(); 456 m_windowShell->clearForNavigation(); 457 } 458 459 void ScriptController::clearForClose() 460 { 461 m_windowShell->clearForClose(); 462 } 463 464 void ScriptController::destroyWindowShell() 465 { 466 m_windowShell->clearForClose(); 467 m_windowShell->destroyGlobal(); 447 468 } 448 469 … … 454 475 void ScriptController::updateDocument() 455 476 { 456 m_ proxy->windowShell()->updateDocument();477 m_windowShell->updateDocument(); 457 478 } 458 479 -
trunk/WebCore/bindings/v8/ScriptController.h
r52823 r52847 64 64 V8Proxy* proxy() { return m_proxy.get(); } 65 65 66 V8DOMWindowShell* mainWorldWindowShell() const; 67 66 68 ScriptValue executeScript(const ScriptSourceCode&); 67 69 ScriptValue executeScript(const String& script, bool forceUserGesture = false); … … 154 156 void updateDocument(); 155 157 158 void clearForClose(); 159 160 // This is very destructive (e.g., out of memory). 161 void destroyWindowShell(); 162 156 163 void updateSecurityOrigin(); 157 164 void clearScriptObjects(); … … 183 190 bool m_paused; 184 191 192 // FIXME: V8Proxy should eventually be removed. 185 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; 197 186 198 typedef HashMap<Widget*, NPObject*> PluginObjectMap; 187 199 -
trunk/WebCore/bindings/v8/V8DOMWindowShell.cpp
r52811 r52847 99 99 : m_frame(frame) 100 100 { 101 } 102 103 V8DOMWindowShell::~V8DOMWindowShell() 104 { 105 clearForClose(); 106 destroyGlobal(); 101 107 } 102 108 -
trunk/WebCore/bindings/v8/V8DOMWindowShell.h
r52666 r52847 47 47 static PassRefPtr<V8DOMWindowShell> create(Frame*); 48 48 49 virtual ~V8DOMWindowShell(); 50 49 51 v8::Handle<v8::Context> context() const { return m_context; } 52 53 // This method is slower than |context()|, but sometimes we need local handles. 54 v8::Local<v8::Context> localHandleForContext() const { return v8::Local<v8::Context>::New(m_context); } 50 55 51 56 // Update document object of the frame. … … 66 71 void clearForNavigation(); 67 72 void clearForClose(); 68 69 73 void destroyGlobal(); 70 74 -
trunk/WebCore/bindings/v8/V8DOMWrapper.cpp
r52811 r52847 803 803 if (proxy) 804 804 // FIXME: Fix this to work properly with isolated worlds (see above). 805 instance = proxy-> windowShell()->createWrapperFromCache(descriptorType);805 instance = proxy->frame()->script()->mainWorldWindowShell()->createWrapperFromCache(descriptorType); 806 806 else { 807 807 v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunction(); … … 1205 1205 // checking if the node already has a wrapper. 1206 1206 V8Proxy* proxy = V8Proxy::retrieve(document->frame()); 1207 if (proxy) 1208 proxy->windowShell()->initContextIfNeeded(); 1207 if (proxy) { 1208 // This code looks wacky: 1209 // 1) The test for |proxy| above is really a test whether JavaScript 1210 // is enabled in this frame. I have no idea if that's needed. 1211 // 2) Calling initContextIfNeeded here is redundant becase just 1212 // grabbing mainWorldWindowShell() already calls initContextIfNeeded. 1213 // FIXME: I bet we can clean this up a bit! 1214 proxy->frame()->script()->mainWorldWindowShell()->initContextIfNeeded(); 1215 } 1209 1216 1210 1217 DOMWrapperMap<Node>& domNodeMap = getDOMNodeMap(); … … 1295 1302 1296 1303 if (isDocument) { 1297 if (proxy) 1298 proxy->windowShell()->updateDocumentWrapper(result); 1304 if (proxy) { 1305 // FIXME: Don't we need to do this for every world? 1306 proxy->frame()->script()->mainWorldWindowShell()->updateDocumentWrapper(result); 1307 } 1299 1308 1300 1309 if (type == V8ClassIndex::HTMLDOCUMENT) { -
trunk/WebCore/bindings/v8/V8IsolatedContext.cpp
r52811 r52847 54 54 : m_world(IsolatedWorld::create()) 55 55 { 56 // FIXME: None of this code belongs here! Basically, ScriptController 57 // should create a new DOMWrapperWorld and a new windowShell and then 58 // evaluate the script. 59 60 V8DOMWindowShell* mainWorldWindowShell = proxy->frame()->script()->mainWorldWindowShell(); 61 56 62 v8::HandleScope scope; 57 63 // FIXME: We should be creating a new V8DOMWindowShell here instead of riping out the context. 58 m_context = SharedPersistent<v8::Context>::create( proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup));64 m_context = SharedPersistent<v8::Context>::create(mainWorldWindowShell->createNewContext(v8::Handle<v8::Object>(), extensionGroup)); 59 65 if (m_context->get().IsEmpty()) 60 66 return; … … 67 73 V8DOMWindowShell::installHiddenObjectPrototype(m_context->get()); 68 74 // FIXME: This will go away once we have a windowShell for the isolated world. 69 proxy->windowShell()->installDOMWindow(m_context->get(), proxy->frame()->domWindow());75 mainWorldWindowShell->installDOMWindow(m_context->get(), proxy->frame()->domWindow()); 70 76 71 77 // Using the default security token means that the canAccess is always -
trunk/WebCore/bindings/v8/V8Proxy.cpp
r52811 r52847 214 214 V8Proxy::V8Proxy(Frame* frame) 215 215 : m_frame(frame) 216 , m_windowShell(V8DOMWindowShell::create(frame))217 216 , m_inlineCode(false) 218 217 , m_timerCallback(false) … … 223 222 V8Proxy::~V8Proxy() 224 223 { 225 clearForClose(); 226 windowShell()->destroyGlobal(); 224 resetIsolatedWorlds(); 227 225 } 228 226 … … 247 245 Frame* frame = V8Proxy::retrieveFrame(context); 248 246 249 V8Proxy* proxy = V8Proxy::retrieve(frame); 250 if (proxy) { 251 // Clean m_context, and event handlers. 252 proxy->clearForClose(); 253 254 proxy->windowShell()->destroyGlobal(); 255 } 247 frame->script()->destroyWindowShell(); 256 248 257 249 ChromiumBridge::notifyJSOutOfMemory(frame); … … 267 259 void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup) 268 260 { 269 // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.270 windowShell()->initContextIfNeeded();271 272 261 v8::HandleScope handleScope; 273 262 V8IsolatedContext* isolatedContext = 0; … … 315 304 // Setup context id for JS debugger. 316 305 v8::Context::Scope contextScope(targetContext); 317 v8::Handle<v8::Context> context = windowShell()->context();306 v8::Handle<v8::Context> context = m_frame->script()->mainWorldWindowShell()->localHandleForContext(); 318 307 if (context.IsEmpty()) 319 308 return false; … … 583 572 } 584 573 m_isolatedWorlds.clear(); 585 }586 587 void V8Proxy::clearForClose()588 {589 resetIsolatedWorlds();590 windowShell()->clearForClose();591 }592 593 void V8Proxy::clearForNavigation()594 {595 resetIsolatedWorlds();596 windowShell()->clearForNavigation();597 574 } 598 575 … … 656 633 v8::Local<v8::Context> V8Proxy::context(Frame* frame) 657 634 { 635 // FIXME: Move this function to ScriptController. 658 636 v8::Local<v8::Context> context = V8Proxy::mainWorldContext(frame); 659 637 if (context.IsEmpty()) … … 671 649 v8::Local<v8::Context> V8Proxy::context() 672 650 { 651 // FIXME: Move this function to ScriptController. 673 652 if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) { 674 653 RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext(); … … 677 656 return v8::Local<v8::Context>::New(context->get()); 678 657 } 679 return mainWorldContext(); 680 } 681 682 v8::Local<v8::Context> V8Proxy::mainWorldContext() 683 { 684 windowShell()->initContextIfNeeded(); 685 return v8::Local<v8::Context>::New(windowShell()->context()); 658 return m_frame->script()->mainWorldWindowShell()->localHandleForContext(); 686 659 } 687 660 688 661 v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame) 689 662 { 690 V8Proxy* proxy = retrieve(frame);691 if (! proxy)663 // FIXME: Move this function to ScriptController. 664 if (!frame->script()->isEnabled()) 692 665 return v8::Local<v8::Context>(); 693 666 694 return proxy->mainWorldContext();667 return frame->script()->mainWorldWindowShell()->localHandleForContext(); 695 668 } 696 669 697 670 v8::Local<v8::Context> V8Proxy::currentContext() 698 671 { 672 // FIXME: Why does this function exist? 699 673 return v8::Context::GetCurrent(); 700 674 } … … 831 805 { 832 806 ASSERT(debugId > 0); 833 v8:: Handle<v8::Context> context = windowShell()->context();807 v8::Local<v8::Context> context = m_frame->script()->mainWorldWindowShell()->localHandleForContext(); 834 808 if (context.IsEmpty()) 835 809 return false; -
trunk/WebCore/bindings/v8/V8Proxy.h
r52811 r52847 153 153 Frame* frame() { return m_frame; } 154 154 155 void clearForNavigation();156 void clearForClose();157 158 155 // FIXME: Need comment. User Gesture related. 159 156 bool inlineCode() const { return m_inlineCode; } … … 310 307 311 308 v8::Local<v8::Context> context(); 312 v8::Local<v8::Context> mainWorldContext();313 314 // FIXME: This should eventually take DOMWrapperWorld argument!315 V8DOMWindowShell* windowShell() const { return m_windowShell.get(); }316 309 317 310 bool setContextDebugId(int id); … … 336 329 static void reportUnsafeAccessTo(Frame* target, DelayReporting delay); 337 330 331 // FIXME: This should move to ScriptController. 332 void resetIsolatedWorlds(); 333 338 334 private: 339 335 // If m_recursionCount is 0, let LocalStorage know so we can release 340 336 // the storage mutex. 341 337 void releaseStorageMutex(); 342 343 void resetIsolatedWorlds();344 338 345 339 // Returns false when we're out of memory in V8. … … 371 365 Frame* m_frame; 372 366 373 // For the moment, we have one of these. Soon we will have one per DOMWrapperWorld.374 RefPtr<V8DOMWindowShell> m_windowShell;375 376 367 // Utility context holding JavaScript functions used internally. 377 368 static v8::Persistent<v8::Context> m_utilityContext; -
trunk/WebCore/bindings/v8/WorldContextHandle.cpp
r52811 r52847 32 32 #include "WorldContextHandle.h" 33 33 34 #include "Frame.h" 34 35 #include "V8IsolatedContext.h" 35 36 … … 49 50 { 50 51 if (m_worldToUse == UseMainWorld) 51 return proxy-> mainWorldContext();52 return proxy->frame()->script()->mainWorldWindowShell()->localHandleForContext(); 52 53 if (!m_context || m_context->get().IsEmpty()) 53 54 return proxy->context(); -
trunk/WebKit/chromium/ChangeLog
r52845 r52847 1 2010-01-05 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 [v8] Move V8DOMWindowShell to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=33232 7 8 Update FrameLoaderClientImpl.cpp to call clearForClose on 9 ScriptController instead of on V8Proxy. 10 11 * src/FrameLoaderClientImpl.cpp: 12 (WebKit::FrameLoaderClientImpl::detachedFromParent3): 13 1 14 2010-01-05 Rachel Petterson <rlp@google.com> 2 15 -
trunk/WebKit/chromium/src/FrameLoaderClientImpl.cpp
r52791 r52847 216 216 // go to a page and then navigate to a new page without getting any asserts 217 217 // or crashes. 218 m_webFrame->frame()->script()-> proxy()->clearForClose();219 218 m_webFrame->frame()->script()->clearForClose(); 219 220 220 // Stop communicating with the WebFrameClient at this point since we are no 221 221 // longer associated with the Page.
Note: See TracChangeset
for help on using the changeset viewer.