Changeset 202497 in webkit


Ignore:
Timestamp:
Jun 27, 2016 10:57:49 AM (8 years ago)
Author:
jdiggs@igalia.com
Message:

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):

Location:
trunk
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202496 r202497  
     12016-06-27  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        AX: Anonymous RenderMathMLOperators are not exposed to the accessibility tree
     4        https://bugs.webkit.org/show_bug.cgi?id=139582
     5        <rdar://problem/26938849>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        This is based on a patch by Frederic Wang <fwang@igalia.com>.
     10
     11        One of the things making it difficult to tell that the operators were not
     12        exposed on the Mac is the fact that the operator text is present. But the
     13        operator text is simply a StaticTextRole object corresponding to the
     14        RenderText descendant of the operator. Furthermore, on the Mac, accessible
     15        math operators have subroles which are missing from the StaticTextRole
     16        object which is exposed. In order to make issues like this more obvious,
     17        add an option to include the subrole to dumpAccessibilityTree() and use it
     18        in the new math-fenced.html.
     19
     20        This change also fixes the mfenced in mac/mathml-elements.html that was
     21        broken after r202420. We enable it again and update the expectations of
     22        that test because the operators are now in the accessibility tree.
     23
     24        We also add a new test to verify the render tree of foreign content in
     25        MathML formulas.
     26
     27        * accessibility/mac/mathml-elements-expected.txt: Updated.
     28        * accessibility/mac/mathml-elements.html: Re-enable the mfenced test.
     29        * accessibility/math-fenced.html: Added.
     30        * accessibility/math-foreign-content.html: Added.
     31        * platform/gtk/accessibility/math-fenced-expected.txt: Added.
     32        * platform/gtk/accessibility/math-foreign-content-expected.txt: Added.
     33        * platform/mac/accessibility/math-fenced-expected.txt: Added.
     34        * platform/mac/accessibility/math-foreign-content-expected.txt: Added.
     35        * resources/accessibility-helper.js: Add option to include subrole in tree.
     36        (dumpAccessibilityTree):
     37
    1382016-06-27  Ryan Haddad  <ryanhaddad@apple.com>
    239
  • trunk/LayoutTests/accessibility/mac/mathml-elements-expected.txt

    r202420 r202497  
    6868PASS fenced.stringAttributeValue('AXMathFencedOpen') is '{'
    6969PASS fenced.stringAttributeValue('AXMathFencedClose') is '}'
     70PASS child.stringValue is 'AXValue: {'
     71PASS child.childAtIndex(0).stringValue is 'AXValue: 2'
     72PASS child.stringValue is 'AXValue: ,'
     73PASS child.childAtIndex(0).stringValue is 'AXValue: a'
     74PASS child.stringValue is 'AXValue: ,'
     75PASS child.childAtIndex(0).stringValue is 'AXValue: e'
     76PASS child.stringValue is 'AXValue: }'
    7077PASS sub.role is 'AXRole: AXGroup'
    7178PASS sub.subrole is 'AXSubrole: AXMathSubscriptSuperscript'
  • trunk/LayoutTests/accessibility/mac/mathml-elements.html

    r202420 r202497  
    109109   shouldBe("fenced.stringAttributeValue('AXMathFencedOpen')", "'{'");
    110110   shouldBe("fenced.stringAttributeValue('AXMathFencedClose')", "'}'");
    111    /*
    112    FIXME: AccessibilityRenderObject should be updated to properly expose the text of mfenced operators.
    113    See https://bugs.webkit.org/show_bug.cgi?id=139582.
    114111   var fenceValues = new Array("{", "2", ",", "a", ",", "e", "}");
    115112   for (var k = 0; k < fenceValues.length; k++) {
     
    120117          shouldBe("child.childAtIndex(0).stringValue", "'AXValue: " + fenceValues[k] + "'");
    121118   }
    122    */
    123119
    124120   // Subscript
  • trunk/LayoutTests/resources/accessibility-helper.js

    r201216 r202497  
    1 function dumpAccessibilityTree(accessibilityObject, stopElement, indent, allAttributesIfNeeded, getValueFromTitle) {
     1function dumpAccessibilityTree(accessibilityObject, stopElement, indent, allAttributesIfNeeded, getValueFromTitle, includeSubrole) {
    22    var str = "";
    33    var i = 0;
     
    66        str += "    ";
    77    str += accessibilityObject.role;
     8    if (includeSubrole === true && accessibilityObject.subrole)
     9        str += " " + accessibilityObject.subrole;
    810    str += " " + (getValueFromTitle === true ? accessibilityObject.title : accessibilityObject.stringValue);
    911    str += allAttributesIfNeeded && accessibilityObject.role == '' ? accessibilityObject.allAttributes() : '';
     
    1719    var count = accessibilityObject.childrenCount;
    1820    for (i = 0; i < count; ++i) {
    19         if (!dumpAccessibilityTree(accessibilityObject.childAtIndex(i), stopElement, indent + 1, allAttributesIfNeeded, getValueFromTitle))
     21        if (!dumpAccessibilityTree(accessibilityObject.childAtIndex(i), stopElement, indent + 1, allAttributesIfNeeded, getValueFromTitle, includeSubrole))
    2022            return false;
    2123    }
  • trunk/Source/WebCore/ChangeLog

    r202494 r202497  
     12016-06-27  Joanmarie Diggs  <jdiggs@igalia.com>
     2
     3        AX: Anonymous RenderMathMLOperators are not exposed to the accessibility tree
     4        https://bugs.webkit.org/show_bug.cgi?id=139582
     5        <rdar://problem/26938849>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        This is based on a patch by Frederic Wang <fwang@igalia.com>.
     10
     11        WebCore assigns the generic MathElementRole AccessibilityRole to elements
     12        which are expected to be included in the accessibility tree. This assignment
     13        is based on the AccessibilityRenderObject's node being a MathMLElement. The
     14        anonymous RenderMathMLOperators fail that test.
     15
     16        From the perspective of accessibility support, these operators function
     17        like MathMLElements. Furthermore, both WebCore and the platforms rely
     18        upon MathElementRole to identify accessible MathML objects. The simplest
     19        fix is to have AccessibilityRenderObject::isMathElement() treat anonymous
     20        MathML operators as if they were MathMLElements.
     21
     22        Now that these operators are being exposed, we need to handle them in
     23        AccessibilityRenderObject::textUnderElement() which assumes that anonymous
     24        objects either have nodes or have children with nodes. And crashes when
     25        that fails to be the case. Making RenderMathMLOperator::textContent()
     26        public and then using it to get the text under anonymous operators solves
     27        this problem. We also assign StaticTextRole to these operators on the Mac
     28        because the default platform mapping of MathElementRole is GroupRole, which
     29        made sense when we had a child RenderText object holding the operator.
     30
     31        Lastly, AccessibilityRenderObject::isIgnoredElementWithinMathTree() no
     32        longer needs to special-case anonymous operators because they now have
     33        MathElementRole.
     34
     35        Tests: accessibility/math-fenced.html
     36               accessibility/math-foreign-content.html
     37
     38        * accessibility/AccessibilityObject.h:
     39        (WebCore::AccessibilityObject::isAnonymousMathOperator):
     40        * accessibility/AccessibilityRenderObject.cpp:
     41        (WebCore::AccessibilityRenderObject::textUnderElement):
     42        (WebCore::AccessibilityRenderObject::stringValue):
     43        (WebCore::AccessibilityRenderObject::isMathElement):
     44        (WebCore::AccessibilityRenderObject::isAnonymousMathOperator):
     45        (WebCore::AccessibilityRenderObject::isIgnoredElementWithinMathTree):
     46        * accessibility/AccessibilityRenderObject.h:
     47        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
     48        (-[WebAccessibilityObjectWrapper role]):
     49        * rendering/mathml/RenderMathMLMath.h:
     50        * rendering/mathml/RenderMathMLOperator.h:
     51        (WebCore::RenderMathMLOperator::textContent):
     52
    1532016-06-27  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    254
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r202063 r202497  
    996996    virtual String mathFencedCloseString() const { return String(); }
    997997    virtual int mathLineThickness() const { return 0; }
     998    virtual bool isAnonymousMathOperator() const { return false; }
    998999   
    9991000    // Multiscripts components.
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r202168 r202497  
    8585#include "RenderMathMLBlock.h"
    8686#include "RenderMathMLFraction.h"
     87#include "RenderMathMLMath.h"
    8788#include "RenderMathMLOperator.h"
    8889#include "RenderMathMLRoot.h"
     
    636637    if (isRenderText && m_renderer->isAnonymous() && ancestorsOfType<RenderMathMLOperator>(*m_renderer).first())
    637638        return downcast<RenderText>(*m_renderer).text();
     639    if (isAnonymousMathOperator()) {
     640        UChar operatorChar = downcast<RenderMathMLOperator>(*m_renderer).textContent();
     641        return operatorChar ? String(&operatorChar, 1) : String();
     642    }
    638643    if (is<RenderMathMLOperator>(*m_renderer) && !m_renderer->isAnonymous())
    639644        return downcast<RenderMathMLOperator>(*m_renderer).element().textContent();
     
    761766       
    762767    if (is<RenderText>(*m_renderer))
     768        return textUnderElement();
     769
     770    if (isAnonymousMathOperator())
    763771        return textUnderElement();
    764772   
     
    36103618        return false;
    36113619   
     3620    // The mfenced element creates anonymous RenderMathMLOperators which should be treated
     3621    // as MathML elements and assigned the MathElementRole so that platform logic regarding
     3622    // inclusion and role mapping is not bypassed.
     3623    if (isAnonymousMathOperator())
     3624        return true;
     3625
    36123626    return is<MathMLElement>(node());
    36133627}
     
    36593673
    36603674    return true;
     3675}
     3676
     3677bool AccessibilityRenderObject::isAnonymousMathOperator() const
     3678{
     3679    return is<RenderMathMLOperator>(m_renderer) && m_renderer->isAnonymous();
    36613680}
    36623681
     
    37523771    if (!m_renderer)
    37533772        return true;
    3754    
    3755     // We ignore anonymous renderers inside math blocks.
    3756     // However, we do not exclude anonymous RenderMathMLOperator nodes created by the mfenced element nor RenderText nodes created by math operators so that the text can be exposed by AccessibilityRenderObject::textUnderElement.
    3757     if (m_renderer->isAnonymous()) {
    3758         if (m_renderer->isRenderMathMLOperator())
    3759             return false;
    3760         for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
    3761             if (parent->isMathElement())
    3762                 return !(m_renderer->isText() && ancestorsOfType<RenderMathMLOperator>(*m_renderer).first());
    3763         }
    3764     }
     3773
     3774    if (is<RenderText>(*m_renderer))
     3775        return false;
    37653776
    37663777    // Only math elements that we explicitly recognize should be included
     
    37753786    }
    37763787
    3777     return false;
     3788    return m_renderer->isAnonymous() && m_renderer->parent() && is<RenderMathMLBlock>(m_renderer->parent());
    37783789}
    37793790
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r201417 r202497  
    328328    String mathFencedCloseString() const override;
    329329    int mathLineThickness() const override;
     330    bool isAnonymousMathOperator() const override;
    330331
    331332    // Multiscripts components.
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

    r202063 r202497  
    22382238        role = StaticTextRole;
    22392239
     2240    // The mfenced element creates anonymous RenderMathMLOperators with no RenderText
     2241    // descendants. Because these anonymous renderers are the only accessible objects
     2242    // containing the operator, assign StaticTextRole.
     2243    if (m_object->isAnonymousMathOperator())
     2244        role = StaticTextRole;
     2245
    22402246    if (role == CanvasRole && m_object->canvasHasFallbackContent())
    22412247        role = GroupRole;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.h

    r200041 r202497  
    4444}
    4545
     46SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLMath, isRenderMathMLMath())
     47
    4648#endif // ENABLE(MATHML)
    4749#endif // RenderMathMLMath_h
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r202420 r202497  
    6363    void updateOperatorProperties();
    6464    void updateFromElement() final;
     65    UChar textContent() const { return m_textContent; }
    6566
    6667protected:
     
    7071    void setLeadingSpace(LayoutUnit leadingSpace) { m_leadingSpace = leadingSpace; }
    7172    void setTrailingSpace(LayoutUnit trailingSpace) { m_trailingSpace = trailingSpace; }
    72     UChar textContent() const { return m_textContent; }
    7373
    7474private:
Note: See TracChangeset for help on using the changeset viewer.