Title: [290554] trunk
Revision
290554
Author
[email protected]
Date
2022-02-26 23:06:29 -0800 (Sat, 26 Feb 2022)

Log Message

Remove Node::deprecatedIsInert
https://bugs.webkit.org/show_bug.cgi?id=230845

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

This change unfortunately regresses focusability state when dynamically setting inert, due to a cached
computed style invalidation bug. This is minor in practice, since focusability usually gets queried in
user-initiated ways, when style already has fully been updated.

However, making this change will improve performance by avoiding a full DOM ancestor walk when there
is no inert attribute on the page, since we will only check a style bit after this patch.

* web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt:
* web-platform-tests/inert/inert-canvas-fallback-content.tentative-expected.txt:
* web-platform-tests/inert/inert-node-is-unfocusable.tentative-expected.txt:

Source/WebCore:

This change unfortunately regresses focusability state when dynamically setting inert, due to a cached
computed style invalidation bug. This is minor in practice, since focusability usually gets queried in
user-initiated ways, when style already has fully been updated.

However, making this change will improve performance by avoiding a full DOM ancestor walk when there
is no inert attribute on the page, since we will only check a style bit after this patch.

* dom/Element.cpp:
(WebCore::Element::isFocusable const):
(WebCore::Element::isFocusableWithoutResolvingFullStyle const):
(WebCore::Element::isVisibleWithoutResolvingFullStyle const): Deleted.
* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::deprecatedIsInert const): Deleted.
* dom/Node.h:
* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::isFocusable const):

LayoutTests:

* platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert-expected.txt: Added.
* platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290553 => 290554)


--- trunk/LayoutTests/ChangeLog	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/LayoutTests/ChangeLog	2022-02-27 07:06:29 UTC (rev 290554)
@@ -1,3 +1,13 @@
+2022-02-26  Tim Nguyen  <[email protected]>
+
+        Remove Node::deprecatedIsInert
+        https://bugs.webkit.org/show_bug.cgi?id=230845
+
+        Reviewed by Antti Koivisto.
+
+        * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert-expected.txt: Added.
+        * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt: Added.
+
 2022-02-26  Kate Cheney  <[email protected]>
 
         Update CSP handling of _javascript_ URLs

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290553 => 290554)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-27 07:06:29 UTC (rev 290554)
@@ -1,3 +1,21 @@
+2022-02-26  Tim Nguyen  <[email protected]>
+
+        Remove Node::deprecatedIsInert
+        https://bugs.webkit.org/show_bug.cgi?id=230845
+
+        Reviewed by Antti Koivisto.
+
+        This change unfortunately regresses focusability state when dynamically setting inert, due to a cached
+        computed style invalidation bug. This is minor in practice, since focusability usually gets queried in
+        user-initiated ways, when style already has fully been updated.
+
+        However, making this change will improve performance by avoiding a full DOM ancestor walk when there
+        is no inert attribute on the page, since we will only check a style bit after this patch.
+
+        * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt:
+        * web-platform-tests/inert/inert-canvas-fallback-content.tentative-expected.txt:
+        * web-platform-tests/inert/inert-node-is-unfocusable.tentative-expected.txt:
+
 2022-02-26  Kate Cheney  <[email protected]>
 
         Update CSP handling of _javascript_ URLs

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt (290553 => 290554)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt	2022-02-27 07:06:29 UTC (rev 290554)
@@ -1,4 +1,4 @@
+This is a dialog
 
+FAIL Test that removing dialog unblocks the document. assert_equals: expected false but got true
 
-PASS Test that removing dialog unblocks the document.
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-canvas-fallback-content.tentative-expected.txt (290553 => 290554)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-canvas-fallback-content.tentative-expected.txt	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-canvas-fallback-content.tentative-expected.txt	2022-02-27 07:06:29 UTC (rev 290554)
@@ -20,22 +20,29 @@
       `a` in `display: none`
      assert_not_equals: got disallowed value Element node <a href="" data-focusable="false">
       `a` in `display...
-PASS
+FAIL
       inert `div`
-
-PASS
+     assert_not_equals: got disallowed value Element node <div tabindex="-1" data-focusable="false">
+      inert `d...
+FAIL
       inert `span`
-
-PASS
+     assert_not_equals: got disallowed value Element node <span tabindex="-1" data-focusable="false">
+      inert `...
+FAIL
       inert `a`
-
-PASS
+     assert_not_equals: got disallowed value Element node <a href="" data-focusable="false">
+      inert `a`
+    </a>
+FAIL
       inert `div` in `display: none`
-
-PASS
+     assert_not_equals: got disallowed value Element node <div tabindex="-1" data-focusable="false">
+      inert `d...
+FAIL
       inert `span` in `display: none`
