Changeset 229080 in webkit


Ignore:
Timestamp:
Feb 27, 2018 2:57:14 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

AX: Spell check and style attributes should be optional when fetching attributed string
https://bugs.webkit.org/show_bug.cgi?id=160744

Patch by Doug Russell <doug@getitdownonpaper.com> on 2018-02-27
Reviewed by Chris Fleizach.

The overhead of fetching a spell checked attributed string via AX API is substantial.
In some cases on the order of 7/8 of the total time spent fetching the string.

This change introduces the new attribute AXAttributedStringForTextMarkerRangeWithOptions which accepts an NSDictionary as it's parameter with keys "AXTextMarkerRange" (AXTextMarkerRangeRef) and "AXSpellCheck" (NSNumber(BOOL)).

AXAttributedStringForTextMarkerRange will remain unchanged.

Source/WebCore:

Tests: accessibility/mac/attributed-string/attributed-string-for-range-with-options.html

accessibility/mac/attributed-string/attributed-string-for-range.html

  • accessibility/mac/WebAccessibilityObjectWrapperMac.mm:

(AXAttributedStringAppendText):
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:spellCheck:]):
(-[WebAccessibilityObjectWrapper accessibilityParameterizedAttributeNames]):
(-[WebAccessibilityObjectWrapper doAXAttributedStringForRange:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Deleted.

Tools:

  • DumpRenderTree/AccessibilityUIElement.cpp:

(attributedStringForTextMarkerRangeCallback):
(attributedStringForTextMarkerRangeWithOptionsCallback):
(AccessibilityUIElement::attributedStringForTextMarkerRange):
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
(AccessibilityUIElement::getJSClass):

  • DumpRenderTree/AccessibilityUIElement.h:
  • DumpRenderTree/ios/AccessibilityUIElementIOS.mm:

(AccessibilityUIElement::attributedStringForTextMarkerRange):
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):

  • DumpRenderTree/mac/AccessibilityUIElementMac.mm:

(createJSStringRef):
(AccessibilityUIElement::attributedStringForTextMarkerRange):
(AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
  • WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
  • WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:

(WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
(WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):

  • WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:

(WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
(WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):

  • WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:

(WTR::createJSStringRef):
(WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
(WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):

LayoutTests:

  • accessibility/mac/attributed-string: Added.
  • accessibility/mac/attributed-string/attributed-string-for-range-expected.txt: Added.
  • accessibility/mac/attributed-string/attributed-string-for-range-with-options-expected.txt: Added.
  • accessibility/mac/attributed-string/attributed-string-for-range-with-options.html: Added.
  • accessibility/mac/attributed-string/attributed-string-for-range.html: Added.
  • accessibility/mac/bounds-for-range-expected.txt:
Location:
trunk
Files:
5 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r229070 r229080  
     12018-02-27  Doug Russell  <doug@getitdownonpaper.com>
     2
     3        AX: Spell check and style attributes should be optional when fetching attributed string
     4        https://bugs.webkit.org/show_bug.cgi?id=160744
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The overhead of fetching a spell checked attributed string via AX API is substantial.
     9        In some cases on the order of 7/8 of the total time spent fetching the string.
     10
     11        This change introduces the new attribute AXAttributedStringForTextMarkerRangeWithOptions which accepts an NSDictionary as it's parameter with keys "AXTextMarkerRange" (AXTextMarkerRangeRef) and "AXSpellCheck" (NSNumber(BOOL)).
     12
     13        AXAttributedStringForTextMarkerRange will remain unchanged.
     14
     15        * accessibility/mac/attributed-string: Added.
     16        * accessibility/mac/attributed-string/attributed-string-for-range-expected.txt: Added.
     17        * accessibility/mac/attributed-string/attributed-string-for-range-with-options-expected.txt: Added.
     18        * accessibility/mac/attributed-string/attributed-string-for-range-with-options.html: Added.
     19        * accessibility/mac/attributed-string/attributed-string-for-range.html: Added.
     20        * accessibility/mac/bounds-for-range-expected.txt:
     21
    1222018-02-27  Antoine Quint  <graouts@apple.com>
    223
  • trunk/LayoutTests/accessibility/mac/bounds-for-range-expected.txt

    r198356 r229080  
    3838AXBoundsForTextMarkerRange
    3939AXAttributedStringForTextMarkerRange
     40AXAttributedStringForTextMarkerRangeWithOptions
    4041AXTextMarkerRangeForUnorderedTextMarkers
    4142AXNextTextMarkerForTextMarker
  • trunk/Source/WebCore/ChangeLog

    r229079 r229080  
     12018-02-27  Doug Russell  <doug@getitdownonpaper.com>
     2
     3        AX: Spell check and style attributes should be optional when fetching attributed string
     4        https://bugs.webkit.org/show_bug.cgi?id=160744
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The overhead of fetching a spell checked attributed string via AX API is substantial.
     9        In some cases on the order of 7/8 of the total time spent fetching the string.
     10
     11        This change introduces the new attribute AXAttributedStringForTextMarkerRangeWithOptions which accepts an NSDictionary as it's parameter with keys "AXTextMarkerRange" (AXTextMarkerRangeRef) and "AXSpellCheck" (NSNumber(BOOL)).
     12
     13        AXAttributedStringForTextMarkerRange will remain unchanged.
     14
     15        Tests: accessibility/mac/attributed-string/attributed-string-for-range-with-options.html
     16               accessibility/mac/attributed-string/attributed-string-for-range.html
     17
     18        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
     19        (AXAttributedStringAppendText):
     20        (-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:spellCheck:]):
     21        (-[WebAccessibilityObjectWrapper accessibilityParameterizedAttributeNames]):
     22        (-[WebAccessibilityObjectWrapper doAXAttributedStringForRange:]):
     23        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
     24        (-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Deleted.
     25
    1262018-02-27  Daniel Bates  <dabates@apple.com>
    227
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

    r228857 r229080  
    10191019}
    10201020
    1021 static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, StringView text)
     1021static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, StringView text, bool spellCheck)
    10221022{
    10231023    // skip invisible text
     
    10391039    // remove inherited attachment from prior AXAttributedStringAppendReplaced
    10401040    [attrString removeAttribute:NSAccessibilityAttachmentTextAttribute range:attrStringRange];
     1041    if (spellCheck) {
    10411042#if PLATFORM(MAC)
    1042     [attrString removeAttribute:NSAccessibilityMarkedMisspelledTextAttribute range:attrStringRange];
    1043 #endif
    1044     [attrString removeAttribute:NSAccessibilityMisspelledTextAttribute range:attrStringRange];
     1043        [attrString removeAttribute:NSAccessibilityMarkedMisspelledTextAttribute range:attrStringRange];
     1044#endif
     1045        [attrString removeAttribute:NSAccessibilityMisspelledTextAttribute range:attrStringRange];
     1046    }
    10451047   
    10461048    // set new attributes
     
    10521054   
    10531055    // do spelling last because it tends to break up the range
    1054     AXAttributeStringSetSpelling(attrString, node, text, attrStringRange);
     1056    if (spellCheck)
     1057        AXAttributeStringSetSpelling(attrString, node, text, attrStringRange);
    10551058}
    10561059
     
    10741077}
    10751078
    1076 - (NSAttributedString*)doAXAttributedStringForTextMarkerRange:(id)textMarkerRange
     1079- (NSAttributedString*)doAXAttributedStringForTextMarkerRange:(id)textMarkerRange spellCheck:(BOOL)spellCheck
    10771080{
    10781081    if (!m_object)
     
    10931096            String listMarkerText = m_object->listMarkerTextForNodeAndPosition(&node, VisiblePosition(it.range()->startPosition()));
    10941097            if (!listMarkerText.isEmpty())
    1095                 AXAttributedStringAppendText(attrString, &node, listMarkerText);
    1096             AXAttributedStringAppendText(attrString, &node, it.text());
     1098                AXAttributedStringAppendText(attrString, &node, listMarkerText, spellCheck);
     1099            AXAttributedStringAppendText(attrString, &node, it.text(), spellCheck);
    10971100        } else {
    10981101            Node* replacedNode = node.traverseToChildAt(offset);
     
    11141117        it.advance();
    11151118    }
    1116    
     1119
    11171120    return [attrString autorelease];
    11181121}
     
    33813384    if (paramAttrs == nil) {
    33823385        paramAttrs = [[NSArray alloc] initWithObjects:
    3383                       @"AXUIElementForTextMarker",
    3384                       @"AXTextMarkerRangeForUIElement",
    3385                       @"AXLineForTextMarker",
    3386                       @"AXTextMarkerRangeForLine",
    3387                       @"AXStringForTextMarkerRange",
    3388                       @"AXTextMarkerForPosition",
    3389                       @"AXBoundsForTextMarkerRange",
    3390                       @"AXAttributedStringForTextMarkerRange",
    3391                       @"AXTextMarkerRangeForUnorderedTextMarkers",
    3392                       @"AXNextTextMarkerForTextMarker",
    3393                       @"AXPreviousTextMarkerForTextMarker",
    3394                       @"AXLeftWordTextMarkerRangeForTextMarker",
    3395                       @"AXRightWordTextMarkerRangeForTextMarker",
    3396                       @"AXLeftLineTextMarkerRangeForTextMarker",
    3397                       @"AXRightLineTextMarkerRangeForTextMarker",
    3398                       @"AXSentenceTextMarkerRangeForTextMarker",
    3399                       @"AXParagraphTextMarkerRangeForTextMarker",
    3400                       @"AXNextWordEndTextMarkerForTextMarker",
    3401                       @"AXPreviousWordStartTextMarkerForTextMarker",
    3402                       @"AXNextLineEndTextMarkerForTextMarker",
    3403                       @"AXPreviousLineStartTextMarkerForTextMarker",
    3404                       @"AXNextSentenceEndTextMarkerForTextMarker",
    3405                       @"AXPreviousSentenceStartTextMarkerForTextMarker",
    3406                       @"AXNextParagraphEndTextMarkerForTextMarker",
    3407                       @"AXPreviousParagraphStartTextMarkerForTextMarker",
    3408                       @"AXStyleTextMarkerRangeForTextMarker",
    3409                       @"AXLengthForTextMarkerRange",
    3410                       NSAccessibilityBoundsForRangeParameterizedAttribute,
    3411                       NSAccessibilityStringForRangeParameterizedAttribute,
    3412                       NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute,
    3413                       NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute,
    3414                       NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute,
    3415                       NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute,
    3416                       NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute,
    3417                       NSAccessibilitySelectTextWithCriteriaParameterizedAttribute,
    3418                       nil];
     3386            @"AXUIElementForTextMarker",
     3387            @"AXTextMarkerRangeForUIElement",
     3388            @"AXLineForTextMarker",
     3389            @"AXTextMarkerRangeForLine",
     3390            @"AXStringForTextMarkerRange",
     3391            @"AXTextMarkerForPosition",
     3392            @"AXBoundsForTextMarkerRange",
     3393            @"AXAttributedStringForTextMarkerRange",
     3394            @"AXAttributedStringForTextMarkerRangeWithOptions",
     3395            @"AXTextMarkerRangeForUnorderedTextMarkers",
     3396            @"AXNextTextMarkerForTextMarker",
     3397            @"AXPreviousTextMarkerForTextMarker",
     3398            @"AXLeftWordTextMarkerRangeForTextMarker",
     3399            @"AXRightWordTextMarkerRangeForTextMarker",
     3400            @"AXLeftLineTextMarkerRangeForTextMarker",
     3401            @"AXRightLineTextMarkerRangeForTextMarker",
     3402            @"AXSentenceTextMarkerRangeForTextMarker",
     3403            @"AXParagraphTextMarkerRangeForTextMarker",
     3404            @"AXNextWordEndTextMarkerForTextMarker",
     3405            @"AXPreviousWordStartTextMarkerForTextMarker",
     3406            @"AXNextLineEndTextMarkerForTextMarker",
     3407            @"AXPreviousLineStartTextMarkerForTextMarker",
     3408            @"AXNextSentenceEndTextMarkerForTextMarker",
     3409            @"AXPreviousSentenceStartTextMarkerForTextMarker",
     3410            @"AXNextParagraphEndTextMarkerForTextMarker",
     3411            @"AXPreviousParagraphStartTextMarkerForTextMarker",
     3412            @"AXStyleTextMarkerRangeForTextMarker",
     3413            @"AXLengthForTextMarkerRange",
     3414            NSAccessibilityBoundsForRangeParameterizedAttribute,
     3415            NSAccessibilityStringForRangeParameterizedAttribute,
     3416            NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute,
     3417            NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute,
     3418            NSAccessibilityEndTextMarkerForBoundsParameterizedAttribute,
     3419            NSAccessibilityStartTextMarkerForBoundsParameterizedAttribute,
     3420            NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute,
     3421            NSAccessibilitySelectTextWithCriteriaParameterizedAttribute,
     3422            nil];
    34193423    }
    34203424   
     
    37503754    PlainTextRange textRange = PlainTextRange(range.location, range.length);
    37513755    RefPtr<Range> webRange = m_object->rangeForPlainTextRange(textRange);
    3752     return [self doAXAttributedStringForTextMarkerRange:[self textMarkerRangeFromRange:webRange]];
     3756    return [self doAXAttributedStringForTextMarkerRange:[self textMarkerRangeFromRange:webRange] spellCheck:YES];
    37533757}
    37543758
     
    40394043        return m_object->stringForRange(range);
    40404044    }
    4041    
     4045
    40424046    if ([attribute isEqualToString:@"AXAttributedStringForTextMarkerRange"])
    4043         return [self doAXAttributedStringForTextMarkerRange:textMarkerRange];
    4044    
     4047        return [self doAXAttributedStringForTextMarkerRange:textMarkerRange spellCheck:YES];
     4048
     4049    if ([attribute isEqualToString:@"AXAttributedStringForTextMarkerRangeWithOptions"]) {
     4050        if (textMarkerRange)
     4051            return [self doAXAttributedStringForTextMarkerRange:textMarkerRange spellCheck:NO];
     4052        if (dictionary) {
     4053            id textMarkerRange = nil;
     4054            id parameter = [dictionary objectForKey:@"AXTextMarkerRange"];
     4055            if (AXObjectIsTextMarkerRange(parameter))
     4056                textMarkerRange = parameter;
     4057            BOOL spellCheck = NO;
     4058            parameter = [dictionary objectForKey:@"AXSpellCheck"];
     4059            if ([parameter isKindOfClass:[NSNumber class]])
     4060                spellCheck = [parameter boolValue];
     4061            return [self doAXAttributedStringForTextMarkerRange:textMarkerRange spellCheck:spellCheck];
     4062        }
     4063        return nil;
     4064    }
     4065
    40454066    if ([attribute isEqualToString:@"AXTextMarkerRangeForUnorderedTextMarkers"]) {
    40464067        if ([array count] < 2)
  • trunk/Tools/ChangeLog

    r229079 r229080  
     12018-02-27  Doug Russell  <doug@getitdownonpaper.com>
     2
     3        AX: Spell check and style attributes should be optional when fetching attributed string
     4        https://bugs.webkit.org/show_bug.cgi?id=160744
     5
     6        Reviewed by Chris Fleizach.
     7
     8        The overhead of fetching a spell checked attributed string via AX API is substantial.
     9        In some cases on the order of 7/8 of the total time spent fetching the string.
     10
     11        This change introduces the new attribute AXAttributedStringForTextMarkerRangeWithOptions which accepts an NSDictionary as it's parameter with keys "AXTextMarkerRange" (AXTextMarkerRangeRef) and "AXSpellCheck" (NSNumber(BOOL)).
     12
     13        AXAttributedStringForTextMarkerRange will remain unchanged.
     14
     15        * DumpRenderTree/AccessibilityUIElement.cpp:
     16        (attributedStringForTextMarkerRangeCallback):
     17        (attributedStringForTextMarkerRangeWithOptionsCallback):
     18        (AccessibilityUIElement::attributedStringForTextMarkerRange):
     19        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     20        (AccessibilityUIElement::getJSClass):
     21        * DumpRenderTree/AccessibilityUIElement.h:
     22        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
     23        (AccessibilityUIElement::attributedStringForTextMarkerRange):
     24        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     25        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
     26        (createJSStringRef):
     27        (AccessibilityUIElement::attributedStringForTextMarkerRange):
     28        (AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     29        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
     30        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
     31        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
     32        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
     33        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     34        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
     35        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
     36        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     37        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
     38        (WTR::createJSStringRef):
     39        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRange):
     40        (WTR::AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions):
     41
    1422018-02-27  Daniel Bates  <dabates@apple.com>
    243
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp

    r226450 r229080  
    882882}
    883883
     884static JSValueRef attributedStringForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     885{
     886    AccessibilityTextMarkerRange* markerRange = 0;
     887    if (argumentCount == 1)
     888        markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
     889
     890    JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->attributedStringForTextMarkerRange(markerRange));
     891    return JSValueMakeString(context, markerRangeString.get());
     892}
     893
     894static JSValueRef attributedStringForTextMarkerRangeWithOptionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     895{
     896    AccessibilityTextMarkerRange* markerRange = nullptr;
     897    bool includeSpellCheck = false;
     898    if (argumentCount == 2) {
     899        markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
     900        includeSpellCheck = JSValueToBoolean(context, arguments[1]);
     901    }
     902
     903    JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->attributedStringForTextMarkerRangeWithOptions(markerRange, includeSpellCheck));
     904    return JSValueMakeString(context, markerRangeString.get());
     905}
     906
    884907static JSValueRef endTextMarkerForBoundsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    885908{
     
    958981static JSValueRef accessibilityElementForTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    959982{
    960     AccessibilityTextMarker* marker = 0;
     983    AccessibilityTextMarker* marker = nullptr;
    961984    if (argumentCount == 1)
    962985        marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
     
    16351658{
    16361659    return 0;
     1660}
     1661
     1662JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
     1663{
     1664    return nullptr;
     1665}
     1666
     1667JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck)
     1668{
     1669    return nullptr;
    16371670}
    16381671
     
    19091942        { "previousTextMarker", previousTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19101943        { "stringForTextMarkerRange", stringForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1944        { "attributedStringForTextMarkerRange", attributedStringForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1945        { "attributedStringForTextMarkerRangeWithOptions", attributedStringForTextMarkerRangeWithOptionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19111946        { "leftWordTextMarkerRangeForTextMarker", leftWordTextMarkerRangeForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19121947        { "rightWordTextMarkerRangeForTextMarker", rightWordTextMarkerRangeForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.h

    r226432 r229080  
    279279   
    280280    JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
     281    JSStringRef attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*);
     282    JSStringRef attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool includeSpellCheck);
    281283    int textMarkerRangeLength(AccessibilityTextMarkerRange*);
    282284    bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
  • trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm

    r226432 r229080  
    543543}
    544544
     545JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
     546{
     547    return nullptr;
     548}
     549
     550JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool)
     551{
     552    return nullptr;
     553}
     554
    545555bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*)
    546556{
  • trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm

    r226432 r229080  
    17121712}
    17131713
     1714static JSStringRef createJSStringRef(id string)
     1715{
     1716    if (!string)
     1717        return nullptr;
     1718    id mutableString = [[[NSMutableString alloc] init] autorelease];
     1719    id attributes = [string attributesAtIndex:0 effectiveRange:nil];
     1720    id attributeEnumerationBlock = ^(NSDictionary<NSString *, id> *attrs, NSRange range, BOOL *stop) {
     1721        BOOL misspelled = [[attrs objectForKey:NSAccessibilityMisspelledTextAttribute] boolValue];
     1722        if (misspelled)
     1723            misspelled = [[attrs objectForKey:NSAccessibilityMarkedMisspelledTextAttribute] boolValue];
     1724        if (misspelled)
     1725            [mutableString appendString:@"Misspelled, "];
     1726        id font = [attributes objectForKey:(id)kAXFontTextAttribute];
     1727        if (font)
     1728            [mutableString appendFormat:@"%@ - %@, ", (id)kAXFontTextAttribute, font];
     1729    };
     1730    [string enumerateAttributesInRange:NSMakeRange(0, [string length]) options:(NSAttributedStringEnumerationOptions)0 usingBlock:attributeEnumerationBlock];
     1731    [mutableString appendString:[string string]];
     1732    return [mutableString createJSStringRef];
     1733}
     1734
     1735JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
     1736{
     1737    id string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:(id)markerRange->platformTextMarkerRange()];
     1738    return createJSStringRef(string);
     1739}
     1740
     1741JSStringRef AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange* markerRange, bool includeSpellCheck)
     1742{
     1743    id parameter = nil;
     1744    if (includeSpellCheck)
     1745        parameter = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:includeSpellCheck], @"AXSpellCheck", (id)markerRange->platformTextMarkerRange(), @"AXTextMarkerRange", nil];
     1746    else
     1747        parameter = (id)markerRange->platformTextMarkerRange();
     1748    id string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRangeWithOptions" forParameter:parameter];
     1749    return createJSStringRef(string);
     1750}
     1751
    17141752AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
    17151753{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h

    r228827 r229080  
    281281    RefPtr<AccessibilityUIElement> accessibilityElementForTextMarker(AccessibilityTextMarker*);
    282282    JSRetainPtr<JSStringRef> stringForTextMarkerRange(AccessibilityTextMarkerRange*);
     283    JSRetainPtr<JSStringRef> attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*);
     284    JSRetainPtr<JSStringRef> attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool);
    283285    int textMarkerRangeLength(AccessibilityTextMarkerRange*);
    284286    bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl

    r228827 r229080  
    210210    AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker marker);
    211211    DOMString stringForTextMarkerRange(AccessibilityTextMarkerRange range);
     212    DOMString attributedStringForTextMarkerRange(AccessibilityTextMarkerRange range);
     213    DOMString attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange range, boolean includeSpellCheck);
    212214    long textMarkerRangeLength(AccessibilityTextMarkerRange range);
    213215    boolean attributedStringForTextMarkerRangeContainsAttribute(DOMString attr, AccessibilityTextMarkerRange range);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

    r228879 r229080  
    22162216}
    22172217
     2218JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*)
     2219{
     2220    return nullptr;
     2221}
     2222
     2223JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange*, bool)
     2224{
     2225    return nullptr;
     2226}
     2227
    22182228bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
    22192229{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

    r226432 r229080  
    11241124}
    11251125
     1126JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
     1127{
     1128    return nullptr;
     1129}
     1130
     1131JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange* markerRange, bool)
     1132{
     1133    return nullptr;
     1134}
     1135
    11261136bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
    11271137{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

    r228827 r229080  
    18071807    return nullptr;
    18081808}
    1809    
     1809
     1810static JSStringRef createJSStringRef(id string)
     1811{
     1812    id mutableString = [[[NSMutableString alloc] init] autorelease];
     1813    id attributes = [string attributesAtIndex:0 effectiveRange:nil];
     1814    id attributeEnumerationBlock = ^(NSDictionary<NSString *, id> *attrs, NSRange range, BOOL *stop) {
     1815        BOOL misspelled = [[attrs objectForKey:NSAccessibilityMisspelledTextAttribute] boolValue];
     1816        if (misspelled)
     1817            misspelled = [[attrs objectForKey:NSAccessibilityMarkedMisspelledTextAttribute] boolValue];
     1818        if (misspelled)
     1819            [mutableString appendString:@"Misspelled, "];
     1820        id font = [attributes objectForKey:(id)kAXFontTextAttribute];
     1821        if (font)
     1822            [mutableString appendFormat:@"%@ - %@, ", (id)kAXFontTextAttribute, font];
     1823    };
     1824    [string enumerateAttributesInRange:NSMakeRange(0, [string length]) options:(NSAttributedStringEnumerationOptions)0 usingBlock:attributeEnumerationBlock];
     1825    [mutableString appendString:[string string]];
     1826    return [mutableString createJSStringRef];
     1827}
     1828
     1829JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
     1830{
     1831    NSAttributedString* string = nil;
     1832
     1833    BEGIN_AX_OBJC_EXCEPTIONS
     1834    string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:(id)markerRange->platformTextMarkerRange()];
     1835    END_AX_OBJC_EXCEPTIONS
     1836
     1837    if (![string isKindOfClass:[NSAttributedString class]])
     1838        return nil;
     1839
     1840    return createJSStringRef(string);
     1841}
     1842
     1843JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForTextMarkerRangeWithOptions(AccessibilityTextMarkerRange* markerRange, bool includeSpellCheck)
     1844{
     1845    NSAttributedString* string = nil;
     1846
     1847    id parameter = nil;
     1848    if (includeSpellCheck)
     1849        parameter = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:includeSpellCheck], @"AXSpellCheck", (id)markerRange->platformTextMarkerRange(), @"AXTextMarkerRange", nil];
     1850    else
     1851        parameter = (id)markerRange->platformTextMarkerRange();
     1852
     1853    BEGIN_AX_OBJC_EXCEPTIONS
     1854    string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRangeWithOptions" forParameter:parameter];
     1855    END_AX_OBJC_EXCEPTIONS
     1856
     1857    if (![string isKindOfClass:[NSAttributedString class]])
     1858        return nil;
     1859
     1860    return createJSStringRef(string);
     1861}
     1862
    18101863bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
    18111864{
Note: See TracChangeset for help on using the changeset viewer.