Bug 1545190 - Allow table in host and row in shadow. r=Jamie a=pascalc
authorEitan Isaacson <eitan@monotonous.org>
Thu, 18 Apr 2019 22:52:06 +0000
changeset 523303 26a86dd8c8bc764d88320c9723e4d3135fed1137
parent 523302 d9dcd33ef48b1322bb19956d35baf72083e7fcca
child 523304 9c937da2511daebe7f34ad3a89e53c87ff56ae5e
push id11138
push userarchaeopteryx@coole-files.de
push dateTue, 23 Apr 2019 19:02:09 +0000
treeherdermozilla-beta@c53e3fd76964 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie, pascalc
bugs1545190
milestone67.0
Bug 1545190 - Allow table in host and row in shadow. r=Jamie a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D27993
accessible/base/nsAccessibilityService.cpp
accessible/tests/mochitest/elm/test_shadowroot_subframe.html
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1388,24 +1388,29 @@ nsAccessibilityService::CreateAccessible
     case eHTMLTableRowType: {
       // Accessible HTML table row may be a child of tbody/tfoot/thead of
       // accessible HTML table or a direct child of accessible of HTML table.
       Accessible* table = aContext->IsTable() ? aContext : nullptr;
       if (!table && aContext->Parent() && aContext->Parent()->IsTable())
         table = aContext->Parent();
 
       if (table) {
-        nsIContent* parentContent = aContent->GetParent();
-        nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
-        if (!parentFrame->IsTableWrapperFrame()) {
-          parentContent = parentContent->GetParent();
+        nsIContent* parentContent = aContent->GetParentOrHostNode()->AsContent();
+        nsIFrame* parentFrame = nullptr;
+        if (parentContent) {
           parentFrame = parentContent->GetPrimaryFrame();
+          if (!parentFrame || !parentFrame->IsTableWrapperFrame()) {
+            parentContent = parentContent->GetParentOrHostNode()->AsContent();
+            if (parentContent) {
+              parentFrame = parentContent->GetPrimaryFrame();
+            }
+          }
         }
 
-        if (parentFrame->IsTableWrapperFrame() &&
+        if (parentFrame && parentFrame->IsTableWrapperFrame() &&
             table->GetContent() == parentContent) {
           newAcc = new HTMLTableRowAccessible(aContent, document);
         }
       }
       break;
     }
     case eHTMLTextFieldType:
       newAcc = new HTMLTextFieldAccessible(aContent, document);
--- a/accessible/tests/mochitest/elm/test_shadowroot_subframe.html
+++ b/accessible/tests/mochitest/elm/test_shadowroot_subframe.html
@@ -19,32 +19,50 @@
           role: ROLE_PUSHBUTTON,
         },
         {
           role: ROLE_LINK,
         },
         ],
       });
 
+      // Shadow root boundary between table and row
+      testElm("table", {
+        role: ROLE_TABLE,
+        children: [
+        {
+          role: ROLE_ROW,
+        },
+        ],
+      });
+
       SimpleTest.finish();
     }
 
     addA11yLoadEvent(doTest);
   </script>
 
 </head>
 <body>
   <div role="group" id="component"></div>
+  <div id="table" role="table" style="display: table;"></div>
+
   <script>
     var component = document.getElementById("component");
     var shadow = component.attachShadow({mode: "open"});
 
     var button = document.createElement("button");
     button.append("Hello");
 
     var a = document.createElement("a");
     a.setAttribute("href", "#");
     a.append(" World");
 
     shadow.appendChild(button);
     shadow.appendChild(a);
+
+    var table = document.getElementById("table");
+    shadow = table.attachShadow({mode: "open"});
+    shadow.innerHTML = "<div style='display: table-row'>" +
+      "<div style='display: table-cell'>hi</div>" +
+      "</div>";
   </script>
 </body>