Title: [230867] trunk/Source/WebCore
Revision
230867
Author
cdu...@apple.com
Date
2018-04-20 16:48:50 -0700 (Fri, 20 Apr 2018)

Log Message

Use WindowProxy in DOMWindow.idl
https://bugs.webkit.org/show_bug.cgi?id=184820

Reviewed by Sam Weinig.

Use WindowProxy in DOMWindow.idl to match the specification more closely.

* bindings/js/JSWindowProxy.h:
* bindings/js/WindowProxy.cpp:
(WebCore::WindowProxy::window const):
* bindings/js/WindowProxy.h:
* bindings/scripts/CodeGeneratorJS.pm:
(NativeToJSValueDOMConvertNeedsState):
* dom/Document.cpp:
* dom/Document.h:
* dom/Document.idl:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::focus):
(WebCore::DOMWindow::self const):
(WebCore::DOMWindow::opener const):
(WebCore::DOMWindow::parent const):
(WebCore::DOMWindow::top const):
(WebCore::DOMWindow::open):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* testing/Internals.cpp:
(WebCore::Internals::openDummyInspectorFrontend):
* testing/Internals.h:
* testing/Internals.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (230866 => 230867)


--- trunk/Source/WebCore/ChangeLog	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/ChangeLog	2018-04-20 23:48:50 UTC (rev 230867)
@@ -1,5 +1,37 @@
 2018-04-20  Chris Dumez  <cdu...@apple.com>
 
+        Use WindowProxy in DOMWindow.idl
+        https://bugs.webkit.org/show_bug.cgi?id=184820
+
+        Reviewed by Sam Weinig.
+
+        Use WindowProxy in DOMWindow.idl to match the specification more closely.
+
+        * bindings/js/JSWindowProxy.h:
+        * bindings/js/WindowProxy.cpp:
+        (WebCore::WindowProxy::window const):
+        * bindings/js/WindowProxy.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (NativeToJSValueDOMConvertNeedsState):
+        * dom/Document.cpp:
+        * dom/Document.h:
+        * dom/Document.idl:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::focus):
+        (WebCore::DOMWindow::self const):
+        (WebCore::DOMWindow::opener const):
+        (WebCore::DOMWindow::parent const):
+        (WebCore::DOMWindow::top const):
+        (WebCore::DOMWindow::open):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * testing/Internals.cpp:
+        (WebCore::Internals::openDummyInspectorFrontend):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
+2018-04-20  Chris Dumez  <cdu...@apple.com>
+
         Update cross-origin SecurityError messages to not include the target origin
         https://bugs.webkit.org/show_bug.cgi?id=184803
         <rdar://problem/39547724>

Modified: trunk/Source/WebCore/bindings/js/JSWindowProxy.h (230866 => 230867)


--- trunk/Source/WebCore/bindings/js/JSWindowProxy.h	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/bindings/js/JSWindowProxy.h	2018-04-20 23:48:50 UTC (rev 230867)
@@ -69,8 +69,9 @@
 
 // JSWindowProxy is a little odd in that it's not a traditional wrapper and has no back pointer.
 // It is, however, strongly owned by AbstractFrame via its WindowProxy, so we can get one from a WindowProxy.
-JSC::JSValue toJS(JSC::ExecState*, WindowProxy&);
+WEBCORE_EXPORT JSC::JSValue toJS(JSC::ExecState*, WindowProxy&);
 inline JSC::JSValue toJS(JSC::ExecState* state, WindowProxy* windowProxy) { return windowProxy ? toJS(state, *windowProxy) : JSC::jsNull(); }
+inline JSC::JSValue toJS(JSC::ExecState* state, const RefPtr<WindowProxy>& windowProxy) { return toJS(state, windowProxy.get()); }
 
 JSWindowProxy& toJSWindowProxy(WindowProxy&, DOMWrapperWorld&);
 inline JSWindowProxy* toJSWindowProxy(WindowProxy* windowProxy, DOMWrapperWorld& world) { return windowProxy ? &toJSWindowProxy(*windowProxy, world) : nullptr; }

Modified: trunk/Source/WebCore/bindings/js/WindowProxy.cpp (230866 => 230867)


--- trunk/Source/WebCore/bindings/js/WindowProxy.cpp	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/bindings/js/WindowProxy.cpp	2018-04-20 23:48:50 UTC (rev 230867)
@@ -165,4 +165,19 @@
         windowProxy->attachDebugger(debugger);
 }
 
