Title: [201012] branches/safari-602.1.32-branch

Diff

Modified: branches/safari-602.1.32-branch/LayoutTests/ChangeLog (201011 => 201012)


--- branches/safari-602.1.32-branch/LayoutTests/ChangeLog	2016-05-17 08:47:21 UTC (rev 201011)
+++ branches/safari-602.1.32-branch/LayoutTests/ChangeLog	2016-05-17 08:47:24 UTC (rev 201012)
@@ -1,5 +1,19 @@
 2016-05-17  Babak Shafiei  <[email protected]>
 
+        Merge r200872. rdar://problem/25993225
+
+    2016-05-13  Nan Wang  <[email protected]>
+
+            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-17  Babak Shafiei  <[email protected]>
+
         Merge r200688. rdar://problem/26013966
 
     2016-05-11  Jer Noble  <[email protected]>

Added: branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt (0 => 201012)


--- branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt	                        (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position-expected.txt	2016-05-17 08:47:24 UTC (rev 201012)
@@ -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: branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html (0 => 201012)


--- branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html	                        (rev 0)
+++ branches/safari-602.1.32-branch/LayoutTests/accessibility/mac/character-offset-from-upstream-position.html	2016-05-17 08:47:24 UTC (rev 201012)
@@ -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: branches/safari-602.1.32-branch/Source/WebCore/ChangeLog (201011 => 201012)


--- branches/safari-602.1.32-branch/Source/WebCore/ChangeLog	2016-05-17 08:47:21 UTC (rev 201011)
+++ branches/safari-602.1.32-branch/Source/WebCore/ChangeLog	2016-05-17 08:47:24 UTC (rev 201012)
@@ -1,5 +1,26 @@
 2016-05-17  Babak Shafiei  <[email protected]>
 
+        Merge r200872. rdar://problem/25993225
+
+    2016-05-13  Nan Wang  <[email protected]>
+
+            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-17  Babak Shafiei  <[email protected]>
+
         Merge r200866. rdar://problem/26253396
 
     2016-05-13  Beth Dakin  <[email protected]>

Modified: branches/safari-602.1.32-branch/Source/WebCore/accessibility/AXObjectCache.cpp (201011 => 201012)


--- branches/safari-602.1.32-branch/Source/WebCore/accessibility/AXObjectCache.cpp	2016-05-17 08:47:21 UTC (rev 201011)
+++ branches/safari-602.1.32-branch/Source/WebCore/accessibility/AXObjectCache.cpp	2016-05-17 08:47:24 UTC (rev 201012)
@@ -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);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to