Title: [281309] trunk
Revision
281309
Author
[email protected]
Date
2021-08-20 05:56:14 -0700 (Fri, 20 Aug 2021)

Log Message

Initial implementation of inert subtrees
https://bugs.webkit.org/show_bug.cgi?id=110952

Reviewed by Antti Koivisto.

Currently covers:
- Blocking focus & selecting
- aria-hidden like behaviour

Hit testing/event retargeting will be covered by https://bugs.webkit.org/show_bug.cgi?id=229330 pending a spec issue

Relevant WPT enabled. More testing coverage will be provided with the inert attribute.

LayoutTests/imported/w3c:

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

Source/WebCore:

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isAXHidden const):
* dom/Element.cpp:
(WebCore::Element::isFocusable const):
* dom/Node.cpp:
(WebCore::Node::canStartSelection const):
(WebCore::Node::isInert const):
* dom/Node.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281308 => 281309)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-08-20 12:56:14 UTC (rev 281309)
@@ -1,5 +1,23 @@
 2021-08-20  Tim Nguyen  <[email protected]>
 
+        Initial implementation of inert subtrees
+        https://bugs.webkit.org/show_bug.cgi?id=110952
+
+        Reviewed by Antti Koivisto.
+
+        Currently covers:
+        - Blocking focus & selecting
+        - aria-hidden like behaviour
+
+        Hit testing/event retargeting will be covered by https://bugs.webkit.org/show_bug.cgi?id=229330 pending a spec issue
+
+        Relevant WPT enabled. More testing coverage will be provided with the inert attribute.
+
+        * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt:
+        * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt:
+
+2021-08-20  Tim Nguyen  <[email protected]>
+
         Ensure ancestors with opacity don't affect top layer elements
         https://bugs.webkit.org/show_bug.cgi?id=229317
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt (281308 => 281309)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/inert-node-is-unfocusable-expected.txt	2021-08-20 12:56:14 UTC (rev 281309)
@@ -4,5 +4,5 @@
 I'm tabindexed.
  Link
 
-FAIL Test that inert nodes are not focusable. assert_equals: body expected false but got true
+PASS Test that inert nodes are not focusable.
 

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/remove-dialog-should-unblock-document-expected.txt	2021-08-20 12:56:14 UTC (rev 281309)
@@ -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/Source/WebCore/ChangeLog (281308 => 281309)


--- trunk/Source/WebCore/ChangeLog	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/Source/WebCore/ChangeLog	2021-08-20 12:56:14 UTC (rev 281309)
@@ -1,3 +1,27 @@
+2021-08-20  Tim Nguyen  <[email protected]>
+
+        Initial implementation of inert subtrees
+        https://bugs.webkit.org/show_bug.cgi?id=110952
+
+        Reviewed by Antti Koivisto.
+
+        Currently covers:
+        - Blocking focus & selecting
+        - aria-hidden like behaviour
+
+        Hit testing/event retargeting will be covered by https://bugs.webkit.org/show_bug.cgi?id=229330 pending a spec issue
+
+        Relevant WPT enabled. More testing coverage will be provided with the inert attribute.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isAXHidden const):
+        * dom/Element.cpp:
+        (WebCore::Element::isFocusable const):
+        * dom/Node.cpp:
+        (WebCore::Node::canStartSelection const):
+        (WebCore::Node::isInert const):
+        * dom/Node.h:
+
 2021-08-20  Alan Bujtas  <[email protected]>
 
         [LFC][Integration] line-clamp is an unsupported CSS property

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (281308 => 281309)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2021-08-20 12:56:14 UTC (rev 281309)
@@ -3227,6 +3227,9 @@
 // http://www.w3.org/TR/wai-aria/terms#def_hidden
 bool AccessibilityObject::isAXHidden() const
 {
+    if (node() && node()->isInert())
+        return true;
+
     if (isFocused())
         return false;
     

Modified: trunk/Source/WebCore/dom/Element.cpp (281308 => 281309)


--- trunk/Source/WebCore/dom/Element.cpp	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/Source/WebCore/dom/Element.cpp	2021-08-20 12:56:14 UTC (rev 281309)
@@ -644,7 +644,7 @@
 
 bool Element::isFocusable() const
 {
-    if (!isConnected() || !supportsFocus())
+    if (!isConnected() || !supportsFocus() || isInert())
         return false;
 
     if (!renderer()) {

Modified: trunk/Source/WebCore/dom/Node.cpp (281308 => 281309)


--- trunk/Source/WebCore/dom/Node.cpp	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/Source/WebCore/dom/Node.cpp	2021-08-20 12:56:14 UTC (rev 281309)
@@ -44,6 +44,7 @@
 #include "FrameView.h"
 #include "HTMLAreaElement.h"
 #include "HTMLBodyElement.h"
+#include "HTMLDialogElement.h"
 #include "HTMLElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLSlotElement.h"
@@ -1126,6 +1127,9 @@
     if (hasEditableStyle())
         return true;
 
+    if (isInert())
+        return false;
+
     if (renderer()) {
         const RenderStyle& style = renderer()->style();
         // We allow selections to begin within an element that has -webkit-user-select: none set,
@@ -2617,6 +2621,23 @@
     return const_cast<void*>(static_cast<const void*>(node));
 }
 
+bool Node::isInert() const
+{
+    if (!isConnected())
+        return true;
+
+    if (this != &document() && this != document().documentElement()) {
+        Node* activeModalDialog = document().activeModalDialog();
+        if (activeModalDialog && !activeModalDialog->containsIncludingShadowDOM(this))
+            return true;
+    }
+
+    if (!document().frame() || !document().frame()->ownerElement())
+        return false;
+
+    return document().frame()->ownerElement()->isInert();
+}
+
 template<> ContainerNode* parent<Tree>(const Node& node)
 {
     return node.parentNode();

Modified: trunk/Source/WebCore/dom/Node.h (281308 => 281309)


--- trunk/Source/WebCore/dom/Node.h	2021-08-20 12:49:48 UTC (rev 281308)
+++ trunk/Source/WebCore/dom/Node.h	2021-08-20 12:56:14 UTC (rev 281309)
@@ -524,6 +524,13 @@
     static int32_t flagIsParsingChildrenFinished() { return static_cast<int32_t>(NodeFlag::IsParsingChildrenFinished); }
 #endif // ENABLE(JIT)
 
+    // Whether the node is inert:
+    // https://html.spec.whatwg.org/multipage/interaction.html#inert
+    // https://github.com/WICG/inert/blob/master/README.md
+    // This can't be in Element because text nodes must be recognized as
+    // inert to prevent text selection.
+    bool isInert() const;
+
 protected:
     enum class NodeFlag : uint32_t {
         IsCharacterData = 1 << 0,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to