[ContentChangeObserver] Move timer removal code from DOMWindow::clearTimeout to DOMTi...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2019 19:19:51 +0000 (19:19 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2019 19:19:51 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195143
<rdar://problem/48462351>

Reviewed by Simon Fraser.

Currently DOMWindow::clearTimeout() is the only callsite that we are interested in, but this is more future-proof.

* page/DOMTimer.cpp:
(WebCore::DOMTimer::removeById):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::clearTimeout):
* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::startObservingDOMTimerExecute):
(WebCore::ContentChangeObserver::stopObservingDOMTimerExecute):
(WebCore::ContentChangeObserver::didRemoveDOMTimer):
(WebCore::ContentChangeObserver::removeDOMTimer): Deleted.
* page/ios/ContentChangeObserver.h:

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

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

index 6d87b04..aca92d8 100644 (file)
@@ -1,3 +1,24 @@
+2019-02-28  Zalan Bujtas  <zalan@apple.com>
+
+        [ContentChangeObserver] Move timer removal code from DOMWindow::clearTimeout to DOMTimer::removeById
+        https://bugs.webkit.org/show_bug.cgi?id=195143
+        <rdar://problem/48462351>
+
+        Reviewed by Simon Fraser.
+
+        Currently DOMWindow::clearTimeout() is the only callsite that we are interested in, but this is more future-proof.
+
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::removeById):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::clearTimeout):
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::startObservingDOMTimerExecute):
+        (WebCore::ContentChangeObserver::stopObservingDOMTimerExecute):
+        (WebCore::ContentChangeObserver::didRemoveDOMTimer):
+        (WebCore::ContentChangeObserver::removeDOMTimer): Deleted.
+        * page/ios/ContentChangeObserver.h:
+
 2019-02-28  Charles Vazac  <cvazac@akamai.com>
 
         Fix Resource Timing buffer edge cases for WPT
index 7737e7c..0d89fe7 100644 (file)
@@ -236,6 +236,14 @@ void DOMTimer::removeById(ScriptExecutionContext& context, int timeoutId)
     if (timeoutId <= 0)
         return;
 
+#if PLATFORM(IOS_FAMILY)
+    if (is<Document>(context) && downcast<Document>(context).page()) {
+        auto& document = downcast<Document>(context);
+        if (auto* timer = document.findTimeout(timeoutId))
+            document.page()->contentChangeObserver().didRemoveDOMTimer(*timer);
+    }
+#endif
+
     if (NestedTimersMap* nestedTimers = NestedTimersMap::instanceForContext(context))
         nestedTimers->remove(timeoutId);
 
index a9116d2..dfa1124 100644 (file)
 #include "PointerLockController.h"
 #endif
 
-#if PLATFORM(IOS_FAMILY)
-#include "ContentChangeObserver.h"
-#endif
-
 namespace WebCore {
 using namespace Inspector;
 
@@ -1683,18 +1679,6 @@ ExceptionOr<int> DOMWindow::setTimeout(JSC::ExecState& state, std::unique_ptr<Sc
 
 void DOMWindow::clearTimeout(int timeoutId)
 {
-#if PLATFORM(IOS_FAMILY)
-    auto handleObservedTimerCancelIfNeeded = [&] {
-        if (!frame() || !frame()->document() || !frame()->document()->page())
-            return;
-        if (timeoutId <= 0)
-            return;
-        auto& document = *frame()->document();
-        if (auto* timer = document.findTimeout(timeoutId))
-            document.page()->contentChangeObserver().removeDOMTimer(*timer);
-    };
-    handleObservedTimerCancelIfNeeded();
-#endif
     ScriptExecutionContext* context = scriptExecutionContext();
     if (!context)
         return;
index 46f86f8..9c377e0 100644 (file)
@@ -117,7 +117,7 @@ void ContentChangeObserver::stopObservingStyleResolve()
     m_page.chrome().client().observedContentChange(m_page.mainFrame());
 }
 
-void ContentChangeObserver::removeDOMTimer(const DOMTimer& timer)
+void ContentChangeObserver::didRemoveDOMTimer(const DOMTimer& timer)
 {
     if (!containsObservedDOMTimer(timer))
         return;
index d6795df..72dd35a 100644 (file)
@@ -39,7 +39,7 @@ public:
     ContentChangeObserver(Page&);
 
     void didInstallDOMTimer(const DOMTimer&, Seconds timeout, bool singleShot);
-    void removeDOMTimer(const DOMTimer&);
+    void didRemoveDOMTimer(const DOMTimer&);
     void startObservingDOMTimerExecute(const DOMTimer&);
     void stopObservingDOMTimerExecute(const DOMTimer&);