Skip to content
Permalink
Browse files
[ContentChangeObserver] Move observing logic from Document::updateSty…
…leIfNeeded to ContentChangeObserver

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

Reviewed by Tim Horton.

This might eventually turn into a regular start/stop content observing call.

* dom/Document.cpp:
(WebCore::Document::updateStyleIfNeeded):
* page/ios/ContentChangeObserver.h:
* page/ios/ContentChangeObserver.mm:
(WebCore::ContentChangeObserver::startObservingStyleResolve):
(WebCore::ContentChangeObserver::stopObservingStyleResolve):

Canonical link: https://commits.webkit.org/209415@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242093 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Feb 26, 2019
1 parent e95186d commit d92033c78fcd856cc77243207ab0dcc546ada4da
Showing 4 changed files with 47 additions and 23 deletions.
@@ -1,3 +1,20 @@
2019-02-26 Zalan Bujtas <zalan@apple.com>

[ContentChangeObserver] Move observing logic from Document::updateStyleIfNeeded to ContentChangeObserver
https://bugs.webkit.org/show_bug.cgi?id=195032
<rdar://problem/48388063>

Reviewed by Tim Horton.

This might eventually turn into a regular start/stop content observing call.

* dom/Document.cpp:
(WebCore::Document::updateStyleIfNeeded):
* page/ios/ContentChangeObserver.h:
* page/ios/ContentChangeObserver.mm:
(WebCore::ContentChangeObserver::startObservingStyleResolve):
(WebCore::ContentChangeObserver::stopObservingStyleResolve):

2019-02-26 Zalan Bujtas <zalan@apple.com>

[ContentChangeObserver] Move CheckForVisibilityChange to ContentChangeObserver class
@@ -2050,36 +2050,17 @@ bool Document::updateStyleIfNeeded()
}

#if PLATFORM(IOS_FAMILY)
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();
}
}
if (auto* page = this->page())
page->contentChangeObserver().startObservingStyleResolve();
#endif
// The early exit above for !needsStyleRecalc() is needed when updateWidgetPositions() is called in runOrScheduleAsynchronousTasks().
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout(*this));

resolveStyle();

#if PLATFORM(IOS_FAMILY)
if (observingContentChange && page()) {
LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: stop observing content change.");
auto& contentChangeObserver = page()->contentChangeObserver();
contentChangeObserver.stopObservingContentChanges();

auto inDeterminedState = contentChangeObserver.observedContentChange() == WKContentVisibilityChange || !contentChangeObserver.countOfObservedDOMTimers();
if (inDeterminedState) {
LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: notify the pending synthetic click handler.");
page()->chrome().client().observedContentChange(*frame());
} else {
LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: can't decided it yet.");
}
}
if (auto* page = this->page())
page->contentChangeObserver().stopObservingStyleResolve();
#endif
return true;
}
@@ -43,6 +43,9 @@ class ContentChangeObserver {
void startObservingDOMTimerExecute(const DOMTimer&);
void stopObservingDOMTimerExecute(const DOMTimer&);

void startObservingStyleResolve();
void stopObservingStyleResolve();

WEBCORE_EXPORT void startObservingContentChanges();
WEBCORE_EXPORT void stopObservingContentChanges();

@@ -86,6 +86,29 @@
}
}

void ContentChangeObserver::startObservingStyleResolve()
{
if (!shouldObserveNextStyleRecalc())
return;
LOG(ContentObservation, "startObservingStyleResolve: start observing style resolve.");
startObservingContentChanges();
}

void ContentChangeObserver::stopObservingStyleResolve()
{
if (!shouldObserveNextStyleRecalc())
return;
LOG(ContentObservation, "stopObservingStyleResolve: stop observing style resolve");
setShouldObserveNextStyleRecalc(false);
auto inDeterminedState = observedContentChange() == WKContentVisibilityChange || !countOfObservedDOMTimers();
if (!inDeterminedState) {
LOG(ContentObservation, "stopObservingStyleResolve: can't decided it yet.");
return;
}
LOG(ContentObservation, "stopObservingStyleResolve: notify the pending synthetic click handler.");
m_page.chrome().client().observedContentChange(m_page.mainFrame());
}

void ContentChangeObserver::removeDOMTimer(const DOMTimer& timer)
{
if (!containsObservedDOMTimer(timer))

0 comments on commit d92033c

Please sign in to comment.