Title: [287787] trunk
Revision
287787
Author
commit-qu...@webkit.org
Date
2022-01-07 14:51:45 -0800 (Fri, 07 Jan 2022)

Log Message

Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
https://bugs.webkit.org/show_bug.cgi?id=234978

Patch by Alexey Shvayka <ashva...@apple.com> on 2022-01-07
Reviewed by Geoff Garen.

Source/WebCore:

This patch removes these events because according to Chrome stats, only 0.04%
of page loads use them [1], which is below the Blink's removal threshold of 0.10%.

All the "top sites" listed as "DOMFocusIn" / "DOMFocusOut" adopters, are now dead.
Also, these events were never implemented in Firefox.

[1] https://chromestatus.com/metrics/feature/timeline/popularity/211

No new tests because it's a feature removal.

* dom/Document.cpp:
(WebCore::Document::setFocusedElement):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::dispatchFocusInEvent):
(WebCore::Element::dispatchFocusOutEvent):
* dom/Element.h:
* dom/EventNames.h:

Source/WebInspectorUI:

* UserInterface/Models/ScriptTimelineRecord.js:
(WI.ScriptTimelineRecord.EventType.displayName):

LayoutTests:

* editing/deleting/insert-in-orphaned-selection-crash.html:
* fast/events/focusinout-expected.txt:
* fast/events/focusinout.html:
* fast/events/scoped/editing-commands.html:
* fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html:
* fast/forms/textarea/textarea-autofocus-removal-while-focusing.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287786 => 287787)


--- trunk/LayoutTests/ChangeLog	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/ChangeLog	2022-01-07 22:51:45 UTC (rev 287787)
@@ -1,3 +1,17 @@
+2022-01-07  Alexey Shvayka  <ashva...@apple.com>
+
+        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
+        https://bugs.webkit.org/show_bug.cgi?id=234978
+
+        Reviewed by Geoff Garen.
+
+        * editing/deleting/insert-in-orphaned-selection-crash.html:
+        * fast/events/focusinout-expected.txt:
+        * fast/events/focusinout.html:
+        * fast/events/scoped/editing-commands.html:
+        * fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html:
+        * fast/forms/textarea/textarea-autofocus-removal-while-focusing.html:
+
 2022-01-07  Kate Cheney  <katherine_che...@apple.com>
 
         CSP: strict-dynamic is causing incorrect and unexpected behavior

Modified: trunk/LayoutTests/editing/deleting/insert-in-orphaned-selection-crash.html (287786 => 287787)


--- trunk/LayoutTests/editing/deleting/insert-in-orphaned-selection-crash.html	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/editing/deleting/insert-in-orphaned-selection-crash.html	2022-01-07 22:51:45 UTC (rev 287787)
@@ -8,7 +8,7 @@
     document.designMode = document.designMode == "on" ? "off" : "on";
     document.execCommand("SelectAll");
 });
-document.addEventListener("DOMFocusIn",  function () {
+document.addEventListener("focusin",  function () {
     document.execCommand('InsertText');
     console.log("The test PASS if it does not CRASH.");
 });

Modified: trunk/LayoutTests/fast/events/focusinout-expected.txt (287786 => 287787)


--- trunk/LayoutTests/fast/events/focusinout-expected.txt	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/fast/events/focusinout-expected.txt	2022-01-07 22:51:45 UTC (rev 287787)
@@ -3,5 +3,3 @@
 PASS
 PASS
 PASS
-PASS
-PASS

Modified: trunk/LayoutTests/fast/events/focusinout.html (287786 => 287787)


--- trunk/LayoutTests/fast/events/focusinout.html	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/fast/events/focusinout.html	2022-01-07 22:51:45 UTC (rev 287787)
@@ -29,22 +29,6 @@
     else
         writeFailed('result2', "Wrong event type");
 }
-
-function focusHandlerTwo(event)
-{
-    if (event.type == "DOMFocusIn")
-        writePass('result3');
-    else
-        writeFailed('result3', "Wrong event type");
-}
-
-function blurHandlerTwo(event)
-{
-    if (event.type == "DOMFocusOut")
-        writePass('result4');
-    else
-        writeFailed('result4', "Wrong event type");
-}
 </script>
 </head>
 <body _onload_="document.getElementById('field').focus();document.getElementById('field').blur()">
@@ -55,8 +39,6 @@
 
 <div id="result1">FAIL</div>
 <div id="result2">FAIL</div>
-<div id="result3">FAIL</div>
-<div id="result4">FAIL</div>
 <div id="result5">FAIL</div>
 <div id="result6">FAIL</div>
 
@@ -63,7 +45,5 @@
 <script>
 document.documentElement.addEventListener("focusin", focusHandler, false);
 document.documentElement.addEventListener("focusout", blurHandler, false);
-document.documentElement.addEventListener("DOMFocusIn", focusHandlerTwo, false);
-document.documentElement.addEventListener("DOMFocusOut", blurHandlerTwo, false);
 </script>
 

Modified: trunk/LayoutTests/fast/events/scoped/editing-commands.html (287786 => 287787)


--- trunk/LayoutTests/fast/events/scoped/editing-commands.html	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/fast/events/scoped/editing-commands.html	2022-01-07 22:51:45 UTC (rev 287787)
@@ -53,8 +53,6 @@
     'DOMNodeRemoved': false,
     'DOMNodeRemovedFromDocument': false,
     'DOMNodeInsertedIntoDocument': true, // this event can never be observed.
-    'DOMFocusIn': false,
-    'DOMFocusOut': false,
     'focusin': false,
     'focusout': false,
 };

