Skip to content
Permalink
Browse files
[ContentChangeObserver] Move DOM timer handling from global to Conten…
…tChangeObserver class

https://bugs.webkit.org/show_bug.cgi?id=195070
<rdar://problem/48417650>

Reviewed by Tim Horton.

Add DOM timer list to ContentChangeObserver and move the related code over from WK functions.

* page/ios/ContentChangeObserver.h:
* page/ios/ContentChangeObserver.mm:
(WebCore::ContentChangeObserver::startObservingDOMTimerScheduling):
(WebCore::ContentChangeObserver::countOfObservedDOMTimers):
(WebCore::ContentChangeObserver::clearObservedDOMTimers):
(WebCore::ContentChangeObserver::setObservedContentChange):
(WebCore::ContentChangeObserver::containsObservedDOMTimer):
(WebCore::ContentChangeObserver::addObservedDOMTimer):
(WebCore::ContentChangeObserver::removeObservedDOMTimer):
* platform/ios/wak/WKContentObservation.cpp:
(WKStartObservingDOMTimerScheduling):
(WKSetObservedContentChange):
(WebThreadGetObservedDOMTimers): Deleted.
(WebThreadCountOfObservedDOMTimers): Deleted.
(WebThreadClearObservedDOMTimers): Deleted.
(WebThreadContainsObservedDOMTimer): Deleted.
(WebThreadAddObservedDOMTimer): Deleted.
(WebThreadRemoveObservedDOMTimer): Deleted.
* platform/ios/wak/WKContentObservation.h:


Canonical link: https://commits.webkit.org/209467@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Feb 27, 2019
1 parent 0df154e commit 86bbe50b8b6b60592bc89a9ab1da9d32120cb803
Showing 5 changed files with 45 additions and 54 deletions.
@@ -1,3 +1,33 @@
2019-02-27 Zalan Bujtas <zalan@apple.com>

[ContentChangeObserver] Move DOM timer handling from global to ContentChangeObserver class
https://bugs.webkit.org/show_bug.cgi?id=195070
<rdar://problem/48417650>

Reviewed by Tim Horton.

Add DOM timer list to ContentChangeObserver and move the related code over from WK functions.

* page/ios/ContentChangeObserver.h:
* page/ios/ContentChangeObserver.mm:
(WebCore::ContentChangeObserver::startObservingDOMTimerScheduling):
(WebCore::ContentChangeObserver::countOfObservedDOMTimers):
(WebCore::ContentChangeObserver::clearObservedDOMTimers):
(WebCore::ContentChangeObserver::setObservedContentChange):
(WebCore::ContentChangeObserver::containsObservedDOMTimer):
(WebCore::ContentChangeObserver::addObservedDOMTimer):
(WebCore::ContentChangeObserver::removeObservedDOMTimer):
* platform/ios/wak/WKContentObservation.cpp:
(WKStartObservingDOMTimerScheduling):
(WKSetObservedContentChange):
(WebThreadGetObservedDOMTimers): Deleted.
(WebThreadCountOfObservedDOMTimers): Deleted.
(WebThreadClearObservedDOMTimers): Deleted.
(WebThreadContainsObservedDOMTimer): Deleted.
(WebThreadAddObservedDOMTimer): Deleted.
(WebThreadRemoveObservedDOMTimer): Deleted.
* platform/ios/wak/WKContentObservation.h:

2019-02-27 Justin Fan <justin_fan@apple.com>
Fix build errors after Web GPU buffer updates changed some IDL fields from unsigned long to unsigned long long.

@@ -94,6 +94,7 @@ class ContentChangeObserver {
void clearTimersAndReportContentChange();

Page& m_page;
HashSet<const DOMTimer*> m_DOMTimerList;
};

}
@@ -60,7 +60,7 @@
if (!containsObservedDOMTimer(timer))
return;
LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback.");
startObservingContentChanges();
WKStartObservingContentChanges();
startObservingStyleRecalcScheduling();
}

@@ -99,7 +99,7 @@
if (!shouldObserveNextStyleRecalc())
return;
LOG(ContentObservation, "startObservingStyleResolve: start observing style resolve.");
startObservingContentChanges();
WKStartObservingContentChanges();
}

void ContentChangeObserver::stopObservingStyleResolve()
@@ -167,6 +167,7 @@
void ContentChangeObserver::startObservingDOMTimerScheduling()
{
WKStartObservingDOMTimerScheduling();
clearObservedDOMTimers();
}

