Title: [242032] trunk/Source
Revision
242032
Author
[email protected]
Date
2019-02-24 22:04:20 -0800 (Sun, 24 Feb 2019)

Log Message

Introduce ContentChangeObserver class
https://bugs.webkit.org/show_bug.cgi?id=194977
<rdar://problem/48338115>

Reviewed by Simon Fraser.

Source/WebCore:

This patch is about piping through all the related WK* calls.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::scheduleStyleRecalc):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::platformSuspendOrStopActiveDOMObjects):
* loader/FrameLoader.cpp:
* page/DOMTimer.cpp:
(WebCore::DOMTimer::install):
(WebCore::DOMTimer::fired):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::clearTimeout):
* page/Frame.cpp:
(WebCore::Frame::willDetachPage):
* page/Page.h:
(WebCore::Page::contentChangeObserver):
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::mouseMoved):
* rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateElementRenderer):
(WebCore::CheckForVisibilityChange::CheckForVisibilityChange):
(WebCore::CheckForVisibilityChange::~CheckForVisibilityChange):

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleSyntheticClick):
(WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::observedContentChange):
(WebChromeClientIOS::clearContentChangeObservers):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242031 => 242032)


--- trunk/Source/WebCore/ChangeLog	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/ChangeLog	2019-02-25 06:04:20 UTC (rev 242032)
@@ -1,3 +1,36 @@
+2019-02-24  Zalan Bujtas  <[email protected]>
+
+        Introduce ContentChangeObserver class
+        https://bugs.webkit.org/show_bug.cgi?id=194977
+        <rdar://problem/48338115>
+
+        Reviewed by Simon Fraser.
+
+        This patch is about piping through all the related WK* calls. 
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::scheduleStyleRecalc):
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::platformSuspendOrStopActiveDOMObjects):
+        * loader/FrameLoader.cpp:
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::install):
+        (WebCore::DOMTimer::fired):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::clearTimeout):
+        * page/Frame.cpp:
+        (WebCore::Frame::willDetachPage):
+        * page/Page.h:
+        (WebCore::Page::contentChangeObserver):
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::EventHandler::mouseMoved):
+        * rendering/updating/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::updateElementRenderer):
+        (WebCore::CheckForVisibilityChange::CheckForVisibilityChange):
+        (WebCore::CheckForVisibilityChange::~CheckForVisibilityChange):
+
 2019-02-24  Simon Fraser  <[email protected]>
 
         Migrate from "fixedPositionRect" to "layoutViewport" in the scrolling tree

Modified: trunk/Source/WebCore/SourcesCocoa.txt (242031 => 242032)


--- trunk/Source/WebCore/SourcesCocoa.txt	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2019-02-25 06:04:20 UTC (rev 242032)
@@ -131,6 +131,7 @@
 page/cocoa/ResourceUsageThreadCocoa.mm
 page/cocoa/SettingsBaseCocoa.mm
 
+page/ios/ContentChangeObserver.mm
 page/ios/EventHandlerIOS.mm
 page/ios/FrameIOS.mm
 page/ios/WebEventRegion.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242031 => 242032)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-02-25 06:04:20 UTC (rev 242032)