Modified: trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html (287786 => 287787)


--- trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html	2022-01-07 22:51:45 UTC (rev 287787)
@@ -9,7 +9,7 @@
 textArea = document.createElement("textarea");
 textArea.setAttribute("autofocus", "");
 textArea.appendChild(document.head);
-textArea.addEventListener("DOMFocusIn", function () { docElement.innerHTML = ""; }, false);
+textArea.addEventListener("focusin", function () { docElement.innerHTML = ""; }, false);
 docElement.appendChild(textArea);
 document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).adoptNode(textArea);
 window.setTimeout(function() {

Modified: trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing.html (287786 => 287787)


--- trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing.html	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing.html	2022-01-07 22:51:45 UTC (rev 287787)
@@ -8,7 +8,7 @@
 }
 const textarea = document.createElement("textarea");
 textarea.setAttribute("autofocus", "");
-textarea.addEventListener("DOMFocusIn", function () { document.documentElement.innerHTML = ""; }, false);
+textarea.addEventListener("focusin", function () { document.documentElement.innerHTML = ""; }, false);
 document.documentElement.appendChild(textarea);
 requestAnimationFrame(() => {
     document.body.innerHTML = "PASS unless crash.";

Modified: trunk/Source/WebCore/ChangeLog (287786 => 287787)


--- trunk/Source/WebCore/ChangeLog	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebCore/ChangeLog	2022-01-07 22:51:45 UTC (rev 287787)
@@ -1,3 +1,29 @@
+2022-01-07  Alexey Shvayka  <ashva...@apple.com>
+
+        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
+        https://bugs.webkit.org/show_bug.cgi?id=234978
+
+        Reviewed by Geoff Garen.
+
+        This patch removes these events because according to Chrome stats, only 0.04%
+        of page loads use them [1], which is below the Blink's removal threshold of 0.10%.
+
+        All the "top sites" listed as "DOMFocusIn" / "DOMFocusOut" adopters, are now dead.
+        Also, these events were never implemented in Firefox.
+
+        [1] https://chromestatus.com/metrics/feature/timeline/popularity/211
+
+        No new tests because it's a feature removal.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedElement):
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchFocusInEvent):
+        (WebCore::Element::dispatchFocusOutEvent):
+        * dom/Element.h:
+        * dom/EventNames.h:
+
 2022-01-07  Kate Cheney  <katherine_che...@apple.com>
 
         CSP: strict-dynamic is causing incorrect and unexpected behavior

Modified: trunk/Source/WebCore/dom/Document.cpp (287786 => 287787)


--- trunk/Source/WebCore/dom/Document.cpp	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-01-07 22:51:45 UTC (rev 287787)
@@ -4658,10 +4658,7 @@
                 newFocusedElement = nullptr;
             }
 
-            oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement.copyRef()); // DOM level 3 name for the bubbling blur event.
-            // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
-            // on it, probably when <rdar://problem/8503958> is resolved.
-            oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement.copyRef()); // DOM level 2 name for compatibility.
+            oldFocusedElement->dispatchFocusOutEvent(newFocusedElement.copyRef()); // DOM level 3 bubbling blur event.
 
             if (m_focusedElement) {
                 // handler shifted focus
@@ -4726,7 +4723,7 @@
             return false;
         }
 
-        m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement.copyRef()); // DOM level 3 bubbling focus event.
+        m_focusedElement->dispatchFocusInEvent(oldFocusedElement.copyRef()); // DOM level 3 bubbling focus event.
 
         if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
@@ -4733,15 +4730,6 @@
             return false;
         }
 
-        // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends
-        // on it, probably when <rdar://problem/8503958> is m.
-        m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement.copyRef()); // DOM level 2 for compatibility.
-
-        if (m_focusedElement != newFocusedElement) {
-            // handler shifted focus
-            return false;
-        }
-
         if (m_focusedElement->isRootEditableElement())
             editor().didBeginEditing();
 

