Changeset 230613 in webkit
- Timestamp:
- Apr 12, 2018 4:55:02 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230602 r230613 1 2018-04-12 Chris Dumez <cdumez@apple.com> 2 3 Introduce remote variants of Frame / DOMWindow classes 4 https://bugs.webkit.org/show_bug.cgi?id=184467 5 <rdar://problem/39011267> 6 7 Reviewed by Ryosuke Niwa. 8 9 Introduce remote variants of Frame / DOMWindow classes, for when these frames / windows 10 are hosted on another WebProcess. Those will be used in a follow-up patch. 11 12 The hierarchy is as follows (class naming will be improved in a follow-up patch to minimise 13 patch size): 14 - AbstractFrame: A frame that can be either local or remote (hosted on another WebProcess) 15 - Frame: A local frame 16 - RemoteFrame: A frame hosted on another WebProcess. A RemoteFrame's window is also remote. 17 - AbstractDOMWindow: A window that be either local or remote (hosted on another WebProcess) 18 - DOMWindow: A local DOMWindow 19 - RemoteDOMWindow: A window hosted on another WebProcess. A RemoteDOMWindow's frame is also 20 remote. A RemoteDOMWindow is always cross-origin. 21 22 This patch introduces global identifiers (unique across all WebProcesses) for both Frames and 23 Windows. This is useful as we need to know which Frame / DOMWindow a particular RemoteFrame / 24 RemoteDOMWindow is pointing to. 25 26 Follow-up patch will add support for converting a local DOMWindow / Frame into a remote ones, 27 when a newly opened window (via window.open) is navigated cross-origin (Bug 184515). 28 29 Other things we'll need to implement in follow-ups: 30 - RemoteDOMWindow will need to know about its opener in order to support the window.opener 31 API. Internally, the opener will be stored as a RemoteFrame so that window.opener always 32 returns the current window in the opener frame (which changes upon navigation). 33 - Nullify a RemoteDOMWindow's frame whenever the window it is pointing to becomes frameless. 34 A frameless window behaves very differently (e.g. very little API is exposed to the Web). 35 This happens when either the newly opened window is either closed or navigated. 36 37 * Sources.txt: 38 * WebCore.xcodeproj/project.pbxproj: 39 * loader/ContentFilter.cpp: 40 (WebCore::ContentFilter::didDecide): 41 * page/AbstractDOMWindow.cpp: Added. 42 (WebCore::AbstractDOMWindow::AbstractDOMWindow): 43 (WebCore::AbstractDOMWindow::~AbstractDOMWindow): 44 * page/AbstractDOMWindow.h: Added. 45 (WebCore::AbstractDOMWindow::identifier const): 46 * page/AbstractFrame.cpp: Added. 47 (WebCore::AbstractFrame::AbstractFrame): 48 (WebCore::AbstractFrame::~AbstractFrame): 49 * page/AbstractFrame.h: Added. 50 (WebCore::AbstractFrame::window const): 51 * page/DOMWindow.cpp: 52 (WebCore::DOMWindow::DOMWindow): 53 * page/DOMWindow.h: 54 (isType): 55 * page/Frame.cpp: 56 (WebCore::Frame::window const): 57 (WebCore::Frame::virtualWindow const): 58 * page/Frame.h: 59 (isType): 60 * page/GlobalFrameIdentifier.h: Added. 61 (WebCore::GlobalFrameIdentifier::encode const): 62 (WebCore::GlobalFrameIdentifier::decode): 63 * page/GlobalWindowIdentifier.h: Added. 64 (WebCore::operator==): 65 (WebCore::GlobalWindowIdentifier::hash const): 66 (WebCore::GlobalWindowIdentifier::encode const): 67 (WebCore::GlobalWindowIdentifier::decode): 68 (WTF::GlobalWindowIdentifierHash::hash): 69 (WTF::GlobalWindowIdentifierHash::equal): 70 (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::emptyValue): 71 (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::constructDeletedValue): 72 (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::isDeletedValue): 73 74 * page/RemoteDOMWindow.cpp: Added. 75 (WebCore::RemoteDOMWindow::RemoteDOMWindow): 76 (WebCore::RemoteDOMWindow::~RemoteDOMWindow): 77 (WebCore::RemoteDOMWindow::self const): 78 (WebCore::RemoteDOMWindow::location const): 79 (WebCore::RemoteDOMWindow::close): 80 (WebCore::RemoteDOMWindow::closed const): 81 (WebCore::RemoteDOMWindow::focus): 82 (WebCore::RemoteDOMWindow::blur): 83 (WebCore::RemoteDOMWindow::length const): 84 (WebCore::RemoteDOMWindow::top const): 85 (WebCore::RemoteDOMWindow::opener const): 86 (WebCore::RemoteDOMWindow::parent const): 87 (WebCore::RemoteDOMWindow::postMessage): 88 The DOM API exposed on RemoteDOMWindow is only the subset of the DOMWindow API that is exposed cross origin, 89 since remote DOMWindow are always from a different origin. The short-term plan is to implement these in a 90 follow-up by relying on IPC (synchronous when necessary) to fetch the information from the real window in 91 the WebProcess where it lives. Longer term, we should probably keep RemoteDOMWindow members in sync with the 92 DOMWindow they're pointing to, so we do not have to rely on synchronous IPC. 93 94 * page/RemoteDOMWindow.h: Added. 95 (isType): 96 * page/RemoteFrame.cpp: Added. 97 (WebCore::RemoteFrame::RemoteFrame): 98 (WebCore::RemoteFrame::~RemoteFrame): 99 (WebCore::RemoteFrame::virtualWindow const): 100 * page/RemoteFrame.h: Added. 101 (isType): 102 1 103 2018-04-12 Daniel Bates <dabates@apple.com> 2 104 -
trunk/Source/WebCore/Sources.txt
r230602 r230613 1312 1312 mathml/MathMLUnknownElement.cpp 1313 1313 1314 page/AbstractDOMWindow.cpp 1315 page/AbstractFrame.cpp 1314 1316 page/AutoscrollController.cpp 1315 1317 page/BarProp.cpp … … 1371 1373 page/PointerLockController.cpp 1372 1374 page/PrintContext.cpp 1375 page/RemoteDOMWindow.cpp 1376 page/RemoteFrame.cpp 1373 1377 page/ResourceUsageData.cpp 1374 1378 page/ResourceUsageOverlay.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r230602 r230613 1202 1202 4689F1AF1267BAE100E8D380 /* FileMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 4689F1AE1267BAE100E8D380 /* FileMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1203 1203 46B63F6C1C6E8D19002E914B /* JSEventTargetCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1204 46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518A207D632800A7D2DD /* AbstractDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1205 46B95196207D633A00A7D2DD /* AbstractFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518F207D632B00A7D2DD /* AbstractFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1206 46B95197207D634000A7D2DD /* GlobalWindowIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95190207D632C00A7D2DD /* GlobalWindowIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1207 46B95198207D634700A7D2DD /* GlobalFrameIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95191207D632D00A7D2DD /* GlobalFrameIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1208 46B95199207D634D00A7D2DD /* RemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1209 46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95192207D632E00A7D2DD /* RemoteFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1204 1210 46C696CB1E7205F700597937 /* CPUMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C696C91E7205E400597937 /* CPUMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1205 1211 46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46C696CA1E7205E400597937 /* CPUMonitor.cpp */; }; … … 7436 7442 4689F1AE1267BAE100E8D380 /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetadata.h; sourceTree = "<group>"; }; 7437 7443 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventTargetCustom.h; sourceTree = "<group>"; }; 7444 46B9518A207D632800A7D2DD /* AbstractDOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractDOMWindow.h; sourceTree = "<group>"; }; 7445 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteFrame.cpp; sourceTree = "<group>"; }; 7446 46B9518D207D632A00A7D2DD /* RemoteDOMWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteDOMWindow.cpp; sourceTree = "<group>"; }; 7447 46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteDOMWindow.h; sourceTree = "<group>"; }; 7448 46B9518F207D632B00A7D2DD /* AbstractFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractFrame.h; sourceTree = "<group>"; }; 7449 46B95190207D632C00A7D2DD /* GlobalWindowIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalWindowIdentifier.h; sourceTree = "<group>"; }; 7450 46B95191207D632D00A7D2DD /* GlobalFrameIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalFrameIdentifier.h; sourceTree = "<group>"; }; 7451 46B95192207D632E00A7D2DD /* RemoteFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteFrame.h; sourceTree = "<group>"; }; 7452 46B95193207D632F00A7D2DD /* AbstractDOMWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractDOMWindow.cpp; sourceTree = "<group>"; }; 7453 46B95194207D633000A7D2DD /* AbstractFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractFrame.cpp; sourceTree = "<group>"; }; 7438 7454 46C696C91E7205E400597937 /* CPUMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUMonitor.h; sourceTree = "<group>"; }; 7439 7455 46C696CA1E7205E400597937 /* CPUMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUMonitor.cpp; sourceTree = "<group>"; }; … … 18949 18965 93C09A820B064F05005ABD4D /* mac */, 18950 18966 1AF62EE114DA22A70041556C /* scrolling */, 18967 46B95193207D632F00A7D2DD /* AbstractDOMWindow.cpp */, 18968 46B9518A207D632800A7D2DD /* AbstractDOMWindow.h */, 18969 46B95194207D633000A7D2DD /* AbstractFrame.cpp */, 18970 46B9518F207D632B00A7D2DD /* AbstractFrame.h */, 18951 18971 724EE54E1DC7F25B00A91FFB /* ActivityState.h */, 18952 18972 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */, … … 19030 19050 65CBFEF80974F607001DAC25 /* FrameView.h */, 19031 19051 574D42791D594FF6002CF50E /* GlobalCrypto.idl */, 19052 46B95191207D632D00A7D2DD /* GlobalFrameIdentifier.h */, 19032 19053 7C9892451F5A07650091DC70 /* GlobalPerformance.idl */, 19054 46B95190207D632C00A7D2DD /* GlobalWindowIdentifier.h */, 19033 19055 BC94D1500C275C8B006BC617 /* History.cpp */, 19034 19056 BC94D1510C275C8B006BC617 /* History.h */, … … 19123 19145 B776D43C1104527500BEB0EC /* PrintContext.cpp */, 19124 19146 B776D43A1104525D00BEB0EC /* PrintContext.h */, 19147 46B9518D207D632A00A7D2DD /* RemoteDOMWindow.cpp */, 19148 46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */, 19149 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */, 19150 46B95192207D632E00A7D2DD /* RemoteFrame.h */, 19125 19151 A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */, 19126 19152 A5071E821C56D079009951BE /* ResourceUsageData.h */, … … 26684 26710 7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */, 26685 26711 7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */, 26712 46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */, 26713 46B95196207D633A00A7D2DD /* AbstractFrame.h in Headers */, 26686 26714 F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */, 26687 26715 41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */, … … 27672 27700 46C83EFE1A9BBE2900A79A41 /* GeoNotifier.h in Headers */, 27673 27701 9746AF2A14F4DDE6003E7A70 /* Geoposition.h in Headers */, 27702 46B95198207D634700A7D2DD /* GlobalFrameIdentifier.h in Headers */, 27703 46B95197207D634000A7D2DD /* GlobalWindowIdentifier.h in Headers */, 27674 27704 086BBD0F136039C2008B15D8 /* Glyph.h in Headers */, 27675 27705 B2C3DA6C0D006CD600EF6F26 /* GlyphBuffer.h in Headers */, … … 29438 29468 CDFC360618CA61C20026E56F /* RemoteCommandListener.h in Headers */, 29439 29469 CD8ACA891D237AA200ECC59E /* RemoteCommandListenerMac.h in Headers */, 29470 46B95199207D634D00A7D2DD /* RemoteDOMWindow.h in Headers */, 29471 46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */, 29440 29472 D06C0D8F0CFD11460065F43F /* RemoveFormatCommand.h in Headers */, 29441 29473 93309E05099E64920056E581 /* RemoveNodeCommand.h in Headers */, -
trunk/Source/WebCore/loader/ContentFilter.cpp
r222113 r230613 232 232 String unblockRequestDeniedScript { m_blockingContentFilter->unblockRequestDeniedScript() }; 233 233 if (!unblockRequestDeniedScript.isEmpty() && frame) { 234 static_assert(std::is_base_of<ThreadSafeRefCounted< Frame>, Frame>::value, "Frame must be ThreadSafeRefCounted.");234 static_assert(std::is_base_of<ThreadSafeRefCounted<AbstractFrame>, Frame>::value, "AbstractFrame must be ThreadSafeRefCounted."); 235 235 unblockHandler.wrapWithDecisionHandler([frame = WTFMove(frame), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) { 236 236 if (!unblocked) -
trunk/Source/WebCore/page/DOMWindow.cpp
r230211 r230613 402 402 403 403 DOMWindow::DOMWindow(Document& document) 404 : ContextDestructionObserver(&document) 404 : AbstractDOMWindow(GlobalWindowIdentifier { Process::identifier(), generateObjectIdentifier<WindowIdentifierType>() }) 405 , ContextDestructionObserver(&document) 405 406 , FrameDestructionObserver(document.frame()) 406 407 { -
trunk/Source/WebCore/page/DOMWindow.h
r230077 r230613 27 27 #pragma once 28 28 29 #include "AbstractDOMWindow.h" 29 30 #include "Base64Utilities.h" 30 31 #include "ContextDestructionObserver.h" 31 #include "EventTarget.h"32 32 #include "ExceptionOr.h" 33 #include "Frame.h" 33 34 #include "FrameDestructionObserver.h" 34 35 #include "ImageBitmap.h" … … 88 89 89 90 // FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document. 91 // FIXME: Rename DOMWindow to LocalWindow and AbstractDOMWindow to DOMWindow. 90 92 class DOMWindow final 91 : public RefCounted<DOMWindow> 92 , public EventTargetWithInlineData 93 : public AbstractDOMWindow 93 94 , public ContextDestructionObserver 94 95 , public FrameDestructionObserver … … 199 200 DOMWindow* top() const; 200 201 202 Frame* frame() const final { return FrameDestructionObserver::frame(); } 203 201 204 String origin() const; 202 205 … … 277 280 void finishedLoading(); 278 281 279 using RefCounted::ref;280 using RefCounted::deref;281 282 282 // HTML 5 key/value storage 283 283 ExceptionOr<Storage*> sessionStorage() const; … … 339 339 explicit DOMWindow(Document&); 340 340 341 EventTargetInterface eventTargetInterface() const final { return DOMWindowEventTargetInterfaceType; }342 341 ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } 342 343 bool isLocalDOMWindow() const final { return true; } 344 bool isRemoteDOMWindow() const final { return false; } 343 345 344 346 Page* page(); … … 347 349 void frameDestroyed() final; 348 350 void willDetachPage() final; 349 350 void refEventTarget() final { ref(); }351 void derefEventTarget() final { deref(); }352 351 353 352 static RefPtr<Frame> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction = nullptr); … … 433 432 434 433 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DOMWindow) 434 static bool isType(const WebCore::AbstractDOMWindow& window) { return window.isLocalDOMWindow(); } 435 435 static bool isType(const WebCore::EventTarget& target) { return target.eventTargetInterface() == WebCore::DOMWindowEventTargetInterfaceType; } 436 436 SPECIALIZE_TYPE_TRAITS_END() -
trunk/Source/WebCore/page/Frame.cpp
r230581 r230613 944 944 } 945 945 946 DOMWindow* Frame::window() const 947 { 948 return document() ? document()->domWindow() : nullptr; 949 } 950 951 AbstractDOMWindow* Frame::virtualWindow() const 952 { 953 return window(); 954 } 955 946 956 String Frame::layerTreeAsText(LayerTreeFlags flags) const 947 957 { -
trunk/Source/WebCore/page/Frame.h
r230211 r230613 28 28 #pragma once 29 29 30 #include "AbstractFrame.h" 30 31 #include "AdjustViewSizeOrNot.h" 31 32 #include "FrameTree.h" … … 33 34 #include "UserScriptTypes.h" 34 35 #include <wtf/HashSet.h> 35 #include <wtf/ThreadSafeRefCounted.h>36 36 #include <wtf/UniqueRef.h> 37 37 … … 62 62 class CSSAnimationController; 63 63 class Color; 64 class DOMWindow; 64 65 class Document; 65 66 class Editor; … … 118 119 typedef unsigned LayerTreeFlags; 119 120 120 class Frame final : public ThreadSafeRefCounted<Frame> { 121 // FIXME: Rename Frame to LocalFrame and AbstractFrame to Frame. 122 class Frame final : public AbstractFrame { 121 123 public: 122 124 WEBCORE_EXPORT static Ref<Frame> create(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*); … … 134 136 135 137 WEBCORE_EXPORT ~Frame(); 138 139 DOMWindow* window() const; 136 140 137 141 void addDestructionObserver(FrameDestructionObserver*); … … 292 296 void dropChildren(); 293 297 298 bool isLocalFrame() const final { return true; } 299 bool isRemoteFrame() const final { return false; } 300 301 AbstractDOMWindow* virtualWindow() const final; 302 294 303 HashSet<FrameDestructionObserver*> m_destructionObservers; 295 304 … … 391 400 392 401 } // namespace WebCore 402 403 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Frame) 404 static bool isType(const WebCore::AbstractFrame& frame) { return frame.isLocalFrame(); } 405 SPECIALIZE_TYPE_TRAITS_END()
Note: See TracChangeset
for help on using the changeset viewer.