Changeset 214112 in webkit


Ignore:
Timestamp:
Mar 17, 2017, 12:48:36 PM (8 years ago)
Author:
n_wang@apple.com
Message:

AX: VoiceOver no longer works corectly with editable text in the web
https://bugs.webkit.org/show_bug.cgi?id=169801

Reviewed by Chris Fleizach.

Source/WebCore:

The issue is that since we are entering text controls when getting the text marker,
the end text marker of the input tag might associate to the placeholder div instead of
the input tag itself.
Fixed the issue by checking the shadow elements using shadowHost() instead of isShadowRoot().
Also, only enter text controls when navigating by characters/indexes, so that both Mac and
iOS will get the correct text marker ranges for shadow host elements.

Tests: accessibility/ios-simulator/element-text-range-for-text-control.html

accessibility/mac/text-markers-for-input-with-placeholder.html

  • accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::traverseToOffsetInRange):
(WebCore::AXObjectCache::startOrEndCharacterOffsetForRange):
(WebCore::AXObjectCache::characterOffsetForIndex):

  • accessibility/AXObjectCache.h:

LayoutTests:

  • accessibility/ios-simulator/element-text-range-for-text-control-expected.txt: Added.
  • accessibility/ios-simulator/element-text-range-for-text-control.html: Added.
  • accessibility/mac/text-markers-for-input-with-placeholder-expected.txt: Added.
  • accessibility/mac/text-markers-for-input-with-placeholder.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214110 r214112  
     12017-03-17  Nan Wang  <n_wang@apple.com>
     2
     3        AX: VoiceOver no longer works corectly with editable text in the web
     4        https://bugs.webkit.org/show_bug.cgi?id=169801
     5
     6        Reviewed by Chris Fleizach.
     7
     8        * accessibility/ios-simulator/element-text-range-for-text-control-expected.txt: Added.
     9        * accessibility/ios-simulator/element-text-range-for-text-control.html: Added.
     10        * accessibility/mac/text-markers-for-input-with-placeholder-expected.txt: Added.
     11        * accessibility/mac/text-markers-for-input-with-placeholder.html: Added.
     12
    1132017-03-17  Dave Hyatt  <hyatt@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r214111 r214112  
     12017-03-17  Nan Wang  <n_wang@apple.com>
     2
     3        AX: VoiceOver no longer works corectly with editable text in the web
     4        https://bugs.webkit.org/show_bug.cgi?id=169801
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The issue is that since we are entering text controls when getting the text marker,
     9        the end text marker of the input tag might associate to the placeholder div instead of
     10        the input tag itself.
     11        Fixed the issue by checking the shadow elements using shadowHost() instead of isShadowRoot().
     12        Also, only enter text controls when navigating by characters/indexes, so that both Mac and
     13        iOS will get the correct text marker ranges for shadow host elements.
     14
     15        Tests: accessibility/ios-simulator/element-text-range-for-text-control.html
     16               accessibility/mac/text-markers-for-input-with-placeholder.html
     17
     18        * accessibility/AXObjectCache.cpp:
     19        (WebCore::AXObjectCache::traverseToOffsetInRange):
     20        (WebCore::AXObjectCache::startOrEndCharacterOffsetForRange):
     21        (WebCore::AXObjectCache::characterOffsetForIndex):
     22        * accessibility/AXObjectCache.h:
     23
    1242017-03-17  Wenson Hsieh  <wenson_hsieh@apple.com>
    225
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r213355 r214112  
    15561556    bool toNodeEnd = option & TraverseOptionToNodeEnd;
    15571557    bool validateOffset = option & TraverseOptionValidateOffset;
     1558    bool doNotEnterTextControls = option & TraverseOptionDoNotEnterTextControls;
    15581559   
    15591560    int offsetInCharacter = 0;
     
    15651566    int lastStartOffset = 0;
    15661567   
    1567     TextIterator iterator(range.get(), TextIteratorEntersTextControls);
     1568    TextIterator iterator(range.get(), doNotEnterTextControls ? TextIteratorDefaultBehavior : TextIteratorEntersTextControls);
    15681569   
    15691570    // When the range has zero length, there might be replaced node or brTag that we need to increment the characterOffset.
     
    16181619                        currentNode = childNode;
    16191620                        hasReplacedNodeOrBR = true;
    1620                     } else if (currentNode->isShadowRoot()) {
     1621                    } else if (Element *shadowHost = currentNode->shadowHost()) {
    16211622                        // Since we are entering text controls, we should set the currentNode
    16221623                        // to be the shadow host when there's no content.
    1623                         currentNode = currentNode->shadowHost();
    1624                         continue;
     1624                        if (nodeIsTextControl(shadowHost)) {
     1625                            currentNode = currentNode->shadowHost();
     1626                            continue;
     1627                        }
    16251628                    } else if (currentNode != previousNode) {
    16261629                        // We should set the start offset and length for the current node in case this is the last iteration.
     
    18381841}
    18391842
    1840 CharacterOffset AXObjectCache::startOrEndCharacterOffsetForRange(RefPtr<Range> range, bool isStart)
     1843CharacterOffset AXObjectCache::startOrEndCharacterOffsetForRange(RefPtr<Range> range, bool isStart, bool enterTextControls)
    18411844{
    18421845    if (!range)
     
    18661869    }
    18671870   
    1868     return traverseToOffsetInRange(WTFMove(copyRange), offset, isStart ? TraverseOptionDefault : TraverseOptionToNodeEnd, stayWithinRange);
     1871    TraverseOption options = isStart ? TraverseOptionDefault : TraverseOptionToNodeEnd;
     1872    if (!enterTextControls)
     1873        options = static_cast<TraverseOption>(options | TraverseOptionDoNotEnterTextControls);
     1874    return traverseToOffsetInRange(WTFMove(copyRange), offset, options, stayWithinRange);
    18691875}
    18701876
     
    26172623   
    26182624    RefPtr<Range> range = obj->elementRange();
    2619     CharacterOffset start = startOrEndCharacterOffsetForRange(range, true);
    2620     CharacterOffset end = startOrEndCharacterOffsetForRange(range, false);
     2625    CharacterOffset start = startOrEndCharacterOffsetForRange(range, true, true);
     2626    CharacterOffset end = startOrEndCharacterOffsetForRange(range, false, true);
    26212627    CharacterOffset result = start;
    26222628    for (int i = 0; i < index; i++) {
  • trunk/Source/WebCore/accessibility/AXObjectCache.h

    r211500 r214112  
    223223    CharacterOffset previousCharacterOffset(const CharacterOffset&, bool ignorePreviousNodeEnd = true);
    224224    void startOrEndTextMarkerDataForRange(TextMarkerData&, RefPtr<Range>, bool);
    225     CharacterOffset startOrEndCharacterOffsetForRange(RefPtr<Range>, bool);
     225    CharacterOffset startOrEndCharacterOffsetForRange(RefPtr<Range>, bool, bool enterTextControls = false);
    226226    AccessibilityObject* accessibilityObjectForTextMarkerData(TextMarkerData&);
    227227    RefPtr<Range> rangeForUnorderedCharacterOffsets(const CharacterOffset&, const CharacterOffset&);
     
    352352   
    353353    // CharacterOffset functions.
    354     enum TraverseOption { TraverseOptionDefault = 1 << 0, TraverseOptionToNodeEnd = 1 << 1, TraverseOptionIncludeStart = 1 << 2, TraverseOptionValidateOffset = 1 << 3 };
     354    enum TraverseOption { TraverseOptionDefault = 1 << 0, TraverseOptionToNodeEnd = 1 << 1, TraverseOptionIncludeStart = 1 << 2, TraverseOptionValidateOffset = 1 << 3, TraverseOptionDoNotEnterTextControls = 1 << 4 };
    355355    Node* nextNode(Node*) const;
    356356    Node* previousNode(Node*) const;
Note: See TracChangeset for help on using the changeset viewer.