-
-PASS
+     assert_not_equals: got disallowed value Element node <span tabindex="-1" data-focusable="false">
+      inert `...
+FAIL
       inert `a` in `display: none`
+     assert_not_equals: got disallowed value Element node <a href="" data-focusable="false">
+      inert `a` in `d...
 
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-node-is-unfocusable.tentative-expected.txt (290553 => 290554)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-node-is-unfocusable.tentative-expected.txt	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/inert/inert-node-is-unfocusable.tentative-expected.txt	2022-02-27 07:06:29 UTC (rev 290554)
@@ -9,5 +9,5 @@
 PASS All focusable elements inside inert subtree are unfocusable
 PASS Can get inert via property
 PASS Elements inside of inert subtrees return false when getting 'inert'
-PASS Setting inert via property correctly modifies inert state
+FAIL Setting inert via property correctly modifies inert state assert_equals: expected true but got false
 

Added: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert-expected.txt (0 => 290554)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert-expected.txt	2022-02-27 07:06:29 UTC (rev 290554)
@@ -0,0 +1,7 @@
+
+
+FAIL dialog.show(): focusing steps should not change focus when dialog is inert assert_equals: dialog.show(): focusing steps should not change focus when dialog is inert expected Element node <input id="outer-input"></input> but got Element node <input autofocus=""></input>
+FAIL dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert assert_equals: dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert expected Element node <body>
+<input id="outer-input">
+<dialog inert="" open="">... but got Element node <input autofocus=""></input>
+

Added: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt (0 => 290554)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt	2022-02-27 07:06:29 UTC (rev 290554)
@@ -0,0 +1,13 @@
+
+PASS dialog element: showModal()
+PASS showModal() on a <dialog> that already has an open attribute throws an InvalidStateError exception
+PASS showModal() on a <dialog> after initial showModal() and removing the open attribute
+PASS showModal() on a <dialog> not in a Document throws an InvalidStateError exception
+PASS when opening multiple dialogs, only the newest one is non-inert
+PASS opening dialog without focusable children
+PASS opening dialog with multiple focusable children
+FAIL opening dialog with multiple focusable children, one having the autofocus attribute assert_equals: expected Element node <input id="i82" value="foobar" autofocus=""></input> but got Element node <body><div id="log"></div>
+<button id="b0">OK</button>
+<d...
+PASS when opening multiple dialogs, the most recently opened is rendered on top
+OK

Modified: trunk/Source/WebCore/ChangeLog (290553 => 290554)


--- trunk/Source/WebCore/ChangeLog	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/ChangeLog	2022-02-27 07:06:29 UTC (rev 290554)
@@ -1,3 +1,28 @@
+2022-02-26  Tim Nguyen  <[email protected]>
+
+        Remove Node::deprecatedIsInert
+        https://bugs.webkit.org/show_bug.cgi?id=230845
+
+        Reviewed by Antti Koivisto.
+
+        This change unfortunately regresses focusability state when dynamically setting inert, due to a cached
+        computed style invalidation bug. This is minor in practice, since focusability usually gets queried in
+        user-initiated ways, when style already has fully been updated.
+
+        However, making this change will improve performance by avoiding a full DOM ancestor walk when there
+        is no inert attribute on the page, since we will only check a style bit after this patch.
+
+        * dom/Element.cpp:
+        (WebCore::Element::isFocusable const):
+        (WebCore::Element::isFocusableWithoutResolvingFullStyle const):
+        (WebCore::Element::isVisibleWithoutResolvingFullStyle const): Deleted.
+        * dom/Element.h:
+        * dom/Node.cpp:
+        (WebCore::Node::deprecatedIsInert const): Deleted.
+        * dom/Node.h:
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::isFocusable const):
+
 2022-02-26  Tyler Wilcock  <[email protected]>
 
         AX: Remove unnecessary AccessibilityRenderObject::init() override

Modified: trunk/Source/WebCore/dom/Element.cpp (290553 => 290554)


--- trunk/Source/WebCore/dom/Element.cpp	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/dom/Element.cpp	2022-02-27 07:06:29 UTC (rev 290554)
@@ -735,7 +735,7 @@
 
 bool Element::isFocusable() const
 {
-    if (!isConnected() || !supportsFocus() || deprecatedIsInert())
+    if (!isConnected() || !supportsFocus())
         return false;
 
     if (!renderer()) {
@@ -742,10 +742,10 @@
         // Elements in canvas fallback content are not rendered, but they are allowed to be
         // focusable as long as their canvas is displayed and visible.
         if (auto* canvas = ancestorsOfType<HTMLCanvasElement>(*this).first())
-            return canvas->isVisibleWithoutResolvingFullStyle();
+            return canvas->isFocusableWithoutResolvingFullStyle();
     }
 
-    return isVisibleWithoutResolvingFullStyle();
+    return isFocusableWithoutResolvingFullStyle();
 }
 
 bool Element::isUserActionElementInActiveChain() const
