Changeset 242032 in webkit


Ignore:
Timestamp:
Feb 24, 2019 10:04:20 PM (5 years ago)
Author:
Alan Bujtas
Message:

Introduce ContentChangeObserver class
https://bugs.webkit.org/show_bug.cgi?id=194977
<rdar://problem/48338115>

Reviewed by Simon Fraser.

Source/WebCore:

This patch is about piping through all the related WK* calls.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp:

(WebCore::Document::scheduleStyleRecalc):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::platformSuspendOrStopActiveDOMObjects):

  • loader/FrameLoader.cpp:
  • page/DOMTimer.cpp:

(WebCore::DOMTimer::install):
(WebCore::DOMTimer::fired):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::clearTimeout):

  • page/Frame.cpp:

(WebCore::Frame::willDetachPage):

  • page/Page.h:

(WebCore::Page::contentChangeObserver):

  • page/ios/EventHandlerIOS.mm:

(WebCore::EventHandler::mouseMoved):

  • rendering/updating/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::updateElementRenderer):
(WebCore::CheckForVisibilityChange::CheckForVisibilityChange):
(WebCore::CheckForVisibilityChange::~CheckForVisibilityChange):

Source/WebKit:

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::handleSyntheticClick):
(WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):

Source/WebKitLegacy/ios:

  • WebCoreSupport/WebChromeClientIOS.mm:

(WebChromeClientIOS::observedContentChange):
(WebChromeClientIOS::clearContentChangeObservers):

