[ContentChangeObserver] Move observing logic from DOMWindow::clearTimeout to ContentC...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 00:20:55 +0000 (00:20 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 00:20:55 +0000 (00:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194988
<rdar://problem/48343040>

Reviewed by Tim Horton.

ContentChangeObserver::removeDOMTimer takes care of the canceled timer removal.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::clearTimeout):
* page/ios/ContentChangeObserver.h:
* page/ios/ContentChangeObserver.mm:
(WebCore::ContentChangeObserver::startObservingDOMTimer):
(WebCore::ContentChangeObserver::stopObservingDOMTimer):
(WebCore::ContentChangeObserver::removeDOMTimer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242060 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/ios/ContentChangeObserver.h
Source/WebCore/page/ios/ContentChangeObserver.mm

index 95920f9..42d0bac 100644 (file)
@@ -1,5 +1,23 @@
 2019-02-25  Zalan Bujtas  <zalan@apple.com>
 
+        [ContentChangeObserver] Move observing logic from DOMWindow::clearTimeout to ContentChangeObserver
+        https://bugs.webkit.org/show_bug.cgi?id=194988
+        <rdar://problem/48343040>
+
+        Reviewed by Tim Horton.
+
+        ContentChangeObserver::removeDOMTimer takes care of the canceled timer removal.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::clearTimeout):
+        * page/ios/ContentChangeObserver.h:
+        * page/ios/ContentChangeObserver.mm:
+        (WebCore::ContentChangeObserver::startObservingDOMTimer):
+        (WebCore::ContentChangeObserver::stopObservingDOMTimer):
+        (WebCore::ContentChangeObserver::removeDOMTimer):
+
+2019-02-25  Zalan Bujtas  <zalan@apple.com>
+
         [ContentChangeObserver] Move observing logic from DOMTimer to ContentChangeObserver
         https://bugs.webkit.org/show_bug.cgi?id=194987
         <rdar://problem/48342910>
index 5a66278..fa75ac5 100644 (file)
@@ -1688,18 +1688,8 @@ void DOMWindow::clearTimeout(int timeoutId)
         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());
+        if (auto* timer = document.findTimeout(timeoutId))
+            document.page()->contentChangeObserver().removeDOMTimer(*timer);
     };
     handleObservedTimerCancelIfNeeded();
 #endif
index 78232b4..6fbe075 100644 (file)
@@ -39,6 +39,7 @@ public:
     ContentChangeObserver(Page&);
 
     void registerDOMTimerForContentObservationIfNeeded(const DOMTimer&, Seconds timeout, bool singleShot);
+    void removeDOMTimer(const DOMTimer&);
     void startObservingDOMTimerExecute(const DOMTimer&);
     void stopObservingDOMTimerExecute(const DOMTimer&);
 
@@ -57,14 +58,14 @@ public:
     void setObservedContentChange(WKContentChange);
     WEBCORE_EXPORT WKContentChange observedContentChange();
 
-    void removeObservedDOMTimer(const DOMTimer&);
-    bool containsObservedDOMTimer(const DOMTimer&);
     WEBCORE_EXPORT unsigned countOfObservedDOMTimers();
     WEBCORE_EXPORT void clearObservedDOMTimers();
 
 private:
     void addObservedDOMTimer(const DOMTimer&);
     bool isObservingDOMTimerScheduling();
+    void removeObservedDOMTimer(const DOMTimer&);
+    bool containsObservedDOMTimer(const DOMTimer&);
 
     void startObservingStyleRecalcScheduling();
     void stopObservingStyleRecalcScheduling();
index 700a6d1..375ebca 100644 (file)
@@ -86,6 +86,17 @@ void ContentChangeObserver::stopObservingDOMTimerExecute(const DOMTimer& timer)
     }
 }
 
+void ContentChangeObserver::removeDOMTimer(const DOMTimer& timer)
+{
+    if (!containsObservedDOMTimer(timer))
+        return;
+    removeObservedDOMTimer(timer);
+    LOG_WITH_STREAM(ContentObservation, stream << "removeDOMTimer: remove registered timer (" << &timer << ")");
+    if (countOfObservedDOMTimers())
+        return;
+    m_page.chrome().client().observedContentChange(m_page.mainFrame());
+}
+
 void ContentChangeObserver::startObservingContentChanges()
 {
     WKStartObservingContentChanges();