@@ -3555,11 +3555,10 @@
     return true;
 }
 
-bool Element::isVisibleWithoutResolvingFullStyle() const
+bool Element::isFocusableWithoutResolvingFullStyle() const
 {
-
     if (renderStyle() || hasValidStyle())
-        return renderStyle() && renderStyle()->visibility() == Visibility::Visible;
+        return renderStyle() && renderStyle()->visibility() == Visibility::Visible && !renderStyle()->effectiveInert();
 
     auto computedStyleForElement = [](Element& element) -> const RenderStyle* {
         auto* style = element.hasNodeFlag(NodeFlag::IsComputedStyleInvalidFlag) ? nullptr : element.existingComputedStyle();
@@ -3574,7 +3573,7 @@
     if (style->display() == DisplayType::None || style->display() == DisplayType::Contents)
         return false;
 
-    if (style->visibility() != Visibility::Visible)
+    if (style->visibility() != Visibility::Visible || style->effectiveInert())
         return false;
 
     for (auto& element : composedTreeAncestors(const_cast<Element&>(*this))) {

Modified: trunk/Source/WebCore/dom/Element.h (290553 => 290554)


--- trunk/Source/WebCore/dom/Element.h	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/dom/Element.h	2022-02-27 07:06:29 UTC (rev 290554)
@@ -378,7 +378,7 @@
     bool needsStyleInvalidation() const;
 
     bool hasValidStyle() const;
-    bool isVisibleWithoutResolvingFullStyle() const;
+    bool isFocusableWithoutResolvingFullStyle() const;
 
     // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
     bool styleAffectedByEmpty() const { return hasStyleFlag(NodeStyleFlag::StyleAffectedByEmpty); }

Modified: trunk/Source/WebCore/dom/Node.cpp (290553 => 290554)


--- trunk/Source/WebCore/dom/Node.cpp	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/dom/Node.cpp	2022-02-27 07:06:29 UTC (rev 290554)
@@ -2615,28 +2615,6 @@
     return const_cast<void*>(static_cast<const void*>(node));
 }
 
-// Please use RenderStyle::effectiveInert instead!
-bool Node::deprecatedIsInert() const
-{
-    if (!isConnected())
-        return true;
-
-    if (this != &document()) {
-        Node* activeModalDialog = document().activeModalDialog();
-        if (activeModalDialog && !activeModalDialog->containsIncludingShadowDOM(this))
-            return true;
-    }
-
-    if (document().settings().inertAttributeEnabled()) {
-        for (RefPtr element = this; element; element = element->parentElementInComposedTree()) {
-            if (is<HTMLElement>(*element) && downcast<HTMLElement>(*element).hasAttribute(HTMLNames::inertAttr))
-                return true;
-        }
-    }
-
-    return false;
-}
-
 template<> ContainerNode* parent<Tree>(const Node& node)
 {
     return node.parentNode();

Modified: trunk/Source/WebCore/dom/Node.h (290553 => 290554)


--- trunk/Source/WebCore/dom/Node.h	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/dom/Node.h	2022-02-27 07:06:29 UTC (rev 290554)
@@ -528,9 +528,6 @@
     static int32_t flagIsParsingChildrenFinished() { return static_cast<int32_t>(NodeFlag::IsParsingChildrenFinished); }
 #endif // ENABLE(JIT)
 
-    // Whether a node is inert, please use RenderStyle::effectiveInert instead!
-    bool deprecatedIsInert() const;
-
 protected:
     enum class NodeFlag : uint32_t {
         IsCharacterData = 1 << 0,

Modified: trunk/Source/WebCore/html/HTMLAreaElement.cpp (290553 => 290554)


--- trunk/Source/WebCore/html/HTMLAreaElement.cpp	2022-02-27 00:46:24 UTC (rev 290553)
+++ trunk/Source/WebCore/html/HTMLAreaElement.cpp	2022-02-27 07:06:29 UTC (rev 290554)
@@ -211,7 +211,7 @@
 bool HTMLAreaElement::isFocusable() const
 {
     RefPtr<HTMLImageElement> image = imageElement();
-    if (!image || !image->isVisibleWithoutResolvingFullStyle())
+    if (!image || !image->isFocusableWithoutResolvingFullStyle())
         return false;
 
     return supportsFocus() && tabIndexSetExplicitly().value_or(0) >= 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to