Changeset 230867 in webkit
- Timestamp:
- Apr 20, 2018 4:48:50 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230864 r230867 1 2018-04-20 Chris Dumez <cdumez@apple.com> 2 3 Use WindowProxy in DOMWindow.idl 4 https://bugs.webkit.org/show_bug.cgi?id=184820 5 6 Reviewed by Sam Weinig. 7 8 Use WindowProxy in DOMWindow.idl to match the specification more closely. 9 10 * bindings/js/JSWindowProxy.h: 11 * bindings/js/WindowProxy.cpp: 12 (WebCore::WindowProxy::window const): 13 * bindings/js/WindowProxy.h: 14 * bindings/scripts/CodeGeneratorJS.pm: 15 (NativeToJSValueDOMConvertNeedsState): 16 * dom/Document.cpp: 17 * dom/Document.h: 18 * dom/Document.idl: 19 * page/DOMWindow.cpp: 20 (WebCore::DOMWindow::focus): 21 (WebCore::DOMWindow::self const): 22 (WebCore::DOMWindow::opener const): 23 (WebCore::DOMWindow::parent const): 24 (WebCore::DOMWindow::top const): 25 (WebCore::DOMWindow::open): 26 * page/DOMWindow.h: 27 * page/DOMWindow.idl: 28 * testing/Internals.cpp: 29 (WebCore::Internals::openDummyInspectorFrontend): 30 * testing/Internals.h: 31 * testing/Internals.idl: 32 1 33 2018-04-20 Chris Dumez <cdumez@apple.com> 2 34 -
trunk/Source/WebCore/bindings/js/JSWindowProxy.h
r230831 r230867 70 70 // JSWindowProxy is a little odd in that it's not a traditional wrapper and has no back pointer. 71 71 // It is, however, strongly owned by AbstractFrame via its WindowProxy, so we can get one from a WindowProxy. 72 JSC::JSValue toJS(JSC::ExecState*, WindowProxy&);72 WEBCORE_EXPORT JSC::JSValue toJS(JSC::ExecState*, WindowProxy&); 73 73 inline JSC::JSValue toJS(JSC::ExecState* state, WindowProxy* windowProxy) { return windowProxy ? toJS(state, *windowProxy) : JSC::jsNull(); } 74 inline JSC::JSValue toJS(JSC::ExecState* state, const RefPtr<WindowProxy>& windowProxy) { return toJS(state, windowProxy.get()); } 74 75 75 76 JSWindowProxy& toJSWindowProxy(WindowProxy&, DOMWrapperWorld&); -
trunk/Source/WebCore/bindings/js/WindowProxy.cpp
r230831 r230867 166 166 } 167 167 168 AbstractDOMWindow* WindowProxy::window() const 169 { 170 return m_frame.window(); 171 } 172 173 void WindowProxy::ref() 174 { 175 m_frame.ref(); 176 } 177 178 void WindowProxy::deref() 179 { 180 m_frame.deref(); 181 } 182 168 183 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/WindowProxy.h
r230831 r230867 76 76 void attachDebugger(JSC::Debugger*); // Attaches/detaches in all worlds/window proxies. 77 77 78 WEBCORE_EXPORT AbstractDOMWindow* window() const; 79 80 WEBCORE_EXPORT void ref(); 81 WEBCORE_EXPORT void deref(); 82 78 83 private: 79 84 JSWindowProxy& createJSWindowProxy(DOMWrapperWorld&); -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r230831 r230867 423 423 424 424 if ($type->name eq "WindowProxy") { 425 AddToIncludes("WindowProxy.h", $includesRef, $conditional); 425 426 AddToIncludes("JSWindowProxy.h", $includesRef, $conditional); 426 427 AddToIncludes("JSDOMConvertWindowProxy.h", $includesRef, $conditional); … … 6554 6555 return 1 if $type->name eq "SerializedScriptValue"; 6555 6556 return 1 if $type->name eq "XPathNSResolver"; 6557 return 1 if $type->name eq "WindowProxy"; 6556 6558 6557 6559 return 0; -
trunk/Source/WebCore/dom/Document.cpp
r230822 r230867 2594 2594 } 2595 2595 2596 ExceptionOr<RefPtr< DOMWindow>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)2596 ExceptionOr<RefPtr<WindowProxy>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features) 2597 2597 { 2598 2598 if (!m_domWindow) -
trunk/Source/WebCore/dom/Document.h
r230822 r230867 186 186 class WebGLRenderingContext; 187 187 class WebGPURenderingContext; 188 class WindowProxy; 188 189 class XPathEvaluator; 189 190 class XPathExpression; … … 620 621 WEBCORE_EXPORT DocumentLoader* loader() const; 621 622 622 WEBCORE_EXPORT ExceptionOr<RefPtr< DOMWindow>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features);623 WEBCORE_EXPORT ExceptionOr<RefPtr<WindowProxy>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features); 623 624 WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String& type, const String& replace); 624 625 -
trunk/Source/WebCore/dom/Document.idl
r229680 r230867 108 108 // the existing 'incumbent document' concept. 109 109 [CEReactions, CallWith=ResponsibleDocument, ImplementedAs=openForBindings, MayThrowException] Document open(optional DOMString type = "text/html", optional DOMString replace = ""); 110 [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] DOMWindowopen(USVString url, DOMString name, DOMString features);110 [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] WindowProxy open(USVString url, DOMString name, DOMString features); 111 111 [CEReactions, ImplementedAs=closeForBindings, MayThrowException] void close(); 112 112 [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void write(DOMString... text); -
trunk/Source/WebCore/page/DOMWindow.cpp
r230864 r230867 107 107 #include "WindowFeatures.h" 108 108 #include "WindowFocusAllowedIndicator.h" 109 #include "WindowProxy.h" 109 110 #include <JavaScriptCore/ScriptCallStack.h> 110 111 #include <JavaScriptCore/ScriptCallStackFactory.h> … … 1015 1016 void DOMWindow::focus(DOMWindow& incumbentWindow) 1016 1017 { 1017 focus(opener() && opener() != this && &incumbentWindow == opener()); 1018 auto* opener = this->opener(); 1019 focus(opener && opener != self() && incumbentWindow.self() == opener); 1018 1020 } 1019 1021 … … 1418 1420 } 1419 1421 1420 DOMWindow* DOMWindow::self() const1421 { 1422 if (!m_frame) 1423 return nullptr; 1424 1425 return m_frame->document()->domWindow();1426 } 1427 1428 DOMWindow* DOMWindow::opener() const1429 { 1430 if (!m_frame) 1431 return nullptr; 1432 1433 Frame* opener= m_frame->loader().opener();1434 if (!opener )1435 return nullptr; 1436 1437 return opener->document()->domWindow();1422 WindowProxy* DOMWindow::self() const 1423 { 1424 if (!m_frame) 1425 return nullptr; 1426 1427 return &m_frame->windowProxy(); 1428 } 1429 1430 WindowProxy* DOMWindow::opener() const 1431 { 1432 if (!m_frame) 1433 return nullptr; 1434 1435 auto* openerFrame = m_frame->loader().opener(); 1436 if (!openerFrame) 1437 return nullptr; 1438 1439 return &openerFrame->windowProxy(); 1438 1440 } 1439 1441 … … 1444 1446 } 1445 1447 1446 DOMWindow* DOMWindow::parent() const 1447 { 1448 if (!m_frame) 1449 return nullptr; 1450 1451 Frame* parent = m_frame->tree().parent(); 1452 if (parent) 1453 return parent->document()->domWindow(); 1454 1455 return m_frame->document()->domWindow(); 1456 } 1457 1458 DOMWindow* DOMWindow::top() const 1459 { 1460 if (!m_frame) 1461 return nullptr; 1462 1463 Page* page = m_frame->page(); 1464 if (!page) 1465 return nullptr; 1466 1467 return m_frame->tree().top().document()->domWindow(); 1448 WindowProxy* DOMWindow::parent() const 1449 { 1450 if (!m_frame) 1451 return nullptr; 1452 1453 auto* parentFrame = m_frame->tree().parent(); 1454 if (parentFrame) 1455 return &parentFrame->windowProxy(); 1456 1457 return &m_frame->windowProxy(); 1458 } 1459 1460 WindowProxy* DOMWindow::top() const 1461 { 1462 if (!m_frame) 1463 return nullptr; 1464 1465 if (!m_frame->page()) 1466 return nullptr; 1467 1468 return &m_frame->tree().top().windowProxy(); 1468 1469 } 1469 1470 … … 2313 2314 } 2314 2315 2315 RefPtr< DOMWindow> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)2316 RefPtr<WindowProxy> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString) 2316 2317 { 2317 2318 if (!isCurrentlyDisplayedInFrame()) … … 2364 2365 2365 2366 if (targetFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL)) 2366 return targetFrame->document()->domWindow();2367 return &targetFrame->windowProxy(); 2367 2368 2368 2369 if (urlString.isEmpty()) 2369 return targetFrame->document()->domWindow();2370 return &targetFrame->windowProxy(); 2370 2371 2371 2372 // For whatever reason, Firefox uses the first window rather than the active window to … … 2374 2375 targetFrame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(), completedURL, firstFrame->loader().outgoingReferrer(), 2375 2376 lockHistory, LockBackForwardList::No); 2376 return targetFrame->document()->domWindow();2377 } 2378 2379 RefPtr<Frame> result= createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);2380 return result ? result->document()->domWindow() : nullptr;2377 return &targetFrame->windowProxy(); 2378 } 2379 2380 auto newFrame = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame); 2381 return newFrame ? &newFrame->windowProxy() : nullptr; 2381 2382 } 2382 2383 -
trunk/Source/WebCore/page/DOMWindow.h
r230864 r230867 159 159 void stop(); 160 160 161 WEBCORE_EXPORT RefPtr< DOMWindow> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString);161 WEBCORE_EXPORT RefPtr<WindowProxy> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString); 162 162 163 163 void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction); … … 194 194 void setDefaultStatus(const String&); 195 195 196 DOMWindow* self() const;197 198 DOMWindow* opener() const;196 WindowProxy* self() const; 197 198 WindowProxy* opener() const; 199 199 void disownOpener(); 200 DOMWindow* parent() const;201 DOMWindow* top() const;200 WindowProxy* parent() const; 201 WindowProxy* top() const; 202 202 203 203 Frame* frame() const final { return FrameDestructionObserver::frame(); } -
trunk/Source/WebCore/page/DOMWindow.idl
r230077 r230867 50 50 ] interface DOMWindow : EventTarget { 51 51 // The current browsing context. 52 [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute DOMWindowwindow;53 [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindowself;52 [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window; 53 [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy self; 54 54 [Unforgeable] readonly attribute Document document; 55 55 attribute DOMString name; … … 71 71 72 72 // Other browsing contexts. 73 [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute DOMWindowframes;73 [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute WindowProxy frames; 74 74 [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length; 75 [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute DOMWindow? top;76 [DoNotCheckSecurityOnGetter, CustomSetter] attribute DOMWindow? opener;77 [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow? parent;75 [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute WindowProxy? top; 76 [DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener; 77 [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy? parent; 78 78 [CheckSecurityForNode] readonly attribute Element? frameElement; 79 [CallWith=ActiveWindow&FirstWindow] DOMWindow? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");79 [CallWith=ActiveWindow&FirstWindow] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = ""); 80 80 81 81 // The user agent. -
trunk/Source/WebCore/testing/Internals.cpp
r230788 r230867 160 160 #include "VoidCallback.h" 161 161 #include "WebCoreJSClientData.h" 162 #if ENABLE(WEBGL) 163 #include "WebGLRenderingContext.h" 164 #endif 162 #include "WindowProxy.h" 165 163 #include "WorkerThread.h" 166 164 #include "WritingDirection.h" … … 204 202 #include "HTMLMediaElement.h" 205 203 #include "TimeRanges.h" 204 #endif 205 206 #if ENABLE(WEBGL) 207 #include "WebGLRenderingContext.h" 206 208 #endif 207 209 … … 2306 2308 } 2307 2309 2308 RefPtr< DOMWindow> Internals::openDummyInspectorFrontend(const String& url)2310 RefPtr<WindowProxy> Internals::openDummyInspectorFrontend(const String& url) 2309 2311 { 2310 2312 auto* inspectedPage = contextDocument()->frame()->page(); 2311 2313 auto* window = inspectedPage->mainFrame().document()->domWindow(); 2312 auto frontendWindow = window->open(*window, *window, url, "", "");2313 m_inspectorFrontend = std::make_unique<InspectorStubFrontend>(*inspectedPage, frontendWindow.copyRef());2314 return frontendWindow ;2314 auto frontendWindowProxy = window->open(*window, *window, url, "", ""); 2315 m_inspectorFrontend = std::make_unique<InspectorStubFrontend>(*inspectedPage, downcast<DOMWindow>(frontendWindowProxy->window())); 2316 return frontendWindowProxy; 2315 2317 } 2316 2318 -
trunk/Source/WebCore/testing/Internals.h
r230788 r230867 350 350 unsigned referencingNodeCount(const Document&) const; 351 351 352 RefPtr< DOMWindow> openDummyInspectorFrontend(const String& url);352 RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url); 353 353 void closeDummyInspectorFrontend(); 354 354 ExceptionOr<void> setInspectorIsUnderTest(bool); -
trunk/Source/WebCore/testing/Internals.idl
r230788 r230867 316 316 unsigned long numberOfLiveDocuments(); 317 317 unsigned long referencingNodeCount(Document document); 318 DOMWindow? openDummyInspectorFrontend(DOMString url);318 WindowProxy? openDummyInspectorFrontend(DOMString url); 319 319 void closeDummyInspectorFrontend(); 320 320 [MayThrowException] void setInspectorIsUnderTest(boolean isUnderTest);
Note: See TracChangeset
for help on using the changeset viewer.