Changeset 230867 in webkit


Ignore:
Timestamp:
Apr 20, 2018 4:48:50 PM (6 years ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230864 r230867  
     12018-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
    1332018-04-20  Chris Dumez  <cdumez@apple.com>
    234
  • trunk/Source/WebCore/bindings/js/JSWindowProxy.h

    r230831 r230867  
    7070// JSWindowProxy is a little odd in that it's not a traditional wrapper and has no back pointer.
    7171// 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&);
     72WEBCORE_EXPORT JSC::JSValue toJS(JSC::ExecState*, WindowProxy&);
    7373inline JSC::JSValue toJS(JSC::ExecState* state, WindowProxy* windowProxy) { return windowProxy ? toJS(state, *windowProxy) : JSC::jsNull(); }
     74inline JSC::JSValue toJS(JSC::ExecState* state, const RefPtr<WindowProxy>& windowProxy) { return toJS(state, windowProxy.get()); }
    7475
    7576JSWindowProxy& toJSWindowProxy(WindowProxy&, DOMWrapperWorld&);
  • trunk/Source/WebCore/bindings/js/WindowProxy.cpp

    r230831 r230867  
    166166}
    167167
     168AbstractDOMWindow* WindowProxy::window() const
     169{
     170    return m_frame.window();
     171}
     172
     173void WindowProxy::ref()
     174{
     175    m_frame.ref();
     176}
     177
     178void WindowProxy::deref()
     179{
     180    m_frame.deref();
     181}
     182
    168183} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/WindowProxy.h

    r230831 r230867  
    7676    void attachDebugger(JSC::Debugger*); // Attaches/detaches in all worlds/window proxies.
    7777
     78    WEBCORE_EXPORT AbstractDOMWindow* window() const;
     79
     80    WEBCORE_EXPORT void ref();
     81    WEBCORE_EXPORT void deref();
     82
    7883private:
    7984    JSWindowProxy& createJSWindowProxy(DOMWrapperWorld&);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r230831 r230867  
    423423
    424424    if ($type->name eq "WindowProxy") {
     425        AddToIncludes("WindowProxy.h", $includesRef, $conditional);
    425426        AddToIncludes("JSWindowProxy.h", $includesRef, $conditional);
    426427        AddToIncludes("JSDOMConvertWindowProxy.h", $includesRef, $conditional);
     
    65546555    return 1 if $type->name eq "SerializedScriptValue";
    65556556    return 1 if $type->name eq "XPathNSResolver";
     6557    return 1 if $type->name eq "WindowProxy";
    65566558   
    65576559    return 0;
  • trunk/Source/WebCore/dom/Document.cpp

    r230822 r230867  
    25942594}
    25952595
    2596 ExceptionOr<RefPtr<DOMWindow>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)
     2596ExceptionOr<RefPtr<WindowProxy>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)
    25972597{
    25982598    if (!m_domWindow)
  • trunk/Source/WebCore/dom/Document.h

    r230822 r230867  
    186186class WebGLRenderingContext;
    187187class WebGPURenderingContext;
     188class WindowProxy;
    188189class XPathEvaluator;
    189190class XPathExpression;
     
    620621    WEBCORE_EXPORT DocumentLoader* loader() const;
    621622
    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);
    623624    WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String& type, const String& replace);
    624625
  • trunk/Source/WebCore/dom/Document.idl

    r229680 r230867  
    108108    // the existing 'incumbent document' concept.
    109109    [CEReactions, CallWith=ResponsibleDocument, ImplementedAs=openForBindings, MayThrowException] Document open(optional DOMString type = "text/html", optional DOMString replace = "");
    110     [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] DOMWindow open(USVString url, DOMString name, DOMString features);
     110    [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] WindowProxy open(USVString url, DOMString name, DOMString features);
    111111    [CEReactions, ImplementedAs=closeForBindings, MayThrowException] void close();
    112112    [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void write(DOMString... text);
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r230864 r230867  
    107107#include "WindowFeatures.h"
    108108#include "WindowFocusAllowedIndicator.h"
     109#include "WindowProxy.h"
    109110#include <JavaScriptCore/ScriptCallStack.h>
    110111#include <JavaScriptCore/ScriptCallStackFactory.h>
     
    10151016void DOMWindow::focus(DOMWindow& incumbentWindow)
    10161017{
    1017     focus(opener() && opener() != this && &incumbentWindow == opener());
     1018    auto* opener = this->opener();
     1019    focus(opener && opener != self() && incumbentWindow.self() == opener);
    10181020}
    10191021
     
    14181420}
    14191421
    1420 DOMWindow* DOMWindow::self() const
    1421 {
    1422     if (!m_frame)
    1423         return nullptr;
    1424 
    1425     return m_frame->document()->domWindow();
    1426 }
    1427 
    1428 DOMWindow* DOMWindow::opener() const
    1429 {
    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();
     1422WindowProxy* DOMWindow::self() const
     1423{
     1424    if (!m_frame)
     1425        return nullptr;
     1426
     1427    return &m_frame->windowProxy();
     1428}
     1429
     1430WindowProxy* 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();
    14381440}
    14391441
     
    14441446}
    14451447
    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();
     1448WindowProxy* 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
     1460WindowProxy* 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();
    14681469}
    14691470
     
    23132314}
    23142315
    2315 RefPtr<DOMWindow> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
     2316RefPtr<WindowProxy> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomicString& frameName, const String& windowFeaturesString)
    23162317{
    23172318    if (!isCurrentlyDisplayedInFrame())
     
    23642365
    23652366        if (targetFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
    2366             return targetFrame->document()->domWindow();
     2367            return &targetFrame->windowProxy();
    23672368
    23682369        if (urlString.isEmpty())
    2369             return targetFrame->document()->domWindow();
     2370            return &targetFrame->windowProxy();
    23702371
    23712372        // For whatever reason, Firefox uses the first window rather than the active window to
     
    23742375        targetFrame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(), completedURL, firstFrame->loader().outgoingReferrer(),
    23752376            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;
    23812382}
    23822383
  • trunk/Source/WebCore/page/DOMWindow.h

    r230864 r230867  
    159159    void stop();
    160160
    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);
    162162
    163163    void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction);
     
    194194    void setDefaultStatus(const String&);
    195195
    196     DOMWindow* self() const;
    197 
    198     DOMWindow* opener() const;
     196    WindowProxy* self() const;
     197
     198    WindowProxy* opener() const;
    199199    void disownOpener();
    200     DOMWindow* parent() const;
    201     DOMWindow* top() const;
     200    WindowProxy* parent() const;
     201    WindowProxy* top() const;
    202202
    203203    Frame* frame() const final { return FrameDestructionObserver::frame(); }
  • trunk/Source/WebCore/page/DOMWindow.idl

    r230077 r230867  
    5050] interface DOMWindow : EventTarget {
    5151    // The current browsing context.
    52     [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute DOMWindow window;
    53     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow self;
     52    [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
     53    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy self;
    5454    [Unforgeable] readonly attribute Document document;
    5555    attribute DOMString name;
     
    7171
    7272    // Other browsing contexts.
    73     [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute DOMWindow frames;
     73    [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute WindowProxy frames;
    7474    [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;
    7878    [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 = "");
    8080
    8181    // The user agent.
  • trunk/Source/WebCore/testing/Internals.cpp

    r230788 r230867  
    160160#include "VoidCallback.h"
    161161#include "WebCoreJSClientData.h"
    162 #if ENABLE(WEBGL)
    163 #include "WebGLRenderingContext.h"
    164 #endif
     162#include "WindowProxy.h"
    165163#include "WorkerThread.h"
    166164#include "WritingDirection.h"
     
    204202#include "HTMLMediaElement.h"
    205203#include "TimeRanges.h"
     204#endif
     205
     206#if ENABLE(WEBGL)
     207#include "WebGLRenderingContext.h"
    206208#endif
    207209
     
    23062308}
    23072309
    2308 RefPtr<DOMWindow> Internals::openDummyInspectorFrontend(const String& url)
     2310RefPtr<WindowProxy> Internals::openDummyInspectorFrontend(const String& url)
    23092311{
    23102312    auto* inspectedPage = contextDocument()->frame()->page();
    23112313    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;
    23152317}
    23162318
  • trunk/Source/WebCore/testing/Internals.h

    r230788 r230867  
    350350    unsigned referencingNodeCount(const Document&) const;
    351351
    352     RefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
     352    RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
    353353    void closeDummyInspectorFrontend();
    354354    ExceptionOr<void> setInspectorIsUnderTest(bool);
  • trunk/Source/WebCore/testing/Internals.idl

    r230788 r230867  
    316316    unsigned long numberOfLiveDocuments();
    317317    unsigned long referencingNodeCount(Document document);
    318     DOMWindow? openDummyInspectorFrontend(DOMString url);
     318    WindowProxy? openDummyInspectorFrontend(DOMString url);
    319319    void closeDummyInspectorFrontend();
    320320    [MayThrowException] void setInspectorIsUnderTest(boolean isUnderTest);
Note: See TracChangeset for help on using the changeset viewer.