@@ -2065,6 +2065,7 @@
 		6F995A3A1A70833700A735F4 /* JSWebGLVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */; };
 		6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
 		6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE198152178397C00446F08 /* InlineLineBreaker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE7CFA02177EEF1005B1573 /* InlineItem.h */; };
 		6FE7CFA42177EF10005B1573 /* LayoutLineBreakBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE7CFA32177EF10005B1573 /* LayoutLineBreakBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9234,6 +9235,7 @@
 		6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
 		6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
 		6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
+		6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
 		6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
 		6FE198132178397B00446F08 /* InlineLineBreaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLineBreaker.cpp; sourceTree = "<group>"; };
 		6FE198152178397C00446F08 /* InlineLineBreaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBreaker.h; sourceTree = "<group>"; };
@@ -9241,6 +9243,7 @@
 		6FE7CFA02177EEF1005B1573 /* InlineItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineItem.h; sourceTree = "<group>"; };
 		6FE7CFA32177EF10005B1573 /* LayoutLineBreakBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutLineBreakBox.h; sourceTree = "<group>"; };
 		6FE7CFA52177F069005B1573 /* LayoutLineBreakBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutLineBreakBox.cpp; sourceTree = "<group>"; };
+		6FE9F09222211035004C5082 /* ContentChangeObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentChangeObserver.mm; sourceTree = "<group>"; };
 		6FFDC43E212EFF1600A9CA91 /* FloatAvoider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatAvoider.cpp; sourceTree = "<group>"; };
 		6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatAvoider.h; sourceTree = "<group>"; };
 		709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleFetchFailureKind.h; sourceTree = "<group>"; };
@@ -16585,6 +16588,8 @@
 		18A6CD6F0D8F2025001DC3CE /* ios */ = {
 			isa = PBXGroup;
 			children = (
+				6FB5E212221F2447003989CF /* ContentChangeObserver.h */,
+				6FE9F09222211035004C5082 /* ContentChangeObserver.mm */,
 				FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
 				FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
 				225A16B30D5C11E900090295 /* WebEventRegion.h */,
@@ -28687,6 +28692,7 @@
 				2DAF343D1EA7E0F100382CD3 /* ConstantPropertyMap.h in Headers */,
 				A818721C0977D3C0005826D9 /* ContainerNode.h in Headers */,
 				E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */,
+				6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */,
 				BC5EB9810E82072500B25965 /* ContentData.h in Headers */,
 				51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */,
 				5CDFA6C81AA4F2DA00EA8746 /* ContentExtensionActions.h in Headers */,

Modified: trunk/Source/WebCore/dom/Document.cpp (242031 => 242032)


--- trunk/Source/WebCore/dom/Document.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -258,6 +258,7 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
+#include "ContentChangeObserver.h"
 #include "CSSFontSelector.h"
 #include "DeviceMotionClientIOS.h"
 #include "DeviceMotionController.h"
@@ -266,8 +267,6 @@
 #include "Geolocation.h"
 #include "Navigator.h"
 #include "NavigatorGeolocation.h"
-#include "WKContentObservation.h"
-#include "WKContentObservationInternal.h"
 #endif
 
 #if ENABLE(IOS_GESTURE_EVENTS)
@@ -1812,9 +1811,12 @@
     ASSERT(childNeedsStyleRecalc() || m_needsFullStyleRebuild);
 
 #if PLATFORM(IOS_FAMILY)
-    if (WKIsObservingStyleRecalcScheduling()) {
-        LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: register this style recalc schedule and observe when it fires.");
-        WKSetObservedContentChange(WKContentIndeterminateChange);
+    if (auto* page = this->page()) {
+        auto& contentChangeObserver = page->contentChangeObserver();
+        if (contentChangeObserver.isObservingStyleRecalcScheduling()) {
+            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: register this style recalc schedule and observe when it fires.");
+            contentChangeObserver.setObservedContentChange(WKContentIndeterminateChange);
+        }
     }
 #endif
 
@@ -2048,11 +2050,15 @@
     }
 
 #if PLATFORM(IOS_FAMILY)
-    auto observingContentChange = WKShouldObserveNextStyleRecalc();
-    if (observingContentChange) {
-        LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: start observing content change.");
-        WKSetShouldObserveNextStyleRecalc(false);
-        WKStartObservingContentChanges();
+    auto observingContentChange = false;
+    if (auto* page = this->page()) {
+        auto& contentChangeObserver = page->contentChangeObserver();
+        observingContentChange = contentChangeObserver.shouldObserveNextStyleRecalc();
+        if (observingContentChange) {
+            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: start observing content change.");
+            contentChangeObserver.setShouldObserveNextStyleRecalc(false);
+            contentChangeObserver.startObservingContentChanges();
+        }
     }
 #endif
     // The early exit above for !needsStyleRecalc() is needed when updateWidgetPositions() is called in runOrScheduleAsynchronousTasks().
@@ -2061,15 +2067,15 @@
     resolveStyle();
 
 #if PLATFORM(IOS_FAMILY)
-    if (observingContentChange) {
+    if (observingContentChange && page()) {
         LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: stop observing content change.");
-        WKStopObservingContentChanges();
+        auto& contentChangeObserver = page()->contentChangeObserver();
+        contentChangeObserver.stopObservingContentChanges();
 
-        auto inDeterminedState = WKObservedContentChange() == WKContentVisibilityChange || !WebThreadCountOfObservedDOMTimers();  
+        auto inDeterminedState = contentChangeObserver.observedContentChange() == WKContentVisibilityChange || !contentChangeObserver.countOfObservedDOMTimers();  
         if (inDeterminedState) {
             LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: notify the pending synthetic click handler.");
-            if (auto* page = this->page())
-                page->chrome().client().observedContentChange(*frame());
+            page()->chrome().client().observedContentChange(*frame());
         } else {
             LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: can't decided it yet.");
         }
@@ -2651,13 +2657,13 @@
 void Document::platformSuspendOrStopActiveDOMObjects()
 {
 #if PLATFORM(IOS_FAMILY)
-    if (WebThreadCountOfObservedDOMTimers() > 0) {
-        LOG_WITH_STREAM(ContentObservation, stream << "Document::platformSuspendOrStopActiveDOMObjects: remove registered timers.");
-        if (auto* frame = this->frame()) {
-            if (auto* page = frame->page())
-                page->chrome().client().clearContentChangeObservers(*frame);
-        }
-    }
+    if (!page() || !frame())
+        return;
+    auto& page = *this->page();
+    if (!page.contentChangeObserver().countOfObservedDOMTimers())
+        return;
+    LOG_WITH_STREAM(ContentObservation, stream << "Document::platformSuspendOrStopActiveDOMObjects: remove registered timers.");
+    page.chrome().client().clearContentChangeObservers(*frame());
 #endif
 }
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (242031 => 242032)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -145,7 +145,6 @@
 #include "DocumentType.h"
 #include "ResourceLoader.h"
 #include "RuntimeApplicationChecks.h"
-#include "WKContentObservation.h"
 #endif
 
 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - FrameLoader::" fmt, this, ##__VA_ARGS__)

Modified: trunk/Source/WebCore/page/DOMTimer.cpp (242031 => 242032)


--- trunk/Source/WebCore/page/DOMTimer.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/page/DOMTimer.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -44,9 +44,8 @@
 #if PLATFORM(IOS_FAMILY)
 #include "Chrome.h"
 #include "ChromeClient.h"
+#include "ContentChangeObserver.h"
 #include "Frame.h"
-#include "WKContentObservation.h"
-#include "WKContentObservationInternal.h"
 #endif
 
 namespace WebCore {
@@ -219,17 +218,6 @@
     // This reference will be released automatically when a one-shot timer fires, when the context
     // is destroyed, or if explicitly cancelled by removeById. 
     DOMTimer* timer = new DOMTimer(context, WTFMove(action), timeout, singleShot);
-#if PLATFORM(IOS_FAMILY)
-    if (WKIsObservingDOMTimerScheduling() && is<Document>(context)) {
-        bool didDeferTimeout = context.activeDOMObjectsAreSuspended();
-        if (!didDeferTimeout && timeout <= 250_ms && singleShot) {
-            WKSetObservedContentChange(WKContentIndeterminateChange);
-            WebThreadAddObservedDOMTimer(timer);
-            LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::install: registed this timer: (" << timer << ") and observe when it fires.");
-        }
-    }
-#endif
-
     timer->suspendIfNeeded();
     InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot);
 
@@ -237,6 +225,25 @@
     if (NestedTimersMap* nestedTimers = NestedTimersMap::instanceForContext(context))
         nestedTimers->add(timer->m_timeoutId, *timer);
 
+#if PLATFORM(IOS_FAMILY)
+    auto startObservingThisTimerIfNeeded = [&] {
+        if (!is<Document>(context))
+            return;
+        if (context.activeDOMObjectsAreSuspended())
+            return;
+        if (timeout > 250_ms || !singleShot)
+            return;
+        auto& contentChangeObserver = downcast<Document>(context).page()->contentChangeObserver();
+        if (!contentChangeObserver.isObservingDOMTimerScheduling())
+            return;
+
+        contentChangeObserver.setObservedContentChange(WKContentIndeterminateChange);
+        contentChangeObserver.addObservedDOMTimer(*timer);
+        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::install: register this timer: (" << m_timeoutId << ") and observe when it fires.");
+    };
+
+    startObservingThisTimerIfNeeded();
+#endif
     return timer->m_timeoutId;
 }
 
@@ -342,18 +349,23 @@
     context.removeTimeout(m_timeoutId);
 
 #if PLATFORM(IOS_FAMILY)
-    auto isObversingLastTimer = false;
+    auto isObservingLastTimer = false;
     auto shouldBeginObservingChanges = false;
-    if (is<Document>(context)) {
-        isObversingLastTimer = WebThreadCountOfObservedDOMTimers() == 1;
-        shouldBeginObservingChanges = WebThreadContainsObservedDOMTimer(this);
+    Page* page = nullptr;
+    if (is<Document>(context) && downcast<Document>(context).page()) {
+        page = downcast<Document>(context).page();
+        auto& contentChangeObserver = page->contentChangeObserver();
+        isObservingLastTimer = contentChangeObserver.countOfObservedDOMTimers() == 1;
+        shouldBeginObservingChanges = contentChangeObserver.containsObservedDOMTimer(*this);
     }
 
     if (shouldBeginObservingChanges) {
-        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: start observing (" << this << ") timer callback.");
-        WKStartObservingContentChanges();
-        WKStartObservingStyleRecalcScheduling();
-        WebThreadRemoveObservedDOMTimer(this);
+        ASSERT(page);
+        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: start observing (" << m_timeoutId << ") timer callback.");
+        auto& contentChangeObserver = page->contentChangeObserver();
+        contentChangeObserver.startObservingContentChanges();
+        contentChangeObserver.startObservingStyleRecalcScheduling();
+        contentChangeObserver.removeObservedDOMTimer(*this);
     }
 #endif
 
@@ -366,22 +378,22 @@
 
 #if PLATFORM(IOS_FAMILY)
     if (shouldBeginObservingChanges) {
-        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: stop observing (" << this << ") timer callback.");
-        WKStopObservingStyleRecalcScheduling();
-        WKStopObservingContentChanges();
+        ASSERT(page);
+        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: stop observing (" << m_timeoutId << ") timer callback.");
+        auto& contentChangeObserver = page->contentChangeObserver();
+        contentChangeObserver.stopObservingStyleRecalcScheduling();
+        contentChangeObserver.stopObservingContentChanges();
 
-        auto observedContentChange = WKObservedContentChange();
+        auto observedContentChange = contentChangeObserver.observedContentChange();
         // Check if the timer callback triggered either a sync or async style update.
-        auto inDeterminedState = observedContentChange == WKContentVisibilityChange || (isObversingLastTimer && observedContentChange == WKContentNoChange);  
+        auto inDeterminedState = observedContentChange == WKContentVisibilityChange || (isObservingLastTimer && observedContentChange == WKContentNoChange);  
         if (inDeterminedState) {
-            LOG(ContentObservation, "DOMTimer::fired: in determined state.");
-            auto& document = downcast<Document>(context);
-            if (auto* page = document.page())
-                page->chrome().client().observedContentChange(*document.frame());
+            LOG_WITH_STREAM(ContentObservation, "DOMTimer::fired(" << m_timeoutId << "): in determined state.");
+            page->chrome().client().observedContentChange(*downcast<Document>(context).frame());
         } else if (observedContentChange == WKContentIndeterminateChange) {
             // An async style recalc has been scheduled. Let's observe it.
-            LOG(ContentObservation, "DOMTimer::fired: wait until next style recalc fires.");
-            WKSetShouldObserveNextStyleRecalc(true);
+            LOG_WITH_STREAM(ContentObservation, "DOMTimer::fired(" << m_timeoutId << "): wait until next style recalc fires.");
+            contentChangeObserver.setShouldObserveNextStyleRecalc(true);
         }
     }
 #endif

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (242031 => 242032)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -139,11 +139,9 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-#include "WKContentObservation.h"
-#include "WKContentObservationInternal.h"
+#include "ContentChangeObserver.h"
 #endif
 
-
 namespace WebCore {
 using namespace Inspector;
 
@@ -1684,21 +1682,26 @@
 void DOMWindow::clearTimeout(int timeoutId)
 {
 #if PLATFORM(IOS_FAMILY)
-    if (auto* frame = this->frame()) {
-        Document* document = frame->document();
-        if (timeoutId > 0 && document) {
-            DOMTimer* timer = document->findTimeout(timeoutId);
-            if (timer && WebThreadContainsObservedDOMTimer(timer)) {
-                LOG_WITH_STREAM(ContentObservation, stream << "DOMWindow::clearTimeout: remove registered timer (" << timer << ")");
-                WebThreadRemoveObservedDOMTimer(timer);
-
-                if (!WebThreadCountOfObservedDOMTimers()) {
-                    if (Page* page = frame->page())
-                        page->chrome().client().observedContentChange(*frame);
-                }
-            }
-        }
-    }
+    auto handleObservedTimerCancelIfNeeded = [&] {
+        if (!frame() || !frame()->document() || !frame()->document()->page())
+            return;
+        if (timeoutId <= 0)
+            return;
+        auto& document = *frame()->document();
+        auto* timer = document.findTimeout(timeoutId);
+        if (!timer)
+            return;
+        auto& page = *document.page();
+        auto& contentChangeObserver = page.contentChangeObserver();
+        if (!contentChangeObserver.containsObservedDOMTimer(*timer))
+            return;
+        LOG_WITH_STREAM(ContentObservation, stream << "DOMWindow::clearTimeout: remove registered timer (" << timer << ")");
+        contentChangeObserver.removeObservedDOMTimer(*timer);
+        if (contentChangeObserver.countOfObservedDOMTimers())
+            return;
+        page.chrome().client().observedContentChange(*frame());
+    };
+    handleObservedTimerCancelIfNeeded();
 #endif
     ScriptExecutionContext* context = scriptExecutionContext();
     if (!context)

Modified: trunk/Source/WebCore/page/Frame.cpp (242031 => 242032)


--- trunk/Source/WebCore/page/Frame.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/page/Frame.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -108,7 +108,7 @@
 #include <wtf/text/StringBuilder.h>
 
 #if PLATFORM(IOS_FAMILY)
-#include "WKContentObservation.h"
+#include "ContentChangeObserver.h"
 #endif
 
 namespace WebCore {
@@ -838,7 +838,7 @@
         page()->scrollingCoordinator()->willDestroyScrollableArea(*m_view);
 
 #if PLATFORM(IOS_FAMILY)
-    if (WebThreadCountOfObservedDOMTimers() > 0 && m_page) {
+    if (page() && page()->contentChangeObserver().countOfObservedDOMTimers()) {
         LOG(ContentObservation, "Frame::willDetachPage: remove registered timers.");
         m_page->chrome().client().clearContentChangeObservers(*this);
     }

Modified: trunk/Source/WebCore/page/Page.h (242031 => 242032)


--- trunk/Source/WebCore/page/Page.h	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/page/Page.h	2019-02-25 06:04:20 UTC (rev 242032)
@@ -66,6 +66,10 @@
 #include "MediaPlaybackTargetContext.h"
 #endif
 
+#if PLATFORM(IOS_FAMILY)
+#include "ContentChangeObserver.h"
+#endif
+
 namespace JSC {
 class Debugger;
 }
@@ -251,6 +255,9 @@
 #if ENABLE(POINTER_LOCK)
     PointerLockController& pointerLockController() const { return *m_pointerLockController; }
 #endif
+#if PLATFORM(IOS_FAMILY)
+    ContentChangeObserver& contentChangeObserver() { return m_contentChangeObserver; }
+#endif
     LibWebRTCProvider& libWebRTCProvider() { return m_libWebRTCProvider.get(); }
     RTCController& rtcController() { return m_rtcController; }
     WEBCORE_EXPORT void disableICECandidateFiltering();
@@ -808,6 +815,7 @@
 
 #if PLATFORM(IOS_FAMILY)
     bool m_enclosedInScrollableAncestorView { false };
+    ContentChangeObserver m_contentChangeObserver;
 #endif
     
     bool m_useSystemAppearance { false };

Added: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (0 => 242032)


--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h	                        (rev 0)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h	2019-02-25 06:04:20 UTC (rev 242032)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(IOS_FAMILY)
+
+#include "WKContentObservation.h"
+
+namespace WebCore {
+
+class DOMTimer;
+
+class ContentChangeObserver {
+public:
+    ContentChangeObserver() = default;
+
+    WEBCORE_EXPORT void startObservingContentChanges();
+    WEBCORE_EXPORT void stopObservingContentChanges();
+    bool isObservingContentChanges();
+
+    WEBCORE_EXPORT void startObservingDOMTimerScheduling();
+    WEBCORE_EXPORT void stopObservingDOMTimerScheduling();
+    bool isObservingDOMTimerScheduling();
+
+    WEBCORE_EXPORT void startObservingStyleRecalcScheduling();
+    WEBCORE_EXPORT void stopObservingStyleRecalcScheduling();
+    bool isObservingStyleRecalcScheduling();
+
+    void setShouldObserveNextStyleRecalc(bool);
+    bool shouldObserveNextStyleRecalc();
+
+    void setObservedContentChange(WKContentChange);
+    WEBCORE_EXPORT WKContentChange observedContentChange();
+
+    void addObservedDOMTimer(DOMTimer&);
+    void removeObservedDOMTimer(DOMTimer&);
+    bool containsObservedDOMTimer(DOMTimer&);
+    WEBCORE_EXPORT unsigned countOfObservedDOMTimers();
+    WEBCORE_EXPORT void clearObservedDOMTimers();
+};
+
+}
+#endif

Added: trunk/Source/WebCore/page/ios/ContentChangeObserver.mm (0 => 242032)


--- trunk/Source/WebCore/page/ios/ContentChangeObserver.mm	                        (rev 0)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.mm	2019-02-25 06:04:20 UTC (rev 242032)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ContentChangeObserver.h"
+
+#if PLATFORM(IOS_FAMILY)
+#import "DOMTimer.h"
+#import "WKContentObservationInternal.h"
+
+namespace WebCore {
+
+void ContentChangeObserver::startObservingContentChanges()
+{
+    WKStartObservingContentChanges();
+}
+
+void ContentChangeObserver::stopObservingContentChanges()
+{
+    WKStopObservingContentChanges();   
+}
+
+bool ContentChangeObserver::isObservingContentChanges()
+{
+    return WKObservingContentChanges();   
+}
+
+void ContentChangeObserver::startObservingDOMTimerScheduling()
+{
+    WKStartObservingDOMTimerScheduling();
+}
+
+void ContentChangeObserver::stopObservingDOMTimerScheduling()
+{
+    WKStopObservingDOMTimerScheduling();
+}
+
+bool ContentChangeObserver::isObservingDOMTimerScheduling()
+{
+    return WKIsObservingDOMTimerScheduling();
+}
+
+void ContentChangeObserver::startObservingStyleRecalcScheduling()
+{
+    WKStartObservingStyleRecalcScheduling();
+}
+
+void ContentChangeObserver::stopObservingStyleRecalcScheduling()
+{
+    WKStopObservingStyleRecalcScheduling();
+}
+
+bool ContentChangeObserver::isObservingStyleRecalcScheduling()
+{
+    return WKIsObservingStyleRecalcScheduling();
+}
+
+void ContentChangeObserver::setShouldObserveNextStyleRecalc(bool observe)
+{
+    WKSetShouldObserveNextStyleRecalc(observe);
+}
+
+bool ContentChangeObserver::shouldObserveNextStyleRecalc()
+{
+    return WKShouldObserveNextStyleRecalc();
+}
+
+WKContentChange ContentChangeObserver::observedContentChange()
+{
+    return WKObservedContentChange();
+}
+
+unsigned ContentChangeObserver::countOfObservedDOMTimers()
+{
+    return WebThreadCountOfObservedDOMTimers();
+}
+
+void ContentChangeObserver::clearObservedDOMTimers()
+{
+    WebThreadClearObservedDOMTimers();
+}
+
+void ContentChangeObserver::setObservedContentChange(WKContentChange change)
+{
+    WKSetObservedContentChange(change);
+}
+
+bool ContentChangeObserver::containsObservedDOMTimer(DOMTimer& timer)
+{
+    return WebThreadContainsObservedDOMTimer(&timer);
+}
+
+void ContentChangeObserver::addObservedDOMTimer(DOMTimer& timer)
+{
+    WebThreadAddObservedDOMTimer(&timer);
+}
+
+void ContentChangeObserver::removeObservedDOMTimer(DOMTimer& timer)
+{
+    WebThreadRemoveObservedDOMTimer(&timer);
+}
+
+}
+
+#endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/page/ios/EventHandlerIOS.mm (242031 => 242032)


--- trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2019-02-25 06:04:20 UTC (rev 242032)
@@ -32,6 +32,7 @@
 #import "AutoscrollController.h"
 #import "Chrome.h"
 #import "ChromeClient.h"
+#import "ContentChangeObserver.h"
 #import "DataTransfer.h"
 #import "DragState.h"
 #import "FocusController.h"
@@ -490,19 +491,22 @@
         return;
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    auto& document = *m_frame.document();
+    // Ensure we start mouse move event dispatching on a clear tree.
+    document.updateStyleIfNeeded();
 
-    m_frame.document()->updateStyleIfNeeded();
+    auto& contentChangeObserver = document.page()->contentChangeObserver();
+    contentChangeObserver.startObservingContentChanges();
+    contentChangeObserver.startObservingDOMTimerScheduling();
 
-    WKStartObservingContentChanges();
-    WKStartObservingDOMTimerScheduling();
     CurrentEventScope scope(event);
     event.wasHandled = mouseMoved(currentPlatformMouseEvent());
-    
-    // FIXME: Why is this here?
-    m_frame.document()->updateStyleIfNeeded();
-    WKStopObservingDOMTimerScheduling();
-    WKStopObservingContentChanges();
 
+    // Run style recalc to be able to capture content changes as the result of the mouse move event.
+    document.updateStyleIfNeeded();
+    contentChangeObserver.stopObservingDOMTimerScheduling();
+    contentChangeObserver.stopObservingContentChanges();
+
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (242031 => 242032)


--- trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2019-02-25 06:04:20 UTC (rev 242032)
@@ -50,8 +50,7 @@
 #include <wtf/SystemTracing.h>
 
 #if PLATFORM(IOS_FAMILY)
-#include "WKContentObservation.h"
-#include "WKContentObservationInternal.h"
+#include "ContentChangeObserver.h"
 #endif
 
 namespace WebCore {
@@ -59,11 +58,12 @@
 #if PLATFORM(IOS_FAMILY)
 class CheckForVisibilityChange {
 public:
-    CheckForVisibilityChange(const Element&);
+    CheckForVisibilityChange(const Element&, Page*);
     ~CheckForVisibilityChange();
 
 private:
     const Element& m_element;
+    Page* m_page { nullptr };
     DisplayType m_previousDisplay;
     Visibility m_previousVisibility;
     Visibility m_previousImplicitVisibility;
@@ -308,7 +308,7 @@
 void RenderTreeUpdater::updateElementRenderer(Element& element, const Style::ElementUpdate& update)
 {
 #if PLATFORM(IOS_FAMILY)
-    CheckForVisibilityChange checkForVisibilityChange(element);
+    CheckForVisibilityChange checkForVisibilityChange(element, m_document.page());
 #endif
 
     bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.hasDisplayContents());
@@ -667,19 +667,24 @@
     return Visibility::Visible;
 }
 
-CheckForVisibilityChange::CheckForVisibilityChange(const Element& element)
+CheckForVisibilityChange::CheckForVisibilityChange(const Element& element, Page* page)
     : m_element(element)
+    , m_page(page)
     , m_previousDisplay(element.renderStyle() ? element.renderStyle()->display() : DisplayType::None)
     , m_previousVisibility(element.renderStyle() ? element.renderStyle()->visibility() : Visibility::Hidden)
-    , m_previousImplicitVisibility(WKObservingContentChanges() && WKObservedContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : Visibility::Visible)
+    , m_previousImplicitVisibility(page && page->contentChangeObserver().isObservingContentChanges() && page->contentChangeObserver().observedContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : Visibility::Visible)
 {
 }
 
 CheckForVisibilityChange::~CheckForVisibilityChange()
 {
-    if (!WKObservingContentChanges())
+    if (!m_page)
         return;
 
+    auto& contentChangeObserver = m_page->contentChangeObserver();
+    if (!contentChangeObserver.isObservingContentChanges())
+        return;
+
     auto* style = m_element.renderStyle();
 
     auto qualifiesForVisibilityCheck = [&] {
@@ -696,7 +701,7 @@
         return;
     if ((m_previousDisplay == DisplayType::None && style->display() != DisplayType::None) || (m_previousVisibility == Visibility::Hidden && style->visibility() != Visibility::Hidden)
         || (m_previousImplicitVisibility == Visibility::Hidden && elementImplicitVisibility(m_element) == Visibility::Visible))
-        WKSetObservedContentChange(WKContentVisibilityChange);
+        contentChangeObserver.setObservedContentChange(WKContentVisibilityChange);
 }
 #endif
 

Modified: trunk/Source/WebKit/ChangeLog (242031 => 242032)


--- trunk/Source/WebKit/ChangeLog	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebKit/ChangeLog	2019-02-25 06:04:20 UTC (rev 242032)
@@ -1,3 +1,15 @@
+2019-02-24  Zalan Bujtas  <[email protected]>
+
+        Introduce ContentChangeObserver class
+        https://bugs.webkit.org/show_bug.cgi?id=194977
+        <rdar://problem/48338115>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleSyntheticClick):
+        (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
+
 2019-02-24  Simon Fraser  <[email protected]>
 
         Migrate from "fixedPositionRect" to "layoutViewport" in the scrolling tree

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (242031 => 242032)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-02-25 06:04:20 UTC (rev 242032)
@@ -57,6 +57,7 @@
 #import <WebCore/Autofill.h>
 #import <WebCore/AutofillElements.h>
 #import <WebCore/Chrome.h>
+#import <WebCore/ContentChangeObserver.h>
 #import <WebCore/DataDetection.h>
 #import <WebCore/DiagnosticLoggingClient.h>
 #import <WebCore/DiagnosticLoggingKeys.h>
@@ -113,7 +114,6 @@
 #import <WebCore/TextIndicator.h>
 #import <WebCore/TextIterator.h>
 #import <WebCore/VisibleUnits.h>
-#import <WebCore/WKContentObservation.h>
 #import <WebCore/WebEvent.h>
 #import <wtf/MathExtras.h>
 #import <wtf/MemoryPressureHandler.h>
@@ -538,11 +538,12 @@
 void WebPage::handleSyntheticClick(Node* nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers)
 {
     IntPoint roundedAdjustedPoint = roundedIntPoint(location);
-    Frame& mainframe = m_page->mainFrame();
+    auto& mainframe = m_page->mainFrame();
+    auto& contentChangeObserver = m_page->contentChangeObserver();
 
     LOG_WITH_STREAM(ContentObservation, stream << "handleSyntheticClick: node(" << nodeRespondingToClick << ") " << location);
-    WKStartObservingContentChanges();
-    WKStartObservingDOMTimerScheduling();
+    contentChangeObserver.startObservingContentChanges();
+    contentChangeObserver.startObservingDOMTimerScheduling();
 
     // FIXME: Pass caps lock state.
     bool shiftKey = modifiers.contains(WebEvent::Modifier::ShiftKey);
@@ -552,8 +553,8 @@
     mainframe.eventHandler().mouseMoved(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap));
     mainframe.document()->updateStyleIfNeeded();
 
-    WKStopObservingDOMTimerScheduling();
-    WKStopObservingContentChanges();
+    contentChangeObserver.stopObservingDOMTimerScheduling();
+    contentChangeObserver.stopObservingContentChanges();
 
     m_pendingSyntheticClickNode = nullptr;
     m_pendingSyntheticClickLocation = FloatPoint();
@@ -562,7 +563,7 @@
     if (m_isClosed)
         return;
 
-    switch (WKObservedContentChange()) {
+    switch (contentChangeObserver.observedContentChange()) {
     case WKContentVisibilityChange:
         // The move event caused new contents to appear. Don't send the click event.
         LOG(ContentObservation, "handleSyntheticClick: Observed meaningful visible change -> hover.");
@@ -588,7 +589,7 @@
     if (!m_pendingSyntheticClickNode)
         return;
     // Only dispatch the click if the document didn't get changed by any timers started by the move event.
-    if (WKObservedContentChange() == WKContentNoChange) {
+    if (m_page->contentChangeObserver().observedContentChange() == WKContentNoChange) {
         LOG(ContentObservation, "No chage was observed -> click.");
         completeSyntheticClick(m_pendingSyntheticClickNode.get(), m_pendingSyntheticClickLocation, m_pendingSyntheticClickModifiers, WebCore::OneFingerTap);
     } else

Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (242031 => 242032)


--- trunk/Source/WebKitLegacy/ios/ChangeLog	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog	2019-02-25 06:04:20 UTC (rev 242032)
@@ -1,3 +1,15 @@
+2019-02-24  Zalan Bujtas  <[email protected]>
+
+        Introduce ContentChangeObserver class
+        https://bugs.webkit.org/show_bug.cgi?id=194977
+        <rdar://problem/48338115>
+
+        Reviewed by Simon Fraser.
+
+        * WebCoreSupport/WebChromeClientIOS.mm:
+        (WebChromeClientIOS::observedContentChange):
+        (WebChromeClientIOS::clearContentChangeObservers):
+
 2019-02-17  David Kilzer  <[email protected]>
 
         Unreviewed, rolling out r241620.

Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm (242031 => 242032)


--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm	2019-02-25 06:03:22 UTC (rev 242031)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm	2019-02-25 06:04:20 UTC (rev 242032)
@@ -44,6 +44,7 @@
 #import "WebView.h"
 #import "WebViewInternal.h"
 #import "WebViewPrivate.h"
+#import <WebCore/ContentChangeObserver.h>
 #import <WebCore/DisabledAdaptations.h>
 #import <WebCore/FileChooser.h>
 #import <WebCore/FloatRect.h>
@@ -183,16 +184,21 @@
 
 void WebChromeClientIOS::observedContentChange(WebCore::Frame& frame)
 {
-    [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:WKObservedContentChange() forFrame:kit(&frame)];
+    if (!frame.page())
+        return;
+    [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:frame.page()->contentChangeObserver().observedContentChange() forFrame:kit(&frame)];
 }
 
 void WebChromeClientIOS::clearContentChangeObservers(WebCore::Frame& frame)
 {
-    ASSERT(WebThreadCountOfObservedDOMTimers() > 0);
-    if (WebThreadCountOfObservedDOMTimers() > 0) {
-        WebThreadClearObservedDOMTimers();
-        observedContentChange(frame);
-    }
+    if (!frame.page())
+        return;
+    auto& contentChangeObserver = frame.page()->contentChangeObserver();
+    ASSERT(contentChangeObserver.countOfObservedDOMTimers());
+    if (!contentChangeObserver.countOfObservedDOMTimers())
+        return;
+    contentChangeObserver.clearObservedDOMTimers();
+    observedContentChange(frame);
 }
 
 static inline NSString *nameForViewportFitValue(ViewportFit value)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to