Diff
Modified: trunk/LayoutTests/ChangeLog (200871 => 200872)
--- trunk/LayoutTests/ChangeLog 2016-05-13 18:56:04 UTC (rev 200871)
+++ trunk/LayoutTests/ChangeLog 2016-05-13 18:57:38 UTC (rev 200872)
@@ -1,3 +1,13 @@
+2016-05-13 Nan Wang <n_w...@apple.com>
+
+ AX: Wrong CharacterOffset from an upstream VisiblePosition
+ https://bugs.webkit.org/show_bug.cgi?id=157644
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/mac/character-offset-from-upstream-position-expected.txt: Added.
+ * accessibility/mac/character-offset-from-upstream-position.html: Added.
+
2016-05-13 Ryan Haddad <ryanhad...@apple.com>
Marking fast/text-autosizing/ios/text-autosizing-after-back.html as a flaky timeout
Added: trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt (0 => 200872)
--- trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt 2016-05-13 18:57:38 UTC (rev 200872)
@@ -0,0 +1,13 @@
+Lorem ipsum vivamus nibh urna mollis at aliquam taciti, etiam arcu mi semper nostra taciti nulla dolor
+This tests that CharacterOffset that comes from an upstream VisiblePosition is correct.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+First Line: Lorem ipsum vivamus nibh
+Second Line: urna mollis at aliquam taciti,
+[firstEnd, secondStart]: 'space'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html (0 => 200872)
--- trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html (rev 0)
+++ trunk/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html 2016-05-13 18:57:38 UTC (rev 200872)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<div id="container">
+
+<div id="text" style="width:200px;" contenteditable="true">Lorem ipsum vivamus nibh urna mollis at aliquam taciti, etiam arcu mi semper nostra taciti nulla dolor</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+ description("This tests that CharacterOffset that comes from an upstream VisiblePosition is correct.");
+
+ if (window.accessibilityController) {
+
+ var div = accessibilityController.accessibleElementById("text");
+ var text = div.childAtIndex(0);
+ var textRange = text.textMarkerRangeForElement(text);
+
+ var start = text.startTextMarkerForTextMarkerRange(textRange);
+ var firstLine = text.lineTextMarkerRangeForTextMarker(start);
+ var firstEnd = text.endTextMarkerForTextMarkerRange(firstLine);
+ debug("First Line: " + text.stringForTextMarkerRange(firstLine));
+
+ var next = text.nextTextMarker(firstEnd);
+ var secondLine = text.lineTextMarkerRangeForTextMarker(next);
+ var secondStart = text.startTextMarkerForTextMarkerRange(secondLine);
+ debug("Second Line: " + text.stringForTextMarkerRange(secondLine));
+
+ // Here firstEnd should contain a upstream position.
+ // We need to make sure firstEnd does not equal to secondStart after
+ // converting to CharacterOffset.
+ var markerRange = text.textMarkerRangeForMarkers(secondStart, firstEnd);
+ var space = ' ';
+ debug("[firstEnd, secondStart]: " + text.stringForTextMarkerRange(markerRange).replace(space, "'space'"));
+ }
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (200871 => 200872)
--- trunk/Source/WebCore/ChangeLog 2016-05-13 18:56:04 UTC (rev 200871)
+++ trunk/Source/WebCore/ChangeLog 2016-05-13 18:57:38 UTC (rev 200872)
@@ -1,3 +1,20 @@
+2016-05-13 Nan Wang <n_w...@apple.com>
+
+ AX: Wrong CharacterOffset from an upstream VisiblePosition
+ https://bugs.webkit.org/show_bug.cgi?id=157644
+
+ Reviewed by Chris Fleizach.
+
+ We should adjust the text marker's CharacterOffset if its corresponding
+ VisiblePosition has upstream affinity.
+
+ Test: accessibility/mac/character-offset-from-upstream-position.html
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::characterOffsetForTextMarkerData):
+ (WebCore::AXObjectCache::traverseToOffsetInRange):
+ (WebCore::AXObjectCache::localCaretRectForCharacterOffset):
+
2016-05-13 Beth Dakin <bda...@apple.com>
Add dyldSPI.h for linked on or after checks, and add one for link preview
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (200871 => 200872)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-05-13 18:56:04 UTC (rev 200871)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-05-13 18:57:38 UTC (rev 200872)
@@ -71,8 +71,10 @@
#include "HTMLLabelElement.h"
#include "HTMLMeterElement.h"
#include "HTMLNames.h"
+#include "InlineElementBox.h"
#include "Page.h"
#include "RenderAttachment.h"
+#include "RenderLineBreak.h"
#include "RenderListBox.h"
#include "RenderMenuList.h"
#include "RenderMeter.h"
@@ -1468,7 +1470,12 @@
if (textMarkerData.ignored)
return CharacterOffset();
- return CharacterOffset(textMarkerData.node, textMarkerData.characterStartIndex, textMarkerData.characterOffset);
+ CharacterOffset result = CharacterOffset(textMarkerData.node, textMarkerData.characterStartIndex, textMarkerData.characterOffset);
+ // When we are at a line wrap and the VisiblePosition is upstream, it means the text marker is at the end of the previous line.
+ // We use the previous CharacterOffset so that it will match the Range.
+ if (textMarkerData.affinity == UPSTREAM)
+ return previousCharacterOffset(result, false);
+ return result;
}
CharacterOffset AXObjectCache::traverseToOffsetInRange(RefPtr<Range>range, int offset, TraverseOption option, bool stayWithinRange)
@@ -1601,6 +1608,11 @@
remaining = offset - cumulativeOffset;
}
+ // Sometimes when we are getting the end CharacterOffset of a line range, the TextIterator will emit an extra space at the end
+ // and make the character count greater than the Range's end offset.
+ if (toNodeEnd && currentNode->isTextNode() && currentNode == &range->endContainer() && range->endOffset() < lastStartOffset + offsetInCharacter)
+ offsetInCharacter = range->endOffset() - lastStartOffset;
+
return CharacterOffset(currentNode, lastStartOffset, offsetInCharacter, remaining);
}
@@ -1999,7 +2011,7 @@
// Sometimes when the node is a replaced node and is ignored in accessibility, we get a wrong CharacterOffset from it.
CharacterOffset result = traverseToOffsetInRange(rangeForNodeContents(obj->node()), characterOffset);
- if (result.remainingOffset > 0 && !result.isNull() && isRendererReplacedElement(result.node->renderer()))
+ if (result.remainingOffset > 0 && !result.isNull() && isRendererReplacedElement(result.node->renderer()))
result.offset += result.remainingOffset;
return result;
}
@@ -2451,6 +2463,9 @@
if (inlineBox)
renderer = &inlineBox->renderer();
+ if (is<RenderLineBreak>(renderer) && downcast<RenderLineBreak>(renderer)->inlineBoxWrapper() != inlineBox)
+ return IntRect();
+
return renderer->localCaretRect(inlineBox, caretOffset);
}