Changeset 242656 in webkit
- Timestamp:
- Mar 8, 2019, 2:12:46 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
page/ios/ContentChangeObserver.cpp (modified) (7 diffs)
-
page/ios/ContentChangeObserver.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242654 r242656 1 2019-03-08 Zalan Bujtas <zalan@apple.com> 2 3 [ContentChangeObserver] Cleanup adjustObservedState 4 https://bugs.webkit.org/show_bug.cgi?id=195470 5 <rdar://problem/48717823> 6 7 Reviewed by Simon Fraser. 8 9 This is in preparation for introducing an observation window from touchStart -> mouseMoved. 10 1. Cancel pending activities (future timers, pending stylesheet recalcs) when visible content change is detected. 11 2. The fixed time window takes care of notifying the client -timers, style recalcs during the window should not signal themselves. 12 3. Reset m_isObservingPendingStyleRecalc at StartedStyleRecalc instead of EndedStyleRecalc. 13 14 * page/ios/ContentChangeObserver.cpp: 15 (WebCore::ContentChangeObserver::domTimerExecuteDidFinish): 16 (WebCore::ContentChangeObserver::styleRecalcDidStart): 17 (WebCore::ContentChangeObserver::styleRecalcDidFinish): 18 (WebCore::ContentChangeObserver::adjustObservedState): 19 * page/ios/ContentChangeObserver.h: 20 (WebCore::ContentChangeObserver::hasPendingActivity const): 21 (WebCore::ContentChangeObserver::isObservationTimeWindowActive const): 22 1 23 2019-03-08 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp
r242654 r242656 94 94 LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback."); 95 95 96 m_ domTimerIsBeingExecuted = true;96 m_observedDomTimerIsBeingExecuted = true; 97 97 adjustObservedState(Event::StartedDOMTimerExecution); 98 98 } … … 100 100 void ContentChangeObserver::domTimerExecuteDidFinish(const DOMTimer& timer) 101 101 { 102 if (! containsObservedDOMTimer(timer))102 if (!m_observedDomTimerIsBeingExecuted) 103 103 return; 104 104 LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: stop observing (" << &timer << ") timer callback."); 105 105 106 m_ domTimerIsBeingExecuted = false;106 m_observedDomTimerIsBeingExecuted = false; 107 107 unregisterDOMTimer(timer); 108 setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());109 108 adjustObservedState(Event::EndedDOMTimerExecution); 110 109 } … … 114 113 if (!isWaitingForStyleRecalc()) 115 114 return; 116 if (hasVisibleChangeState())117 return;118 115 LOG(ContentObservation, "startObservingStyleRecalc: start observing style recalc."); 119 116 120 m_ styleRecalcIsBeingExecuted= true;117 m_isInObservedStyleRecalc = true; 121 118 adjustObservedState(Event::StartedStyleRecalc); 122 119 } … … 124 121 void ContentChangeObserver::styleRecalcDidFinish() 125 122 { 126 if (! isWaitingForStyleRecalc())123 if (!m_isInObservedStyleRecalc) 127 124 return; 128 125 LOG(ContentObservation, "stopObservingStyleRecalc: stop observing style recalc"); 129 126 130 m_ styleRecalcIsBeingExecuted= false;127 m_isInObservedStyleRecalc = false; 131 128 adjustObservedState(Event::EndedStyleRecalc); 132 129 } … … 230 227 void ContentChangeObserver::adjustObservedState(Event event) 231 228 { 232 auto notifyContentChangeIfNeeded = [&] { 229 auto adjustStateAndNotifyContentChangeIfNeeded = [&] { 230 // Demote to "no change" when there's no pending activity anymore. 231 if (observedContentChange() == WKContentIndeterminateChange && !hasPendingActivity()) 232 setHasNoChangeState(); 233 233 234 if (!hasDeterminateState()) { 234 235 LOG(ContentObservation, "notifyContentChangeIfNeeded: not in a determined state yet."); … … 249 250 setShouldObserveDOMTimerScheduling(true); 250 251 break; 252 case Event::EndedTouchStartEventDispatching: 253 setShouldObserveDOMTimerScheduling(false); 254 break; 251 255 case Event::StartedMouseMovedEventDispatching: 252 256 ASSERT(!m_document.hasPendingStyleRecalc()); … … 258 262 m_isMouseMovedPrecededByTouch = false; 259 263 break; 260 case Event::StartedDOMTimerExecution:261 case Event::StartedStyleRecalc:262 ASSERT(observedContentChange() == WKContentIndeterminateChange);263 break;264 case Event::EndedTouchStartEventDispatching:265 264 case Event::EndedMouseMovedEventDispatching: 266 265 setShouldObserveDOMTimerScheduling(false); 267 266 break; 267 case Event::StartedStyleRecalc: 268 setShouldObserveNextStyleRecalc(false); 269 FALLTHROUGH; 270 case Event::StartedDOMTimerExecution: 271 ASSERT(isObservationTimeWindowActive() || observedContentChange() == WKContentIndeterminateChange); 272 break; 268 273 case Event::InstalledDOMTimer: 269 274 case Event::StartedFixedObservationTimeWindow: 270 // Expecting a timer fire. Promote to an indeterminate state.271 275 ASSERT(!hasVisibleChangeState()); 272 276 setHasIndeterminateState(); 273 277 break; 278 case Event::EndedDOMTimerExecution: 279 setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc()); 280 FALLTHROUGH; 274 281 case Event::EndedStyleRecalc: 275 setShouldObserveNextStyleRecalc(false);276 FALLTHROUGH;277 282 case Event::RemovedDOMTimer: 278 case Event::EndedDOMTimerExecution: 283 if (!isObservationTimeWindowActive()) 284 adjustStateAndNotifyContentChangeIfNeeded(); 285 break; 279 286 case Event::EndedFixedObservationTimeWindow: 280 // Demote to "no change" when there's no pending activity anymore. 281 if (observedContentChange() == WKContentIndeterminateChange && !hasPendingActivity()) 282 setHasNoChangeState(); 283 notifyContentChangeIfNeeded(); 287 adjustStateAndNotifyContentChangeIfNeeded(); 284 288 break; 285 289 case Event::ContentVisibilityChanged: 286 290 setHasVisibleChangeState(); 291 // Remove pending activities. We don't need to observe them anymore. 292 setShouldObserveNextStyleRecalc(false); 293 clearObservedDOMTimers(); 287 294 break; 288 295 } -
trunk/Source/WebCore/page/ios/ContentChangeObserver.h
r242654 r242656 120 120 bool isWaitingForStyleRecalc() const { return m_isWaitingForStyleRecalc; } 121 121 122 bool isObservingContentChanges() const { return m_mouseMovedEventIsBeingDispatched || m_touchEventIsBeingDispatched || m_ domTimerIsBeingExecuted || m_styleRecalcIsBeingExecuted|| m_contentObservationTimer.isActive(); }122 bool isObservingContentChanges() const { return m_mouseMovedEventIsBeingDispatched || m_touchEventIsBeingDispatched || m_observedDomTimerIsBeingExecuted || m_isInObservedStyleRecalc || m_contentObservationTimer.isActive(); } 123 123 124 124 void cancelPendingActivities(); … … 132 132 bool hasDeterminateState() const; 133 133 134 bool hasPendingActivity() const { return hasObservedDOMTimer() || m_document.hasPendingStyleRecalc() || m_contentObservationTimer.isActive(); } 134 bool hasPendingActivity() const { return hasObservedDOMTimer() || m_document.hasPendingStyleRecalc() || isObservationTimeWindowActive(); } 135 bool isObservationTimeWindowActive() const { return m_contentObservationTimer.isActive(); } 135 136 #if !ASSERT_DISABLED 136 137 bool isNotifyContentChangeAllowed() const; … … 161 162 bool m_touchEventIsBeingDispatched { false }; 162 163 bool m_isWaitingForStyleRecalc { false }; 163 bool m_ styleRecalcIsBeingExecuted{ false };164 bool m_isInObservedStyleRecalc { false }; 164 165 bool m_isObservingDOMTimerScheduling { false }; 165 bool m_ domTimerIsBeingExecuted { false };166 bool m_observedDomTimerIsBeingExecuted { false }; 166 167 bool m_isMouseMovedPrecededByTouch { false }; 167 168 bool m_mouseMovedEventIsBeingDispatched { false };
Note:
See TracChangeset
for help on using the changeset viewer.