<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165535] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165535">165535</a></dd>
<dt>Author</dt> <dd>cfleizach@apple.com</dd>
<dt>Date</dt> <dd>2014-03-13 09:28:24 -0700 (Thu, 13 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: accessibility data table heuristics fail on this jQuery table
https://bugs.webkit.org/show_bug.cgi?id=129369

Reviewed by Mario Sanchez Prada.

Source/WebCore: 

Updated accessibility/table-detection.html

If a table uses display style of table-row-group, the RenderTable gets disassociated from the HTMLTableElement.
We can find that element in a different way by asking for the parent of the first table section.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::activeDescendant):
    This method was accessing an object's element unsafely and this table change exposed the issue.
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::tableElement):
(WebCore::AccessibilityTable::isDataTable):
* accessibility/AccessibilityTable.h:

LayoutTests: 

* accessibility/table-detection.html:
* platform/mac/accessibility/table-detection-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsaccessibilitytabledetectionhtml">trunk/LayoutTests/accessibility/table-detection.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacaccessibilitytabledetectionexpectedtxt">trunk/LayoutTests/platform/mac/accessibility/table-detection-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityTablecpp">trunk/Source/WebCore/accessibility/AccessibilityTable.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityTableh">trunk/Source/WebCore/accessibility/AccessibilityTable.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/LayoutTests/ChangeLog        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-03-12  Chris Fleizach  &lt;cfleizach@apple.com&gt;
+
+        AX: accessibility data table heuristics fail on this jQuery table
+        https://bugs.webkit.org/show_bug.cgi?id=129369
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/table-detection.html:
+        * platform/mac/accessibility/table-detection-expected.txt:
+
</ins><span class="cx"> 2014-03-12  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Subpixel rendering: LayoutTests/compositing/hidpi-simple-container-layer-on-device-pixel-expected.html fails on Mountain Lion WK2 debug
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitytabledetectionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/accessibility/table-detection.html (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/table-detection.html        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/LayoutTests/accessibility/table-detection.html        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+&lt;!DOCTYPE html&gt;
</ins><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx">     if (window.testRunner)
</span><span class="lines">@@ -211,6 +212,25 @@
</span><span class="cx">     &lt;tr&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;/tr&gt;
</span><span class="cx">     &lt;/table&gt;
</span><span class="cx"> 
</span><ins>+    &lt;h2 tabindex=0&gt;
+        This should be a table even though it uses table-row-group for it's display type.
+    &lt;/h2&gt;
+
+    &lt;style&gt;
+    @media all { 
+       .tableRowGroup {
+          display: table-row-group !important;
+       }
+    }
+    &lt;/style&gt;
+
+    &lt;table border=0 class=&quot;tableRowGroup&quot;&gt;
+    &lt;thead&gt;&lt;tr&gt;&lt;th&gt;head&lt;/th&gt;&lt;th&gt;head2&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
+    &lt;tbody class=&quot;rowGroup&quot;&gt;
+    &lt;tr&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;td&gt;asdf&lt;/td&gt;&lt;/tr&gt;
+    &lt;/tbody&gt;
+    &lt;/table&gt;
+
</ins><span class="cx">     &lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
</span><span class="cx">     
</span><span class="cx">     &lt;script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacaccessibilitytabledetectionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/accessibility/table-detection-expected.txt (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/accessibility/table-detection-expected.txt        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/LayoutTests/platform/mac/accessibility/table-detection-expected.txt        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -392,7 +392,7 @@
</span><span class="cx"> AXChildren: &lt;array of size 1&gt;
</span><span class="cx"> AXHelp: 
</span><span class="cx"> AXParent: &lt;AXGroup&gt;
</span><del>-AXSize: NSSize: {769, 26}
</del><ins>+AXSize: NSSize: {769, 27}
</ins><span class="cx"> AXTitle: 
</span><span class="cx"> AXDescription: 
</span><span class="cx"> AXValue: 
</span><span class="lines">@@ -424,7 +424,7 @@
</span><span class="cx"> AXChildren: &lt;array of size 1&gt;
</span><span class="cx"> AXHelp: 
</span><span class="cx"> AXParent: &lt;AXGroup&gt;
</span><del>-AXSize: NSSize: {130, 14}
</del><ins>+AXSize: NSSize: {130, 19}
</ins><span class="cx"> AXTitle: 
</span><span class="cx"> AXDescription: 
</span><span class="cx"> AXValue: 
</span><span class="lines">@@ -762,3 +762,45 @@
</span><span class="cx"> asdf
</span><span class="cx"> asdf
</span><span class="cx"> 
</span><ins>+This should be a table even though it uses table-row-group for it's display type.
+
+AXRole: AXTable
+AXSubrole: (null)
+AXRoleDescription: table
+AXChildren: &lt;array of size 5&gt;
+AXHelp: 
+AXParent: &lt;AXTable&gt;
+AXSize: NSSize: {84, 47}
+AXTitle: 
+AXDescription: 
+AXValue: 
+AXFocused: 0
+AXEnabled: 1
+AXWindow: &lt;AXTable&gt;
+AXSelectedTextMarkerRange: (null)
+AXStartTextMarker: &lt;AXTable&gt;
+AXEndTextMarker: &lt;AXTable&gt;
+AXVisited: 0
+AXLinkedUIElements: (null)
+AXSelected: 0
+AXBlockQuoteLevel: 0
+AXTopLevelUIElement: &lt;AXTable&gt;
+AXLanguage: 
+AXDOMIdentifier: 
+AXDOMClassList: &lt;array of size 0&gt;
+AXRows: &lt;array of size 2&gt;
+AXVisibleRows: &lt;array of size 2&gt;
+AXColumns: &lt;array of size 2&gt;
+AXVisibleColumns: &lt;array of size 2&gt;
+AXVisibleCells: &lt;array of size 4&gt;
+AXColumnHeaderUIElements: &lt;array of size 2&gt;
+AXRowHeaderUIElements: &lt;array of size 1&gt;
+AXHeader: &lt;AXTable&gt;
+AXColumnCount: 2
+AXRowCount: 2
+AXElementBusy: 0
+
+
+head        head2
+asdf        asdf
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/Source/WebCore/ChangeLog        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-03-13  Chris Fleizach  &lt;cfleizach@apple.com&gt;
+
+        AX: accessibility data table heuristics fail on this jQuery table
+        https://bugs.webkit.org/show_bug.cgi?id=129369
+
+        Reviewed by Mario Sanchez Prada.
+
+        Updated accessibility/table-detection.html
+
+        If a table uses display style of table-row-group, the RenderTable gets disassociated from the HTMLTableElement.
+        We can find that element in a different way by asking for the parent of the first table section.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::activeDescendant):
+            This method was accessing an object's element unsafely and this table change exposed the issue.
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::tableElement):
+        (WebCore::AccessibilityTable::isDataTable):
+        * accessibility/AccessibilityTable.h:
+
</ins><span class="cx"> 2014-03-13  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ensure that layout milestones complete in all cases
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -2271,19 +2271,19 @@
</span><span class="cx"> AccessibilityObject* AccessibilityRenderObject::activeDescendant() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_renderer)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     
</span><del>-    if (m_renderer-&gt;node() &amp;&amp; !m_renderer-&gt;node()-&gt;isElementNode())
-        return 0;
-    Element* element = toElement(m_renderer-&gt;node());
-        
-    const AtomicString&amp; activeDescendantAttrStr = element-&gt;getAttribute(aria_activedescendantAttr);
</del><ins>+    const AtomicString&amp; activeDescendantAttrStr = getAttribute(aria_activedescendantAttr);
</ins><span class="cx">     if (activeDescendantAttrStr.isNull() || activeDescendantAttrStr.isEmpty())
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     
</span><ins>+    Element* element = this-&gt;element();
+    if (!element)
+        return nullptr;
+    
</ins><span class="cx">     Element* target = element-&gt;treeScope().getElementById(activeDescendantAttrStr);
</span><span class="cx">     if (!target)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     
</span><span class="cx">     if (AXObjectCache* cache = axObjectCache()) {
</span><span class="cx">         AccessibilityObject* obj = cache-&gt;getOrCreate(target);
</span><span class="lines">@@ -2292,7 +2292,7 @@
</span><span class="cx">             return obj;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void AccessibilityRenderObject::handleAriaExpandedChanged()
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityTablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -90,6 +90,28 @@
</span><span class="cx">     return m_isAccessibilityTable;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+HTMLTableElement* AccessibilityTable::tableElement() const
+{
+    if (!m_renderer-&gt;isTable())
+        return nullptr;
+    
+    RenderTable* table = toRenderTable(m_renderer);
+    if (table-&gt;element() &amp;&amp; isHTMLTableElement(table-&gt;element()))
+        return toHTMLTableElement(table-&gt;element());
+    
+    // If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement.
+    // We can instead find it by asking the firstSection for its parent.
+    RenderTableSection* firstBody = table-&gt;firstBody();
+    if (!firstBody || !firstBody-&gt;element())
+        return nullptr;
+    
+    Element* actualTable = firstBody-&gt;element()-&gt;parentElement();
+    if (!actualTable || !isHTMLTableElement(actualTable))
+        return nullptr;
+    
+    return toHTMLTableElement(actualTable);
+}
+    
</ins><span class="cx"> bool AccessibilityTable::isDataTable() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_renderer)
</span><span class="lines">@@ -105,28 +127,29 @@
</span><span class="cx">     if (node() &amp;&amp; node()-&gt;hasEditableStyle())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    if (!m_renderer-&gt;isTable())
+        return false;
+
</ins><span class="cx">     // This employs a heuristic to determine if this table should appear.
</span><span class="cx">     // Only &quot;data&quot; tables should be exposed as tables.
</span><span class="cx">     // Unfortunately, there is no good way to determine the difference
</span><span class="cx">     // between a &quot;layout&quot; table and a &quot;data&quot; table.
</span><del>-    
</del><span class="cx">     RenderTable* table = toRenderTable(m_renderer);
</span><del>-    if (!table-&gt;element() || !isHTMLTableElement(table-&gt;element()))
-        return false;
</del><ins>+    HTMLTableElement* tableElement = this-&gt;tableElement();
+    if (tableElement) {
+        // If there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table.
+        if (!tableElement-&gt;summary().isEmpty() || tableElement-&gt;tHead() || tableElement-&gt;tFoot() || tableElement-&gt;caption())
+            return true;
+        
+        // If someone used &quot;rules&quot; attribute than the table should appear.
+        if (!tableElement-&gt;rules().isEmpty())
+            return true;
</ins><span class="cx"> 
</span><del>-    // if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
-    HTMLTableElement* tableElement = toHTMLTableElement(table-&gt;element());
-    if (!tableElement-&gt;summary().isEmpty() || tableElement-&gt;tHead() || tableElement-&gt;tFoot() || tableElement-&gt;caption())
-        return true;
-    
-    // if someone used &quot;rules&quot; attribute than the table should appear
-    if (!tableElement-&gt;rules().isEmpty())
-        return true;    
-
-    // if there's a colgroup or col element, it's probably a data table.
-    for (const auto&amp; child : childrenOfType&lt;Element&gt;(*tableElement)) {
-        if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
-            return true;
</del><ins>+        // If there's a colgroup or col element, it's probably a data table.
+        for (const auto&amp; child : childrenOfType&lt;Element&gt;(*tableElement)) {
+            if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
+                return true;
+        }
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     // go through the cell's and check for tell-tale signs of &quot;data&quot; table status
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityTableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.h (165534 => 165535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityTable.h        2014-03-13 15:41:42 UTC (rev 165534)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.h        2014-03-13 16:28:24 UTC (rev 165535)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class AccessibilityTableCell;
</span><ins>+class HTMLTableElement;
</ins><span class="cx"> class RenderTableSection;
</span><span class="cx">     
</span><span class="cx"> class AccessibilityTable : public AccessibilityRenderObject {
</span><span class="lines">@@ -96,6 +97,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     virtual void titleElementText(Vector&lt;AccessibilityText&gt;&amp;) const override;
</span><ins>+    HTMLTableElement* tableElement() const;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityTable, isTable())
</span></span></pre>
</div>
</div>

</body>
</html>