Title: [288867] trunk/Source/WebCore
Revision
288867
Author
[email protected]
Date
2022-01-31 21:47:38 -0800 (Mon, 31 Jan 2022)

Log Message

Fix handling of access key events
https://bugs.webkit.org/show_bug.cgi?id=234147
<rdar://problem/86320218>

Reviewed by David Kilzer.

Improve focus handling for HTMLElement-based elements to ensure accessKey events
are properly dispatched.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::press): Ensure correct object is used after 'accessKeyAction'
is invoked.
* dom/EventDispatcher.cpp:
(WebCore::callDefaultEventHandlersInBubblingOrder) Protect element during default
event bubbling.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::reportValidity): Ensure correct element is
used after focus event.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleAccessKey): Ensure correct object is used after
'accessKeyAction' is invoked.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288866 => 288867)


--- trunk/Source/WebCore/ChangeLog	2022-02-01 04:32:46 UTC (rev 288866)
+++ trunk/Source/WebCore/ChangeLog	2022-02-01 05:47:38 UTC (rev 288867)
@@ -1,3 +1,27 @@
+2022-01-31  Brent Fulgham  <[email protected]>
+
+        Fix handling of access key events
+        https://bugs.webkit.org/show_bug.cgi?id=234147
+        <rdar://problem/86320218>
+
+        Reviewed by David Kilzer.
+
+        Improve focus handling for HTMLElement-based elements to ensure accessKey events
+        are properly dispatched.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::press): Ensure correct object is used after 'accessKeyAction'
+        is invoked.
+        * dom/EventDispatcher.cpp:
+        (WebCore::callDefaultEventHandlersInBubblingOrder) Protect element during default
+        event bubbling.
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::reportValidity): Ensure correct element is
+        used after focus event.
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleAccessKey): Ensure correct object is used after
+        'accessKeyAction' is invoked.
+
 2022-01-31  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] Pattern should hold SourceImage which can be converted to a NativeImage only when needed

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (288866 => 288867)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-02-01 04:32:46 UTC (rev 288866)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2022-02-01 05:47:38 UTC (rev 288867)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2009, 2011, 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1029,6 +1029,7 @@
         dispatchedEvent = dispatchTouchEvent();
 #endif
     
+    Ref protectedPressElement { *pressElement };
     return dispatchedEvent || pressElement->accessKeyAction(true) || pressElement->dispatchSimulatedClick(nullptr, SendMouseUpDownEvents);
 }
     

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (288866 => 288867)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2022-02-01 04:32:46 UTC (rev 288866)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2022-02-01 05:47:38 UTC (rev 288867)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2022 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2010, 2011, 2012, 2013 Google Inc. All rights reserved.
@@ -60,7 +60,8 @@
         return;
 
     // Non-bubbling events call only one default event handler, the one for the target.
-    path.contextAt(0).node()->defaultEventHandler(event);
+    Ref rootNode { *path.contextAt(0).node() };
+    rootNode->defaultEventHandler(event);
     ASSERT(!event.defaultPrevented());
 
     if (event.defaultHandled() || !event.bubbles())
@@ -68,7 +69,8 @@
 
     size_t size = path.size();
     for (size_t i = 1; i < size; ++i) {
-        path.contextAt(i).node()->defaultEventHandler(event);
+        Ref currentNode { *path.contextAt(i).node() };
+        currentNode->defaultEventHandler(event);
         ASSERT(!event.defaultPrevented());
         if (event.defaultHandled())
             return;

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (288866 => 288867)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2022-02-01 04:32:46 UTC (rev 288866)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2022-02-01 05:47:38 UTC (rev 288867)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2022 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov ([email protected])
  *
  * This library is free software; you can redistribute it and/or
@@ -473,6 +473,7 @@
     document().updateLayoutIgnorePendingStylesheets();
 
     if (isConnected() && isFocusable()) {
+        Ref protectedThis { *this };
         focusAndShowValidationMessage();
         return false;
     }

Modified: trunk/Source/WebCore/page/EventHandler.cpp (288866 => 288867)


--- trunk/Source/WebCore/page/EventHandler.cpp	2022-02-01 04:32:46 UTC (rev 288866)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2022-02-01 05:47:38 UTC (rev 288867)
@@ -3479,7 +3479,7 @@
 
     if ((event.modifiers() - PlatformEvent::Modifier::ShiftKey) != accessKeyModifiers())
         return false;
-    auto* element = m_frame.document()->elementForAccessKey(event.unmodifiedText());
+    RefPtr element = m_frame.document()->elementForAccessKey(event.unmodifiedText());
     if (!element)
         return false;
     element->accessKeyAction(false);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to