Title: [94994] branches/chromium/874
Revision
94994
Author
[email protected]
Date
2011-09-12 17:26:50 -0700 (Mon, 12 Sep 2011)

Log Message

Merge 94988 - REGRESSION: Moving up doesn't work in some cases
https://bugs.webkit.org/show_bug.cgi?id=67522

Reviewed by Eric Seidel.

Source/WebCore: 

The bug was caused by previousLinePosition's attempting to obtain the last root line box using
a position at minCaretOffset (which is, in practice, located at the beginning of wrapped lines).

Fix the bug by calling maxCaretOffset instead. Because isCandidate returns false at (br, 1),
use the positionBeforeNode for br elements.

Test: editing/selection/move-up-into-wrapped-line.html

* editing/visible_units.cpp:
(WebCore::previousLinePosition):

LayoutTests: 

Add a test to move caret upwards from an empty line below wrapped lines.

WebKit used to skip wrapped lines and placed caret at the beginning of the first of those wrapped lines
instead of before the last.

* editing/selection/move-up-into-wrapped-line-expected.txt: Added.
* editing/selection/move-up-into-wrapped-line.html: Added.
Review URL: http://codereview.chromium.org/7878009

Modified Paths

Added Paths

Diff

Copied: branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line-expected.txt (from rev 94988, trunk/LayoutTests/editing/selection/move-up-into-wrapped-line-expected.txt) (0 => 94994)


--- branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line-expected.txt	                        (rev 0)
+++ branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line-expected.txt	2011-09-13 00:26:50 UTC (rev 94994)
@@ -0,0 +1,10 @@
+This test moves up caret into a wrapped line. 
+i.e. the caret is moved from the empty line below "hello world" to before "world".
+| "
+"
+| <div>
+|   "hello <#selection-caret>world"
+| <div>
+|   <br>
+| "
+"

Copied: branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line.html (from rev 94988, trunk/LayoutTests/editing/selection/move-up-into-wrapped-line.html) (0 => 94994)


--- branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line.html	                        (rev 0)
+++ branches/chromium/874/LayoutTests/editing/selection/move-up-into-wrapped-line.html	2011-09-13 00:26:50 UTC (rev 94994)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="width: 6ex;" contenteditable=true>
+<div>hello world</div><div><br></div>
+</div>
+<script src=""
+<script>
+
+Markup.description('This test moves up caret into a wrapped line. \n'
+ + 'i.e. the caret is moved from the empty line below "hello world" to before "world".');
+
+var div = document.getElementsByTagName('div')[0];
+div.focus();
+getSelection().setPosition(div, div.childNodes.length);
+getSelection().modify('move', 'backward', 'line');
+
+Markup.dump(div);
+
+</script>
+</body>
+</html>

Modified: branches/chromium/874/Source/WebCore/editing/visible_units.cpp (94993 => 94994)


--- branches/chromium/874/Source/WebCore/editing/visible_units.cpp	2011-09-13 00:07:52 UTC (rev 94993)
+++ branches/chromium/874/Source/WebCore/editing/visible_units.cpp	2011-09-13 00:26:50 UTC (rev 94994)
@@ -533,7 +533,7 @@
         while (n) {
             if (highestEditableRoot(firstPositionInOrBeforeNode(n)) != highestRoot)
                 break;
-            Position pos = createLegacyEditingPosition(n, caretMinOffset(n));
+            Position pos = n->hasTagName(brTag) ? positionBeforeNode(n) : createLegacyEditingPosition(n, caretMaxOffset(n));
             if (pos.isCandidate()) {
                 pos.getInlineBoxAndOffset(DOWNSTREAM, box, ignoredCaretOffset);
                 if (box) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to