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

Changeset 243557 in webkit


Ignore:
Timestamp:
Mar 27, 2019, 12:41:22 PM (7 years ago)
Author:
Alan Bujtas
Message:

[ContentChangeObserver] Always dispatch the synthetic click asynchronously
https://bugs.webkit.org/show_bug.cgi?id=196278
<rdar://problem/49299968>

Reviewed by Simon Fraser.

This patch ensures that all completeSyntheticClick() calls happen in an asynchronous manner (unless the feature is turned off).

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::dispatchSyntheticMouseMove):
(WebKit::WebPage::handleSyntheticClick):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r243553 r243557  
     12019-03-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        [ContentChangeObserver] Always dispatch the synthetic click asynchronously
     4        https://bugs.webkit.org/show_bug.cgi?id=196278
     5        <rdar://problem/49299968>
     6
     7        Reviewed by Simon Fraser.
     8
     9        This patch ensures that all completeSyntheticClick() calls happen in an asynchronous manner (unless the feature is turned off).
     10
     11        * WebProcess/WebPage/ios/WebPageIOS.mm:
     12        (WebKit::dispatchSyntheticMouseMove):
     13        (WebKit::WebPage::handleSyntheticClick):
     14
    1152019-03-27  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r243415 r243557  
    562562    auto metaKey = modifiers.contains(WebEvent::Modifier::MetaKey);
    563563    auto mouseEvent = PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, NoButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap);
     564    // FIXME: Pass caps lock state.
    564565    mainFrame.eventHandler().dispatchSyntheticMouseMove(mouseEvent);
    565566}
     
    567568void WebPage::handleSyntheticClick(Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebEvent::Modifier> modifiers)
    568569{
     570    if (!nodeRespondingToClick.document().settings().contentChangeObserverEnabled()) {
     571        completeSyntheticClick(nodeRespondingToClick, location, modifiers, WebCore::OneFingerTap);
     572        return;
     573    }
     574
    569575    auto& respondingDocument = nodeRespondingToClick.document();
    570     auto& mainFrame = m_page->mainFrame();
    571     // FIXME: Pass caps lock state.
    572576    {
    573577        LOG_WITH_STREAM(ContentObservation, stream << "handleSyntheticClick: node(" << &nodeRespondingToClick << ") " << location);
    574578        ContentChangeObserver::MouseMovedScope observingScope(respondingDocument);
     579        auto& mainFrame = m_page->mainFrame();
    575580        dispatchSyntheticMouseMove(mainFrame, location, modifiers);
    576581        mainFrame.document()->updateStyleIfNeeded();
     
    580585        return;
    581586
    582     if (is<HTMLFormControlElement>(nodeRespondingToClick)) {
    583         LOG(ContentObservation, "handleSyntheticClick: Target node is a form control -> click.");
    584         completeSyntheticClick(nodeRespondingToClick, location, modifiers, WebCore::OneFingerTap);
    585         return;
    586     }
    587587    auto& contentChangeObserver = respondingDocument.contentChangeObserver();
    588588    auto observedContentChange = contentChangeObserver.observedContentChange();
    589     if (observedContentChange == WKContentVisibilityChange) {
    590         // The move event caused new contents to appear. Don't send the click event, but just ensure that the mouse is on the most recent content.
    591         dispatchSyntheticMouseMove(mainFrame, location, modifiers);
    592         LOG(ContentObservation, "handleSyntheticClick: Observed meaningful visible change -> hover.");
    593         return;
    594     }
    595     const Seconds observationDuration = 32_ms;
    596     contentChangeObserver.startContentObservationForDuration(observationDuration);
    597     if (contentChangeObserver.observedContentChange() == WKContentNoChange) {
    598         ASSERT(!respondingDocument.settings().contentChangeObserverEnabled());
    599         completeSyntheticClick(nodeRespondingToClick, location, modifiers, WebCore::OneFingerTap);
    600         return;
    601     }
    602 
    603     LOG(ContentObservation, "handleSyntheticClick: Can't decide it yet -> wait.");
    604     // Wait for callback to completePendingSyntheticClickForContentChangeObserver() to decide whether to send the click event.
    605     m_pendingSyntheticClickNode = &nodeRespondingToClick;
    606     m_pendingSyntheticClickLocation = location;
    607     m_pendingSyntheticClickModifiers = modifiers;
     589
     590    auto continueContentObservation = !(observedContentChange == WKContentVisibilityChange || is<HTMLFormControlElement>(nodeRespondingToClick));
     591    if (continueContentObservation) {
     592        // Wait for callback to completePendingSyntheticClickForContentChangeObserver() to decide whether to send the click event.
     593        const Seconds observationDuration = 32_ms;
     594        contentChangeObserver.startContentObservationForDuration(observationDuration);
     595        LOG(ContentObservation, "handleSyntheticClick: Can't decide it yet -> wait.");
     596        m_pendingSyntheticClickNode = &nodeRespondingToClick;
     597        m_pendingSyntheticClickLocation = location;
     598        m_pendingSyntheticClickModifiers = modifiers;
     599        return;
     600    }
     601
     602    callOnMainThread([protectedThis = makeRefPtr(this), targetNode = Ref<Node>(nodeRespondingToClick), location, modifiers, observedContentChange] {
     603        if (protectedThis->m_isClosed || !protectedThis->corePage())
     604            return;
     605
     606        if (observedContentChange == WKContentVisibilityChange) {
     607            // The move event caused new contents to appear. Don't send synthetic click event, but just ensure that the mouse is on the most recent content.
     608            dispatchSyntheticMouseMove(protectedThis->corePage()->mainFrame(), location, modifiers);
     609            LOG(ContentObservation, "handleSyntheticClick: Observed meaningful visible change -> hover.");
     610            return;
     611        }
     612        LOG(ContentObservation, "handleSyntheticClick: calling completeSyntheticClick -> click.");
     613        protectedThis->completeSyntheticClick(targetNode, location, modifiers, WebCore::OneFingerTap);
     614    });
    608615}
    609616
Note: See TracChangeset for help on using the changeset viewer.