Changeset 242676 in webkit
- Timestamp:
- Mar 9, 2019, 6:25:42 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 26 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp (modified) (3 diffs)
-
WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h (modified) (1 diff)
-
WebCore/css/StyleMedia.idl (modified) (1 diff)
-
WebCore/loader/appcache/ApplicationCacheHost.cpp (modified) (2 diffs)
-
WebCore/loader/appcache/ApplicationCacheHost.h (modified) (2 diffs)
-
WebCore/loader/appcache/DOMApplicationCache.cpp (modified) (1 diff)
-
WebCore/loader/appcache/DOMApplicationCache.h (modified) (3 diffs)
-
WebCore/page/BarProp.idl (modified) (1 diff)
-
WebCore/page/DOMSelection.idl (modified) (1 diff)
-
WebCore/page/DOMWindow.cpp (modified) (7 diffs)
-
WebCore/page/DOMWindow.h (modified) (3 diffs)
-
WebCore/page/DOMWindowExtension.cpp (modified) (5 diffs)
-
WebCore/page/DOMWindowExtension.h (modified) (3 diffs)
-
WebCore/page/DOMWindowProperty.cpp (modified) (2 diffs)
-
WebCore/page/DOMWindowProperty.h (modified) (2 diffs)
-
WebCore/page/History.idl (modified) (1 diff)
-
WebCore/page/Location.idl (modified) (1 diff)
-
WebCore/page/Navigator.cpp (modified) (2 diffs)
-
WebCore/page/PerformanceNavigation.idl (modified) (1 diff)
-
WebCore/page/PerformanceTiming.idl (modified) (1 diff)
-
WebCore/page/Screen.idl (modified) (1 diff)
-
WebCore/page/VisualViewport.cpp (modified) (1 diff)
-
WebCore/plugins/DOMMimeTypeArray.idl (modified) (1 diff)
-
WebCore/plugins/DOMPluginArray.idl (modified) (1 diff)
-
WebKit/WebProcess/InjectedBundle/API/glib/DOM/DOMObjectCache.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242675 r242676 1 2019-03-09 Chris Dumez <cdumez@apple.com> 2 3 Simplify DOMWindowProperty code / handling 4 https://bugs.webkit.org/show_bug.cgi?id=195495 5 6 Reviewed by Ryosuke Niwa. 7 8 DOMWindowProperty code was unnecessarily complex because DOMWindowExtension inherited 9 from it and DOMWindowExtension needs a lot of information about the global object's 10 lifetime to communicate to the injected bbundle client. This subclassing is also 11 very confusing because a DOMWindowExtension is not a *property* on the Window object. 12 13 This patch updates DOMWindowExtension to stop subclassing DOMWindowProperty and 14 moves all the complexity from DOMWindowProperty to DOMWindowExtension. 15 DOMWindowProperty is now a very simple base class which merely has a WeakPtr to 16 the window and getters for the window and the frame. 17 18 * Modules/indexeddb/DOMWindowIndexedDatabase.cpp: 19 (WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase): 20 (WebCore::DOMWindowIndexedDatabase::indexedDB): 21 * Modules/indexeddb/DOMWindowIndexedDatabase.h: 22 There is no reason for DOMWindowIndexedDatabase to move its IDBFactory to a 23 separate data member which in PageCache. Script do not run while in PageCache. 24 Also, frames are nulled out while in the PageCache so the indexedDB() getter 25 would return null anyway while in PageCache. 26 27 * css/StyleMedia.idl: 28 * loader/appcache/ApplicationCacheHost.cpp: 29 (WebCore::ApplicationCacheHost::setDOMApplicationCache): 30 Store a WeakPtr to the DOMApplicationCache for safety. 31 32 (WebCore::ApplicationCacheHost::dispatchDOMEvent): 33 Do not fire events on the DOMApplicationCache if it is frameless to maintain 34 previous behavior. Previously, the DOMApplicationCache would have been nulled 35 out when detached from its frame so we would not have fired events. 36 37 * loader/appcache/ApplicationCacheHost.h: 38 * loader/appcache/DOMApplicationCache.cpp: 39 * loader/appcache/DOMApplicationCache.h: 40 Remove some unnecessary complexity. The ApplicationCacheHost is owned by the 41 DocumentLoader, which changes on navigation. There is therefore no reason to 42 null out the DOMApplicationCache on the ApplicationCacheHost when its gets 43 detached from its frame or enters PageCache. 44 45 * page/BarProp.idl: 46 * page/DOMSelection.idl: 47 * page/DOMWindow.cpp: 48 (WebCore::DOMWindow::willDestroyCachedFrame): 49 (WebCore::DOMWindow::willDestroyDocumentInFrame): 50 (WebCore::DOMWindow::willDetachDocumentFromFrame): 51 (WebCore::DOMWindow::registerExtension): 52 (WebCore::DOMWindow::unregisterExtension): 53 54 (WebCore::DOMWindow::resetDOMWindowProperties): Removed. 55 Stop clearing some of the DOMWindow's properties when the document gets destroyed or when 56 the Window for the initial empty document gets reused on navigation. I think we used to 57 need this because DOMWindowProperty used to hold pointers to their frame. However, this 58 is no longer the case nowadays as DOMWindowProperty objects get their frame from their 59 Window. 60 61 (WebCore::DOMWindow::resetUnlessSuspendedForDocumentSuspension): 62 (WebCore::DOMWindow::suspendForPageCache): 63 (WebCore::DOMWindow::resumeFromPageCache): 64 * page/DOMWindow.h: 65 * page/DOMWindowExtension.cpp: 66 (WebCore::DOMWindowExtension::DOMWindowExtension): 67 (WebCore::DOMWindowExtension::~DOMWindowExtension): 68 (WebCore::DOMWindowExtension::frame const): 69 (WebCore::DOMWindowExtension::suspendForPageCache): 70 (WebCore::DOMWindowExtension::resumeFromPageCache): 71 (WebCore::DOMWindowExtension::willDestroyGlobalObjectInCachedFrame): 72 (WebCore::DOMWindowExtension::willDestroyGlobalObjectInFrame): 73 (WebCore::DOMWindowExtension::willDetachGlobalObjectFromFrame): 74 * page/DOMWindowExtension.h: 75 * page/DOMWindowProperty.cpp: 76 (WebCore::DOMWindowProperty::DOMWindowProperty): 77 * page/DOMWindowProperty.h: 78 (WebCore::DOMWindowProperty::window const): 79 * page/History.idl: 80 * page/Location.idl: 81 * page/Navigator.cpp: 82 (WebCore::Navigator::plugins): 83 (WebCore::Navigator::mimeTypes): 84 * page/PerformanceNavigation.idl: 85 * page/PerformanceTiming.idl: 86 * page/Screen.idl: 87 * page/VisualViewport.cpp: 88 (WebCore::VisualViewport::scriptExecutionContext const): 89 * plugins/DOMMimeTypeArray.idl: 90 * plugins/DOMPluginArray.idl: 91 1 92 2019-03-09 Zalan Bujtas <zalan@apple.com> 2 93 -
trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
r237029 r242676 39 39 DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(DOMWindow* window) 40 40 : DOMWindowProperty(window) 41 , m_window(window)42 41 { 43 42 } … … 61 60 } 62 61 63 void DOMWindowIndexedDatabase::suspendForPageCache()64 {65 m_suspendedIDBFactory = WTFMove(m_idbFactory);66 DOMWindowProperty::suspendForPageCache();67 }68 69 void DOMWindowIndexedDatabase::resumeFromPageCache()70 {71 DOMWindowProperty::resumeFromPageCache();72 m_idbFactory = WTFMove(m_suspendedIDBFactory);73 }74 75 void DOMWindowIndexedDatabase::willDestroyGlobalObjectInCachedFrame()76 {77 m_suspendedIDBFactory = nullptr;78 DOMWindowProperty::willDestroyGlobalObjectInCachedFrame();79 }80 81 void DOMWindowIndexedDatabase::willDestroyGlobalObjectInFrame()82 {83 m_idbFactory = nullptr;84 DOMWindowProperty::willDestroyGlobalObjectInFrame();85 }86 87 void DOMWindowIndexedDatabase::willDetachGlobalObjectFromFrame()88 {89 m_idbFactory = nullptr;90 DOMWindowProperty::willDetachGlobalObjectFromFrame();91 }92 93 62 IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow& window) 94 63 { … … 98 67 IDBFactory* DOMWindowIndexedDatabase::indexedDB() 99 68 { 100 Document* document = m_window->document(); 69 auto* window = this->window(); 70 if (!window) 71 return nullptr; 72 73 auto* document = window->document(); 101 74 if (!document) 102 75 return nullptr; 103 76 104 Page* page = document->page();77 auto* page = document->page(); 105 78 if (!page) 106 79 return nullptr; 107 80 108 if (! m_window->isCurrentlyDisplayedInFrame())81 if (!window->isCurrentlyDisplayedInFrame()) 109 82 return nullptr; 110 83 -
trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h
r237029 r242676 46 46 WEBCORE_EXPORT static IDBFactory* indexedDB(DOMWindow&); 47 47 48 void suspendForPageCache() override;49 void resumeFromPageCache() override;50 void willDestroyGlobalObjectInCachedFrame() override;51 void willDestroyGlobalObjectInFrame() override;52 void willDetachGlobalObjectFromFrame() override;53 54 48 private: 55 49 IDBFactory* indexedDB(); 56 50 static const char* supplementName(); 57 51 58 DOMWindow* m_window;59 52 RefPtr<IDBFactory> m_idbFactory; 60 RefPtr<IDBFactory> m_suspendedIDBFactory;61 53 }; 62 54 -
trunk/Source/WebCore/css/StyleMedia.idl
r199969 r242676 28 28 NoInterfaceObject, 29 29 GenerateIsReachable=ImplFrame, 30 ImplementationLacksVTable, 30 31 ] interface StyleMedia { 31 32 readonly attribute DOMString type; -
trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
r240437 r242676 297 297 { 298 298 ASSERT(!m_domApplicationCache || !domApplicationCache); 299 m_domApplicationCache = domApplicationCache;299 m_domApplicationCache = makeWeakPtr(domApplicationCache); 300 300 } 301 301 … … 380 380 void ApplicationCacheHost::dispatchDOMEvent(const AtomicString& eventType, int total, int done) 381 381 { 382 if (!m_domApplicationCache )382 if (!m_domApplicationCache || !m_domApplicationCache->frame()) 383 383 return; 384 384 385 m_domApplicationCache->dispatchEvent(createApplicationCacheEvent(eventType, total, done)); 385 386 } -
trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h
r238771 r242676 35 35 #include <wtf/URL.h> 36 36 #include <wtf/Vector.h> 37 #include <wtf/WeakPtr.h> 37 38 38 39 namespace WebCore { … … 147 148 bool maybeLoadFallbackForMainError(const ResourceRequest&, const ResourceError&); 148 149 149 DOMApplicationCache* m_domApplicationCache { nullptr };150 WeakPtr<DOMApplicationCache> m_domApplicationCache; 150 151 DocumentLoader& m_documentLoader; 151 152 -
trunk/Source/WebCore/loader/appcache/DOMApplicationCache.cpp
r237029 r242676 40 40 if (auto* host = applicationCacheHost()) 41 41 host->setDOMApplicationCache(this); 42 }43 44 void DOMApplicationCache::suspendForPageCache()45 {46 if (auto* host = applicationCacheHost())47 host->setDOMApplicationCache(nullptr);48 DOMWindowProperty::suspendForPageCache();49 }50 51 void DOMApplicationCache::resumeFromPageCache()52 {53 DOMWindowProperty::resumeFromPageCache();54 if (auto* host = applicationCacheHost())55 host->setDOMApplicationCache(this);56 }57 58 void DOMApplicationCache::willDestroyGlobalObjectInFrame()59 {60 if (auto* host = applicationCacheHost())61 host->setDOMApplicationCache(nullptr);62 DOMWindowProperty::willDestroyGlobalObjectInFrame();63 42 } 64 43 -
trunk/Source/WebCore/loader/appcache/DOMApplicationCache.h
r237029 r242676 28 28 #include "DOMWindowProperty.h" 29 29 #include "EventTarget.h" 30 #include <wtf/WeakPtr.h> 30 31 31 32 namespace WebCore { … … 34 35 class Frame; 35 36 36 class DOMApplicationCache final : public RefCounted<DOMApplicationCache>, public EventTargetWithInlineData, public DOMWindowProperty {37 class DOMApplicationCache final : public RefCounted<DOMApplicationCache>, public EventTargetWithInlineData, public DOMWindowProperty, public CanMakeWeakPtr<DOMApplicationCache> { 37 38 public: 38 39 static Ref<DOMApplicationCache> create(DOMWindow& window) { return adoptRef(*new DOMApplicationCache(window)); } … … 56 57 ScriptExecutionContext* scriptExecutionContext() const final; 57 58 58 void suspendForPageCache() final;59 void resumeFromPageCache() final;60 void willDestroyGlobalObjectInFrame() final;61 62 59 ApplicationCacheHost* applicationCacheHost() const; 63 60 }; -
trunk/Source/WebCore/page/BarProp.idl
r165676 r242676 29 29 [ 30 30 GenerateIsReachable=ImplFrame, 31 ImplementationLacksVTable, 31 32 ] interface BarProp { 32 33 readonly attribute boolean visible; -
trunk/Source/WebCore/page/DOMSelection.idl
r207571 r242676 31 31 [ 32 32 GenerateIsReachable=ImplFrame, 33 ImplementationLacksVTable, 33 34 InterfaceName=Selection, 34 35 ] interface DOMSelection { -
trunk/Source/WebCore/page/DOMWindow.cpp
r242664 r242676 46 46 #include "DOMTokenList.h" 47 47 #include "DOMURL.h" 48 #include "DOMWindowExtension.h"49 48 #include "DeviceMotionController.h" 50 49 #include "DeviceMotionData.h" … … 452 451 void DOMWindow::willDestroyCachedFrame() 453 452 { 454 // It is necessary to copy m_ properties to a separate vector because the DOMWindowPropertiesmay453 // It is necessary to copy m_observers to a separate vector because the Observer may 455 454 // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInCachedFrame. 456 for (auto* property : copyToVector(m_properties)) {457 if (m_ properties.contains(property))458 property->willDestroyGlobalObjectInCachedFrame();455 for (auto* observer : copyToVector(m_observers)) { 456 if (m_observers.contains(observer)) 457 observer->willDestroyGlobalObjectInCachedFrame(); 459 458 } 460 459 } … … 462 461 void DOMWindow::willDestroyDocumentInFrame() 463 462 { 464 // It is necessary to copy m_ properties to a separate vector because the DOMWindowPropertiesmay463 // It is necessary to copy m_observers to a separate vector because the Observer may 465 464 // unregister themselves from the DOMWindow as a result of the call to willDestroyGlobalObjectInFrame. 466 for (auto* property : copyToVector(m_properties)) {467 if (m_ properties.contains(property))468 property->willDestroyGlobalObjectInFrame();465 for (auto* observer : copyToVector(m_observers)) { 466 if (m_observers.contains(observer)) 467 observer->willDestroyGlobalObjectInFrame(); 469 468 } 470 469 } … … 475 474 return; 476 475 477 // It is necessary to copy m_ properties to a separate vector because the DOMWindowPropertiesmay476 // It is necessary to copy m_observers to a separate vector because the Observer may 478 477 // unregister themselves from the DOMWindow as a result of the call to willDetachGlobalObjectFromFrame. 479 for (auto& property : copyToVector(m_properties)) {480 if (m_ properties.contains(property))481 property->willDetachGlobalObjectFromFrame();478 for (auto& observer : copyToVector(m_observers)) { 479 if (m_observers.contains(observer)) 480 observer->willDetachGlobalObjectFromFrame(); 482 481 } 483 482 … … 504 503 #endif 505 504 506 void DOMWindow::register Property(DOMWindowProperty& property)507 { 508 m_ properties.add(&property);509 } 510 511 void DOMWindow::unregister Property(DOMWindowProperty& property)512 { 513 m_ properties.remove(&property);505 void DOMWindow::registerObserver(Observer& observer) 506 { 507 m_observers.add(&observer); 508 } 509 510 void DOMWindow::unregisterObserver(Observer& observer) 511 { 512 m_observers.remove(&observer); 514 513 } 515 514 … … 519 518 return; 520 519 willDestroyDocumentInFrame(); 521 resetDOMWindowProperties();522 520 } 523 521 524 522 void DOMWindow::suspendForPageCache() 525 523 { 526 for (auto* property : copyToVector(m_properties)) {527 if (m_ properties.contains(property))528 property->suspendForPageCache();524 for (auto* observer : copyToVector(m_observers)) { 525 if (m_observers.contains(observer)) 526 observer->suspendForPageCache(); 529 527 } 530 528 … … 534 532 void DOMWindow::resumeFromPageCache() 535 533 { 536 for (auto* property : copyToVector(m_properties)) {537 if (m_ properties.contains(property))538 property->resumeFromPageCache();534 for (auto* observer : copyToVector(m_observers)) { 535 if (m_observers.contains(observer)) 536 observer->resumeFromPageCache(); 539 537 } 540 538 541 539 m_suspendedForDocumentSuspension = false; 542 }543 544 void DOMWindow::resetDOMWindowProperties()545 {546 m_properties.clear();547 548 m_applicationCache = nullptr;549 m_crypto = nullptr;550 m_history = nullptr;551 m_localStorage = nullptr;552 m_location = nullptr;553 m_locationbar = nullptr;554 m_media = nullptr;555 m_menubar = nullptr;556 m_navigator = nullptr;557 m_personalbar = nullptr;558 m_screen = nullptr;559 m_scrollbars = nullptr;560 m_selection = nullptr;561 m_sessionStorage = nullptr;562 m_statusbar = nullptr;563 m_toolbar = nullptr;564 m_performance = nullptr;565 m_visualViewport = nullptr;566 540 } 567 541 -
trunk/Source/WebCore/page/DOMWindow.h
r242664 r242676 114 114 void didSecureTransitionTo(Document&); 115 115 116 void registerProperty(DOMWindowProperty&); 117 void unregisterProperty(DOMWindowProperty&); 116 class Observer { 117 public: 118 virtual ~Observer() { } 119 120 virtual void suspendForPageCache() { } 121 virtual void resumeFromPageCache() { } 122 virtual void willDestroyGlobalObjectInCachedFrame() { } 123 virtual void willDestroyGlobalObjectInFrame() { } 124 virtual void willDetachGlobalObjectFromFrame() { } 125 }; 126 127 void registerObserver(Observer&); 128 void unregisterObserver(Observer&); 118 129 119 130 void resetUnlessSuspendedForDocumentSuspension(); … … 370 381 bool isInsecureScriptAccess(DOMWindow& activeWindow, const String& urlString); 371 382 372 void resetDOMWindowProperties();373 374 383 #if ENABLE(DEVICE_ORIENTATION) 375 384 void failedToRegisterDeviceMotionEventListener(); … … 387 396 Optional<bool> m_canShowModalDialogOverride; 388 397 389 HashSet< DOMWindowProperty*> m_properties;398 HashSet<Observer*> m_observers; 390 399 391 400 mutable RefPtr<Crypto> m_crypto; -
trunk/Source/WebCore/page/DOMWindowExtension.cpp
r241848 r242676 37 37 38 38 DOMWindowExtension::DOMWindowExtension(DOMWindow* window, DOMWrapperWorld& world) 39 : DOMWindowProperty(window)39 : m_window(makeWeakPtr(window)) 40 40 , m_world(world) 41 41 , m_wasDetached(false) 42 42 { 43 43 ASSERT(this->frame()); 44 if (m_window) 45 m_window->registerObserver(*this); 46 } 47 48 DOMWindowExtension::~DOMWindowExtension() 49 { 50 if (m_window) 51 m_window->unregisterObserver(*this); 52 } 53 54 Frame* DOMWindowExtension::frame() const 55 { 56 return m_window ? m_window->frame() : nullptr; 44 57 } 45 58 … … 54 67 55 68 m_disconnectedFrame = WTFMove(frame); 56 57 DOMWindowProperty::suspendForPageCache();58 69 } 59 70 60 71 void DOMWindowExtension::resumeFromPageCache() 61 72 { 73 ASSERT(frame()); 62 74 ASSERT(m_disconnectedFrame == frame()); 63 64 DOMWindowProperty::resumeFromPageCache(); 75 ASSERT(frame()->document()->domWindow() == m_window); 76 65 77 m_disconnectedFrame = nullptr; 66 78 … … 79 91 m_disconnectedFrame = nullptr; 80 92 81 DOMWindowProperty::willDestroyGlobalObjectInCachedFrame(); 93 // DOMWindowExtension lifetime isn't tied directly to the DOMWindow itself so it is important that it unregister 94 // itself from any DOMWindow it is associated with if that DOMWindow is going away. 95 ASSERT(m_window); 96 if (m_window) 97 m_window->unregisterObserver(*this); 98 m_window = nullptr; 82 99 } 83 100 … … 96 113 } 97 114 98 DOMWindowProperty::willDestroyGlobalObjectInFrame(); 115 // DOMWindowExtension lifetime isn't tied directly to the DOMWindow itself so it is important that it unregister 116 // itself from any DOMWindow it is associated with if that DOMWindow is going away. 117 ASSERT(m_window); 118 if (m_window) 119 m_window->unregisterObserver(*this); 120 m_window = nullptr; 99 121 } 100 122 … … 113 135 114 136 m_wasDetached = true; 115 DOMWindowProperty::willDetachGlobalObjectFromFrame();116 137 } 117 138 -
trunk/Source/WebCore/page/DOMWindowExtension.h
r237029 r242676 26 26 #pragma once 27 27 28 #include "DOMWindow Property.h"28 #include "DOMWindow.h" 29 29 #include <wtf/RefCounted.h> 30 30 #include <wtf/RefPtr.h> 31 #include <wtf/WeakPtr.h> 31 32 32 33 namespace WebCore { 33 34 34 class DOMWindowExtension;35 35 class DOMWrapperWorld; 36 36 class Frame; 37 37 38 class DOMWindowExtension : public RefCounted<DOMWindowExtension>, public DOMWindowProperty{38 class DOMWindowExtension final : public RefCounted<DOMWindowExtension>, public DOMWindow::Observer { 39 39 public: 40 40 static Ref<DOMWindowExtension> create(DOMWindow* window, DOMWrapperWorld& world) … … 43 43 } 44 44 45 void suspendForPageCache() override; 46 void resumeFromPageCache() override; 47 void willDestroyGlobalObjectInCachedFrame() override; 48 void willDestroyGlobalObjectInFrame() override; 49 void willDetachGlobalObjectFromFrame() override; 45 WEBCORE_EXPORT ~DOMWindowExtension(); 50 46 47 void suspendForPageCache() final; 48 void resumeFromPageCache() final; 49 void willDestroyGlobalObjectInCachedFrame() final; 50 void willDestroyGlobalObjectInFrame() final; 51 void willDetachGlobalObjectFromFrame() final; 52 53 WEBCORE_EXPORT Frame* frame() const; 51 54 DOMWrapperWorld& world() const { return m_world; } 52 55 … … 54 57 WEBCORE_EXPORT DOMWindowExtension(DOMWindow*, DOMWrapperWorld&); 55 58 59 WeakPtr<DOMWindow> m_window; 56 60 Ref<DOMWrapperWorld> m_world; 57 61 RefPtr<Frame> m_disconnectedFrame; -
trunk/Source/WebCore/page/DOMWindowProperty.cpp
r237029 r242676 29 29 30 30 #include "DOMWindow.h" 31 #include "Document.h"32 31 #include "Frame.h" 33 32 … … 35 34 36 35 DOMWindowProperty::DOMWindowProperty(DOMWindow* window) 37 : m_window(window) 38 { 39 if (m_window) 40 m_window->registerProperty(*this); 41 } 42 43 DOMWindowProperty::~DOMWindowProperty() 44 { 45 if (m_window) 46 m_window->unregisterProperty(*this); 47 48 m_window = nullptr; 49 } 50 51 void DOMWindowProperty::suspendForPageCache() 52 { 53 ASSERT(m_window); 54 } 55 56 void DOMWindowProperty::resumeFromPageCache() 57 { 58 // If this property is being reconnected to its Frame to enter the PageCache, it must have 59 // been disconnected from its Frame in the first place and it should still have an associated DOMWindow. 60 ASSERT(frame()); 61 ASSERT(frame()->document()->domWindow() == m_window); 62 } 63 64 void DOMWindowProperty::willDestroyGlobalObjectInCachedFrame() 65 { 66 // If the property has been disconnected from its Frame for the page cache, then it must have originally had a Frame 67 // and therefore should still have an associated DOMWindow. 68 ASSERT(m_window); 69 70 // DOMWindowProperty lifetime isn't tied directly to the DOMWindow itself so it is important that it unregister 71 // itself from any DOMWindow it is associated with if that DOMWindow is going away. 72 if (m_window) 73 m_window->unregisterProperty(*this); 74 m_window = nullptr; 75 } 76 77 void DOMWindowProperty::willDestroyGlobalObjectInFrame() 78 { 79 ASSERT(m_window); 80 81 // DOMWindowProperty lifetime isn't tied directly to the DOMWindow itself so it is important that it unregister 82 // itself from any DOMWindow it is associated with if that DOMWindow is going away. 83 if (m_window) 84 m_window->unregisterProperty(*this); 85 m_window = nullptr; 86 } 87 88 void DOMWindowProperty::willDetachGlobalObjectFromFrame() 36 : m_window(makeWeakPtr(window)) 89 37 { 90 38 } -
trunk/Source/WebCore/page/DOMWindowProperty.h
r237029 r242676 26 26 #pragma once 27 27 28 #include <wtf/WeakPtr.h> 29 28 30 namespace WebCore { 29 31 … … 33 35 class DOMWindowProperty { 34 36 public: 35 explicit DOMWindowProperty(DOMWindow*); 36 37 virtual void suspendForPageCache(); 38 virtual void resumeFromPageCache(); 39 virtual void willDestroyGlobalObjectInCachedFrame(); 40 virtual void willDestroyGlobalObjectInFrame(); 41 virtual void willDetachGlobalObjectFromFrame(); 42 43 WEBCORE_EXPORT Frame* frame() const; 44 DOMWindow* window() const { return m_window; } 37 Frame* frame() const; 38 DOMWindow* window() const { return m_window.get(); } 45 39 46 40 protected: 47 virtual ~DOMWindowProperty(); 41 explicit DOMWindowProperty(DOMWindow*); 42 ~DOMWindowProperty() = default; 48 43 49 DOMWindow* m_window; 44 private: 45 WeakPtr<DOMWindow> m_window; 50 46 }; 51 47 -
trunk/Source/WebCore/page/History.idl
r229392 r242676 27 27 GenerateIsReachable=ImplFrame, 28 28 JSCustomMarkFunction, 29 ImplementationLacksVTable, 29 30 ] interface History { 30 31 readonly attribute unsigned long length; -
trunk/Source/WebCore/page/Location.idl
r222429 r242676 41 41 GenerateIsReachable=ImplFrame, 42 42 IsImmutablePrototypeExoticObject, 43 ImplementationLacksVTable, 43 44 Unforgeable 44 45 ] interface Location { -
trunk/Source/WebCore/page/Navigator.cpp
r240641 r242676 168 168 } 169 169 if (!m_plugins) 170 m_plugins = DOMPluginArray::create( m_window);170 m_plugins = DOMPluginArray::create(window()); 171 171 return *m_plugins; 172 172 } … … 179 179 } 180 180 if (!m_mimeTypes) 181 m_mimeTypes = DOMMimeTypeArray::create( m_window);181 m_mimeTypes = DOMMimeTypeArray::create(window()); 182 182 return *m_mimeTypes; 183 183 } -
trunk/Source/WebCore/page/PerformanceNavigation.idl
r219954 r242676 30 30 31 31 // See: http://www.w3.org/TR/navigation-timing/ 32 interface PerformanceNavigation { 32 [ 33 ImplementationLacksVTable, 34 ] interface PerformanceNavigation { 33 35 const unsigned short TYPE_NAVIGATE = 0; 34 36 const unsigned short TYPE_RELOAD = 1; -
trunk/Source/WebCore/page/PerformanceTiming.idl
r219954 r242676 30 30 31 31 // See: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html 32 interface PerformanceTiming { 32 [ 33 ImplementationLacksVTable, 34 ] interface PerformanceTiming { 33 35 readonly attribute unsigned long long navigationStart; 34 36 readonly attribute unsigned long long unloadEventStart; -
trunk/Source/WebCore/page/Screen.idl
r209247 r242676 30 30 [ 31 31 GenerateIsReachable=ImplFrame, 32 ImplementationLacksVTable, 32 33 ] interface Screen { 33 34 readonly attribute unsigned long height; -
trunk/Source/WebCore/page/VisualViewport.cpp
r236917 r242676 51 51 ScriptExecutionContext* VisualViewport::scriptExecutionContext() const 52 52 { 53 if (!m_window) 53 auto window = this->window(); 54 if (!window) 54 55 return nullptr; 55 return static_cast<ContextDestructionObserver*>( m_window)->scriptExecutionContext();56 return static_cast<ContextDestructionObserver*>(window)->scriptExecutionContext(); 56 57 } 57 58 -
trunk/Source/WebCore/plugins/DOMMimeTypeArray.idl
r210667 r242676 22 22 GenerateIsReachable=ImplFrame, 23 23 LegacyUnenumerableNamedProperties, 24 ImplementationLacksVTable, 24 25 InterfaceName=MimeTypeArray, 25 26 ] interface DOMMimeTypeArray { -
trunk/Source/WebCore/plugins/DOMPluginArray.idl
r210667 r242676 22 22 GenerateIsReachable=ImplFrame, 23 23 LegacyUnenumerableNamedProperties, 24 ImplementationLacksVTable, 24 25 InterfaceName=PluginArray, 25 26 ] interface DOMPluginArray { -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/DOM/DOMObjectCache.cpp
r236917 r242676 20 20 #include "DOMObjectCache.h" 21 21 22 #include <WebCore/DOMWindow Property.h>22 #include <WebCore/DOMWindow.h> 23 23 #include <WebCore/Document.h> 24 24 #include <WebCore/Frame.h> … … 114 114 115 115 private: 116 class DOMWindowObserver final : public WebCore::DOMWindowProperty{116 class DOMWindowObserver final : public WebCore::DOMWindow::Observer { 117 117 WTF_MAKE_FAST_ALLOCATED; 118 118 public: 119 119 DOMWindowObserver(WebCore::DOMWindow& window, DOMObjectCacheFrameObserver& frameObserver) 120 : DOMWindowProperty(&window)120 : m_window(makeWeakPtr(window)) 121 121 , m_frameObserver(frameObserver) 122 122 { 123 } 124 125 virtual ~DOMWindowObserver() 123 window.registerObserver(*this); 124 } 125 126 ~DOMWindowObserver() 126 127 { 127 } 128 if (m_window) 129 m_window->unregisterObserver(*this); 130 } 131 132 WebCore::DOMWindow* window() const { return m_window.get(); } 128 133 129 134 private: 130 135 void willDetachGlobalObjectFromFrame() override 131 136 { 132 // Clear the DOMWindowProperty first, and then notify the Frame observer.133 DOMWindowProperty::willDetachGlobalObjectFromFrame();134 137 m_frameObserver.willDetachGlobalObjectFromFrame(); 135 138 } 136 139 140 WeakPtr<WebCore::DOMWindow> m_window; 137 141 DOMObjectCacheFrameObserver& m_frameObserver; 138 142 };
Note:
See TracChangeset
for help on using the changeset viewer.