+AbstractDOMWindow* WindowProxy::window() const
+{
+    return m_frame.window();
+}
+
+void WindowProxy::ref()
+{
+    m_frame.ref();
+}
+
+void WindowProxy::deref()
+{
+    m_frame.deref();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/WindowProxy.h (230866 => 230867)


--- trunk/Source/WebCore/bindings/js/WindowProxy.h	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/bindings/js/WindowProxy.h	2018-04-20 23:48:50 UTC (rev 230867)
@@ -75,6 +75,11 @@
     // Debugger can be nullptr to detach any existing Debugger.
     void attachDebugger(JSC::Debugger*); // Attaches/detaches in all worlds/window proxies.
 
+    WEBCORE_EXPORT AbstractDOMWindow* window() const;
+
+    WEBCORE_EXPORT void ref();
+    WEBCORE_EXPORT void deref();
+
 private:
     JSWindowProxy& createJSWindowProxy(DOMWrapperWorld&);
     WEBCORE_EXPORT JSWindowProxy& createJSWindowProxyWithInitializedScript(DOMWrapperWorld&);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (230866 => 230867)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-04-20 23:48:50 UTC (rev 230867)
@@ -422,6 +422,7 @@
     }
 
     if ($type->name eq "WindowProxy") {
+        AddToIncludes("WindowProxy.h", $includesRef, $conditional);
         AddToIncludes("JSWindowProxy.h", $includesRef, $conditional);
         AddToIncludes("JSDOMConvertWindowProxy.h", $includesRef, $conditional);
         return;
@@ -6553,6 +6554,7 @@
     return 1 if $type->name eq "JSON";
     return 1 if $type->name eq "SerializedScriptValue";
     return 1 if $type->name eq "XPathNSResolver";
+    return 1 if $type->name eq "WindowProxy";
     
     return 0;
 }

Modified: trunk/Source/WebCore/dom/Document.cpp (230866 => 230867)


--- trunk/Source/WebCore/dom/Document.cpp	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-04-20 23:48:50 UTC (rev 230867)
@@ -2593,7 +2593,7 @@
     return parser() ? parser()->asScriptableDocumentParser() : nullptr;
 }
 
-ExceptionOr<RefPtr<DOMWindow>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)
+ExceptionOr<RefPtr<WindowProxy>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)
 {
     if (!m_domWindow)
         return Exception { InvalidAccessError };

Modified: trunk/Source/WebCore/dom/Document.h (230866 => 230867)


--- trunk/Source/WebCore/dom/Document.h	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/dom/Document.h	2018-04-20 23:48:50 UTC (rev 230867)
@@ -185,6 +185,7 @@
 class WebGL2RenderingContext;
 class WebGLRenderingContext;
 class WebGPURenderingContext;
+class WindowProxy;
 class XPathEvaluator;
 class XPathExpression;
 class XPathNSResolver;
@@ -619,7 +620,7 @@
     
     WEBCORE_EXPORT DocumentLoader* loader() const;
 
-    WEBCORE_EXPORT ExceptionOr<RefPtr<DOMWindow>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features);
+    WEBCORE_EXPORT ExceptionOr<RefPtr<WindowProxy>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features);
     WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String& type, const String& replace);
 
     // FIXME: We should rename this at some point and give back the name 'open' to the HTML specified ones.

Modified: trunk/Source/WebCore/dom/Document.idl (230866 => 230867)


--- trunk/Source/WebCore/dom/Document.idl	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/dom/Document.idl	2018-04-20 23:48:50 UTC (rev 230867)
@@ -107,7 +107,7 @@
     // that the caller document matches those semantics. It is possible we should replace it with
     // the existing 'incumbent document' concept.
     [CEReactions, CallWith=ResponsibleDocument, ImplementedAs=openForBindings, MayThrowException] Document open(optional DOMString type = "text/html", optional DOMString replace = "");