Modified: trunk/Source/WebCore/dom/Element.cpp (287786 => 287787)


--- trunk/Source/WebCore/dom/Element.cpp	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebCore/dom/Element.cpp	2022-01-07 22:51:45 UTC (rev 287787)
@@ -3182,18 +3182,16 @@
     focus();
 }
 
-void Element::dispatchFocusInEvent(const AtomString& eventType, RefPtr<Element>&& oldFocusedElement)
+void Element::dispatchFocusInEvent(RefPtr<Element>&& oldFocusedElement)
 {
     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
-    ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
-    dispatchScopedEvent(FocusEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(oldFocusedElement)));
+    dispatchScopedEvent(FocusEvent::create(eventNames().focusinEvent, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(oldFocusedElement)));
 }
 
-void Element::dispatchFocusOutEvent(const AtomString& eventType, RefPtr<Element>&& newFocusedElement)
+void Element::dispatchFocusOutEvent(RefPtr<Element>&& newFocusedElement)
 {
     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
-    ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
-    dispatchScopedEvent(FocusEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(newFocusedElement)));
+    dispatchScopedEvent(FocusEvent::create(eventNames().focusoutEvent, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(newFocusedElement)));
 }
 
 void Element::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection)

Modified: trunk/Source/WebCore/dom/Element.h (287786 => 287787)


--- trunk/Source/WebCore/dom/Element.h	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebCore/dom/Element.h	2022-01-07 22:51:45 UTC (rev 287787)
@@ -569,8 +569,10 @@
     bool dispatchWheelEvent(const PlatformWheelEvent&, OptionSet<EventHandling>&, EventIsCancelable = EventIsCancelable::Yes);
     bool dispatchKeyEvent(const PlatformKeyboardEvent&);
     bool dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
-    void dispatchFocusInEvent(const AtomString& eventType, RefPtr<Element>&& oldFocusedElement);
-    void dispatchFocusOutEvent(const AtomString& eventType, RefPtr<Element>&& newFocusedElement);
+
+    // FIXME: Consider changing signature to accept Element* because all callers perform copyRef().
+    void dispatchFocusInEvent(RefPtr<Element>&& oldFocusedElement);
+    void dispatchFocusOutEvent(RefPtr<Element>&& newFocusedElement);
     virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection);
     virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement);
     void dispatchWebKitImageReadyEventForTesting();

Modified: trunk/Source/WebCore/dom/EventNames.h (287786 => 287787)


--- trunk/Source/WebCore/dom/EventNames.h	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebCore/dom/EventNames.h	2022-01-07 22:51:45 UTC (rev 287787)
@@ -44,8 +44,6 @@
     macro(DOMActivate) \
     macro(DOMCharacterDataModified) \
     macro(DOMContentLoaded) \
-    macro(DOMFocusIn) \
-    macro(DOMFocusOut) \
     macro(DOMNodeInserted) \
     macro(DOMNodeInsertedIntoDocument) \
     macro(DOMNodeRemoved) \

Modified: trunk/Source/WebInspectorUI/ChangeLog (287786 => 287787)


--- trunk/Source/WebInspectorUI/ChangeLog	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebInspectorUI/ChangeLog	2022-01-07 22:51:45 UTC (rev 287787)
@@ -1,3 +1,13 @@
+2022-01-07  Alexey Shvayka  <ashva...@apple.com>
+
+        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
+        https://bugs.webkit.org/show_bug.cgi?id=234978
+
+        Reviewed by Geoff Garen.
+
+        * UserInterface/Models/ScriptTimelineRecord.js:
+        (WI.ScriptTimelineRecord.EventType.displayName):
+
 2022-01-07  Patrick Angle  <pan...@apple.com>
 
         Uncaught Exception: Cannot step over because debugger is not paused

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js (287786 => 287787)


--- trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js	2022-01-07 22:46:50 UTC (rev 287786)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js	2022-01-07 22:51:45 UTC (rev 287787)
@@ -212,8 +212,6 @@
         nameMap.set("DOMActivate", "DOM Activate");
         nameMap.set("DOMCharacterDataModified", "DOM Character Data Modified");
         nameMap.set("DOMContentLoaded", "DOM Content Loaded");
-        nameMap.set("DOMFocusIn", "DOM Focus In");
-        nameMap.set("DOMFocusOut", "DOM Focus Out");
         nameMap.set("DOMNodeInserted", "DOM Node Inserted");
         nameMap.set("DOMNodeInsertedIntoDocument", "DOM Node Inserted Into Document");
         nameMap.set("DOMNodeRemoved", "DOM Node Removed");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to