Diff
Modified: branches/safari-611.1.21.1-branch/LayoutTests/ChangeLog (273665 => 273666)
--- branches/safari-611.1.21.1-branch/LayoutTests/ChangeLog 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/LayoutTests/ChangeLog 2021-03-01 19:47:34 UTC (rev 273666)
@@ -1,3 +1,64 @@
+2021-03-01 Kocsen Chung <kocsen_ch...@apple.com>
+
+ Cherry-pick r273227. rdar://problem/74880937
+
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
+
+ Reviewed by Chris Fleizach and Darin Adler.
+
+ Source/WebCore:
+
+ Test: accessibility/mac/textmarker-range-for-range.html
+
+ Clients like VoiceOver often need the ability to convert a text range
+ into an accessibility TextMarkerRange.
+ This patch adds [WebAccessibilityObjectWrapper textMarkerRangeForNSRange]
+ to allow clients to efficiently perform this conversion.
+ This is the Mac implementation, iOS implementation is pending.
+
+ * accessibility/AccessibilityObject.h:
+ (WebCore::AccessibilityObject::allowsTextRanges const):
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/AccessibilityObjectMac.mm:
+ (WebCore::AccessibilityObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper textMarkerRangeForNSRange:]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+ * editing/Editing.cpp:
+ (WebCore::visiblePositionForIndexUsingCharacterIterator):
+ Only advance the CharacterIterator if not atEnd yet.
+
+ Tools:
+
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+
+ LayoutTests:
+
+ * accessibility/mac/textmarker-range-for-range-expected.txt: Added.
+ * accessibility/mac/textmarker-range-for-range.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-21 Andres Gonzalez <andresg...@apple.com>
+
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
+
+ Reviewed by Chris Fleizach and Darin Adler.
+
+ * accessibility/mac/textmarker-range-for-range-expected.txt: Added.
+ * accessibility/mac/textmarker-range-for-range.html: Added.
+
2021-02-26 Alan Coon <alanc...@apple.com>
Cherry-pick r273512. rdar://problem/74799698
Added: branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range-expected.txt (0 => 273666)
--- branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range-expected.txt (rev 0)
+++ branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range-expected.txt 2021-03-01 19:47:34 UTC (rev 273666)
@@ -0,0 +1,297 @@
+Think different Apple
+
+bold italic
+underline last!
+
+Hello World!
+This test that textMarkerRangeForRange works properly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+content length: 65
+All ranges from index 0 to each character in the text:
+0
+''
+1
+'T'
+2
+'Th'
+3
+'Thi'
+4
+'Thin'
+5
+'Think'
+6
+'Think '
+7
+'Think d'
+8
+'Think di'
+9
+'Think dif'
+10
+'Think diff'
+11
+'Think diffe'
+12
+'Think differ'
+13
+'Think differe'
+14
+'Think differen'
+15
+'Think different'
+16
+'Think different '
+17
+'Think different A'
+18
+'Think different Ap'
+19
+'Think different App'
+20
+'Think different Appl'
+21
+'Think different Apple'
+22
+'Think different Apple'
+23
+'Think different Apple
+
+'
+24
+'Think different Apple
+
+b'
+25
+'Think different Apple
+
+bo'
+26
+'Think different Apple
+
+bol'
+27
+'Think different Apple
+
+bold'
+28
+'Think different Apple
+
+bold '
+29
+'Think different Apple
+
+bold i'
+30
+'Think different Apple
+
+bold it'
+31
+'Think different Apple
+
+bold ita'
+32
+'Think different Apple
+
+bold ital'
+33
+'Think different Apple
+
+bold itali'
+34
+'Think different Apple
+
+bold italic'
+35
+'Think different Apple
+
+bold italic
+'
+36
+'Think different Apple
+
+bold italic
+u'
+37
+'Think different Apple
+
+bold italic
+un'
+38
+'Think different Apple
+
+bold italic
+und'
+39
+'Think different Apple
+
+bold italic
+unde'
+40
+'Think different Apple
+
+bold italic
+under'
+41
+'Think different Apple
+
+bold italic
+underl'
+42
+'Think different Apple
+
+bold italic
+underli'
+43
+'Think different Apple
+
+bold italic
+underlin'
+44
+'Think different Apple
+
+bold italic
+underline'
+45
+'Think different Apple
+
+bold italic
+underline '
+46
+'Think different Apple
+
+bold italic
+underline l'
+47
+'Think different Apple
+
+bold italic
+underline la'
+48
+'Think different Apple
+
+bold italic
+underline las'
+49
+'Think different Apple
+
+bold italic
+underline last'
+50
+'Think different Apple
+
+bold italic
+underline last!'
+51
+'Think different Apple
+
+bold italic
+underline last!'
+52
+'Think different Apple
+
+bold italic
+underline last!
+
+'
+53
+'Think different Apple
+
+bold italic
+underline last!
+
+H'
+54
+'Think different Apple
+
+bold italic
+underline last!
+
+He'
+55
+'Think different Apple
+
+bold italic
+underline last!
+
+Hel'
+56
+'Think different Apple
+
+bold italic
+underline last!
+
+Hell'
+57
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello'
+58
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello '
+59
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello W'
+60
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello Wo'
+61
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello Wor'
+62
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello Worl'
+63
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello World'
+64
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello World!'
+Get the range for the word Apple:
+'Apple'
+Out of range values:
+'Think different Apple
+
+bold italic
+underline last!
+
+Hello World!'
+''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range.html (0 => 273666)
--- branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range.html (rev 0)
+++ branches/safari-611.1.21.1-branch/LayoutTests/accessibility/mac/textmarker-range-for-range.html 2021-03-01 19:47:34 UTC (rev 273666)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="content" role="group">
+ <p>Think <em>different</em> <a href=""
+ <p><b>bold</b> <i>italic</i><br><u>underline</u> <em>last!</em></p>
+ <button>Hello World!</button>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+ description("This test that textMarkerRangeForRange works properly.");
+
+ if (window.accessibilityController) {
+ axElement = accessibilityController.accessibleElementById("content");
+ contentTextMarkerRange = axElement.textMarkerRangeForElement(axElement);
+ textLength = axElement.stringForTextMarkerRange(contentTextMarkerRange).length;
+ debug("content length: " + textLength);
+
+ debug("All ranges from index 0 to each character in the text:");
+ for (i = 0; i < textLength; ++i) {
+ debug(i);
+ textMarkerRange = axElement.textMarkerRangeForRange(0, i);
+ debug("'" + axElement.stringForTextMarkerRange(textMarkerRange) + "'");
+ }
+
+ debug("Get the range for the word Apple:");
+ textMarkerRange = axElement.textMarkerRangeForRange(16, 5);
+ debug("'" + axElement.stringForTextMarkerRange(textMarkerRange) + "'");
+
+ debug("Out of range values:");
+ textMarkerRange = axElement.textMarkerRangeForRange(0, 100);
+ debug("'" + axElement.stringForTextMarkerRange(textMarkerRange) + "'");
+ textMarkerRange = axElement.textMarkerRangeForRange(70, 100);
+ debug("'" + axElement.stringForTextMarkerRange(textMarkerRange) + "'");
+ }
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/safari-611.1.21.1-branch/LayoutTests/platform/mac-wk1/TestExpectations (273665 => 273666)
--- branches/safari-611.1.21.1-branch/LayoutTests/platform/mac-wk1/TestExpectations 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/LayoutTests/platform/mac-wk1/TestExpectations 2021-03-01 19:47:34 UTC (rev 273666)
@@ -964,6 +964,7 @@
webkit.org/b/210198 webgl/2.0.0/conformance2/attribs/gl-vertexattribipointer.html [ Slow ]
webkit.org/b/208477 accessibility/mac/text-marker-for-index.html [ Skip ]
+accessibility/mac/textmarker-range-for-range.html [ Skip ]
accessibility/mac/isolated-tree-mode-on-off.html [ Skip ]
accessibility/aria-current-state-changed-notification.html [ Skip ]
accessibility/aria-current.html [ Skip ]
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/ChangeLog (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/ChangeLog 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/ChangeLog 2021-03-01 19:47:34 UTC (rev 273666)
@@ -1,3 +1,84 @@
+2021-03-01 Kocsen Chung <kocsen_ch...@apple.com>
+
+ Cherry-pick r273227. rdar://problem/74880937
+
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
+
+ Reviewed by Chris Fleizach and Darin Adler.
+
+ Source/WebCore:
+
+ Test: accessibility/mac/textmarker-range-for-range.html
+
+ Clients like VoiceOver often need the ability to convert a text range
+ into an accessibility TextMarkerRange.
+ This patch adds [WebAccessibilityObjectWrapper textMarkerRangeForNSRange]
+ to allow clients to efficiently perform this conversion.
+ This is the Mac implementation, iOS implementation is pending.
+
+ * accessibility/AccessibilityObject.h:
+ (WebCore::AccessibilityObject::allowsTextRanges const):
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/AccessibilityObjectMac.mm:
+ (WebCore::AccessibilityObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper textMarkerRangeForNSRange:]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+ * editing/Editing.cpp:
+ (WebCore::visiblePositionForIndexUsingCharacterIterator):
+ Only advance the CharacterIterator if not atEnd yet.
+
+ Tools:
+
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+
+ LayoutTests:
+
+ * accessibility/mac/textmarker-range-for-range-expected.txt: Added.
+ * accessibility/mac/textmarker-range-for-range.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-21 Andres Gonzalez <andresg...@apple.com>
+
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
+
+ Reviewed by Chris Fleizach and Darin Adler.
+
+ Test: accessibility/mac/textmarker-range-for-range.html
+
+ Clients like VoiceOver often need the ability to convert a text range
+ into an accessibility TextMarkerRange.
+ This patch adds [WebAccessibilityObjectWrapper textMarkerRangeForNSRange]
+ to allow clients to efficiently perform this conversion.
+ This is the Mac implementation, iOS implementation is pending.
+
+ * accessibility/AccessibilityObject.h:
+ (WebCore::AccessibilityObject::allowsTextRanges const):
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/AccessibilityObjectMac.mm:
+ (WebCore::AccessibilityObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper textMarkerRangeForNSRange:]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+ * editing/Editing.cpp:
+ (WebCore::visiblePositionForIndexUsingCharacterIterator):
+ Only advance the CharacterIterator if not atEnd yet.
+
2021-02-26 Alan Coon <alanc...@apple.com>
Cherry-pick r273558. rdar://problem/74800042
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObject.h (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObject.h 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObject.h 2021-03-01 19:47:34 UTC (rev 273666)
@@ -539,6 +539,9 @@
VisiblePositionRange lineRangeForPosition(const VisiblePosition&) const override;
Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const override;
+#if PLATFORM(MAC)
+ AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const override;
+#endif
static String stringForVisiblePositionRange(const VisiblePositionRange&);
String stringForRange(const SimpleRange&) const override;
@@ -823,7 +826,7 @@
#endif
#if !(ENABLE(ACCESSIBILITY) && USE(ATK))
-inline bool AccessibilityObject::allowsTextRanges() const { return isTextControl(); }
+inline bool AccessibilityObject::allowsTextRanges() const { return true; }
inline unsigned AccessibilityObject::getLengthForTextRange() const { return text().length(); }
#endif
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObjectInterface.h (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2021-03-01 19:47:34 UTC (rev 273666)
@@ -49,6 +49,8 @@
OBJC_CLASS WebAccessibilityObjectWrapper;
typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper;
typedef struct _NSRange NSRange;
+typedef const struct __AXTextMarker* AXTextMarkerRef;
+typedef const struct __AXTextMarkerRange* AXTextMarkerRangeRef;
#elif USE(ATK)
typedef struct _WebKitAccessible WebKitAccessible;
typedef struct _WebKitAccessible AccessibilityObjectWrapper;
@@ -1274,6 +1276,10 @@
virtual VisiblePositionRange lineRangeForPosition(const VisiblePosition&) const = 0;
virtual Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const = 0;
+#if PLATFORM(MAC)
+ // FIXME: make this a COCOA method.
+ virtual AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const = 0;
+#endif
virtual String stringForRange(const SimpleRange&) const = 0;
virtual IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const = 0;
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2021-03-01 19:47:34 UTC (rev 273666)
@@ -402,6 +402,9 @@
VisiblePositionRange visiblePositionRangeForRange(const PlainTextRange&) const override;
VisiblePositionRange lineRangeForPosition(const VisiblePosition&) const override;
Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const override;
+#if PLATFORM(MAC)
+ AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const override;
+#endif
String stringForRange(const SimpleRange&) const override;
IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const override;
IntRect boundsForRange(const SimpleRange&) const override;
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm 2021-03-01 19:47:34 UTC (rev 273666)
@@ -59,6 +59,14 @@
[wrapper() detachIsolatedObject:detachmentType];
}
+AXTextMarkerRangeRef AXIsolatedObject::textMarkerRangeForNSRange(const NSRange& range) const
+{
+ return Accessibility::retrieveValueFromMainThread<AXTextMarkerRangeRef>([&range, this] () -> AXTextMarkerRangeRef {
+ auto* axObject = associatedAXObject();
+ return axObject ? axObject->textMarkerRangeForNSRange(range) : nullptr;
+ });
+}
+
} // WebCore
#endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE) && PLATFORM(MAC)
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm 2021-03-01 19:47:34 UTC (rev 273666)
@@ -280,6 +280,13 @@
return String();
}
+AXTextMarkerRangeRef AccessibilityObject::textMarkerRangeForNSRange(const NSRange& range) const
+{
+ return textMarkerRangeFromVisiblePositions(axObjectCache(),
+ visiblePositionForIndex(range.location),
+ visiblePositionForIndex(range.location + range.length));
+}
+
namespace Accessibility {
PlatformRoleMap createPlatformRoleMap()
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2021-03-01 19:47:34 UTC (rev 273666)
@@ -3495,6 +3495,12 @@
});
}
+- (AXTextMarkerRangeRef)textMarkerRangeForNSRange:(const NSRange&)range
+{
+ auto* backingObject = self.updateObjectBackingStore;
+ return backingObject ? backingObject->textMarkerRangeForNSRange(range) : nil;
+}
+
// FIXME: No reason for this to be a method instead of a function; can get document from range.
- (NSRange)_convertToNSRange:(const SimpleRange&)range
{
@@ -4039,15 +4045,14 @@
auto* backingObject = protectedSelf.get().axBackingObject;
if (!backingObject)
return CGRectZero;
- auto* cache = backingObject->axObjectCache();
- if (!cache)
+
+ auto start = backingObject->visiblePositionForIndex(range.location);
+ auto end = backingObject->visiblePositionForIndex(range.location + range.length);
+ auto webRange = makeSimpleRange({ start, end });
+ if (!webRange)
return CGRectZero;
- CharacterOffset start = cache->characterOffsetForIndex(range.location, backingObject);
- CharacterOffset end = cache->characterOffsetForIndex(range.location+range.length, backingObject);
- auto range = cache->rangeForUnorderedCharacterOffsets(start, end);
- if (!range)
- return CGRectZero;
- auto bounds = FloatRect(backingObject->boundsForRange(*range));
+
+ auto bounds = FloatRect(backingObject->boundsForRange(*webRange));
return [protectedSelf convertRectToSpace:bounds space:AccessibilityConversionSpace::Screen];
});
return [NSValue valueWithRect:rect];
Modified: branches/safari-611.1.21.1-branch/Source/WebCore/editing/Editing.cpp (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Source/WebCore/editing/Editing.cpp 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Source/WebCore/editing/Editing.cpp 2021-03-01 19:47:34 UTC (rev 273666)
@@ -1101,7 +1101,8 @@
auto range = makeRangeSelectingNodeContents(node);
CharacterIterator it(range);
- it.advance(index - 1);
+ if (!it.atEnd())
+ it.advance(index - 1);
if (!it.atEnd() && it.text().length() == 1 && it.text()[0] == '\n') {
// FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines.
Modified: branches/safari-611.1.21.1-branch/Tools/ChangeLog (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Tools/ChangeLog 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Tools/ChangeLog 2021-03-01 19:47:34 UTC (rev 273666)
@@ -1,23 +1,88 @@
- 2021-02-25 Myles C. Maxfield <mmaxfi...@apple.com>
+2021-03-01 Kocsen Chung <kocsen_ch...@apple.com>
- Unreviewed, reverting r273390 and r273391.
- https://bugs.webkit.org/show_bug.cgi?id=222449
+ Cherry-pick r273227. rdar://problem/74880937
- Didn't fix the extreme test variance, and caused some internal
- performance bots to hang during testing
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
+
+ Reviewed by Chris Fleizach and Darin Adler.
+
+ Source/WebCore:
+
+ Test: accessibility/mac/textmarker-range-for-range.html
+
+ Clients like VoiceOver often need the ability to convert a text range
+ into an accessibility TextMarkerRange.
+ This patch adds [WebAccessibilityObjectWrapper textMarkerRangeForNSRange]
+ to allow clients to efficiently perform this conversion.
+ This is the Mac implementation, iOS implementation is pending.
+
+ * accessibility/AccessibilityObject.h:
+ (WebCore::AccessibilityObject::allowsTextRanges const):
+ * accessibility/AccessibilityObjectInterface.h:
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
+ (WebCore::AXIsolatedObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/AccessibilityObjectMac.mm:
+ (WebCore::AccessibilityObject::textMarkerRangeForNSRange const):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper textMarkerRangeForNSRange:]):
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+ * editing/Editing.cpp:
+ (WebCore::visiblePositionForIndexUsingCharacterIterator):
+ Only advance the CharacterIterator if not atEnd yet.
+
+ Tools:
+
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+
+ LayoutTests:
+
+ * accessibility/mac/textmarker-range-for-range-expected.txt: Added.
+ * accessibility/mac/textmarker-range-for-range.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Reverted changesets:
+ 2021-02-21 Andres Gonzalez <andresg...@apple.com>
- "MotionMark scores are super sensitive to a single long frame"
- https://bugs.webkit.org/show_bug.cgi?id=220847
- https://trac.webkit.org/changeset/273390
+ Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.
+ https://bugs.webkit.org/show_bug.cgi?id=222154
- "MotionMark scores are super sensitive to a single long frame"
- https://bugs.webkit.org/show_bug.cgi?id=220847
- https://trac.webkit.org/changeset/273391
+ Reviewed by Chris Fleizach and Darin Adler.
- * Scripts/webkitpy/benchmark_runner/data/plans/motionmark1.1.plan:
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+ (WTR::AccessibilityUIElement::textMarkerRangeForRange):
+ 2021-02-25 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Unreviewed, reverting r273390 and r273391.
+ https://bugs.webkit.org/show_bug.cgi?id=222449
+
+ Didn't fix the extreme test variance, and caused some internal
+ performance bots to hang during testing
+
+ Reverted changesets:
+
+ "MotionMark scores are super sensitive to a single long frame"
+ https://bugs.webkit.org/show_bug.cgi?id=220847
+ https://trac.webkit.org/changeset/273390
+
+ "MotionMark scores are super sensitive to a single long frame"
+ https://bugs.webkit.org/show_bug.cgi?id=220847
+ https://trac.webkit.org/changeset/273391
+
+ * Scripts/webkitpy/benchmark_runner/data/plans/motionmark1.1.plan:
+
2021-02-25 Russell Epstein <repst...@apple.com>
Cherry-pick r273314. rdar://problem/74753323
Modified: branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp 2021-03-01 19:47:34 UTC (rev 273666)
@@ -102,6 +102,7 @@
#endif
#if !PLATFORM(MAC) || !HAVE(ACCESSIBILITY)
+RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForRange(unsigned, unsigned) { return nullptr; }
RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange() { return nullptr; }
void AccessibilityUIElement::resetSelectedTextMarkerRange() { }
void AccessibilityUIElement::setBoolAttributeValue(JSStringRef, bool) { }
Modified: branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h 2021-03-01 19:47:34 UTC (rev 273666)
@@ -298,6 +298,7 @@
RefPtr<AccessibilityTextMarkerRange> misspellingTextMarkerRange(AccessibilityTextMarkerRange* start, bool forward);
RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForElement(AccessibilityUIElement*);
RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
+ RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForRange(unsigned location, unsigned length);
RefPtr<AccessibilityTextMarkerRange> selectedTextMarkerRange();
void resetSelectedTextMarkerRange();
bool replaceTextInRange(JSStringRef, int position, int length);
Modified: branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl 2021-03-01 19:47:34 UTC (rev 273666)
@@ -218,6 +218,7 @@
AccessibilityTextMarkerRange misspellingTextMarkerRange(AccessibilityTextMarkerRange start, boolean forward);
AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement element);
AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker startMarker, AccessibilityTextMarker endMarker);
+ AccessibilityTextMarkerRange textMarkerRangeForRange(unsigned long location, unsigned long length);
AccessibilityTextMarkerRange selectedTextMarkerRange();
undefined resetSelectedTextMarkerRange();
boolean replaceTextInRange(DOMString string, long position, long length);
Modified: branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (273665 => 273666)
--- branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm 2021-03-01 19:40:25 UTC (rev 273665)
+++ branches/safari-611.1.21.1-branch/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm 2021-03-01 19:47:34 UTC (rev 273666)
@@ -83,6 +83,7 @@
- (BOOL)isIsolatedObject;
- (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string;
- (BOOL)accessibilityInsertText:(NSString *)text;
+- (id)textMarkerRangeForNSRange:(const NSRange&)nsRange;
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
- (NSUInteger)accessibilityIndexOfChild:(id)child;
- (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute;
@@ -1822,6 +1823,15 @@
return nullptr;
}
+RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForRange(unsigned location, unsigned length)
+{
+ BEGIN_AX_OBJC_EXCEPTIONS
+ return AccessibilityTextMarkerRange::create([m_element textMarkerRangeForNSRange:NSMakeRange(location, length)]);
+ END_AX_OBJC_EXCEPTIONS
+
+ return nullptr;
+}
+
RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange()
{
BEGIN_AX_OBJC_EXCEPTIONS