Location:
trunk/Source
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242031 r242032  
     12019-02-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        Introduce ContentChangeObserver class
     4        https://bugs.webkit.org/show_bug.cgi?id=194977
     5        <rdar://problem/48338115>
     6
     7        Reviewed by Simon Fraser.
     8
     9        This patch is about piping through all the related WK* calls.
     10
     11        * SourcesCocoa.txt:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * dom/Document.cpp:
     14        (WebCore::Document::scheduleStyleRecalc):
     15        (WebCore::Document::updateStyleIfNeeded):
     16        (WebCore::Document::platformSuspendOrStopActiveDOMObjects):
     17        * loader/FrameLoader.cpp:
     18        * page/DOMTimer.cpp:
     19        (WebCore::DOMTimer::install):
     20        (WebCore::DOMTimer::fired):
     21        * page/DOMWindow.cpp:
     22        (WebCore::DOMWindow::clearTimeout):
     23        * page/Frame.cpp:
     24        (WebCore::Frame::willDetachPage):
     25        * page/Page.h:
     26        (WebCore::Page::contentChangeObserver):
     27        * page/ios/EventHandlerIOS.mm:
     28        (WebCore::EventHandler::mouseMoved):
     29        * rendering/updating/RenderTreeUpdater.cpp:
     30        (WebCore::RenderTreeUpdater::updateElementRenderer):
     31        (WebCore::CheckForVisibilityChange::CheckForVisibilityChange):
     32        (WebCore::CheckForVisibilityChange::~CheckForVisibilityChange):
     33
    1342019-02-24  Simon Fraser  <simon.fraser@apple.com>
    235
  • trunk/Source/WebCore/SourcesCocoa.txt

    r241997 r242032  
    132132page/cocoa/SettingsBaseCocoa.mm
    133133
     134page/ios/ContentChangeObserver.mm
    134135page/ios/EventHandlerIOS.mm
    135136page/ios/FrameIOS.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r242019 r242032  
    20662066                6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
    20672067                6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2068                6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    20682069                6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE198152178397C00446F08 /* InlineLineBreaker.h */; settings = {ATTRIBUTES = (Private, ); }; };
    20692070                6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE7CFA02177EEF1005B1573 /* InlineItem.h */; };
     
    92359236                6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
    92369237                6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
     9238                6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
    92379239                6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
    92389240                6FE198132178397B00446F08 /* InlineLineBreaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLineBreaker.cpp; sourceTree = "<group>"; };
     
    92429244                6FE7CFA32177EF10005B1573 /* LayoutLineBreakBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutLineBreakBox.h; sourceTree = "<group>"; };
    92439245                6FE7CFA52177F069005B1573 /* LayoutLineBreakBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutLineBreakBox.cpp; sourceTree = "<group>"; };
     9246                6FE9F09222211035004C5082 /* ContentChangeObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentChangeObserver.mm; sourceTree = "<group>"; };
    92449247                6FFDC43E212EFF1600A9CA91 /* FloatAvoider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatAvoider.cpp; sourceTree = "<group>"; };
    92459248                6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatAvoider.h; sourceTree = "<group>"; };
     
    1658616589                        isa = PBXGroup;
    1658716590                        children = (
     16591                                6FB5E212221F2447003989CF /* ContentChangeObserver.h */,
     16592                                6FE9F09222211035004C5082 /* ContentChangeObserver.mm */,
    1658816593                                FE6938B51045D67E008EABB6 /* EventHandlerIOS.mm */,
    1658916594                                FED13D3B0CEA936A00D89466 /* FrameIOS.mm */,
     
    2868828693                                A818721C0977D3C0005826D9 /* ContainerNode.h in Headers */,
    2868928694                                E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */,
     28695                                6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */,
    2869028696                                BC5EB9810E82072500B25965 /* ContentData.h in Headers */,
    2869128697                                51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */,
  • trunk/Source/WebCore/dom/Document.cpp

    r242014 r242032  
    259259
    260260#if PLATFORM(IOS_FAMILY)
     261#include "ContentChangeObserver.h"
    261262#include "CSSFontSelector.h"
    262263#include "DeviceMotionClientIOS.h"
     
    267268#include "Navigator.h"
    268269#include "NavigatorGeolocation.h"
    269 #include "WKContentObservation.h"
    270 #include "WKContentObservationInternal.h"
    271270#endif
    272271
     
    18131812
    18141813#if PLATFORM(IOS_FAMILY)
    1815     if (WKIsObservingStyleRecalcScheduling()) {
    1816         LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: register this style recalc schedule and observe when it fires.");
    1817         WKSetObservedContentChange(WKContentIndeterminateChange);
     1814    if (auto* page = this->page()) {
     1815        auto& contentChangeObserver = page->contentChangeObserver();
     1816        if (contentChangeObserver.isObservingStyleRecalcScheduling()) {
     1817            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: register this style recalc schedule and observe when it fires.");
     1818            contentChangeObserver.setObservedContentChange(WKContentIndeterminateChange);
     1819        }
    18181820    }
    18191821#endif
     
    20492051
    20502052#if PLATFORM(IOS_FAMILY)
    2051     auto observingContentChange = WKShouldObserveNextStyleRecalc();
    2052     if (observingContentChange) {
    2053         LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: start observing content change.");
    2054         WKSetShouldObserveNextStyleRecalc(false);
    2055         WKStartObservingContentChanges();
     2053    auto observingContentChange = false;
     2054    if (auto* page = this->page()) {
     2055        auto& contentChangeObserver = page->contentChangeObserver();
     2056        observingContentChange = contentChangeObserver.shouldObserveNextStyleRecalc();
     2057        if (observingContentChange) {
     2058            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: start observing content change.");
     2059            contentChangeObserver.setShouldObserveNextStyleRecalc(false);
     2060            contentChangeObserver.startObservingContentChanges();
     2061        }
    20562062    }
    20572063#endif
     
    20622068
    20632069#if PLATFORM(IOS_FAMILY)
    2064     if (observingContentChange) {
     2070    if (observingContentChange && page()) {
    20652071        LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: stop observing content change.");
    2066         WKStopObservingContentChanges();
    2067 
    2068         auto inDeterminedState = WKObservedContentChange() == WKContentVisibilityChange || !WebThreadCountOfObservedDOMTimers(); 
     2072        auto& contentChangeObserver = page()->contentChangeObserver();
     2073        contentChangeObserver.stopObservingContentChanges();
     2074
     2075        auto inDeterminedState = contentChangeObserver.observedContentChange() == WKContentVisibilityChange || !contentChangeObserver.countOfObservedDOMTimers(); 
    20692076        if (inDeterminedState) {
    20702077            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: notify the pending synthetic click handler.");
    2071             if (auto* page = this->page())
    2072                 page->chrome().client().observedContentChange(*frame());
     2078            page()->chrome().client().observedContentChange(*frame());
    20732079        } else {
    20742080            LOG_WITH_STREAM(ContentObservation, stream << "Document(" << this << ")::scheduleStyleRecalc: can't decided it yet.");
     
    26522658{
    26532659#if PLATFORM(IOS_FAMILY)
    2654     if (WebThreadCountOfObservedDOMTimers() > 0) {
    2655         LOG_WITH_STREAM(ContentObservation, stream << "Document::platformSuspendOrStopActiveDOMObjects: remove registered timers.");
    2656         if (auto* frame = this->frame()) {
    2657             if (auto* page = frame->page())
    2658                 page->chrome().client().clearContentChangeObservers(*frame);
    2659         }
    2660     }
     2660    if (!page() || !frame())
     2661        return;
     2662    auto& page = *this->page();
     2663    if (!page.contentChangeObserver().countOfObservedDOMTimers())
     2664        return;
     2665    LOG_WITH_STREAM(ContentObservation, stream << "Document::platformSuspendOrStopActiveDOMObjects: remove registered timers.");
     2666    page.chrome().client().clearContentChangeObservers(*frame());
    26612667#endif
    26622668}
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r241918 r242032  
    146146#include "ResourceLoader.h"
    147147#include "RuntimeApplicationChecks.h"
    148 #include "WKContentObservation.h"
    149148#endif
    150149
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r241499 r242032  
    4545#include "Chrome.h"
    4646#include "ChromeClient.h"
     47#include "ContentChangeObserver.h"
    4748#include "Frame.h"
    48 #include "WKContentObservation.h"
    49 #include "WKContentObservationInternal.h"
    5049#endif
    5150
     
    220219    // is destroyed, or if explicitly cancelled by removeById.
    221220    DOMTimer* timer = new DOMTimer(context, WTFMove(action), timeout, singleShot);
    222 #if PLATFORM(IOS_FAMILY)
    223     if (WKIsObservingDOMTimerScheduling() && is<Document>(context)) {
    224         bool didDeferTimeout = context.activeDOMObjectsAreSuspended();
    225         if (!didDeferTimeout && timeout <= 250_ms && singleShot) {
    226             WKSetObservedContentChange(WKContentIndeterminateChange);
    227             WebThreadAddObservedDOMTimer(timer);
    228             LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::install: registed this timer: (" << timer << ") and observe when it fires.");
    229         }
    230     }
    231 #endif
    232 
    233221    timer->suspendIfNeeded();
    234222    InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot);
     
    238226        nestedTimers->add(timer->m_timeoutId, *timer);
    239227
     228#if PLATFORM(IOS_FAMILY)
     229    auto startObservingThisTimerIfNeeded = [&] {
     230        if (!is<Document>(context))
     231            return;
     232        if (context.activeDOMObjectsAreSuspended())
     233            return;
     234        if (timeout > 250_ms || !singleShot)
     235            return;
     236        auto& contentChangeObserver = downcast<Document>(context).page()->contentChangeObserver();
     237        if (!contentChangeObserver.isObservingDOMTimerScheduling())
     238            return;
     239
     240        contentChangeObserver.setObservedContentChange(WKContentIndeterminateChange);
     241        contentChangeObserver.addObservedDOMTimer(*timer);
     242        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::install: register this timer: (" << m_timeoutId << ") and observe when it fires.");
     243    };
     244
     245    startObservingThisTimerIfNeeded();
     246#endif
    240247    return timer->m_timeoutId;
    241248}
     
    343350
    344351#if PLATFORM(IOS_FAMILY)
    345     auto isObversingLastTimer = false;
     352    auto isObservingLastTimer = false;
    346353    auto shouldBeginObservingChanges = false;
    347     if (is<Document>(context)) {
    348         isObversingLastTimer = WebThreadCountOfObservedDOMTimers() == 1;
    349         shouldBeginObservingChanges = WebThreadContainsObservedDOMTimer(this);
     354    Page* page = nullptr;
     355    if (is<Document>(context) && downcast<Document>(context).page()) {
     356        page = downcast<Document>(context).page();
     357        auto& contentChangeObserver = page->contentChangeObserver();
     358        isObservingLastTimer = contentChangeObserver.countOfObservedDOMTimers() == 1;
     359        shouldBeginObservingChanges = contentChangeObserver.containsObservedDOMTimer(*this);
    350360    }
    351361
    352362    if (shouldBeginObservingChanges) {
    353         LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: start observing (" << this << ") timer callback.");
    354         WKStartObservingContentChanges();
    355         WKStartObservingStyleRecalcScheduling();
    356         WebThreadRemoveObservedDOMTimer(this);
     363        ASSERT(page);
     364        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: start observing (" << m_timeoutId << ") timer callback.");
     365        auto& contentChangeObserver = page->contentChangeObserver();
     366        contentChangeObserver.startObservingContentChanges();
     367        contentChangeObserver.startObservingStyleRecalcScheduling();
     368        contentChangeObserver.removeObservedDOMTimer(*this);
    357369    }
    358370#endif
     
    367379#if PLATFORM(IOS_FAMILY)
    368380    if (shouldBeginObservingChanges) {
    369         LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: stop observing (" << this << ") timer callback.");
    370         WKStopObservingStyleRecalcScheduling();
    371         WKStopObservingContentChanges();
    372 
    373         auto observedContentChange = WKObservedContentChange();
     381        ASSERT(page);
     382        LOG_WITH_STREAM(ContentObservation, stream << "DOMTimer::fired: stop observing (" << m_timeoutId << ") timer callback.");
     383        auto& contentChangeObserver = page->contentChangeObserver();
     384        contentChangeObserver.stopObservingStyleRecalcScheduling();
     385        contentChangeObserver.stopObservingContentChanges();
     386
     387        auto observedContentChange = contentChangeObserver.observedContentChange();
    374388        // Check if the timer callback triggered either a sync or async style update.
    375         auto inDeterminedState = observedContentChange == WKContentVisibilityChange || (isObversingLastTimer && observedContentChange == WKContentNoChange); 
     389        auto inDeterminedState = observedContentChange == WKContentVisibilityChange || (isObservingLastTimer && observedContentChange == WKContentNoChange); 
    376390        if (inDeterminedState) {
    377             LOG(ContentObservation, "DOMTimer::fired: in determined state.");
    378             auto& document = downcast<Document>(context);
    379             if (auto* page = document.page())
    380                 page->chrome().client().observedContentChange(*document.frame());
     391            LOG_WITH_STREAM(ContentObservation, "DOMTimer::fired(" << m_timeoutId << "): in determined state.");
     392            page->chrome().client().observedContentChange(*downcast<Document>(context).frame());
    381393        } else if (observedContentChange == WKContentIndeterminateChange) {
    382394            // An async style recalc has been scheduled. Let's observe it.
    383             LOG(ContentObservation, "DOMTimer::fired: wait until next style recalc fires.");
    384             WKSetShouldObserveNextStyleRecalc(true);
     395            LOG_WITH_STREAM(ContentObservation, "DOMTimer::fired(" << m_timeoutId << "): wait until next style recalc fires.");
     396            contentChangeObserver.setShouldObserveNextStyleRecalc(true);
    385397        }
    386398    }
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r241848 r242032  
    140140
    141141#if PLATFORM(IOS_FAMILY)
    142 #include "WKContentObservation.h"
    143 #include "WKContentObservationInternal.h"
    144 #endif
    145 
     142#include "ContentChangeObserver.h"
     143#endif
    146144
    147145namespace WebCore {
     
    16851683{
    16861684#if PLATFORM(IOS_FAMILY)
    1687     if (auto* frame = this->frame()) {
    1688         Document* document = frame->document();
    1689         if (timeoutId > 0 && document) {
    1690             DOMTimer* timer = document->findTimeout(timeoutId);
    1691             if (timer && WebThreadContainsObservedDOMTimer(timer)) {
    1692                 LOG_WITH_STREAM(ContentObservation, stream << "DOMWindow::clearTimeout: remove registered timer (" << timer << ")");
    1693                 WebThreadRemoveObservedDOMTimer(timer);
    1694 
    1695                 if (!WebThreadCountOfObservedDOMTimers()) {
    1696                     if (Page* page = frame->page())
    1697                         page->chrome().client().observedContentChange(*frame);
    1698                 }
    1699             }
    1700         }
    1701     }
     1685    auto handleObservedTimerCancelIfNeeded = [&] {
     1686        if (!frame() || !frame()->document() || !frame()->document()->page())
     1687            return;
     1688        if (timeoutId <= 0)
     1689            return;
     1690        auto& document = *frame()->document();
     1691        auto* timer = document.findTimeout(timeoutId);
     1692        if (!timer)
     1693            return;
     1694        auto& page = *document.page();
     1695        auto& contentChangeObserver = page.contentChangeObserver();
     1696        if (!contentChangeObserver.containsObservedDOMTimer(*timer))
     1697            return;
     1698        LOG_WITH_STREAM(ContentObservation, stream << "DOMWindow::clearTimeout: remove registered timer (" << timer << ")");
     1699        contentChangeObserver.removeObservedDOMTimer(*timer);
     1700        if (contentChangeObserver.countOfObservedDOMTimers())
     1701            return;
     1702        page.chrome().client().observedContentChange(*frame());
     1703    };
     1704    handleObservedTimerCancelIfNeeded();
    17021705#endif
    17031706    ScriptExecutionContext* context = scriptExecutionContext();
  • trunk/Source/WebCore/page/Frame.cpp

    r241331 r242032  
    109109
    110110#if PLATFORM(IOS_FAMILY)
    111 #include "WKContentObservation.h"
     111#include "ContentChangeObserver.h"
    112112#endif
    113113
     
    839839
    840840#if PLATFORM(IOS_FAMILY)
    841     if (WebThreadCountOfObservedDOMTimers() > 0 && m_page) {
     841    if (page() && page()->contentChangeObserver().countOfObservedDOMTimers()) {
    842842        LOG(ContentObservation, "Frame::willDetachPage: remove registered timers.");
    843843        m_page->chrome().client().clearContentChangeObservers(*this);
  • trunk/Source/WebCore/page/Page.h

    r241978 r242032  
    6565#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    6666#include "MediaPlaybackTargetContext.h"
     67#endif
     68
     69#if PLATFORM(IOS_FAMILY)
     70#include "ContentChangeObserver.h"
    6771#endif
    6872
     
    252256    PointerLockController& pointerLockController() const { return *m_pointerLockController; }
    253257#endif
     258#if PLATFORM(IOS_FAMILY)
     259    ContentChangeObserver& contentChangeObserver() { return m_contentChangeObserver; }
     260#endif
    254261    LibWebRTCProvider& libWebRTCProvider() { return m_libWebRTCProvider.get(); }
    255262    RTCController& rtcController() { return m_rtcController; }
     
    809816#if PLATFORM(IOS_FAMILY)
    810817    bool m_enclosedInScrollableAncestorView { false };
     818    ContentChangeObserver m_contentChangeObserver;
    811819#endif
    812820   
  • trunk/Source/WebCore/page/ios/EventHandlerIOS.mm

    r241044 r242032  
    3333#import "Chrome.h"
    3434#import "ChromeClient.h"
     35#import "ContentChangeObserver.h"
    3536#import "DataTransfer.h"
    3637#import "DragState.h"
     
    491492
    492493    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    493 
    494     m_frame.document()->updateStyleIfNeeded();
    495 
    496     WKStartObservingContentChanges();
    497     WKStartObservingDOMTimerScheduling();
     494    auto& document = *m_frame.document();
     495    // Ensure we start mouse move event dispatching on a clear tree.
     496    document.updateStyleIfNeeded();
     497
     498    auto& contentChangeObserver = document.page()->contentChangeObserver();
     499    contentChangeObserver.startObservingContentChanges();
     500    contentChangeObserver.startObservingDOMTimerScheduling();
     501
    498502    CurrentEventScope scope(event);
    499503    event.wasHandled = mouseMoved(currentPlatformMouseEvent());
    500    
    501     // FIXME: Why is this here?
    502     m_frame.document()->updateStyleIfNeeded();
    503     WKStopObservingDOMTimerScheduling();
    504     WKStopObservingContentChanges();
     504
     505    // Run style recalc to be able to capture content changes as the result of the mouse move event.
     506    document.updateStyleIfNeeded();
     507    contentChangeObserver.stopObservingDOMTimerScheduling();
     508    contentChangeObserver.stopObservingContentChanges();
    505509
    506510    END_BLOCK_OBJC_EXCEPTIONS;
  • trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp

    r239427 r242032  
    5151
    5252#if PLATFORM(IOS_FAMILY)
    53 #include "WKContentObservation.h"
    54 #include "WKContentObservationInternal.h"
     53#include "ContentChangeObserver.h"
    5554#endif
    5655
     
    6059class CheckForVisibilityChange {
    6160public:
    62     CheckForVisibilityChange(const Element&);
     61    CheckForVisibilityChange(const Element&, Page*);
    6362    ~CheckForVisibilityChange();
    6463
    6564private:
    6665    const Element& m_element;
     66    Page* m_page { nullptr };
    6767    DisplayType m_previousDisplay;
    6868    Visibility m_previousVisibility;
     
    309309{
    310310#if PLATFORM(IOS_FAMILY)
    311     CheckForVisibilityChange checkForVisibilityChange(element);
     311    CheckForVisibilityChange checkForVisibilityChange(element, m_document.page());
    312312#endif
    313313
     
    668668}
    669669
    670 CheckForVisibilityChange::CheckForVisibilityChange(const Element& element)
     670CheckForVisibilityChange::CheckForVisibilityChange(const Element& element, Page* page)
    671671    : m_element(element)
     672    , m_page(page)
    672673    , m_previousDisplay(element.renderStyle() ? element.renderStyle()->display() : DisplayType::None)
    673674    , m_previousVisibility(element.renderStyle() ? element.renderStyle()->visibility() : Visibility::Hidden)
    674     , m_previousImplicitVisibility(WKObservingContentChanges() && WKObservedContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : Visibility::Visible)
     675    , m_previousImplicitVisibility(page && page->contentChangeObserver().isObservingContentChanges() && page->contentChangeObserver().observedContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : Visibility::Visible)
    675676{
    676677}
     
    678679CheckForVisibilityChange::~CheckForVisibilityChange()
    679680{
    680     if (!WKObservingContentChanges())
     681    if (!m_page)
     682        return;
     683
     684    auto& contentChangeObserver = m_page->contentChangeObserver();
     685    if (!contentChangeObserver.isObservingContentChanges())
    681686        return;
    682687
     
    697702    if ((m_previousDisplay == DisplayType::None && style->display() != DisplayType::None) || (m_previousVisibility == Visibility::Hidden && style->visibility() != Visibility::Hidden)
    698703        || (m_previousImplicitVisibility == Visibility::Hidden && elementImplicitVisibility(m_element) == Visibility::Visible))
    699         WKSetObservedContentChange(WKContentVisibilityChange);
     704        contentChangeObserver.setObservedContentChange(WKContentVisibilityChange);
    700705}
    701706#endif
  • trunk/Source/WebKit/ChangeLog

    r242031 r242032  
     12019-02-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        Introduce ContentChangeObserver class
     4        https://bugs.webkit.org/show_bug.cgi?id=194977
     5        <rdar://problem/48338115>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebProcess/WebPage/ios/WebPageIOS.mm:
     10        (WebKit::WebPage::handleSyntheticClick):
     11        (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
     12
    1132019-02-24  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r241971 r242032  
    5858#import <WebCore/AutofillElements.h>
    5959#import <WebCore/Chrome.h>
     60#import <WebCore/ContentChangeObserver.h>
    6061#import <WebCore/DataDetection.h>
    6162#import <WebCore/DiagnosticLoggingClient.h>
     
    114115#import <WebCore/TextIterator.h>
    115116#import <WebCore/VisibleUnits.h>
    116 #import <WebCore/WKContentObservation.h>
    117117#import <WebCore/WebEvent.h>
    118118#import <wtf/MathExtras.h>
     
    539539{
    540540    IntPoint roundedAdjustedPoint = roundedIntPoint(location);
    541     Frame& mainframe = m_page->mainFrame();
     541    auto& mainframe = m_page->mainFrame();
     542    auto& contentChangeObserver = m_page->contentChangeObserver();
    542543
    543544    LOG_WITH_STREAM(ContentObservation, stream << "handleSyntheticClick: node(" << nodeRespondingToClick << ") " << location);
    544     WKStartObservingContentChanges();
    545     WKStartObservingDOMTimerScheduling();
     545    contentChangeObserver.startObservingContentChanges();
     546    contentChangeObserver.startObservingDOMTimerScheduling();
    546547
    547548    // FIXME: Pass caps lock state.
     
    553554    mainframe.document()->updateStyleIfNeeded();
    554555
    555     WKStopObservingDOMTimerScheduling();
    556     WKStopObservingContentChanges();
     556    contentChangeObserver.stopObservingDOMTimerScheduling();
     557    contentChangeObserver.stopObservingContentChanges();
    557558
    558559    m_pendingSyntheticClickNode = nullptr;
     
    563564        return;
    564565
    565     switch (WKObservedContentChange()) {
     566    switch (contentChangeObserver.observedContentChange()) {
    566567    case WKContentVisibilityChange:
    567568        // The move event caused new contents to appear. Don't send the click event.
     
    589590        return;
    590591    // Only dispatch the click if the document didn't get changed by any timers started by the move event.
    591     if (WKObservedContentChange() == WKContentNoChange) {
     592    if (m_page->contentChangeObserver().observedContentChange() == WKContentNoChange) {
    592593        LOG(ContentObservation, "No chage was observed -> click.");
    593594        completeSyntheticClick(m_pendingSyntheticClickNode.get(), m_pendingSyntheticClickLocation, m_pendingSyntheticClickModifiers, WebCore::OneFingerTap);
  • trunk/Source/WebKitLegacy/ios/ChangeLog

    r241654 r242032  
     12019-02-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        Introduce ContentChangeObserver class
     4        https://bugs.webkit.org/show_bug.cgi?id=194977
     5        <rdar://problem/48338115>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebCoreSupport/WebChromeClientIOS.mm:
     10        (WebChromeClientIOS::observedContentChange):
     11        (WebChromeClientIOS::clearContentChangeObservers):
     12
    1132019-02-17  David Kilzer  <ddkilzer@apple.com>
    214
  • trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm

    r239658 r242032  
    4545#import "WebViewInternal.h"
    4646#import "WebViewPrivate.h"
     47#import <WebCore/ContentChangeObserver.h>
    4748#import <WebCore/DisabledAdaptations.h>
    4849#import <WebCore/FileChooser.h>
     
    184185void WebChromeClientIOS::observedContentChange(WebCore::Frame& frame)
    185186{
    186     [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:WKObservedContentChange() forFrame:kit(&frame)];
     187    if (!frame.page())
     188        return;
     189    [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:frame.page()->contentChangeObserver().observedContentChange() forFrame:kit(&frame)];
    187190}
    188191
    189192void WebChromeClientIOS::clearContentChangeObservers(WebCore::Frame& frame)
    190193{
    191     ASSERT(WebThreadCountOfObservedDOMTimers() > 0);
    192     if (WebThreadCountOfObservedDOMTimers() > 0) {
    193         WebThreadClearObservedDOMTimers();
    194         observedContentChange(frame);
    195     }
     194    if (!frame.page())
     195        return;
     196    auto& contentChangeObserver = frame.page()->contentChangeObserver();
     197    ASSERT(contentChangeObserver.countOfObservedDOMTimers());
     198    if (!contentChangeObserver.countOfObservedDOMTimers())
     199        return;
     200    contentChangeObserver.clearObservedDOMTimers();
     201    observedContentChange(frame);
    196202}
    197203
Note: See TracChangeset for help on using the changeset viewer.