Changeset 158914 in webkit


Ignore:
Timestamp:
Nov 8, 2013 2:55:38 AM (10 years ago)
Author:
mario@webkit.org
Message:

AX: [ATK] <span> elements exposed through ATK when not needed
https://bugs.webkit.org/show_bug.cgi?id=123885

Reviewed by Chris Fleizach.

Source/WebCore:

As per SVN r158195, the way it's decided whether <span> elements
should be ignored or not has slightly changed, causing that the
GTK/EFL ports expose them in cases that they should be ignored,
such as for text elements that neither are focusable (e.g. by
explicitly setting tabindex) nor have a meaningful accessible name
suggesting they should be exposed.

As a result, the flattening that ATK based ports normally do for
this kind of elements (by folding them into their parents) do not
work correctly anymore, making two tests to fail:

platform/gtk/accessibility/spans-paragraphs-and-divs.html
platform/gtk/accessibility/spans.html

This patch encapsulates the part of the logic that affects this in
the computeAccessibilityIsIgnored() method, placing it in a
new method of AccessibilityObject that we can call from ATK's
accessibilityPlatformIncludesObject() to ensure we hide those
<span> elements when they don't fulfill those requirements.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::hasAttributesRequiredForInclusion):
New virtual method encapsulating part of the logic from the function
that computes whether accessibility should be ignored or not.

  • accessibility/AccessibilityObject.h:
  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::hasAttributesRequiredForInclusion):
Override of the new method adding additional checks, as extracted from
the original bits in computeAccessibilityIsIgnored().

  • accessibility/AccessibilityNodeObject.h:
  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
Use the newly added function where we had the original code before.

  • accessibility/atk/AccessibilityObjectAtk.cpp:

(WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
Make sure <span> elements are ignored if they are not focusable
and they don't have a meaningful accessible name.

LayoutTests:

Removed failure expectations for tests now passing.

  • platform/gtk/TestExpectations: Removed expectations.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158913 r158914  
     12013-11-08  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        AX: [ATK] <span> elements exposed through ATK when not needed
     4        https://bugs.webkit.org/show_bug.cgi?id=123885
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Removed failure expectations for tests now passing.
     9
     10        * platform/gtk/TestExpectations: Removed expectations.
     11
    1122013-11-08  Krzysztof Czech  <k.czech@samsung.com>
    213
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r158913 r158914  
    13231323webkit.org/b/114259 platform/gtk/accessibility/combo-box-collapsed-selection-changed.html [ Failure ]
    13241324
    1325 webkit.org/b/123885 platform/gtk/accessibility/spans-paragraphs-and-divs.html [ Failure ]
    1326 webkit.org/b/123885 platform/gtk/accessibility/spans.html [ Failure ]
    1327 
    13281325webkit.org/b/114612 editing/style/block-style-005.html [ Failure ]
    13291326
  • trunk/Source/WebCore/ChangeLog

    r158910 r158914  
     12013-11-08  Mario Sanchez Prada  <mario.prada@samsung.com>
     2
     3        AX: [ATK] <span> elements exposed through ATK when not needed
     4        https://bugs.webkit.org/show_bug.cgi?id=123885
     5
     6        Reviewed by Chris Fleizach.
     7
     8        As per SVN r158195, the way it's decided whether <span> elements
     9        should be ignored or not has slightly changed, causing that the
     10        GTK/EFL ports expose them in cases that they should be ignored,
     11        such as for text elements that neither are focusable (e.g. by
     12        explicitly setting tabindex) nor have a meaningful accessible name
     13        suggesting they should be exposed.
     14
     15        As a result, the flattening that ATK based ports normally do for
     16        this kind of elements (by folding them into their parents) do not
     17        work correctly anymore, making two tests to fail:
     18
     19            platform/gtk/accessibility/spans-paragraphs-and-divs.html
     20            platform/gtk/accessibility/spans.html
     21
     22        This patch encapsulates the part of the logic that affects this in
     23        the computeAccessibilityIsIgnored() method, placing it in a
     24        new method of AccessibilityObject that we can call from ATK's
     25        accessibilityPlatformIncludesObject() to ensure we hide those
     26        <span> elements when they don't fulfill those requirements.
     27
     28        * accessibility/AccessibilityObject.cpp:
     29        (WebCore::AccessibilityObject::hasAttributesRequiredForInclusion):
     30        New virtual method encapsulating part of the logic from the function
     31        that computes whether accessibility should be ignored or not.
     32        * accessibility/AccessibilityObject.h:
     33
     34        * accessibility/AccessibilityNodeObject.cpp:
     35        (WebCore::AccessibilityNodeObject::hasAttributesRequiredForInclusion):
     36        Override of the new method adding additional checks, as extracted from
     37        the original bits in computeAccessibilityIsIgnored().
     38        * accessibility/AccessibilityNodeObject.h:
     39
     40        * accessibility/AccessibilityRenderObject.cpp:
     41        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
     42        Use the newly added function where we had the original code before.
     43
     44        * accessibility/atk/AccessibilityObjectAtk.cpp:
     45        (WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
     46        Make sure <span> elements are ignored if they are not focusable
     47        and they don't have a meaningful accessible name.
     48
    1492013-11-08  Carlos Garcia Campos  <cgarcia@igalia.com>
    250
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r158743 r158914  
    19151915}
    19161916
     1917bool AccessibilityNodeObject::hasAttributesRequiredForInclusion() const
     1918{
     1919    if (AccessibilityObject::hasAttributesRequiredForInclusion())
     1920        return true;
     1921
     1922    if (!ariaAccessibilityDescription().isEmpty())
     1923        return true;
     1924
     1925    return false;
     1926}
     1927
    19171928bool AccessibilityNodeObject::canSetFocusAttribute() const
    19181929{
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h

    r157782 r158914  
    129129    virtual void colorValue(int& r, int& g, int& b) const OVERRIDE;
    130130    virtual String ariaLabeledByAttribute() const OVERRIDE;
     131    virtual bool hasAttributesRequiredForInclusion() const OVERRIDE FINAL;
    131132
    132133    virtual Element* actionElement() const OVERRIDE;
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r158617 r158914  
    4343#include "LocalizedStrings.h"
    4444#include "MainFrame.h"
     45#include "MathMLNames.h"
    4546#include "NodeList.h"
    4647#include "NodeTraversal.h"
     
    511512        previousObject = startObject;
    512513    }
     514}
     515
     516bool AccessibilityObject::hasAttributesRequiredForInclusion() const
     517{
     518    // These checks are simplified in the interest of execution speed.
     519    if (!getAttribute(aria_helpAttr).isEmpty()
     520        || !getAttribute(aria_describedbyAttr).isEmpty()
     521        || !getAttribute(altAttr).isEmpty()
     522        || !getAttribute(titleAttr).isEmpty())
     523        return true;
     524
     525#if ENABLE(MATHML)
     526    if (!getAttribute(MathMLNames::alttextAttr).isEmpty())
     527        return true;
     528#endif
     529
     530    return false;
    513531}
    514532
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r158743 r158914  
    608608    // A programmatic way to set a name on an AccessibleObject.
    609609    virtual void setAccessibleName(const AtomicString&) { }
     610    virtual bool hasAttributesRequiredForInclusion() const;
    610611
    611612    // Accessibility Text - (To be deprecated).
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r158844 r158914  
    12981298        return false;
    12991299   
    1300     // Using the help text, title or accessibility description (so we
    1301     // check if there's some kind of accessible name for the element)
    1302     // to decide an element's visibility is not as definitive as
    1303     // previous checks, so this should remain as one of the last.
    1304     //
    1305     // These checks are simplified in the interest of execution speed;
    1306     // for example, any element having an alt attribute will make it
    1307     // not ignored, rather than just images.
    1308     if (!getAttribute(aria_helpAttr).isEmpty() || !getAttribute(aria_describedbyAttr).isEmpty() || !getAttribute(altAttr).isEmpty() || !getAttribute(titleAttr).isEmpty())
     1300    // Using the presence of an accessible name to decide an element's visibility is not
     1301    // as definitive as previous checks, so this should remain as one of the last.
     1302    if (hasAttributesRequiredForInclusion())
    13091303        return false;
    13101304
     
    13131307    if (isGenericFocusableElement() && node->firstChild())
    13141308        return false;
    1315 
    1316     if (!ariaAccessibilityDescription().isEmpty())
    1317         return false;
    1318 
    1319 #if ENABLE(MATHML)
    1320     if (!getAttribute(MathMLNames::alttextAttr).isEmpty())
    1321         return false;
    1322 #endif
    13231309
    13241310    // <span> tags are inline tags and not meant to convey information if they have no other aria
  • trunk/Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp

    r156295 r158914  
    2222#include "AccessibilityObject.h"
    2323
     24#include "HTMLNames.h"
    2425#include "RenderObject.h"
    2526#include "RenderText.h"
     
    7980        return IgnoreObject;
    8081
     82    // Lines past this point only make sense for AccessibilityRenderObjects.
     83    RenderObject* renderObject = renderer();
     84    if (!renderObject)
     85        return DefaultBehavior;
     86
     87    // We don't want <span> elements to show up in the accessibility hierarchy unless
     88    // we have good reasons for that (e.g. focusable or visible because of containing
     89    // a meaningful accessible name, maybe set through ARIA), so we can use
     90    // atk_component_grab_focus() to set the focus to it.
     91    Node* node = renderObject->node();
     92    if (node && node->hasTagName(HTMLNames::spanTag) && !canSetFocusAttribute() && !hasAttributesRequiredForInclusion())
     93        return IgnoreObject;
     94
    8195    // Given a paragraph or div containing a non-nested anonymous block, WebCore
    8296    // ignores the paragraph or div and includes the block. We want the opposite:
     
    87101        // Don't call textUnderElement() here, because it's slow and it can
    88102        // crash when called while we're in the middle of a subtree being deleted.
    89         if (!renderer()->firstChildSlow())
     103        if (!renderObject->firstChildSlow())
    90104            return DefaultBehavior;
    91105
     
    93107            return DefaultBehavior;
    94108
    95         for (RenderObject* r = renderer()->firstChildSlow(); r; r = r->nextSibling()) {
     109        for (RenderObject* r = renderObject->firstChildSlow(); r; r = r->nextSibling()) {
    96110            if (r->isAnonymousBlock())
    97111                return IncludeObject;
     
    110124    // have we encountered instances where the parent of an anonymous block also lacked
    111125    // an aria role but the grandparent had one.
    112     if (renderer() && renderer()->isAnonymousBlock() && !parent->renderer()->isBody()
     126    if (renderObject && renderObject->isAnonymousBlock() && !parent->renderer()->isBody()
    113127        && parent->ariaRoleAttribute() == UnknownRole)
    114128        return IgnoreObject;
Note: See TracChangeset for help on using the changeset viewer.