AX: Anonymous RenderMathMLOperators are not exposed to the accessibility tree https://bugs.webkit.org/show_bug.cgi?id=139582 <rdar://problem/26938849> Reviewed by Chris Fleizach. This is based on a patch by Frederic Wang <fwang@igalia.com>. Source/WebCore: WebCore assigns the generic MathElementRole AccessibilityRole to elements which are expected to be included in the accessibility tree. This assignment is based on the AccessibilityRenderObject's node being a MathMLElement. The anonymous RenderMathMLOperators fail that test. From the perspective of accessibility support, these operators function like MathMLElements. Furthermore, both WebCore and the platforms rely upon MathElementRole to identify accessible MathML objects. The simplest fix is to have AccessibilityRenderObject::isMathElement() treat anonymous MathML operators as if they were MathMLElements. Now that these operators are being exposed, we need to handle them in AccessibilityRenderObject::textUnderElement() which assumes that anonymous objects either have nodes or have children with nodes. And crashes when that fails to be the case. Making RenderMathMLOperator::textContent() public and then using it to get the text under anonymous operators solves this problem. We also assign StaticTextRole to these operators on the Mac because the default platform mapping of MathElementRole is GroupRole, which made sense when we had a child RenderText object holding the operator. Lastly, AccessibilityRenderObject::isIgnoredElementWithinMathTree() no longer needs to special-case anonymous operators because they now have MathElementRole. Tests: accessibility/math-fenced.html accessibility/math-foreign-content.html * accessibility/AccessibilityObject.h: (WebCore::AccessibilityObject::isAnonymousMathOperator): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::textUnderElement): (WebCore::AccessibilityRenderObject::stringValue): (WebCore::AccessibilityRenderObject::isMathElement): (WebCore::AccessibilityRenderObject::isAnonymousMathOperator): (WebCore::AccessibilityRenderObject::isIgnoredElementWithinMathTree): * accessibility/AccessibilityRenderObject.h: * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper role]): * rendering/mathml/RenderMathMLMath.h: * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::textContent): LayoutTests: One of the things making it difficult to tell that the operators were not exposed on the Mac is the fact that the operator text is present. But the operator text is simply a StaticTextRole object corresponding to the RenderText descendant of the operator. Furthermore, on the Mac, accessible math operators have subroles which are missing from the StaticTextRole object which is exposed. In order to make issues like this more obvious, add an option to include the subrole to dumpAccessibilityTree() and use it in the new math-fenced.html. This change also fixes the mfenced in mac/mathml-elements.html that was broken after r202420. We enable it again and update the expectations of that test because the operators are now in the accessibility tree. We also add a new test to verify the render tree of foreign content in MathML formulas. * accessibility/mac/mathml-elements-expected.txt: Updated. * accessibility/mac/mathml-elements.html: Re-enable the mfenced test. * accessibility/math-fenced.html: Added. * accessibility/math-foreign-content.html: Added. * platform/gtk/accessibility/math-fenced-expected.txt: Added. * platform/gtk/accessibility/math-foreign-content-expected.txt: Added. * platform/mac/accessibility/math-fenced-expected.txt: Added. * platform/mac/accessibility/math-foreign-content-expected.txt: Added. * resources/accessibility-helper.js: Add option to include subrole in tree. (dumpAccessibilityTree): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202497 268f45cc-cd09-0410-ab3c-d52691b4dbfc

- [D] LayoutTests/accessibility/math-foreign-content.html