Title: [201443] trunk
- Revision
- 201443
- Author
- n_w...@apple.com
- Date
- 2016-05-26 18:41:18 -0700 (Thu, 26 May 2016)
Log Message
AX: Wrong CharacterOffset from VisiblePosition with composed characters
https://bugs.webkit.org/show_bug.cgi?id=158138
Reviewed by Chris Fleizach.
Source/WebCore:
The conversion logic is not correct when the text node contains composed characters.
We should use VisiblePosition's offset directly for text nodes so we won't mess things up.
Test: accessibility/mac/character-offset-visible-position-conversion-with-emoji.html
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::visiblePositionFromCharacterOffset):
(WebCore::AXObjectCache::characterOffsetFromVisiblePosition):
LayoutTests:
* accessibility/mac/character-offset-visible-position-conversion-with-emoji-expected.txt: Added.
* accessibility/mac/character-offset-visible-position-conversion-with-emoji.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201442 => 201443)
--- trunk/LayoutTests/ChangeLog 2016-05-27 00:40:09 UTC (rev 201442)
+++ trunk/LayoutTests/ChangeLog 2016-05-27 01:41:18 UTC (rev 201443)
@@ -1,3 +1,13 @@
+2016-05-26 Nan Wang <n_w...@apple.com>
+
+ AX: Wrong CharacterOffset from VisiblePosition with composed characters
+ https://bugs.webkit.org/show_bug.cgi?id=158138
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/mac/character-offset-visible-position-conversion-with-emoji-expected.txt: Added.
+ * accessibility/mac/character-offset-visible-position-conversion-with-emoji.html: Added.
+
2016-05-26 Brent Fulgham <bfulg...@apple.com>
DOM mutation methods fail to re-check validity of node insertion after removing nodes from old parent
Added: trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji-expected.txt (0 => 201443)
--- trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji-expected.txt 2016-05-27 01:41:18 UTC (rev 201443)
@@ -0,0 +1,11 @@
+Hi 😎
+This tests that CharacterOffset and VisiblePosition convert correctly when there are composed characters.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Hi 😎
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji.html (0 => 201443)
--- trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji.html (rev 0)
+++ trunk/LayoutTests/accessibility/mac/character-offset-visible-position-conversion-with-emoji.html 2016-05-27 01:41:18 UTC (rev 201443)
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head><meta charset="UTF-8"></head>
+ <script src=""
+ <body id="body" tabindex="0">
+ <div tabindex="0" id="text" contenteditable=true>
+ Hi 😎
+ </div>
+
+ <p id="description"></p>
+ <div id="console"></div>
+
+ <script>
+
+ description("This tests that CharacterOffset and VisiblePosition convert correctly when there are composed characters.");
+
+ var index = 0;
+ if (window.accessibilityController) {
+ accessibilityController.enableEnhancedAccessibility(true);
+ var webArea = accessibilityController.rootElement.childAtIndex(0);
+ webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true);
+
+ document.getElementById("text").focus();
+ var text = accessibilityController.accessibleElementById("text");
+
+ eventSender.keyDown("rightArrow");
+ eventSender.keyDown("rightArrow");
+ eventSender.keyDown("rightArrow");
+ eventSender.keyDown("rightArrow");
+ var textMarkerRange = text.selectedTextMarkerRange();
+ var elementRange = text.textMarkerRangeForElement(text);
+ var startMarker = text.startTextMarkerForTextMarkerRange(elementRange);
+ var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange);
+ debug(text.stringForTextMarkerRange(text.textMarkerRangeForMarkers(endMarker, startMarker)));
+ }
+
+ </script>
+
+ <script src=""
+
+ </body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (201442 => 201443)
--- trunk/Source/WebCore/ChangeLog 2016-05-27 00:40:09 UTC (rev 201442)
+++ trunk/Source/WebCore/ChangeLog 2016-05-27 01:41:18 UTC (rev 201443)
@@ -1,3 +1,19 @@
+2016-05-26 Nan Wang <n_w...@apple.com>
+
+ AX: Wrong CharacterOffset from VisiblePosition with composed characters
+ https://bugs.webkit.org/show_bug.cgi?id=158138
+
+ Reviewed by Chris Fleizach.
+
+ The conversion logic is not correct when the text node contains composed characters.
+ We should use VisiblePosition's offset directly for text nodes so we won't mess things up.
+
+ Test: accessibility/mac/character-offset-visible-position-conversion-with-emoji.html
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::visiblePositionFromCharacterOffset):
+ (WebCore::AXObjectCache::characterOffsetFromVisiblePosition):
+
2016-05-26 Darin Adler <da...@apple.com>
Media queries and platform screen modernization and streamlining
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (201442 => 201443)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-05-27 00:40:09 UTC (rev 201442)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-05-27 01:41:18 UTC (rev 201443)
@@ -1952,21 +1952,10 @@
if (characterOffset.isNull())
return VisiblePosition();
- RefPtr<AccessibilityObject> obj = this->getOrCreate(characterOffset.node);
- if (!obj)
- return VisiblePosition();
-
- // nextVisiblePosition means advancing one character. Use this to calculate the character offset.
- VisiblePositionRange vpRange = obj->visiblePositionRange();
- VisiblePosition start = vpRange.start;
-
- // Sometimes vpRange.start will be the previous node's end position and VisiblePosition will count the leading line break as 1 offset.
- int characterCount = start.deepEquivalent().deprecatedNode() == characterOffset.node ? characterOffset.offset : characterOffset.offset + characterOffset.startIndex;
- VisiblePosition result = start;
- for (int i = 0; i < characterCount; i++)
- result = obj->nextVisiblePosition(result);
-
- return result;
+ // Create a collapsed range and use that to form a VisiblePosition, so that the case with
+ // composed characters will be covered.
+ RefPtr<Range> range = rangeForUnorderedCharacterOffsets(characterOffset, characterOffset);
+ return VisiblePosition(range->startPosition());
}
CharacterOffset AXObjectCache::characterOffsetFromVisiblePosition(const VisiblePosition& visiblePos)
@@ -1978,6 +1967,9 @@
Node* domNode = deepPos.deprecatedNode();
ASSERT(domNode);
+ if (domNode->offsetInCharacters())
+ return CharacterOffset(domNode, 0, deepPos.deprecatedEditingOffset(), 0);
+
RefPtr<AccessibilityObject> obj = this->getOrCreate(domNode);
if (!obj)
return CharacterOffset();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes