Changeset 126103 in webkit
- Timestamp:
- Aug 20, 2012 5:31:09 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126100 r126103 1 2012-08-20 Kentaro Hara <haraken@chromium.org> 2 3 [V8] Move retrieve{Window,Frame,PerContextData}() from V8Proxy to V8Binding 4 https://bugs.webkit.org/show_bug.cgi?id=94460 5 6 Reviewed by Adam Barth. 7 8 To kill V8Proxy, we move retrieve{Window,Frame,PerContextData}() 9 from V8Proxy to V8Binding. Also, this patch renames these methods as follows: 10 11 - retrieveWindow() -> toDOMWindow() 12 - retrieveFrame() -> toFrameIfNotDetached() 13 - retrievePerContextData() -> perContextDataForCurrentWorld() 14 15 No tests. No change in behavior. 16 17 * bindings/v8/BindingState.cpp: 18 (WebCore::activeDOMWindow): 19 (WebCore::firstDOMWindow): 20 (WebCore::activeFrame): 21 (WebCore::firstFrame): 22 (WebCore::currentFrame): 23 (WebCore::currentDocument): 24 * bindings/v8/PageScriptDebugServer.cpp: 25 (WebCore::retrieveFrameWithGlobalObjectCheck): 26 (WebCore::PageScriptDebugServer::getDebugListenerForContext): 27 (WebCore::PageScriptDebugServer::runMessageLoopOnPause): 28 * bindings/v8/V8Binding.cpp: 29 (WebCore::retrieveWindow): 30 (WebCore): 31 (WebCore::retrieveFrame): 32 (WebCore::retrievePerContextData): 33 * bindings/v8/V8Binding.h: 34 (WebCore): 35 * bindings/v8/V8DOMWrapper.cpp: 36 (WebCore::V8DOMWrapper::constructorForType): 37 * bindings/v8/V8NPUtils.cpp: 38 (WebCore::convertV8ObjectToNPVariant): 39 * bindings/v8/V8Proxy.cpp: 40 (WebCore::V8Proxy::handleOutOfMemory): 41 (WebCore::V8Proxy::context): 42 (WebCore::V8Proxy::matchesCurrentContext): 43 * bindings/v8/V8Proxy.h: 44 (V8Proxy): 45 1 46 2012-08-20 Abhishek Arya <inferno@chromium.org> 2 47 -
trunk/Source/WebCore/bindings/v8/BindingState.cpp
r125592 r126103 35 35 #include "Frame.h" 36 36 #include "ScriptController.h" 37 #include "V8 Proxy.h"37 #include "V8Binding.h" 38 38 #include <wtf/StdLibExtras.h> 39 39 … … 59 59 DOMWindow* activeDOMWindow(BindingState*) 60 60 { 61 return V8Proxy::retrieveWindow(activeContext());61 return toDOMWindow(activeContext()); 62 62 } 63 63 64 64 DOMWindow* firstDOMWindow(BindingState*) 65 65 { 66 return V8Proxy::retrieveWindow(v8::Context::GetEntered());66 return toDOMWindow(v8::Context::GetEntered()); 67 67 } 68 68 … … 72 72 if (context.IsEmpty()) 73 73 return 0; 74 return V8Proxy::retrieveFrame(context);74 return toFrameIfNotDetached(context); 75 75 } 76 76 … … 80 80 if (context.IsEmpty()) 81 81 return 0; 82 return V8Proxy::retrieveFrame(context);82 return toFrameIfNotDetached(context); 83 83 } 84 84 … … 88 88 if (context.IsEmpty()) 89 89 return 0; 90 return V8Proxy::retrieveFrame(context);90 return toFrameIfNotDetached(context); 91 91 } 92 92 93 93 Document* currentDocument(BindingState*) 94 94 { 95 DOMWindow* current = V8Proxy::retrieveWindow(v8::Context::GetCurrent());95 DOMWindow* current = toDOMWindow(v8::Context::GetCurrent()); 96 96 if (!current) 97 97 return 0; -
trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp
r124583 r126103 48 48 namespace WebCore { 49 49 50 static Frame* retrieveFrame (v8::Handle<v8::Context> context)50 static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context) 51 51 { 52 52 if (context.IsEmpty()) … … 62 62 return 0; 63 63 64 return V8Proxy::retrieveFrame(context);64 return toFrameIfNotDetached(context); 65 65 } 66 66 … … 168 168 { 169 169 v8::HandleScope scope; 170 Frame* frame = retrieveFrame (context);170 Frame* frame = retrieveFrameWithGlobalObjectCheck(context); 171 171 if (!frame) 172 172 return 0; … … 177 177 { 178 178 v8::HandleScope scope; 179 Frame* frame = retrieveFrame (context);179 Frame* frame = retrieveFrameWithGlobalObjectCheck(context); 180 180 m_pausedPage = frame->page(); 181 181 -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r126004 r126103 35 35 #include "DOMStringList.h" 36 36 #include "Element.h" 37 #include "Frame.h" 37 38 #include "MemoryInstrumentation.h" 38 39 #include "PlatformString.h" 39 40 #include "QualifiedName.h" 40 41 #include "V8DOMStringList.h" 42 #include "V8DOMWindow.h" 41 43 #include "V8Element.h" 42 44 #include "V8ObjectConstructor.h" 43 #include "V8Proxy.h"44 45 45 46 #include <wtf/MathExtras.h> … … 382 383 } 383 384 385 DOMWindow* toDOMWindow(v8::Handle<v8::Context> context) 386 { 387 v8::Handle<v8::Object> global = context->Global(); 388 ASSERT(!global.IsEmpty()); 389 global = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), global); 390 ASSERT(!global.IsEmpty()); 391 return V8DOMWindow::toNative(global); 392 } 393 394 Frame* toFrameIfNotDetached(v8::Handle<v8::Context> context) 395 { 396 DOMWindow* window = toDOMWindow(context); 397 if (window->isCurrentlyDisplayedInFrame()) 398 return window->frame(); 399 // We return 0 here because |context| is detached from the Frame. If we 400 // did return |frame| we could get in trouble because the frame could be 401 // navigated to another security origin. 402 return 0; 403 } 404 405 V8PerContextData* perContextDataForCurrentWorld(Frame* frame) 406 { 407 V8IsolatedContext* isolatedContext; 408 if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered()))) 409 return isolatedContext->perContextData(); 410 return frame->script()->windowShell()->perContextData(); 411 } 412 384 413 void crashIfV8IsDead() 385 414 { -
trunk/Source/WebCore/bindings/v8/V8Binding.h
r126004 r126103 369 369 PassRefPtr<DOMStringList> toDOMStringList(v8::Handle<v8::Value>); 370 370 371 // Returns the window object associated with a context. 372 DOMWindow* toDOMWindow(v8::Handle<v8::Context>); 373 374 // Returns the frame object of the window object associated with 375 // a context, if the window is currently being displayed in the Frame. 376 Frame* toFrameIfNotDetached(v8::Handle<v8::Context>); 377 378 // Returns the PerContextData associated with a frame for the current isolated world. 379 V8PerContextData* perContextDataForCurrentWorld(Frame*); 380 371 381 void crashIfV8IsDead(); 372 382 -
trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp
r125995 r126103 96 96 return v8::Local<v8::Function>(); 97 97 98 if (V8PerContextData* contextData = V8Proxy::retrievePerContextData(frame))98 if (V8PerContextData* contextData = perContextDataForCurrentWorld(frame)) 99 99 return contextData->constructorForType(type); 100 100 -
trunk/Source/WebCore/bindings/v8/V8NPUtils.cpp
r124542 r126103 70 70 STRINGN_TO_NPVARIANT(utf8Chars, length-1, *result); 71 71 } else if (object->IsObject()) { 72 DOMWindow* window = V8Proxy::retrieveWindow(v8::Context::GetCurrent());72 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); 73 73 NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(object), window); 74 74 if (npobject) -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r126086 r126103 141 141 142 142 // Warning, error, disable JS for this frame? 143 Frame* frame = V8Proxy::retrieveFrame(context);143 Frame* frame = toFrameIfNotDetached(context); 144 144 if (!frame) 145 145 return true; … … 320 320 } 321 321 322 DOMWindow* V8Proxy::retrieveWindow(v8::Handle<v8::Context> context)323 {324 v8::Handle<v8::Object> global = context->Global();325 ASSERT(!global.IsEmpty());326 global = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), global);327 ASSERT(!global.IsEmpty());328 return V8DOMWindow::toNative(global);329 }330 331 Frame* V8Proxy::retrieveFrame(v8::Handle<v8::Context> context)332 {333 DOMWindow* window = retrieveWindow(context);334 if (window->isCurrentlyDisplayedInFrame())335 return window->frame();336 // We return 0 here because |context| is detached from the Frame. If we337 // did return |frame| we could get in trouble because the frame could be338 // navigated to another security origin.339 return 0;340 }341 342 V8PerContextData* V8Proxy::retrievePerContextData(Frame* frame)343 {344 V8IsolatedContext* isolatedContext;345 if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered())))346 return isolatedContext->perContextData();347 return frame->script()->windowShell()->perContextData();348 }349 350 322 v8::Local<v8::Context> V8Proxy::context(Frame* frame) 351 323 { … … 356 328 if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) { 357 329 context = v8::Local<v8::Context>::New(isolatedContext->context()); 358 if (frame != V8Proxy::retrieveFrame(context))330 if (frame != toFrameIfNotDetached(context)) 359 331 return v8::Local<v8::Context>(); 360 332 } … … 367 339 if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) { 368 340 RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext(); 369 if (m_frame != V8Proxy::retrieveFrame(context->get()))341 if (m_frame != toFrameIfNotDetached(context->get())) 370 342 return v8::Local<v8::Context>(); 371 343 return v8::Local<v8::Context>::New(context->get()); … … 387 359 if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) { 388 360 context = isolatedContext->sharedContext()->get(); 389 if (m_frame != V8Proxy::retrieveFrame(context))361 if (m_frame != toFrameIfNotDetached(context)) 390 362 return false; 391 363 } else { -
trunk/Source/WebCore/bindings/v8/V8Proxy.h
r126086 r126103 104 104 v8::Local<v8::Value> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]); 105 105 106 // Returns the window object associated with a context.107 static DOMWindow* retrieveWindow(v8::Handle<v8::Context>);108 109 // Returns the frame object of the window object associated with110 // a context.111 static Frame* retrieveFrame(v8::Handle<v8::Context>);112 113 static V8PerContextData* retrievePerContextData(Frame*);114 115 106 // Returns V8 Context of a frame. If none exists, creates 116 107 // a new context. It is potentially slow and consumes memory. -
trunk/Source/WebKit/chromium/ChangeLog
r126099 r126103 1 2012-08-20 Kentaro Hara <haraken@chromium.org> 2 3 [V8] Move retrieve{Window,Frame,PerContextData}() from V8Proxy to V8Binding 4 https://bugs.webkit.org/show_bug.cgi?id=94460 5 6 Reviewed by Adam Barth. 7 8 To kill V8Proxy, we move retrieve{Window,Frame,PerContextData}() 9 from V8Proxy to V8Binding. Also, this patch renames these methods as follows: 10 11 - retrieveWindow() -> toDOMWindow() 12 - retrieveFrame() -> toFrameIfNotDetached() 13 - retrievePerContextData() -> perContextDataForCurrentWorld() 14 15 No tests. No change in behavior. 16 17 * src/WebBindings.cpp: 18 (WebKit::makeIntArrayImpl): 19 (WebKit::makeStringArrayImpl): 20 * src/WebFrameImpl.cpp: 21 (WebKit::WebFrame::frameForContext): 22 1 23 2012-08-20 James Robinson <jamesr@chromium.org> 2 24 -
trunk/Source/WebKit/chromium/src/WebBindings.cpp
r124931 r126103 291 291 result->Set(i, v8::Number::New(data[i])); 292 292 293 DOMWindow* window = V8Proxy::retrieveWindow(v8::Context::GetCurrent());293 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); 294 294 return npCreateV8ScriptObject(0, result, window); 295 295 } … … 302 302 result->Set(i, data[i].data() ? v8::String::New(reinterpret_cast<const uint16_t*>((data[i].data())), data[i].length()) : v8::String::New("")); 303 303 304 DOMWindow* window = V8Proxy::retrieveWindow(v8::Context::GetCurrent());304 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); 305 305 return npCreateV8ScriptObject(0, result, window); 306 306 } -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r126098 r126103 584 584 #if WEBKIT_USING_V8 585 585 WebFrame* WebFrame::frameForContext(v8::Handle<v8::Context> context) 586 { 587 return WebFrameImpl::fromFrame(V8Proxy::retrieveFrame(context));586 { 587 return WebFrameImpl::fromFrame(toFrameIfNotDetached(context)); 588 588 } 589 589 #endif
Note: See TracChangeset
for help on using the changeset viewer.