Skip to content
Permalink
Browse files
[ContentChangeObserver] Move observing logic from DOMWindow::clearTim…
…eout 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):


Canonical link: https://commits.webkit.org/209384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242060 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Feb 26, 2019
1 parent 05d01d0 commit 9a88a2f39f0c6ee2a527c61f2b138c7bff02e4b9
Showing 4 changed files with 34 additions and 14 deletions.
@@ -1,3 +1,21 @@
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
@@ -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
@@ -39,6 +39,7 @@ class ContentChangeObserver {
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 @@ class ContentChangeObserver {
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();
@@ -86,6 +86,17 @@
}
}

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();

0 comments on commit 9a88a2f

Please sign in to comment.