⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242656 in webkit


Ignore:
Timestamp:
Mar 8, 2019, 2:12:46 PM (7 years ago)
Author:
Alan Bujtas
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242654 r242656  
     12019-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
    1232019-03-08  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp

    r242654 r242656  
    9494    LOG_WITH_STREAM(ContentObservation, stream << "startObservingDOMTimerExecute: start observing (" << &timer << ") timer callback.");
    9595
    96     m_domTimerIsBeingExecuted = true;
     96    m_observedDomTimerIsBeingExecuted = true;
    9797    adjustObservedState(Event::StartedDOMTimerExecution);
    9898}
     
    100100void ContentChangeObserver::domTimerExecuteDidFinish(const DOMTimer& timer)
    101101{
    102     if (!containsObservedDOMTimer(timer))
     102    if (!m_observedDomTimerIsBeingExecuted)
    103103        return;
    104104    LOG_WITH_STREAM(ContentObservation, stream << "stopObservingDOMTimerExecute: stop observing (" << &timer << ") timer callback.");
    105105
    106     m_domTimerIsBeingExecuted = false;
     106    m_observedDomTimerIsBeingExecuted = false;
    107107    unregisterDOMTimer(timer);
    108     setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());
    109108    adjustObservedState(Event::EndedDOMTimerExecution);
    110109}
     
    114113    if (!isWaitingForStyleRecalc())
    115114        return;
    116     if (hasVisibleChangeState())
    117         return;
    118115    LOG(ContentObservation, "startObservingStyleRecalc: start observing style recalc.");
    119116
    120     m_styleRecalcIsBeingExecuted = true;
     117    m_isInObservedStyleRecalc = true;
    121118    adjustObservedState(Event::StartedStyleRecalc);
    122119}
     
    124121void ContentChangeObserver::styleRecalcDidFinish()
    125122{
    126     if (!isWaitingForStyleRecalc())
     123    if (!m_isInObservedStyleRecalc)
    127124        return;
    128125    LOG(ContentObservation, "stopObservingStyleRecalc: stop observing style recalc");
    129126
    130     m_styleRecalcIsBeingExecuted = false;
     127    m_isInObservedStyleRecalc = false;
    131128    adjustObservedState(Event::EndedStyleRecalc);
    132129}
     
    230227void ContentChangeObserver::adjustObservedState(Event event)
    231228{
    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
    233234        if (!hasDeterminateState()) {
    234235            LOG(ContentObservation, "notifyContentChangeIfNeeded: not in a determined state yet.");
     
    249250        setShouldObserveDOMTimerScheduling(true);
    250251        break;
     252    case Event::EndedTouchStartEventDispatching:
     253        setShouldObserveDOMTimerScheduling(false);
     254        break;
    251255    case Event::StartedMouseMovedEventDispatching:
    252256        ASSERT(!m_document.hasPendingStyleRecalc());
     
    258262        m_isMouseMovedPrecededByTouch = false;
    259263        break;
    260     case Event::StartedDOMTimerExecution:
    261     case Event::StartedStyleRecalc:
    262         ASSERT(observedContentChange() == WKContentIndeterminateChange);
    263         break;
    264     case Event::EndedTouchStartEventDispatching:
    265264    case Event::EndedMouseMovedEventDispatching:
    266265        setShouldObserveDOMTimerScheduling(false);
    267266        break;
     267    case Event::StartedStyleRecalc:
     268        setShouldObserveNextStyleRecalc(false);
     269        FALLTHROUGH;
     270    case Event::StartedDOMTimerExecution:
     271        ASSERT(isObservationTimeWindowActive() || observedContentChange() == WKContentIndeterminateChange);
     272        break;
    268273    case Event::InstalledDOMTimer:
    269274    case Event::StartedFixedObservationTimeWindow:
    270         // Expecting a timer fire. Promote to an indeterminate state.
    271275        ASSERT(!hasVisibleChangeState());
    272276        setHasIndeterminateState();
    273277        break;
     278    case Event::EndedDOMTimerExecution:
     279        setShouldObserveNextStyleRecalc(m_document.hasPendingStyleRecalc());
     280        FALLTHROUGH;
    274281    case Event::EndedStyleRecalc:
    275         setShouldObserveNextStyleRecalc(false);
    276         FALLTHROUGH;
    277282    case Event::RemovedDOMTimer:
    278     case Event::EndedDOMTimerExecution:
     283        if (!isObservationTimeWindowActive())
     284            adjustStateAndNotifyContentChangeIfNeeded();
     285        break;
    279286    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();
    284288        break;
    285289    case Event::ContentVisibilityChanged:
    286290        setHasVisibleChangeState();
     291        // Remove pending activities. We don't need to observe them anymore.
     292        setShouldObserveNextStyleRecalc(false);
     293        clearObservedDOMTimers();
    287294        break;
    288295    }
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.h

    r242654 r242656  
    120120    bool isWaitingForStyleRecalc() const { return m_isWaitingForStyleRecalc; }
    121121
    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(); }
    123123
    124124    void cancelPendingActivities();
     
    132132    bool hasDeterminateState() const;
    133133
    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(); }
    135136#if !ASSERT_DISABLED
    136137    bool isNotifyContentChangeAllowed() const;
     
    161162    bool m_touchEventIsBeingDispatched { false };
    162163    bool m_isWaitingForStyleRecalc { false };
    163     bool m_styleRecalcIsBeingExecuted { false };
     164    bool m_isInObservedStyleRecalc { false };
    164165    bool m_isObservingDOMTimerScheduling { false };
    165     bool m_domTimerIsBeingExecuted { false };
     166    bool m_observedDomTimerIsBeingExecuted { false };
    166167    bool m_isMouseMovedPrecededByTouch { false };
    167168    bool m_mouseMovedEventIsBeingDispatched { false };
Note: See TracChangeset for help on using the changeset viewer.