Title: [242656] trunk/Source/WebCore
- Revision
- 242656
- Author
- [email protected]
- Date
- 2019-03-08 14:12:46 -0800 (Fri, 08 Mar 2019)
Log Message
[ContentChangeObserver] Cleanup adjustObservedState
https://bugs.webkit.org/show_bug.cgi?id=195470
<rdar://problem/48717823>
Reviewed by Simon Fraser.
This is in preparation for introducing an observation window from touchStart -> mouseMoved.
1. Cancel pending activities (future timers, pending stylesheet recalcs) when visible content change is detected.
2. The fixed time window takes care of notifying the client -timers, style recalcs during the window should not signal themselves.
3. Reset m_isObservingPendingStyleRecalc at StartedStyleRecalc instead of EndedStyleRecalc.
* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::domTimerExecuteDidFinish):
(WebCore::ContentChangeObserver::styleRecalcDidStart):
(WebCore::ContentChangeObserver::styleRecalcDidFinish):
(WebCore::ContentChangeObserver::adjustObservedState):
* page/ios/ContentChangeObserver.h:
(WebCore::ContentChangeObserver::hasPendingActivity const):
(WebCore::ContentChangeObserver::isObservationTimeWindowActive const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (242655 => 242656)
--- trunk/Source/WebCore/ChangeLog 2019-03-08 21:59:34 UTC (rev 242655)
+++ trunk/Source/WebCore/ChangeLog 2019-03-08 22:12:46 UTC (rev 242656)
@@ -1,5 +1,27 @@
2019-03-08 Zalan Bujtas <[email protected]>
+ [ContentChangeObserver] Cleanup adjustObservedState
+ https://bugs.webkit.org/show_bug.cgi?id=195470
+ <rdar://problem/48717823>
+
+ Reviewed by Simon Fraser.
+
+ This is in preparation for introducing an observation window from touchStart -> mouseMoved.
+ 1. Cancel pending activities (future timers, pending stylesheet recalcs) when visible content change is detected.
+ 2. The fixed time window takes care of notifying the client -timers, style recalcs during the window should not signal themselves.
+ 3. Reset m_isObservingPendingStyleRecalc at StartedStyleRecalc instead of EndedStyleRecalc.
+
+ * page/ios/ContentChangeObserver.cpp:
+ (WebCore::ContentChangeObserver::domTimerExecuteDidFinish):
+ (WebCore::ContentChangeObserver::styleRecalcDidStart):
+ (WebCore::ContentChangeObserver::styleRecalcDidFinish):
+ (WebCore::ContentChangeObserver::adjustObservedState):
+ * page/ios/ContentChangeObserver.h:
+ (WebCore::ContentChangeObserver::hasPendingActivity const):
+ (WebCore::ContentChangeObserver::isObservationTimeWindowActive const):
+
+2019-03-08 Zalan Bujtas <[email protected]>
+
[ContentChangeObserver] Add StartedDOMTimerExecution and StartedStyleRecalc
https://bugs.webkit.org/show_bug.cgi?id=195463
<rdar://problem/48714762>
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp (242655 => 242656)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-03-08 21:59:34 UTC (rev 242655)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp 2019-03-08 22:12:46 UTC (rev 242656)
@@ -93,19 +93,18 @@
return;
LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback.");
- m_domTimerIsBeingExecuted = true;
+ m_observedDomTimerIsBeingExecuted = true;
adjustObservedState(Event::StartedDOMTimerExecution);
}
void ContentChangeObserver::domTimerExecuteDidFinish(const DOMTimer& timer)
{
- if (!containsObservedDOMTimer(timer))
+ if (!m_observedDomTimerIsBeingExecuted)
return;
LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: stop observing (" << &timer << ") timer callback.");
- m_domTimerIsBeingExecuted = false;
+ m_observedDomTimerIsBeingExecuted = false;
unregisterDOMTimer(timer);
- setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());
adjustObservedState(Event::EndedDOMTimerExecution);
}
@@ -113,21 +112,19 @@
{
if (!isWaitingForStyleRecalc())
return;
- if (hasVisibleChangeState())
- return;
LOG(ContentObservation, "startObservingStyleRecalc: start observing style recalc.");
- m_styleRecalcIsBeingExecuted = true;
+ m_isInObservedStyleRecalc = true;
adjustObservedState(Event::StartedStyleRecalc);
}
void ContentChangeObserver::styleRecalcDidFinish()
{
- if (!isWaitingForStyleRecalc())
+ if (!m_isInObservedStyleRecalc)
return;
LOG(ContentObservation, "stopObservingStyleRecalc: stop observing style recalc");
- m_styleRecalcIsBeingExecuted = false;
+ m_isInObservedStyleRecalc = false;
adjustObservedState(Event::EndedStyleRecalc);
}
@@ -229,7 +226,11 @@
void ContentChangeObserver::adjustObservedState(Event event)
{
- auto notifyContentChangeIfNeeded = [&] {
+ auto adjustStateAndNotifyContentChangeIfNeeded = [&] {
+ // Demote to "no change" when there's no pending activity anymore.
+ if (observedContentChange() == WKContentIndeterminateChange && !hasPendingActivity())
+ setHasNoChangeState();
+
if (!hasDeterminateState()) {
LOG(ContentObservation, "notifyContentChangeIfNeeded: not in a determined state yet.");
return;
@@ -248,6 +249,9 @@
m_isMouseMovedPrecededByTouch = true;
setShouldObserveDOMTimerScheduling(true);
break;
+ case Event::EndedTouchStartEventDispatching:
+ setShouldObserveDOMTimerScheduling(false);
+ break;
case Event::StartedMouseMovedEventDispatching:
ASSERT(!m_document.hasPendingStyleRecalc());
if (!m_isMouseMovedPrecededByTouch) {
@@ -257,33 +261,36 @@
setShouldObserveDOMTimerScheduling(true);
m_isMouseMovedPrecededByTouch = false;
break;
- case Event::StartedDOMTimerExecution:
- case Event::StartedStyleRecalc:
- ASSERT(observedContentChange() == WKContentIndeterminateChange);
- break;
- case Event::EndedTouchStartEventDispatching:
case Event::EndedMouseMovedEventDispatching:
setShouldObserveDOMTimerScheduling(false);
break;
+ case Event::StartedStyleRecalc:
+ setShouldObserveNextStyleRecalc(false);
+ FALLTHROUGH;
+ case Event::StartedDOMTimerExecution:
+ ASSERT(isObservationTimeWindowActive() || observedContentChange() == WKContentIndeterminateChange);
+ break;
case Event::InstalledDOMTimer:
case Event::StartedFixedObservationTimeWindow:
- // Expecting a timer fire. Promote to an indeterminate state.
ASSERT(!hasVisibleChangeState());
setHasIndeterminateState();
break;
+ case Event::EndedDOMTimerExecution:
+ setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());
+ FALLTHROUGH;
case Event::EndedStyleRecalc:
- setShouldObserveNextStyleRecalc(false);
- FALLTHROUGH;
case Event::RemovedDOMTimer:
- case Event::EndedDOMTimerExecution:
+ if (!isObservationTimeWindowActive())
+ adjustStateAndNotifyContentChangeIfNeeded();
+ break;
case Event::EndedFixedObservationTimeWindow:
- // Demote to "no change" when there's no pending activity anymore.
- if (observedContentChange() == WKContentIndeterminateChange && !hasPendingActivity())
- setHasNoChangeState();
- notifyContentChangeIfNeeded();
+ adjustStateAndNotifyContentChangeIfNeeded();
break;
case Event::ContentVisibilityChanged:
setHasVisibleChangeState();
+ // Remove pending activities. We don't need to observe them anymore.
+ setShouldObserveNextStyleRecalc(false);
+ clearObservedDOMTimers();
break;
}
}
Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.h (242655 => 242656)
--- trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-03-08 21:59:34 UTC (rev 242655)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.h 2019-03-08 22:12:46 UTC (rev 242656)
@@ -119,7 +119,7 @@
void setShouldObserveNextStyleRecalc(bool);
bool isWaitingForStyleRecalc() const { return m_isWaitingForStyleRecalc; }
- bool isObservingContentChanges() const { return m_mouseMovedEventIsBeingDispatched || m_touchEventIsBeingDispatched || m_domTimerIsBeingExecuted || m_styleRecalcIsBeingExecuted || m_contentObservationTimer.isActive(); }
+ bool isObservingContentChanges() const { return m_mouseMovedEventIsBeingDispatched || m_touchEventIsBeingDispatched || m_observedDomTimerIsBeingExecuted || m_isInObservedStyleRecalc || m_contentObservationTimer.isActive(); }
void cancelPendingActivities();
@@ -131,7 +131,8 @@
bool hasObservedDOMTimer() const { return !m_DOMTimerList.isEmpty(); }
bool hasDeterminateState() const;
- bool hasPendingActivity() const { return hasObservedDOMTimer() || m_document.hasPendingStyleRecalc() || m_contentObservationTimer.isActive(); }
+ bool hasPendingActivity() const { return hasObservedDOMTimer() || m_document.hasPendingStyleRecalc() || isObservationTimeWindowActive(); }
+ bool isObservationTimeWindowActive() const { return m_contentObservationTimer.isActive(); }
#if !ASSERT_DISABLED
bool isNotifyContentChangeAllowed() const;
#endif
@@ -160,9 +161,9 @@
HashSet<const DOMTimer*> m_DOMTimerList;
bool m_touchEventIsBeingDispatched { false };
bool m_isWaitingForStyleRecalc { false };
- bool m_styleRecalcIsBeingExecuted { false };
+ bool m_isInObservedStyleRecalc { false };
bool m_isObservingDOMTimerScheduling { false };
- bool m_domTimerIsBeingExecuted { false };
+ bool m_observedDomTimerIsBeingExecuted { false };
bool m_isMouseMovedPrecededByTouch { false };
bool m_mouseMovedEventIsBeingDispatched { false };
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes