Title: [232316] trunk/Source
Revision
232316
Author
[email protected]
Date
2018-05-30 16:30:09 -0700 (Wed, 30 May 2018)

Log Message

NavigationAction does not need to hold initiating DOM Event
https://bugs.webkit.org/show_bug.cgi?id=185958
<rdar://problem/40531539>

Reviewed by Simon Fraser.

Source/WebCore:

Take a similar approach as was done in <https://bugs.webkit.org/show_bug.cgi?id=185712>
and have NavigationAction hold only as many details of the initiating DOM Event as
necessary to support WebKit functionality. Retaining a DOM Event effectively retains
the document that associated with the event. And DocumentLoader always keeps around
the NavigationAction of the last navigation for the "benefit of the various policy handlers".
Therefore, having NavigationAction hold only the relevant details of the DOM Event
instead of the DOM Event itself we avoid keeping the document we navigated from alive
longer than necessary.

* dom/MouseRelatedEvent.h:
* dom/UIEventWithKeyState.h:
* loader/NavigationAction.cpp:
(WebCore::NavigationAction::UIEventWithKeyStateData::UIEventWithKeyStateData): Added.
(WebCore::NavigationAction::MouseEventData::MouseEventData): Added.
(WebCore::keyStateDataForFirstEventWithKeyState): Added.
(WebCore::mouseEventDataForFirstMouseEvent): Added.
* loader/NavigationAction.h:
(WebCore::NavigationAction::keyStateEventData const): Added.
(WebCore::NavigationAction::mouseEventData const): Added
(WebCore::NavigationAction::event const): Deleted.

Source/WebKit:

Write in terms of NavigationAction::{keyStateEventData, mouseEventDataForFirstMouseEvent}().

* WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
(WebKit::mouseButtonForMouseEventData):
(WebKit::syntheticClickTypeForMouseEventData):
(WebKit::clickLocationInRootViewCoordinatesForMouseEventData):
(WebKit::InjectedBundleNavigationAction::modifiersForNavigationAction):
(WebKit::InjectedBundleNavigationAction::mouseButtonForNavigationAction):
(WebKit::InjectedBundleNavigationAction::syntheticClickTypeForNavigationAction):
(WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction):
(WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
(WebKit::mouseEventForNavigationAction): Deleted.
(WebKit::mouseButtonForMouseEvent): Deleted.
(WebKit::syntheticClickTypeForMouseEvent): Deleted.
(WebKit::clickLocationInRootViewCoordinatesForMouseEvent): Deleted.

Source/WebKitLegacy/mac:

Write in terms of NavigationAction::{keyStateEventData, mouseEventDataForFirstMouseEvent}().

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::actionDictionary const):
(findMouseEvent): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232315 => 232316)


--- trunk/Source/WebCore/ChangeLog	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebCore/ChangeLog	2018-05-30 23:30:09 UTC (rev 232316)
@@ -1,3 +1,32 @@
+2018-05-30  Daniel Bates  <[email protected]>
+
+        NavigationAction does not need to hold initiating DOM Event
+        https://bugs.webkit.org/show_bug.cgi?id=185958
+        <rdar://problem/40531539>
+
+        Reviewed by Simon Fraser.
+
+        Take a similar approach as was done in <https://bugs.webkit.org/show_bug.cgi?id=185712>
+        and have NavigationAction hold only as many details of the initiating DOM Event as
+        necessary to support WebKit functionality. Retaining a DOM Event effectively retains
+        the document that associated with the event. And DocumentLoader always keeps around
+        the NavigationAction of the last navigation for the "benefit of the various policy handlers".
+        Therefore, having NavigationAction hold only the relevant details of the DOM Event
+        instead of the DOM Event itself we avoid keeping the document we navigated from alive
+        longer than necessary. 
+
+        * dom/MouseRelatedEvent.h:
+        * dom/UIEventWithKeyState.h:
+        * loader/NavigationAction.cpp:
+        (WebCore::NavigationAction::UIEventWithKeyStateData::UIEventWithKeyStateData): Added.
+        (WebCore::NavigationAction::MouseEventData::MouseEventData): Added.
+        (WebCore::keyStateDataForFirstEventWithKeyState): Added.
+        (WebCore::mouseEventDataForFirstMouseEvent): Added.
+        * loader/NavigationAction.h:
+        (WebCore::NavigationAction::keyStateEventData const): Added.
+        (WebCore::NavigationAction::mouseEventData const): Added
+        (WebCore::NavigationAction::event const): Deleted.
+
 2018-05-30  Youenn Fablet  <[email protected]>
 
         Revert changes made to URLWithUserTypedString made in https://trac.webkit.org/changeset/232281

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.h (232315 => 232316)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.h	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.h	2018-05-30 23:30:09 UTC (rev 232316)
@@ -58,7 +58,7 @@
     void setIsSimulated(bool value) { m_isSimulated = value; }
     int pageX() const final;
     int pageY() const final;
-    WEBCORE_EXPORT FloatPoint locationInRootViewCoordinates() const;
+    FloatPoint locationInRootViewCoordinates() const;
     virtual const LayoutPoint& pageLocation() const;
     WEBCORE_EXPORT int x() const;
     WEBCORE_EXPORT int y() const;

Modified: trunk/Source/WebCore/dom/UIEventWithKeyState.h (232315 => 232316)


--- trunk/Source/WebCore/dom/UIEventWithKeyState.h	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebCore/dom/UIEventWithKeyState.h	2018-05-30 23:30:09 UTC (rev 232316)
@@ -81,6 +81,6 @@
     bool m_capsLockKey { false };
 };
 
-WEBCORE_EXPORT UIEventWithKeyState* findEventWithKeyState(Event*);
+UIEventWithKeyState* findEventWithKeyState(Event*);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/NavigationAction.cpp (232315 => 232316)


--- trunk/Source/WebCore/loader/NavigationAction.cpp	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebCore/loader/NavigationAction.cpp	2018-05-30 23:30:09 UTC (rev 232316)
@@ -30,10 +30,10 @@
 #include "NavigationAction.h"
 
 #include "Document.h"
-#include "Event.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "HistoryItem.h"
+#include "MouseEvent.h"
 
 namespace WebCore {
 
@@ -44,6 +44,25 @@
 {
 }
 
+NavigationAction::UIEventWithKeyStateData::UIEventWithKeyStateData(const UIEventWithKeyState& uiEvent)
+    : isTrusted { uiEvent.isTrusted() }
+    , shiftKey { uiEvent.shiftKey() }
+    , ctrlKey { uiEvent.ctrlKey() }
+    , altKey { uiEvent.altKey() }
+    , metaKey { uiEvent.metaKey() }
+{
+}
+
+NavigationAction::MouseEventData::MouseEventData(const MouseEvent& mouseEvent)
+    : UIEventWithKeyStateData { mouseEvent }
+    , absoluteLocation { mouseEvent.absoluteLocation() }
+    , locationInRootViewCoordinates { mouseEvent.locationInRootViewCoordinates() }
+    , button { mouseEvent.button() }
+    , syntheticClickType { mouseEvent.syntheticClickType() }
+    , buttonDown { mouseEvent.buttonDown() }
+{
+}
+
 NavigationAction::NavigationAction() = default;
 NavigationAction::~NavigationAction() = default;
 
@@ -58,6 +77,22 @@
     return url.isBlankURL() || url.protocolIsData() || (url.protocolIsBlob() && document.securityOrigin().canRequest(url));
 }
 
+static std::optional<NavigationAction::UIEventWithKeyStateData> keyStateDataForFirstEventWithKeyState(Event* event)
+{
+    if (UIEventWithKeyState* uiEvent = findEventWithKeyState(event))
+        return NavigationAction::UIEventWithKeyStateData { *uiEvent };
+    return std::nullopt;
+}
+
+static std::optional<NavigationAction::MouseEventData> mouseEventDataForFirstMouseEvent(Event* event)
+{
+    for (Event* e = event; e; e = e->underlyingEvent()) {
+        if (e->isMouseEvent())
+            return NavigationAction::MouseEventData { static_cast<const MouseEvent&>(*e) };
+    }
+    return std::nullopt;
+}
+
 NavigationAction::NavigationAction(Document& requester, const ResourceRequest& resourceRequest, InitiatedByMainFrame initiatedByMainFrame, NavigationType type, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, Event* event, const AtomicString& downloadAttribute)
     : m_requester { requester }
     , m_resourceRequest { resourceRequest }