-    [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] DOMWindow open(USVString url, DOMString name, DOMString features);
+    [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] WindowProxy open(USVString url, DOMString name, DOMString features);
     [CEReactions, ImplementedAs=closeForBindings, MayThrowException] void close();
     [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void write(DOMString... text);
     [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void writeln(DOMString... text);

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (230866 => 230867)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2018-04-20 23:48:50 UTC (rev 230867)
@@ -106,6 +106,7 @@
 #include "WebKitPoint.h"
 #include "WindowFeatures.h"
 #include "WindowFocusAllowedIndicator.h"
+#include "WindowProxy.h"
 #include <_javascript_Core/ScriptCallStack.h>
 #include <_javascript_Core/ScriptCallStackFactory.h>
 #include <algorithm>
@@ -1014,7 +1015,8 @@
 
 void DOMWindow::focus(DOMWindow& incumbentWindow)
 {
-    focus(opener() && opener() != this && &incumbentWindow == opener());
+    auto* opener = this->opener();
+    focus(opener && opener != self() && incumbentWindow.self() == opener);
 }
 
 void DOMWindow::focus(bool allowFocus)
@@ -1417,24 +1419,24 @@
     page->chrome().setStatusbarText(*m_frame, m_defaultStatus);
 }
 
-DOMWindow* DOMWindow::self() const
+WindowProxy* DOMWindow::self() const
 {
     if (!m_frame)
         return nullptr;
 
-    return m_frame->document()->domWindow();
+    return &m_frame->windowProxy();
 }
 
-DOMWindow* DOMWindow::opener() const
+WindowProxy* DOMWindow::opener() const
 {
     if (!m_frame)
         return nullptr;
 
-    Frame* opener = m_frame->loader().opener();
-    if (!opener)
+    auto* openerFrame = m_frame->loader().opener();
+    if (!openerFrame)
         return nullptr;
 
-    return opener->document()->domWindow();
+    return &openerFrame->windowProxy();
 }
 
 void DOMWindow::disownOpener()
@@ -1443,28 +1445,27 @@
         m_frame->loader().setOpener(nullptr);
 }
 
-DOMWindow* DOMWindow::parent() const
+WindowProxy* DOMWindow::parent() const
 {
     if (!m_frame)
         return nullptr;
 
-    Frame* parent = m_frame->tree().parent();
-    if (parent)
-        return parent->document()->domWindow();
+    auto* parentFrame = m_frame->tree().parent();
+    if (parentFrame)
+        return &parentFrame->windowProxy();
 
-    return m_frame->document()->domWindow();
+    return &m_frame->windowProxy();
 }
 
-DOMWindow* DOMWindow::top() const
+WindowProxy* DOMWindow::top() const
 {
     if (!m_frame)
         return nullptr;
 
-    Page* page = m_frame->page();
-    if (!page)
+    if (!m_frame->page())
         return nullptr;
 
-    return m_frame->tree().top().document()->domWindow();
+    return &m_frame->tree().top().windowProxy();
 }
 
 String DOMWindow::origin() const
@@ -2312,7 +2313,7 @@
     return windowFeatures.noopener ? nullptr : newFrame;
 }
 
-RefPtr<DOMWindow> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
+RefPtr<WindowProxy> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
 {
     if (!isCurrentlyDisplayedInFrame())
         return nullptr;
@@ -2363,10 +2364,10 @@
         URL completedURL = firstFrame->document()->completeURL(urlString);
 
         if (targetFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
-            return targetFrame->document()->domWindow();
+            return &targetFrame->windowProxy();
 
         if (urlString.isEmpty())
-            return targetFrame->document()->domWindow();
+            return &targetFrame->windowProxy();
 
         // For whatever reason, Firefox uses the first window rather than the active window to
         // determine the outgoing referrer. We replicate that behavior here.
@@ -2373,11 +2374,11 @@
         LockHistory lockHistory = UserGestureIndicator::processingUserGesture() ? LockHistory::No : LockHistory::Yes;
         targetFrame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(), completedURL, firstFrame->loader().outgoingReferrer(),
             lockHistory, LockBackForwardList::No);
-        return targetFrame->document()->domWindow();
+        return &targetFrame->windowProxy();
     }
 
-    RefPtr<Frame> result = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);
-    return result ? result->document()->domWindow() : nullptr;
+    auto newFrame = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);
+    return newFrame ? &newFrame->windowProxy() : nullptr;
 }
 
 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void (DOMWindow&)>& prepareDialogFunction)

Modified: trunk/Source/WebCore/page/DOMWindow.h (230866 => 230867)


--- trunk/Source/WebCore/page/DOMWindow.h	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/page/DOMWindow.h	2018-04-20 23:48:50 UTC (rev 230867)
@@ -158,7 +158,7 @@
     void print();
     void stop();
 
-    WEBCORE_EXPORT RefPtr<DOMWindow> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString);
+    WEBCORE_EXPORT RefPtr<WindowProxy> open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString);
 
     void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction);
 
@@ -193,12 +193,12 @@
     String defaultStatus() const;
     void setDefaultStatus(const String&);
 
-    DOMWindow* self() const;
+    WindowProxy* self() const;
 
-    DOMWindow* opener() const;
+    WindowProxy* opener() const;
     void disownOpener();
-    DOMWindow* parent() const;
-    DOMWindow* top() const;
+    WindowProxy* parent() const;
+    WindowProxy* top() const;
 
     Frame* frame() const final { return FrameDestructionObserver::frame(); }
 

Modified: trunk/Source/WebCore/page/DOMWindow.idl (230866 => 230867)


