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

Changeset 242340 in webkit


Ignore:
Timestamp:
Mar 3, 2019, 10:05:44 PM (7 years ago)
Author:
Alan Bujtas
Message:

[ContentChangeObserver] Content observation should be limited to the current document.
https://bugs.webkit.org/show_bug.cgi?id=195256
<rdar://problem/48544402>

Source/WebCore:

Move ContentChangeObserver from Page to Document.
It limits content observation to the target node's owner document.

Reviewed by Simon Fraser.

  • dom/Document.cpp:

(WebCore::m_contentChangeObserver):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::willDetachPage):
(WebCore::Document::platformSuspendOrStopActiveDOMObjects):
(WebCore::m_undoManager): Deleted.

  • dom/Document.h:

(WebCore::Document::contentChangeObserver):

  • page/DOMTimer.cpp:

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

  • page/Frame.cpp:

(WebCore::Frame::willDetachPage):

  • page/Page.cpp:

(WebCore::Page::Page):

  • page/Page.h:

(WebCore::Page::pointerLockController const):
(WebCore::Page::contentChangeObserver): Deleted.

  • page/ios/ContentChangeObserver.cpp:

(WebCore::ContentChangeObserver::ContentChangeObserver):
(WebCore::ContentChangeObserver::didInstallDOMTimer):
(WebCore::ContentChangeObserver::stopObservingDOMTimerExecute):
(WebCore::ContentChangeObserver::stopObservingStyleRecalc):
(WebCore::ContentChangeObserver::clearTimersAndReportContentChange):
(WebCore::ContentChangeObserver::startObservingMouseMoved):
(WebCore::ContentChangeObserver::hasDeterminateState const):
(WebCore::ContentChangeObserver::adjustObservedState):
(WebCore::ContentChangeObserver::notifyContentChangeIfNeeded):
(WebCore::ContentChangeObserver::StyleChangeScope::StyleChangeScope):
(WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope):
(WebCore::ContentChangeObserver::MouseMovedScope::MouseMovedScope):
(WebCore::ContentChangeObserver::MouseMovedScope::~MouseMovedScope):
(WebCore::ContentChangeObserver::StyleRecalcScope::StyleRecalcScope):
(WebCore::ContentChangeObserver::StyleRecalcScope::~StyleRecalcScope):
(WebCore::ContentChangeObserver::DOMTimerScope::DOMTimerScope):
(WebCore::ContentChangeObserver::DOMTimerScope::~DOMTimerScope):
(WebCore::hasPendingStyleRecalc): Deleted.

  • page/ios/ContentChangeObserver.h:
  • page/ios/EventHandlerIOS.mm:

(WebCore::EventHandler::mouseMoved):

  • rendering/updating/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::updateElementRenderer):

Source/WebKit:

Reviewed by Simon Fraser.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::handleSyntheticClick):
(WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
(WebKit::WebPage::completeSyntheticClick):
(WebKit::WebPage::handleTap):
(WebKit::WebPage::handleTwoFingerTapAtPoint):
(WebKit::WebPage::commitPotentialTap):

Source/WebKitLegacy/ios:

Reviewed by Simon Fraser.

  • WebCoreSupport/WebChromeClientIOS.mm:

(WebChromeClientIOS::observedContentChange):

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242333 r242340  
     12019-03-03  Zalan Bujtas  <zalan@apple.com>
     2
     3        [ContentChangeObserver] Content observation should be limited to the current document.
     4        https://bugs.webkit.org/show_bug.cgi?id=195256
     5        <rdar://problem/48544402>
     6
     7        Move ContentChangeObserver from Page to Document.
     8        It limits content observation to the target node's owner document.
     9
     10        Reviewed by Simon Fraser.
     11
     12        * dom/Document.cpp:
     13        (WebCore::m_contentChangeObserver):
     14        (WebCore::Document::updateStyleIfNeeded):
     15        (WebCore::Document::willDetachPage):
     16        (WebCore::Document::platformSuspendOrStopActiveDOMObjects):
     17        (WebCore::m_undoManager): Deleted.
     18        * dom/Document.h:
     19        (WebCore::Document::contentChangeObserver):
     20        * page/DOMTimer.cpp:
     21        (WebCore::DOMTimer::install):
     22        (WebCore::DOMTimer::removeById):
     23        (WebCore::DOMTimer::fired):
     24        * page/Frame.cpp:
     25        (WebCore::Frame::willDetachPage):
     26        * page/Page.cpp:
     27        (WebCore::Page::Page):
     28        * page/Page.h:
     29        (WebCore::Page::pointerLockController const):
     30        (WebCore::Page::contentChangeObserver): Deleted.
     31        * page/ios/ContentChangeObserver.cpp:
     32        (WebCore::ContentChangeObserver::ContentChangeObserver):
     33        (WebCore::ContentChangeObserver::didInstallDOMTimer):
     34        (WebCore::ContentChangeObserver::stopObservingDOMTimerExecute):
     35        (WebCore::ContentChangeObserver::stopObservingStyleRecalc):
     36        (WebCore::ContentChangeObserver::clearTimersAndReportContentChange):
     37        (WebCore::ContentChangeObserver::startObservingMouseMoved):
     38        (WebCore::ContentChangeObserver::hasDeterminateState const):
     39        (WebCore::ContentChangeObserver::adjustObservedState):
     40        (WebCore::ContentChangeObserver::notifyContentChangeIfNeeded):
     41        (WebCore::ContentChangeObserver::StyleChangeScope::StyleChangeScope):
     42        (WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope):
     43        (WebCore::ContentChangeObserver::MouseMovedScope::MouseMovedScope):
     44        (WebCore::ContentChangeObserver::MouseMovedScope::~MouseMovedScope):
     45        (WebCore::ContentChangeObserver::StyleRecalcScope::StyleRecalcScope):
     46        (WebCore::ContentChangeObserver::StyleRecalcScope::~StyleRecalcScope):
     47        (WebCore::ContentChangeObserver::DOMTimerScope::DOMTimerScope):
     48        (WebCore::ContentChangeObserver::DOMTimerScope::~DOMTimerScope):
     49        (WebCore::hasPendingStyleRecalc): Deleted.
     50        * page/ios/ContentChangeObserver.h:
     51        * page/ios/EventHandlerIOS.mm:
     52        (WebCore::EventHandler::mouseMoved):
     53        * rendering/updating/RenderTreeUpdater.cpp:
     54        (WebCore::RenderTreeUpdater::updateElementRenderer):
     55
    1562019-03-02  Simon Fraser  <simon.fraser@apple.com>
    257
  • trunk/Source/WebCore/dom/Document.cpp

    r242308 r242340  
    20522052
    20532053#if PLATFORM(IOS_FAMILY)
    2054     ContentChangeObserver::StyleRecalcScope observingScope(page());
     2054    ContentChangeObserver::StyleRecalcScope observingScope(*this);
    20552055#endif
    20562056    // The early exit above for !needsStyleRecalc() is needed when updateWidgetPositions() is called in runOrScheduleAsynchronousTasks().
     
    23842384{
    23852385    FrameDestructionObserver::willDetachPage();
    2386 
     2386#if PLATFORM(IOS_FAMILY)
     2387    contentChangeObserver().willDetachPage();
     2388#endif
    23872389    if (domWindow() && frame())
    23882390        InspectorInstrumentation::frameWindowDiscarded(*frame(), domWindow());
     
    26332635{
    26342636#if PLATFORM(IOS_FAMILY)
    2635     if (auto* page = this->page())
    2636         page->contentChangeObserver().didSuspendActiveDOMObjects();
     2637    contentChangeObserver().didSuspendActiveDOMObjects();
    26372638#endif
    26382639}
     
    86848685#endif
    86858686
     8687#if PLATFORM(IOS_FAMILY)
     8688ContentChangeObserver& Document::contentChangeObserver()
     8689{
     8690    if (!m_contentChangeObserver)
     8691        m_contentChangeObserver = std::make_unique<ContentChangeObserver>(*this);
     8692    return *m_contentChangeObserver;
     8693}
     8694#endif
     8695
    86868696} // namespace WebCore
  • trunk/Source/WebCore/dom/Document.h

    r242137 r242340  
    100100class Comment;
    101101class ConstantPropertyMap;
     102class ContentChangeObserver;
    102103class DOMImplementation;
    103104class DOMSelection;
     
    872873    // Called when <meta name="apple-mobile-web-app-orientations"> changes.
    873874    void processWebAppOrientations();
     875
     876    ContentChangeObserver& contentChangeObserver();
    874877#endif
    875878   
     
    20782081
    20792082    Ref<UndoManager> m_undoManager;
     2083#if PLATFORM(IOS_FAMILY)
     2084    std::unique_ptr<ContentChangeObserver> m_contentChangeObserver;
     2085#endif
    20802086};
    20812087
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r242253 r242340  
    223223        nestedTimers->add(timer->m_timeoutId, *timer);
    224224#if PLATFORM(IOS_FAMILY)
    225     if (is<Document>(context) && downcast<Document>(context).page())
    226         downcast<Document>(context).page()->contentChangeObserver().didInstallDOMTimer(*timer, timeout, singleShot);
     225    if (is<Document>(context))
     226        downcast<Document>(context).contentChangeObserver().didInstallDOMTimer(*timer, timeout, singleShot);
    227227#endif
    228228    return timer->m_timeoutId;
     
    238238
    239239#if PLATFORM(IOS_FAMILY)
    240     if (is<Document>(context) && downcast<Document>(context).page()) {
     240    if (is<Document>(context)) {
    241241        auto& document = downcast<Document>(context);
    242242        if (auto* timer = document.findTimeout(timeoutId))
    243             document.page()->contentChangeObserver().didRemoveDOMTimer(*timer);
     243            document.contentChangeObserver().didRemoveDOMTimer(*timer);
    244244    }
    245245#endif
     
    344344
    345345#if PLATFORM(IOS_FAMILY)
    346     ContentChangeObserver::DOMTimerScope observingScope(is<Document>(context) ? downcast<Document>(context).page() : nullptr, *this);
     346    ContentChangeObserver::DOMTimerScope observingScope(is<Document>(context) ? &downcast<Document>(context) : nullptr, *this);
    347347#endif
    348348    m_action->execute(context);
  • trunk/Source/WebCore/page/Frame.cpp

    r242317 r242340  
    108108#include <wtf/text/StringBuilder.h>
    109109
    110 #if PLATFORM(IOS_FAMILY)
    111 #include "ContentChangeObserver.h"
    112 #endif
    113 
    114110namespace WebCore {
    115111
     
    844840        page()->scrollingCoordinator()->willDestroyScrollableArea(*m_view);
    845841
    846 #if PLATFORM(IOS_FAMILY)
    847     if (auto* page = this->page())
    848         page->contentChangeObserver().willDetachPage();
    849 #endif
    850 
    851842    script().clearScriptObjects();
    852843    script().updatePlatformScriptObjects();
  • trunk/Source/WebCore/page/Page.cpp

    r242113 r242340  
    150150#endif
    151151
    152 #if PLATFORM(IOS_FAMILY)
    153 #include "ContentChangeObserver.h"
    154 #endif
    155 
    156152namespace WebCore {
    157153
     
    236232    , m_webGLStateTracker(WTFMove(pageConfiguration.webGLStateTracker))
    237233    , m_libWebRTCProvider(WTFMove(pageConfiguration.libWebRTCProvider))
    238 #if PLATFORM(IOS_FAMILY)
    239     , m_contentChangeObserver(std::make_unique<ContentChangeObserver>(*this))
    240 #endif
    241234    , m_verticalScrollElasticity(ScrollElasticityAllowed)
    242235    , m_horizontalScrollElasticity(ScrollElasticityAllowed)
  • trunk/Source/WebCore/page/Page.h

    r242113 r242340  
    8787class ChromeClient;
    8888class Color;
    89 #if PLATFORM(IOS_FAMILY)
    90 class ContentChangeObserver;
    91 #endif
    9289class ContextMenuClient;
    9390class ContextMenuController;
     
    256253    PointerLockController& pointerLockController() const { return *m_pointerLockController; }
    257254#endif
    258 #if PLATFORM(IOS_FAMILY)
    259     ContentChangeObserver& contentChangeObserver() { return *m_contentChangeObserver; }
    260 #endif
    261255    LibWebRTCProvider& libWebRTCProvider() { return m_libWebRTCProvider.get(); }
    262256    RTCController& rtcController() { return m_rtcController; }
     
    819813#if PLATFORM(IOS_FAMILY)
    820814    bool m_enclosedInScrollableAncestorView { false };
    821     std::unique_ptr<ContentChangeObserver> m_contentChangeObserver;
    822815#endif
    823816   
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp

    r242324 r242340  
    3030#include "ChromeClient.h"
    3131#include "DOMTimer.h"
     32#include "Document.h"
    3233#include "Logging.h"
    3334#include "NodeRenderStyle.h"
     
    3637namespace WebCore {
    3738
    38 static bool hasPendingStyleRecalc(const Page& page)
    39 {
    40     for (auto* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    41         if (auto* document = frame->document()) {
    42             if (document->hasPendingStyleRecalc())
    43                 return true;
    44         }
    45     }
    46     return false;
    47 }
    48 
    49 ContentChangeObserver::ContentChangeObserver(Page& page)
    50     : m_page(page)
     39ContentChangeObserver::ContentChangeObserver(Document& document)
     40    : m_document(document)
    5141{
    5242}
     
    5444void ContentChangeObserver::didInstallDOMTimer(const DOMTimer& timer, Seconds timeout, bool singleShot)
    5545{
    56     if (!m_page.mainFrame().document())
    57         return;
    58     if (m_page.mainFrame().document()->activeDOMObjectsAreSuspended())
     46    if (m_document.activeDOMObjectsAreSuspended())
    5947        return;
    6048    if (timeout > 250_ms || !singleShot)
     
    9684    m_isObservingContentChanges = false;
    9785    unregisterDOMTimer(timer);
    98     setShouldObserveStyleRecalc(WebCore::hasPendingStyleRecalc(m_page));
     86    setShouldObserveStyleRecalc(m_document.hasPendingStyleRecalc());
    9987    notifyContentChangeIfNeeded();
    10088}
     
    118106
    119107    setShouldObserveStyleRecalc(false);
     108    m_isObservingContentChanges = false;
    120109    adjustObservedState(Event::StyleRecalcFinished);
    121110    notifyContentChangeIfNeeded();
     
    129118
    130119    clearObservedDOMTimers();
    131     m_page.chrome().client().observedContentChange(m_page.mainFrame());
     120    ASSERT(m_document.page());
     121    ASSERT(m_document.frame());
     122    m_document.page()->chrome().client().observedContentChange(*m_document.frame());
    132123}
    133124
     
    150141void ContentChangeObserver::startObservingMouseMoved()
    151142{
    152     ASSERT(!hasPendingStyleRecalc(m_page));
     143    ASSERT(!m_document.hasPendingStyleRecalc());
    153144    clearObservedDOMTimers();
    154145    startObservingDOMTimerScheduling();
     
    191182    if (hasVisibleChangeState())
    192183        return true;
    193     return observedContentChange() == WKContentNoChange && !hasObservedDOMTimer() && !hasPendingStyleRecalc(m_page);
     184    return observedContentChange() == WKContentNoChange && !hasObservedDOMTimer() && !m_document.hasPendingStyleRecalc();
    194185}
    195186
     
    208199    case Event::StyleRecalcFinished:
    209200        // Demote to "no change" when there's no pending activity anymore.
    210         if (observedContentChange() == WKContentIndeterminateChange && !hasObservedDOMTimer() && !hasPendingStyleRecalc(m_page))
     201        if (observedContentChange() == WKContentIndeterminateChange && !hasObservedDOMTimer() && !m_document.hasPendingStyleRecalc())
    211202            setHasNoChangeState();
    212203        break;
     
    224215    }
    225216    LOG_WITH_STREAM(ContentObservation, stream << "notifyContentChangeIfNeeded: sending observedContentChange ->" << observedContentChange());
    226     m_page.chrome().client().observedContentChange(m_page.mainFrame());
     217    ASSERT(m_document.page());
     218    ASSERT(m_document.frame());
     219    m_document.page()->chrome().client().observedContentChange(*m_document.frame());
    227220}
    228221
     
    251244}
    252245
    253 ContentChangeObserver::StyleChangeScope::StyleChangeScope(Page* page, const Element& element)
    254     : m_contentChangeObserver(page ? &page->contentChangeObserver() : nullptr)
     246ContentChangeObserver::StyleChangeScope::StyleChangeScope(Document& document, const Element& element)
     247    : m_contentChangeObserver(document.contentChangeObserver())
    255248    , m_element(element)
    256     , m_needsObserving(m_contentChangeObserver && m_contentChangeObserver->isObservingContentChanges() && m_contentChangeObserver->observedContentChange() != WKContentVisibilityChange)
     249    , m_needsObserving(m_contentChangeObserver.isObservingContentChanges() && m_contentChangeObserver.observedContentChange() != WKContentVisibilityChange)
    257250{
    258251    if (m_needsObserving) {
     
    285278        || (m_previousVisibility == Visibility::Hidden && style->visibility() != Visibility::Hidden)
    286279        || (m_previousImplicitVisibility == Visibility::Hidden && elementImplicitVisibility(m_element) == Visibility::Visible))
    287         m_contentChangeObserver->contentVisibilityDidChange();
    288 }
    289 
    290 ContentChangeObserver::MouseMovedScope::MouseMovedScope(Page* page)
    291     : m_contentChangeObserver(page ? &page->contentChangeObserver() : nullptr)
    292 {
    293     if (m_contentChangeObserver)
    294         m_contentChangeObserver->startObservingMouseMoved();
     280        m_contentChangeObserver.contentVisibilityDidChange();
     281}
     282
     283ContentChangeObserver::MouseMovedScope::MouseMovedScope(Document& document)
     284    : m_contentChangeObserver(document.contentChangeObserver())
     285{
     286    m_contentChangeObserver.startObservingMouseMoved();
    295287}
    296288
    297289ContentChangeObserver::MouseMovedScope::~MouseMovedScope()
    298290{
    299     if (m_contentChangeObserver)
    300         m_contentChangeObserver->stopObservingMouseMoved();
    301 }
    302 
    303 ContentChangeObserver::StyleRecalcScope::StyleRecalcScope(Page* page)
    304     : m_contentChangeObserver(page ? &page->contentChangeObserver() : nullptr)
    305 {
    306     if (m_contentChangeObserver)
    307         m_contentChangeObserver->startObservingStyleRecalc();
     291    m_contentChangeObserver.stopObservingMouseMoved();
     292}
     293
     294ContentChangeObserver::StyleRecalcScope::StyleRecalcScope(Document& document)
     295    : m_contentChangeObserver(document.contentChangeObserver())
     296{
     297    m_contentChangeObserver.startObservingStyleRecalc();
    308298}
    309299
    310300ContentChangeObserver::StyleRecalcScope::~StyleRecalcScope()
    311301{
    312     if (m_contentChangeObserver)
    313         m_contentChangeObserver->stopObservingStyleRecalc();
    314 }
    315 
    316 ContentChangeObserver::DOMTimerScope::DOMTimerScope(Page* page, const DOMTimer& domTimer)
    317     : m_contentChangeObserver(page ? &page->contentChangeObserver() : nullptr)
     302    m_contentChangeObserver.stopObservingStyleRecalc();
     303}
     304
     305ContentChangeObserver::DOMTimerScope::DOMTimerScope(Document* document, const DOMTimer& domTimer)
     306    : m_contentChangeObserver(document ? &document->contentChangeObserver() : nullptr)
    318307    , m_domTimer(domTimer)
    319308{
  • trunk/Source/WebCore/page/ios/ContentChangeObserver.h

    r242324 r242340  
    3333
    3434class DOMTimer;
    35 class Page;
     35class Document;
    3636
    3737class ContentChangeObserver {
    3838public:
    39     ContentChangeObserver(Page&);
     39    ContentChangeObserver(Document&);
    4040
    4141    WEBCORE_EXPORT WKContentChange observedContentChange() const;
     
    4949    class StyleChangeScope {
    5050    public:
    51         StyleChangeScope(Page*, const Element&);
     51        StyleChangeScope(Document&, const Element&);
    5252        ~StyleChangeScope();
    5353
    5454    private:
    55         ContentChangeObserver* m_contentChangeObserver { nullptr };
     55        ContentChangeObserver& m_contentChangeObserver;
    5656        const Element& m_element;
    5757        bool m_needsObserving { false };
     
    6363    class MouseMovedScope {
    6464    public:
    65         WEBCORE_EXPORT MouseMovedScope(Page*);
     65        WEBCORE_EXPORT MouseMovedScope(Document&);
    6666        WEBCORE_EXPORT ~MouseMovedScope();
    6767    private:
    68         ContentChangeObserver* m_contentChangeObserver { nullptr };
     68        ContentChangeObserver& m_contentChangeObserver;
    6969    };
    7070
    7171    class StyleRecalcScope {
    7272    public:
    73         StyleRecalcScope(Page*);
     73        StyleRecalcScope(Document&);
    7474        ~StyleRecalcScope();
    7575    private:
    76         ContentChangeObserver* m_contentChangeObserver { nullptr };
     76        ContentChangeObserver& m_contentChangeObserver;
    7777    };
    7878
    7979    class DOMTimerScope {
    8080    public:
    81         DOMTimerScope(Page*, const DOMTimer&);
     81        DOMTimerScope(Document*, const DOMTimer&);
    8282        ~DOMTimerScope();
    8383    private:
     
    131131    void adjustObservedState(Event);
    132132
    133     Page& m_page;
     133    Document& m_document;
    134134    HashSet<const DOMTimer*> m_DOMTimerList;
    135135    bool m_shouldObserveStyleRecalc { false };
  • trunk/Source/WebCore/page/ios/EventHandlerIOS.mm

    r242324 r242340  
    497497    CurrentEventScope scope(event);
    498498    {
    499         ContentChangeObserver::MouseMovedScope observingScope(document.page());
     499        ContentChangeObserver::MouseMovedScope observingScope(document);
    500500        event.wasHandled = mouseMoved(currentPlatformMouseEvent());
    501501        // Run style recalc to be able to capture content changes as the result of the mouse move event.
  • trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp

    r242234 r242340  
    294294{
    295295#if PLATFORM(IOS_FAMILY)
    296     ContentChangeObserver::StyleChangeScope observingScope(m_document.page(), element);
     296    ContentChangeObserver::StyleChangeScope observingScope(m_document, element);
    297297#endif
    298298
  • trunk/Source/WebKit/ChangeLog

    r242339 r242340  
     12019-03-03  Zalan Bujtas  <zalan@apple.com>
     2
     3        [ContentChangeObserver] Content observation should be limited to the current document.
     4        https://bugs.webkit.org/show_bug.cgi?id=195256
     5        <rdar://problem/48544402>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebProcess/WebPage/WebPage.h:
     10        * WebProcess/WebPage/ios/WebPageIOS.mm:
     11        (WebKit::WebPage::handleSyntheticClick):
     12        (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
     13        (WebKit::WebPage::completeSyntheticClick):
     14        (WebKit::WebPage::handleTap):
     15        (WebKit::WebPage::handleTwoFingerTapAtPoint):
     16        (WebKit::WebPage::commitPotentialTap):
     17
    1182019-03-03  Tim Horton  <timothy_horton@apple.com>
    219
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r242317 r242340  
    11901190    void getFocusedElementInformation(FocusedElementInformation&);
    11911191    void platformInitializeAccessibility();
    1192     void handleSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>);
    1193     void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::SyntheticClickType);
     1192    void handleSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>);
     1193    void completeSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::SyntheticClickType);
    11941194    void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
    11951195    void resetTextAutosizing();
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r242324 r242340  
    536536}
    537537
    538 void WebPage::handleSyntheticClick(Node* nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers)
     538void WebPage::handleSyntheticClick(Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers)
    539539{
    540540    IntPoint roundedAdjustedPoint = roundedIntPoint(location);
    541     auto& mainframe = m_page->mainFrame();
    542     auto& contentChangeObserver = m_page->contentChangeObserver();
    543 
     541    auto& respondingDocument = nodeRespondingToClick.document();
    544542    // FIXME: Pass caps lock state.
    545543    bool shiftKey = modifiers.contains(WebEvent::Modifier::ShiftKey);
     
    548546    bool metaKey = modifiers.contains(WebEvent::Modifier::MetaKey);
    549547    {
    550         LOG_WITH_STREAM(ContentObservation, stream << "handleSyntheticClick: node(" << nodeRespondingToClick << ") " << location);
    551         ContentChangeObserver::MouseMovedScope observingScope(m_page.get());
     548        LOG_WITH_STREAM(ContentObservation, stream << "handleSyntheticClick: node(" << &nodeRespondingToClick << ") " << location);
     549        ContentChangeObserver::MouseMovedScope observingScope(respondingDocument);
     550        auto& mainframe = m_page->mainFrame();
    552551        mainframe.eventHandler().mouseMoved(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap));
    553552        mainframe.document()->updateStyleIfNeeded();
     
    561560        return;
    562561
    563     switch (contentChangeObserver.observedContentChange()) {
     562    switch (respondingDocument.contentChangeObserver().observedContentChange()) {
    564563    case WKContentVisibilityChange:
    565564        // The move event caused new contents to appear. Don't send the click event.
     
    568567    case WKContentIndeterminateChange: {
    569568        // Wait for callback to completePendingSyntheticClickForContentChangeObserver() to decide whether to send the click event.
    570         m_pendingSyntheticClickNode = nodeRespondingToClick;
     569        m_pendingSyntheticClickNode = &nodeRespondingToClick;
    571570        m_pendingSyntheticClickLocation = location;
    572571        m_pendingSyntheticClickModifiers = modifiers;
     
    586585    if (!m_pendingSyntheticClickNode)
    587586        return;
     587    auto observedContentChange = m_pendingSyntheticClickNode->document().contentChangeObserver().observedContentChange();
    588588    // Only dispatch the click if the document didn't get changed by any timers started by the move event.
    589     if (m_page->contentChangeObserver().observedContentChange() == WKContentNoChange) {
     589    if (observedContentChange == WKContentNoChange) {
    590590        LOG(ContentObservation, "No chage was observed -> click.");
    591         completeSyntheticClick(m_pendingSyntheticClickNode.get(), m_pendingSyntheticClickLocation, m_pendingSyntheticClickModifiers, WebCore::OneFingerTap);
     591        completeSyntheticClick(*m_pendingSyntheticClickNode, m_pendingSyntheticClickLocation, m_pendingSyntheticClickModifiers, WebCore::OneFingerTap);
    592592    } else
    593593        LOG(ContentObservation, "Observed meaningful visible change -> hover.");
     
    598598}
    599599
    600 void WebPage::completeSyntheticClick(Node* nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers, SyntheticClickType syntheticClickType)
     600void WebPage::completeSyntheticClick(Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers, SyntheticClickType syntheticClickType)
    601601{
    602602    IntPoint roundedAdjustedPoint = roundedIntPoint(location);
     
    635635        elementDidRefocus(*newFocusedElement);
    636636
    637     if (!tapWasHandled || !nodeRespondingToClick || !nodeRespondingToClick->isElementNode())
     637    if (!tapWasHandled || !nodeRespondingToClick.isElementNode())
    638638        send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(location)));
    639639   
     
    658658#endif
    659659    else
    660         handleSyntheticClick(nodeRespondingToClick, adjustedPoint, modifiers);
     660        handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers);
    661661}
    662662
     
    769769    } else
    770770#endif
    771         completeSyntheticClick(nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap);
     771        completeSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap);
    772772}
    773773
     
    838838        } else
    839839#endif
    840             handleSyntheticClick(nodeRespondingToClick, adjustedPoint, modifiers);
     840            handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers);
    841841    } else
    842842        commitPotentialTapFailed();
  • trunk/Source/WebKitLegacy/ios/ChangeLog

    r242108 r242340  
     12019-03-03  Zalan Bujtas  <zalan@apple.com>
     2
     3        [ContentChangeObserver] Content observation should be limited to the current document.
     4        https://bugs.webkit.org/show_bug.cgi?id=195256
     5        <rdar://problem/48544402>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebCoreSupport/WebChromeClientIOS.mm:
     10        (WebChromeClientIOS::observedContentChange):
     11
    1122019-02-26  Zalan Bujtas  <zalan@apple.com>
    213
  • trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm

    r242108 r242340  
    185185void WebChromeClientIOS::observedContentChange(WebCore::Frame& frame)
    186186{
    187     if (!frame.page())
     187    if (!frame.document())
    188188        return;
    189     [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:frame.page()->contentChangeObserver().observedContentChange() forFrame:kit(&frame)];
     189    [[webView() _UIKitDelegateForwarder] webView:webView() didObserveDeferredContentChange:frame.document()->contentChangeObserver().observedContentChange() forFrame:kit(&frame)];
    190190}
    191191
Note: See TracChangeset for help on using the changeset viewer.