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

Changeset 287787 in webkit


Ignore:
Timestamp:
Jan 7, 2022, 2:51:45 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Alexey Shvayka <ashvayka@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:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r287783 r287787  
     12022-01-07  Alexey Shvayka  <ashvayka@apple.com>
     2
     3        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
     4        https://bugs.webkit.org/show_bug.cgi?id=234978
     5
     6        Reviewed by Geoff Garen.
     7
     8        * editing/deleting/insert-in-orphaned-selection-crash.html:
     9        * fast/events/focusinout-expected.txt:
     10        * fast/events/focusinout.html:
     11        * fast/events/scoped/editing-commands.html:
     12        * fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html:
     13        * fast/forms/textarea/textarea-autofocus-removal-while-focusing.html:
     14
    1152022-01-07  Kate Cheney  <katherine_cheney@apple.com>
    216
  • trunk/LayoutTests/editing/deleting/insert-in-orphaned-selection-crash.html

    r272779 r287787  
    99    document.execCommand("SelectAll");
    1010});
    11 document.addEventListener("DOMFocusIn",  function () {
     11document.addEventListener("focusin",  function () {
    1212    document.execCommand('InsertText');
    1313    console.log("The test PASS if it does not CRASH.");
  • trunk/LayoutTests/fast/events/focusinout-expected.txt

    r56402 r287787  
    44PASS
    55PASS
    6 PASS
    7 PASS
  • trunk/LayoutTests/fast/events/focusinout.html

    r120792 r287787  
    3030        writeFailed('result2', "Wrong event type");
    3131}
    32 
    33 function focusHandlerTwo(event)
    34 {
    35     if (event.type == "DOMFocusIn")
    36         writePass('result3');
    37     else
    38         writeFailed('result3', "Wrong event type");
    39 }
    40 
    41 function blurHandlerTwo(event)
    42 {
    43     if (event.type == "DOMFocusOut")
    44         writePass('result4');
    45     else
    46         writeFailed('result4', "Wrong event type");
    47 }
    4832</script>
    4933</head>
     
    5640<div id="result1">FAIL</div>
    5741<div id="result2">FAIL</div>
    58 <div id="result3">FAIL</div>
    59 <div id="result4">FAIL</div>
    6042<div id="result5">FAIL</div>
    6143<div id="result6">FAIL</div>
     
    6446document.documentElement.addEventListener("focusin", focusHandler, false);
    6547document.documentElement.addEventListener("focusout", blurHandler, false);
    66 document.documentElement.addEventListener("DOMFocusIn", focusHandlerTwo, false);
    67 document.documentElement.addEventListener("DOMFocusOut", blurHandlerTwo, false);
    6848</script>
    6949
  • trunk/LayoutTests/fast/events/scoped/editing-commands.html

    r120792 r287787  
    5454    'DOMNodeRemovedFromDocument': false,
    5555    'DOMNodeInsertedIntoDocument': true, // this event can never be observed.
    56     'DOMFocusIn': false,
    57     'DOMFocusOut': false,
    5856    'focusin': false,
    5957    'focusout': false,
  • trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html

    r131709 r287787  
    1010textArea.setAttribute("autofocus", "");
    1111textArea.appendChild(document.head);
    12 textArea.addEventListener("DOMFocusIn", function () { docElement.innerHTML = ""; }, false);
     12textArea.addEventListener("focusin", function () { docElement.innerHTML = ""; }, false);
    1313docElement.appendChild(textArea);
    1414document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).adoptNode(textArea);
  • trunk/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing.html

    r283659 r287787  
    99const textarea = document.createElement("textarea");
    1010textarea.setAttribute("autofocus", "");
    11 textarea.addEventListener("DOMFocusIn", function () { document.documentElement.innerHTML = ""; }, false);
     11textarea.addEventListener("focusin", function () { document.documentElement.innerHTML = ""; }, false);
    1212document.documentElement.appendChild(textarea);
    1313requestAnimationFrame(() => {
  • trunk/Source/WebCore/ChangeLog

    r287783 r287787  
     12022-01-07  Alexey Shvayka  <ashvayka@apple.com>
     2
     3        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
     4        https://bugs.webkit.org/show_bug.cgi?id=234978
     5
     6        Reviewed by Geoff Garen.
     7
     8        This patch removes these events because according to Chrome stats, only 0.04%
     9        of page loads use them [1], which is below the Blink's removal threshold of 0.10%.
     10
     11        All the "top sites" listed as "DOMFocusIn" / "DOMFocusOut" adopters, are now dead.
     12        Also, these events were never implemented in Firefox.
     13
     14        [1] https://chromestatus.com/metrics/feature/timeline/popularity/211
     15
     16        No new tests because it's a feature removal.
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::setFocusedElement):
     20        * dom/Document.h:
     21        * dom/Element.cpp:
     22        (WebCore::Element::dispatchFocusInEvent):
     23        (WebCore::Element::dispatchFocusOutEvent):
     24        * dom/Element.h:
     25        * dom/EventNames.h:
     26
    1272022-01-07  Kate Cheney  <katherine_cheney@apple.com>
    228
  • trunk/Source/WebCore/dom/Document.cpp

    r287761 r287787  
    46594659            }
    46604660
    4661             oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement.copyRef()); // DOM level 3 name for the bubbling blur event.
    4662             // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
    4663             // on it, probably when <rdar://problem/8503958> is resolved.
    4664             oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement.copyRef()); // DOM level 2 name for compatibility.
     4661            oldFocusedElement->dispatchFocusOutEvent(newFocusedElement.copyRef()); // DOM level 3 bubbling blur event.
    46654662
    46664663            if (m_focusedElement) {
     
    47274724        }
    47284725
    4729         m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement.copyRef()); // DOM level 3 bubbling focus event.
    4730 
    4731         if (m_focusedElement != newFocusedElement) {
    4732             // handler shifted focus
    4733             return false;
    4734         }
    4735 
    4736         // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends
    4737         // on it, probably when <rdar://problem/8503958> is m.
    4738         m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement.copyRef()); // DOM level 2 for compatibility.
     4726        m_focusedElement->dispatchFocusInEvent(oldFocusedElement.copyRef()); // DOM level 3 bubbling focus event.
    47394727
    47404728        if (m_focusedElement != newFocusedElement) {
  • trunk/Source/WebCore/dom/Element.cpp

    r287744 r287787  
    31833183}
    31843184
    3185 void Element::dispatchFocusInEvent(const AtomString& eventType, RefPtr<Element>&& oldFocusedElement)
     3185void Element::dispatchFocusInEvent(RefPtr<Element>&& oldFocusedElement)
    31863186{
    31873187    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
    3188     ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
    3189     dispatchScopedEvent(FocusEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(oldFocusedElement)));
    3190 }
    3191 
    3192 void Element::dispatchFocusOutEvent(const AtomString& eventType, RefPtr<Element>&& newFocusedElement)
     3188    dispatchScopedEvent(FocusEvent::create(eventNames().focusinEvent, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(oldFocusedElement)));
     3189}
     3190
     3191void Element::dispatchFocusOutEvent(RefPtr<Element>&& newFocusedElement)
    31933192{
    31943193    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
    3195     ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
    3196     dispatchScopedEvent(FocusEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(newFocusedElement)));
     3194    dispatchScopedEvent(FocusEvent::create(eventNames().focusoutEvent, Event::CanBubble::Yes, Event::IsCancelable::No, document().windowProxy(), 0, WTFMove(newFocusedElement)));
    31973195}
    31983196
  • trunk/Source/WebCore/dom/Element.h

    r287707 r287787  
    570570    bool dispatchKeyEvent(const PlatformKeyboardEvent&);
    571571    bool dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
    572     void dispatchFocusInEvent(const AtomString& eventType, RefPtr<Element>&& oldFocusedElement);
    573     void dispatchFocusOutEvent(const AtomString& eventType, RefPtr<Element>&& newFocusedElement);
     572
     573    // FIXME: Consider changing signature to accept Element* because all callers perform copyRef().
     574    void dispatchFocusInEvent(RefPtr<Element>&& oldFocusedElement);
     575    void dispatchFocusOutEvent(RefPtr<Element>&& newFocusedElement);
    574576    virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection);
    575577    virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement);
  • trunk/Source/WebCore/dom/EventNames.h

    r287253 r287787  
    4545    macro(DOMCharacterDataModified) \
    4646    macro(DOMContentLoaded) \
    47     macro(DOMFocusIn) \
    48     macro(DOMFocusOut) \
    4947    macro(DOMNodeInserted) \
    5048    macro(DOMNodeInsertedIntoDocument) \
  • trunk/Source/WebInspectorUI/ChangeLog

    r287776 r287787  
     12022-01-07  Alexey Shvayka  <ashvayka@apple.com>
     2
     3        Remove obsolete DOM Level 2 "DOMFocusIn" / "DOMFocusOut" events
     4        https://bugs.webkit.org/show_bug.cgi?id=234978
     5
     6        Reviewed by Geoff Garen.
     7
     8        * UserInterface/Models/ScriptTimelineRecord.js:
     9        (WI.ScriptTimelineRecord.EventType.displayName):
     10
    1112022-01-07  Patrick Angle  <pangle@apple.com>
    212
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

    r286223 r287787  
    213213        nameMap.set("DOMCharacterDataModified", "DOM Character Data Modified");
    214214        nameMap.set("DOMContentLoaded", "DOM Content Loaded");
    215         nameMap.set("DOMFocusIn", "DOM Focus In");
    216         nameMap.set("DOMFocusOut", "DOM Focus Out");
    217215        nameMap.set("DOMNodeInserted", "DOM Node Inserted");
    218216        nameMap.set("DOMNodeInsertedIntoDocument", "DOM Node Inserted Into Document");
Note: See TracChangeset for help on using the changeset viewer.