@@ -64,7 +99,8 @@
     , m_type { type }
     , m_shouldOpenExternalURLsPolicy { shouldOpenExternalURLsPolicy }
     , m_initiatedByMainFrame { initiatedByMainFrame }
-    , m_event { event }
+    , m_keyStateEventData { keyStateDataForFirstEventWithKeyState(event) }
+    , m_mouseEventData { mouseEventDataForFirstMouseEvent(event) }
     , m_downloadAttribute { downloadAttribute }
     , m_treatAsSameOriginNavigation { shouldTreatAsSameOriginNavigation(requester, resourceRequest.url()) }
 {
@@ -89,7 +125,8 @@
     , m_type { navigationType(frameLoadType, isFormSubmission, !!event) }
     , m_shouldOpenExternalURLsPolicy { shouldOpenExternalURLsPolicy }
     , m_initiatedByMainFrame { initiatedByMainFrame }
-    , m_event { event }
+    , m_keyStateEventData { keyStateDataForFirstEventWithKeyState(event) }
+    , m_mouseEventData { mouseEventDataForFirstMouseEvent(event) }
     , m_downloadAttribute { downloadAttribute }
     , m_treatAsSameOriginNavigation { shouldTreatAsSameOriginNavigation(requester, resourceRequest.url()) }
 {

Modified: trunk/Source/WebCore/loader/NavigationAction.h (232315 => 232316)


--- trunk/Source/WebCore/loader/NavigationAction.h	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebCore/loader/NavigationAction.h	2018-05-30 23:30:09 UTC (rev 232316)
@@ -30,6 +30,7 @@
 
 #include "BackForwardItemIdentifier.h"
 #include "FrameLoaderTypes.h"
+#include "LayoutPoint.h"
 #include "ResourceRequest.h"
 #include "SecurityOrigin.h"
 #include "UserGestureIndicator.h"
@@ -40,7 +41,12 @@
 class Document;
 class Event;
 class HistoryItem;
+class MouseEvent;
+class UIEventWithKeyState;
 
+// NavigationAction should never hold a strong reference to the originating document either directly
+// or indirectly as doing so prevents its destruction even after navigating away from it because
+// DocumentLoader keeps around the NavigationAction for the last navigation.
 class NavigationAction {
 public:
     NavigationAction();
@@ -71,6 +77,27 @@
     };
     const std::optional<Requester>& requester() const { return m_requester; }
 
+    struct UIEventWithKeyStateData {
+        UIEventWithKeyStateData(const UIEventWithKeyState&);
+
+        bool isTrusted;
+        bool shiftKey;
+        bool ctrlKey;
+        bool altKey;
+        bool metaKey;
+    };
+    struct MouseEventData : UIEventWithKeyStateData {
+        MouseEventData(const MouseEvent&);
+
+        LayoutPoint absoluteLocation;
+        FloatPoint locationInRootViewCoordinates;
+        unsigned short button;
+        unsigned short syntheticClickType;
+        bool buttonDown;
+    };
+    const std::optional<UIEventWithKeyStateData>& keyStateEventData() const { return m_keyStateEventData; }
+    const std::optional<MouseEventData>& mouseEventData() const { return m_mouseEventData; }
+
     NavigationAction copyWithShouldOpenExternalURLsPolicy(ShouldOpenExternalURLsPolicy) const;
 
     bool isEmpty() const { return !m_requester || m_requester->url().isEmpty() || m_resourceRequest.url().isEmpty(); }
@@ -79,7 +106,6 @@
     const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
 
     NavigationType type() const { return m_type; }
-    const Event* event() const { return m_event.get(); }
 
     bool processingUserGesture() const { return m_userGestureToken ? m_userGestureToken->processingUserGesture() : false; }
     RefPtr<UserGestureToken> userGestureToken() const { return m_userGestureToken; }
@@ -101,12 +127,15 @@
     const std::optional<BackForwardItemIdentifier>& targetBackForwardItemIdentifier() const { return m_targetBackForwardItemIdentifier; }
 
 private:
+    // Do not add a strong reference to the originating document or a subobject that holds the
+    // originating document. See comment above the class for more details.
     std::optional<Requester> m_requester;
     ResourceRequest m_resourceRequest;
     NavigationType m_type;
     ShouldOpenExternalURLsPolicy m_shouldOpenExternalURLsPolicy;
     InitiatedByMainFrame m_initiatedByMainFrame;
-    RefPtr<Event> m_event;
+    std::optional<UIEventWithKeyStateData> m_keyStateEventData;
+    std::optional<MouseEventData> m_mouseEventData;
     RefPtr<UserGestureToken> m_userGestureToken { UserGestureIndicator::currentUserGesture() };
     AtomicString m_downloadAttribute;
     bool m_treatAsSameOriginNavigation;

Modified: trunk/Source/WebKit/ChangeLog (232315 => 232316)


--- trunk/Source/WebKit/ChangeLog	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebKit/ChangeLog	2018-05-30 23:30:09 UTC (rev 232316)
@@ -1,3 +1,27 @@
+2018-05-30  Daniel Bates  <[email protected]>
+
+        NavigationAction does not need to hold initiating DOM Event
+        https://bugs.webkit.org/show_bug.cgi?id=185958
+        <rdar://problem/40531539>
+
+        Reviewed by Simon Fraser.
+
+        Write in terms of NavigationAction::{keyStateEventData, mouseEventDataForFirstMouseEvent}().
+
+        * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
+        (WebKit::mouseButtonForMouseEventData):
+        (WebKit::syntheticClickTypeForMouseEventData):
+        (WebKit::clickLocationInRootViewCoordinatesForMouseEventData):
+        (WebKit::InjectedBundleNavigationAction::modifiersForNavigationAction):
+        (WebKit::InjectedBundleNavigationAction::mouseButtonForNavigationAction):
+        (WebKit::InjectedBundleNavigationAction::syntheticClickTypeForNavigationAction):
+        (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction):
+        (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
+        (WebKit::mouseEventForNavigationAction): Deleted.
+        (WebKit::mouseButtonForMouseEvent): Deleted.
+        (WebKit::syntheticClickTypeForMouseEvent): Deleted.
+        (WebKit::clickLocationInRootViewCoordinatesForMouseEvent): Deleted.
+
 2018-05-30  Andy Estes  <[email protected]>
 
         [Cocoa] Add an SPI to suppress connection termination errors from CFNetwork when network interfaces change

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp (232315 => 232316)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp	2018-05-30 23:30:09 UTC (rev 232316)
@@ -38,79 +38,57 @@
 
 namespace WebKit {
 
-static const MouseEvent* mouseEventForNavigationAction(const NavigationAction& navigationAction)
+static WebMouseEvent::Button mouseButtonForMouseEventData(const std::optional<NavigationAction::MouseEventData>& mouseEventData)
 {
-    for (const Event* e = navigationAction.event(); e; e = e->underlyingEvent()) {
-        if (e->isMouseEvent())
-            return static_cast<const MouseEvent*>(e);
-    }
-    return 0;
+    if (mouseEventData && mouseEventData->buttonDown && mouseEventData->isTrusted)
+        return static_cast<WebMouseEvent::Button>(mouseEventData->button);
+    return WebMouseEvent::NoButton;
 }
 
-static WebMouseEvent::Button mouseButtonForMouseEvent(const MouseEvent* mouseEvent)
+static WebMouseEvent::SyntheticClickType syntheticClickTypeForMouseEventData(const std::optional<NavigationAction::MouseEventData>& mouseEventData)
 {
-    if (!mouseEvent)
-        return WebMouseEvent::NoButton;
-
-    if (!mouseEvent->buttonDown() || !mouseEvent->isTrusted())
-        return WebMouseEvent::NoButton;
-
-    return static_cast<WebMouseEvent::Button>(mouseEvent->button());
+    if (mouseEventData && mouseEventData->buttonDown && mouseEventData->isTrusted)
+        return static_cast<WebMouseEvent::SyntheticClickType>(mouseEventData->syntheticClickType);
+    return WebMouseEvent::NoTap;
 }
-
-static WebMouseEvent::SyntheticClickType syntheticClickTypeForMouseEvent(const MouseEvent* mouseEvent)
-{
-    if (!mouseEvent)
-        return WebMouseEvent::NoTap;
     
-    if (!mouseEvent->buttonDown() || !mouseEvent->isTrusted())
-        return WebMouseEvent::NoTap;
-    
-    return static_cast<WebMouseEvent::SyntheticClickType>(mouseEvent->syntheticClickType());
-}
-    
-static FloatPoint clickLocationInRootViewCoordinatesForMouseEvent(const MouseEvent* mouseEvent)
+static FloatPoint clickLocationInRootViewCoordinatesForMouseEventData(const std::optional<NavigationAction::MouseEventData>& mouseEventData)
 {
-    if (!mouseEvent)
-        return { };
-    
-    if (!mouseEvent->buttonDown() || !mouseEvent->isTrusted())
-        return { };
-    
-    return mouseEvent->locationInRootViewCoordinates();
+    if (mouseEventData && mouseEventData->buttonDown && mouseEventData->isTrusted)
+        return mouseEventData->locationInRootViewCoordinates;
+    return { };
 }
 
 WebEvent::Modifiers InjectedBundleNavigationAction::modifiersForNavigationAction(const NavigationAction& navigationAction)
 {
     uint32_t modifiers = 0;
-    const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()));
-    if (keyStateEvent && keyStateEvent->isTrusted()) {
-        if (keyStateEvent->shiftKey())
+    auto keyStateEventData = navigationAction.keyStateEventData();
+    if (keyStateEventData && keyStateEventData->isTrusted) {
+        if (keyStateEventData->shiftKey)
             modifiers |= WebEvent::ShiftKey;
-        if (keyStateEvent->ctrlKey())
+        if (keyStateEventData->ctrlKey)
             modifiers |= WebEvent::ControlKey;
-        if (keyStateEvent->altKey())
+        if (keyStateEventData->altKey)
             modifiers |= WebEvent::AltKey;
-        if (keyStateEvent->metaKey())
+        if (keyStateEventData->metaKey)
             modifiers |= WebEvent::MetaKey;
     }
-
     return static_cast<WebEvent::Modifiers>(modifiers);
 }
 
 WebMouseEvent::Button InjectedBundleNavigationAction::mouseButtonForNavigationAction(const NavigationAction& navigationAction)
 {
-    return mouseButtonForMouseEvent(mouseEventForNavigationAction(navigationAction));
+    return mouseButtonForMouseEventData(navigationAction.mouseEventData());
 }
 
 WebMouseEvent::SyntheticClickType InjectedBundleNavigationAction::syntheticClickTypeForNavigationAction(const NavigationAction& navigationAction)
 {
-    return syntheticClickTypeForMouseEvent(mouseEventForNavigationAction(navigationAction));
+    return syntheticClickTypeForMouseEventData(navigationAction.mouseEventData());
 }
     
 FloatPoint InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction(const NavigationAction& navigationAction)
 {
-    return clickLocationInRootViewCoordinatesForMouseEvent(mouseEventForNavigationAction(navigationAction));
+    return clickLocationInRootViewCoordinatesForMouseEventData(navigationAction.mouseEventData());
 }
 
 Ref<InjectedBundleNavigationAction> InjectedBundleNavigationAction::create(WebFrame* frame, const NavigationAction& action, RefPtr<FormState>&& formState)
@@ -126,9 +104,9 @@
     , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow || navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes)
     , m_shouldTryAppLinks(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow)
 {
-    if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) {
-        m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler().hitTestResultAtPoint(mouseEvent->absoluteLocation()));
-        m_mouseButton   = mouseButtonForMouseEvent(mouseEvent);
+    if (auto mouseEventData = navigationAction.mouseEventData()) {
+        m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler().hitTestResultAtPoint(mouseEventData->absoluteLocation));
+        m_mouseButton = mouseButtonForMouseEventData(mouseEventData);
         m_syntheticClickType = syntheticClickTypeForNavigationAction(navigationAction);
         m_clickLocationInRootViewCoordinates = clickLocationInRootViewCoordinatesForNavigationAction(navigationAction);
     }

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (232315 => 232316)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-30 23:30:09 UTC (rev 232316)
@@ -1,3 +1,17 @@
+2018-05-30  Daniel Bates  <[email protected]>
+
+        NavigationAction does not need to hold initiating DOM Event
+        https://bugs.webkit.org/show_bug.cgi?id=185958
+        <rdar://problem/40531539>
+
+        Reviewed by Simon Fraser.
+
+        Write in terms of NavigationAction::{keyStateEventData, mouseEventDataForFirstMouseEvent}().
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::actionDictionary const):
+        (findMouseEvent): Deleted.
+
 2018-05-27  Dan Bernstein  <[email protected]>
 
         Reverted the changes made for https://webkit.org/b/186016

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (232315 => 232316)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2018-05-30 23:23:00 UTC (rev 232315)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2018-05-30 23:30:09 UTC (rev 232316)
@@ -1555,28 +1555,19 @@
     return [webView _userAgentString];
 }
 
-static const MouseEvent* findMouseEvent(const Event* event)
-{
-    for (const Event* e = event; e; e = e->underlyingEvent())
-        if (e->isMouseEvent())
-            return static_cast<const MouseEvent*>(e);
-    return 0;
-}
-
 NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& action, FormState* formState) const
 {
     unsigned modifierFlags = 0;
-    const Event* event = action.event();
 #if !PLATFORM(IOS)
-    const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(event));
-    if (keyStateEvent && keyStateEvent->isTrusted()) {
-        if (keyStateEvent->ctrlKey())
+    auto keyStateEventData = action.keyStateEventData();
+    if (keyStateEventData && keyStateEventData->isTrusted) {
+        if (keyStateEventData->ctrlKey)
             modifierFlags |= NSEventModifierFlagControl;
-        if (keyStateEvent->altKey())
+        if (keyStateEventData->altKey)
             modifierFlags |= NSEventModifierFlagOption;
-        if (keyStateEvent->shiftKey())
+        if (keyStateEventData->shiftKey)
             modifierFlags |= NSEventModifierFlagShift;
-        if (keyStateEvent->metaKey())
+        if (keyStateEventData->metaKey)
             modifierFlags |= NSEventModifierFlagCommand;
     }
 #else
@@ -1592,14 +1583,14 @@
         originalURL, WebActionOriginalURLKey,
         nil];
 
-    if (const MouseEvent* mouseEvent = findMouseEvent(event)) {
+    if (auto mouseEventData = action.mouseEventData()) {
         WebElementDictionary *element = [[WebElementDictionary alloc]
-            initWithHitTestResult:core(m_webFrame.get())->eventHandler().hitTestResultAtPoint(mouseEvent->absoluteLocation())];
+            initWithHitTestResult:core(m_webFrame.get())->eventHandler().hitTestResultAtPoint(mouseEventData->absoluteLocation)];
         [result setObject:element forKey:WebActionElementKey];
         [element release];
 
-        if (mouseEvent->isTrusted())
-            [result setObject:[NSNumber numberWithInt:mouseEvent->button()] forKey:WebActionButtonKey];
+        if (mouseEventData->isTrusted)
+            [result setObject:[NSNumber numberWithInt:mouseEventData->button] forKey:WebActionButtonKey];
         else
             [result setObject:[NSNumber numberWithInt:WebCore::NoButton] forKey:WebActionButtonKey];
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to