Diff
Modified: branches/safari-604-branch/LayoutTests/ChangeLog (220021 => 220022)
--- branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-28 22:19:44 UTC (rev 220021)
+++ branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-28 22:19:47 UTC (rev 220022)
@@ -1,5 +1,19 @@
2017-07-28 Jason Marcell <[email protected]>
+ Cherry-pick r219949. rdar://problem/33595616
+
+ 2017-07-26 Nan Wang <[email protected]>
+
+ AX: Incorrect range from index and length in contenteditable with <p> tags
+ https://bugs.webkit.org/show_bug.cgi?id=174856
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/mac/range-for-contenteditable-newline-expected.txt:
+ * accessibility/mac/range-for-contenteditable-newline.html:
+
+2017-07-28 Jason Marcell <[email protected]>
+
Cherry-pick r219906. rdar://problem/33595387
2017-07-26 Nan Wang <[email protected]>
Modified: branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline-expected.txt (220021 => 220022)
--- branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline-expected.txt 2017-07-28 22:19:44 UTC (rev 220021)
+++ branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline-expected.txt 2017-07-28 22:19:47 UTC (rev 220022)
@@ -7,9 +7,9 @@
def
-The quick brown fox
+ab
-jumped over the lazy dog
+cd ef
Text in a pre element
is displayed in a fixed-width
@@ -26,14 +26,11 @@
PASS textareaTextHello is 'hello'
PASS textareaTextWorld is 'world'
PASS textDEF is 'def'
-PASS rangeForLine is '{21, 25}'
-PASS textLine is 'jumped over the lazy dog'
-PASS firstLine is 0
-PASS secondLine is 1
+PASS rangeValue is '[newline][newline]cd'
PASS rangeForLine is '{22, 30}'
PASS textLine is 'is displayed in a fixed-width\n'
PASS firstLine is 0
-FAIL secondLine should be 1. Was 2.
+PASS secondLine is 1
PASS successfullyParsed is true
TEST COMPLETE
Modified: branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline.html (220021 => 220022)
--- branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline.html 2017-07-28 22:19:44 UTC (rev 220021)
+++ branches/safari-604-branch/LayoutTests/accessibility/mac/range-for-contenteditable-newline.html 2017-07-28 22:19:47 UTC (rev 220022)
@@ -13,8 +13,8 @@
<div id="textcontrol2" contenteditable="true">abc<div><br></div<div><br></div><div><br></div><div>def</div></div>
<div id="textcontrol3" contenteditable="true">
-<p>The quick brown fox</p>
-<p>jumped over the lazy dog</p>
+<p>ab</p>
+<p>cd ef</p>
</div>
<div id="textcontrol4" contenteditable="true">
@@ -59,14 +59,10 @@
// Test line ranges in contenteditable
var textControl3 = accessibilityController.accessibleElementById("textcontrol3");
- var rangeForLine = textControl3.rangeForLine(1);
- shouldBe("rangeForLine", "'{21, 25}'");
- var textLine = textControl3.stringForRange(21, 25);
- shouldBe("textLine", "'jumped over the lazy dog'");
- var firstLine = textControl3.lineForIndex(20);
- var secondLine = textControl3.lineForIndex(46);
- shouldBe("firstLine", "0");
- shouldBe("secondLine", "1");
+ var rangeValue = textControl3.stringForRange(2, 4);
+ // Replace the newline characters, and make sure it has two of them
+ rangeValue = rangeValue.replace(/(?:\r\n|\r|\n)/g, '[newline]');
+ shouldBe("rangeValue", "'[newline][newline]cd'");
// pre tag in contenteditable
var textControl4 = accessibilityController.accessibleElementById("textcontrol4");
@@ -75,7 +71,7 @@
textLine = textControl4.stringForRange(22, 30);
shouldBe("textLine", "'is displayed in a fixed-width\\n'");
firstLine = textControl4.lineForIndex(21);
- secondLine = textControl4.lineForIndex(52);
+ secondLine = textControl4.lineForIndex(51);
shouldBe("firstLine", "0");
shouldBe("secondLine", "1");
Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220021 => 220022)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-28 22:19:44 UTC (rev 220021)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-28 22:19:47 UTC (rev 220022)
@@ -1,5 +1,25 @@
2017-07-28 Jason Marcell <[email protected]>
+ Cherry-pick r219949. rdar://problem/33595616
+
+ 2017-07-26 Nan Wang <[email protected]>
+
+ AX: Incorrect range from index and length in contenteditable with <p> tags
+ https://bugs.webkit.org/show_bug.cgi?id=174856
+
+ Reviewed by Chris Fleizach.
+
+ When asking for the string inside a text control with a given range, we sometimes get
+ a wrong string at the line boundary due to a bad plain range to text marker conversion.
+ To fix this, we should use the exsisting method on text controls to avoid this issue.
+
+ Updated the test to test the problematic case.
+
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+
+2017-07-28 Jason Marcell <[email protected]>
+
Cherry-pick r219906. rdar://problem/33595387
2017-07-26 Nan Wang <[email protected]>
Modified: branches/safari-604-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (220021 => 220022)
--- branches/safari-604-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2017-07-28 22:19:44 UTC (rev 220021)
+++ branches/safari-604-branch/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2017-07-28 22:19:47 UTC (rev 220022)
@@ -3960,6 +3960,11 @@
}
if ([attribute isEqualToString:NSAccessibilityStringForRangeParameterizedAttribute]) {
+ if (m_object->isTextControl()) {
+ PlainTextRange plainTextRange = PlainTextRange(range.location, range.length);
+ return m_object->doAXStringForRange(plainTextRange);
+ }
+
CharacterOffset start = cache->characterOffsetForIndex(range.location, m_object);
CharacterOffset end = cache->characterOffsetForIndex(range.location + range.length, m_object);
if (start.isNull() || end.isNull())