--- trunk/Source/WebCore/page/DOMWindow.idl	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2018-04-20 23:48:50 UTC (rev 230867)
@@ -49,8 +49,8 @@
     PrimaryGlobal,
 ] interface DOMWindow : EventTarget {
     // The current browsing context.
-    [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute DOMWindow window;
-    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow self;
+    [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
+    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy self;
     [Unforgeable] readonly attribute Document document;
     attribute DOMString name;
     [DoNotCheckSecurity, PutForwards=href, Unforgeable] readonly attribute Location? location; // FIXME: Should not be nullable.
@@ -70,13 +70,13 @@
     [DoNotCheckSecurity, ForwardDeclareInHeader] void blur();
 
     // Other browsing contexts.
-    [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute DOMWindow frames;
+    [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute WindowProxy frames;
     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
-    [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute DOMWindow? top;
-    [DoNotCheckSecurityOnGetter, CustomSetter] attribute DOMWindow? opener;
-    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow? parent;
+    [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute WindowProxy? top;
+    [DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener;
+    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy? parent;
     [CheckSecurityForNode] readonly attribute Element? frameElement;
-    [CallWith=ActiveWindow&FirstWindow] DOMWindow? open(optional USVString url = "" optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
+    [CallWith=ActiveWindow&FirstWindow] WindowProxy? open(optional USVString url = "" optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
 
     // The user agent.
     readonly attribute Navigator navigator;

Modified: trunk/Source/WebCore/testing/Internals.cpp (230866 => 230867)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-04-20 23:48:50 UTC (rev 230867)
@@ -159,9 +159,7 @@
 #include "ViewportArguments.h"
 #include "VoidCallback.h"
 #include "WebCoreJSClientData.h"
-#if ENABLE(WEBGL)
-#include "WebGLRenderingContext.h"
-#endif
+#include "WindowProxy.h"
 #include "WorkerThread.h"
 #include "WritingDirection.h"
 #include "XMLHttpRequest.h"
@@ -205,6 +203,10 @@
 #include "TimeRanges.h"
 #endif
 
+#if ENABLE(WEBGL)
+#include "WebGLRenderingContext.h"
+#endif
+
 #if ENABLE(SPEECH_SYNTHESIS)
 #include "DOMWindowSpeechSynthesis.h"
 #include "PlatformSpeechSynthesizerMock.h"
@@ -2305,13 +2307,13 @@
     return document.referencingNodeCount();
 }
 
-RefPtr<DOMWindow> Internals::openDummyInspectorFrontend(const String& url)
+RefPtr<WindowProxy> Internals::openDummyInspectorFrontend(const String& url)
 {
     auto* inspectedPage = contextDocument()->frame()->page();
     auto* window = inspectedPage->mainFrame().document()->domWindow();
-    auto frontendWindow = window->open(*window, *window, url, "", "");
-    m_inspectorFrontend = std::make_unique<InspectorStubFrontend>(*inspectedPage, frontendWindow.copyRef());
-    return frontendWindow;
+    auto frontendWindowProxy = window->open(*window, *window, url, "", "");
+    m_inspectorFrontend = std::make_unique<InspectorStubFrontend>(*inspectedPage, downcast<DOMWindow>(frontendWindowProxy->window()));
+    return frontendWindowProxy;
 }
 
 void Internals::closeDummyInspectorFrontend()

Modified: trunk/Source/WebCore/testing/Internals.h (230866 => 230867)


--- trunk/Source/WebCore/testing/Internals.h	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/testing/Internals.h	2018-04-20 23:48:50 UTC (rev 230867)
@@ -349,7 +349,7 @@
     unsigned numberOfLiveDocuments() const;
     unsigned referencingNodeCount(const Document&) const;
 
-    RefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
+    RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
     void closeDummyInspectorFrontend();
     ExceptionOr<void> setInspectorIsUnderTest(bool);
 

Modified: trunk/Source/WebCore/testing/Internals.idl (230866 => 230867)


--- trunk/Source/WebCore/testing/Internals.idl	2018-04-20 23:45:09 UTC (rev 230866)
+++ trunk/Source/WebCore/testing/Internals.idl	2018-04-20 23:48:50 UTC (rev 230867)
@@ -315,7 +315,7 @@
     unsigned long numberOfLiveNodes();
     unsigned long numberOfLiveDocuments();
     unsigned long referencingNodeCount(Document document);
-    DOMWindow? openDummyInspectorFrontend(DOMString url);
+    WindowProxy? openDummyInspectorFrontend(DOMString url);
     void closeDummyInspectorFrontend();
     [MayThrowException] void setInspectorIsUnderTest(boolean isUnderTest);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to