void ContentChangeObserver::stopObservingDOMTimerScheduling()
@@ -211,12 +212,12 @@

unsigned ContentChangeObserver::countOfObservedDOMTimers()
{
return WebThreadCountOfObservedDOMTimers();
return m_DOMTimerList.size();
}

void ContentChangeObserver::clearObservedDOMTimers()
{
WebThreadClearObservedDOMTimers();
m_DOMTimerList.clear();
}

void ContentChangeObserver::setObservedContentChange(WKContentChange change)
@@ -226,17 +227,23 @@

bool ContentChangeObserver::containsObservedDOMTimer(const DOMTimer& timer)
{
return WebThreadContainsObservedDOMTimer(const_cast<DOMTimer*>(&timer));
return m_DOMTimerList.contains(&timer);
}

void ContentChangeObserver::addObservedDOMTimer(const DOMTimer& timer)
{
WebThreadAddObservedDOMTimer(const_cast<DOMTimer*>(&timer));
ASSERT(isObservingDOMTimerScheduling());
if (observedContentChange() == WKContentVisibilityChange)
return;
m_DOMTimerList.add(&timer);
}

void ContentChangeObserver::removeObservedDOMTimer(const DOMTimer& timer)
{
WebThreadRemoveObservedDOMTimer(const_cast<DOMTimer*>(&timer));
m_DOMTimerList.remove(&timer);
// Force reset the content change flag when the last observed content modifier is removed. We should not be in indeterminate state anymore.
if (!countOfObservedDOMTimers() && observedContentChange() == WKContentIndeterminateChange)
setObservedContentChange(WKContentNoChange);
}

static Visibility elementImplicitVisibility(const Element& element)
@@ -59,7 +59,6 @@ void WKStopObservingContentChanges(void)
void WKStartObservingDOMTimerScheduling(void)
{
_WKObservingDOMTimerScheduling = true;
WebThreadClearObservedDOMTimers();
}

void WKStopObservingDOMTimerScheduling(void)
@@ -110,8 +109,6 @@ void WKSetObservedContentChange(WKContentChange change)

if (change == WKContentVisibilityChange) {
_WKContentChange = change;
// Don't need to listen to DOM timers/style recalcs anymore.
WebThreadClearObservedDOMTimers();
_WKObservingNextStyleRecalc = false;
return;
}
@@ -123,45 +120,4 @@ void WKSetObservedContentChange(WKContentChange change)
ASSERT_NOT_REACHED();
}

using DOMTimerList = HashSet<void*>;
static DOMTimerList& WebThreadGetObservedDOMTimers()
{
ASSERT(WebThreadIsLockedOrDisabled());
static NeverDestroyed<DOMTimerList> observedDOMTimers;
return observedDOMTimers;
}

int WebThreadCountOfObservedDOMTimers(void)
{
return WebThreadGetObservedDOMTimers().size();
}

void WebThreadClearObservedDOMTimers()
{
WebThreadGetObservedDOMTimers().clear();
}

bool WebThreadContainsObservedDOMTimer(void* timer)
{
return WebThreadGetObservedDOMTimers().contains(timer);
}

void WebThreadAddObservedDOMTimer(void* timer)
{
ASSERT(_WKObservingDOMTimerScheduling);
if (_WKContentChange != WKContentVisibilityChange)
WebThreadGetObservedDOMTimers().add(timer);
}

void WebThreadRemoveObservedDOMTimer(void* timer)
{
WebThreadGetObservedDOMTimers().remove(timer);
// Force reset the content change flag when the last observed content modifier is removed. We should not be in indeterminate state anymore.
if (WebThreadCountOfObservedDOMTimers())
return;
if (WKObservedContentChange() != WKContentIndeterminateChange)
return;
_WKContentChange = WKContentNoChange;
}

#endif // PLATFORM(IOS_FAMILY)
@@ -55,9 +55,6 @@ WEBCORE_EXPORT bool WKShouldObserveNextStyleRecalc(void);

WEBCORE_EXPORT WKContentChange WKObservedContentChange(void);

WEBCORE_EXPORT int WebThreadCountOfObservedDOMTimers(void);
WEBCORE_EXPORT void WebThreadClearObservedDOMTimers(void);

#ifdef __cplusplus
}
#endif

0 comments on commit 86bbe50

Please sign in to comment.