Caret positioned at the end of a text line (followed by an empty block) in vertical...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 05:59:02 +0000 (05:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 05:59:02 +0000 (05:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106452

Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2013-02-14
Reviewed by Ryosuke Niwa.

Source/WebCore:

Pressing the down or the right arrow key at the end of a text line in
vertical writing mode would make the caret dissapear. This occurs only
when the text line is followed by an empty block.

When trying to compute the next position for placing the caret (for
down/right key), we try to ascertain whether the renderer (in this
case the empty block) is a valid candidate or not. For blockFlow
elements we check against their height.
In vertical writing mode though we would fail such a check since we
should instead be comparing against the renderer's width and not
it's height. Thus, a valid position for the placement of the caret
was not found in such a case.

Test: editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html

* dom/Position.cpp:
(WebCore::Position::isCandidate):
* dom/PositionIterator.cpp:
(WebCore::PositionIterator::isCandidate):
Instead of checking against the height(), check against the
logicalHeight() of the renderer has been added. logicalHeight()
on blockFlow renderer's returns a value in accordance with
the writing mode.

LayoutTests:

* editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode-expected.txt: Added.
* editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html: Added.
Layout test case added for verifying that pressing the down or the right arrow
key at the end of the text line in vertical writing mode will not make the caret
dissapear.
Caret positions at the start, the end, and after pressing the right and the down
arrow keys at the end of the text line, are compared for verification.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142960 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/PositionIterator.cpp

index 008337680b3dd0568630a3363731fba364f457e1..f2becb3c5aeac3a291742b3b5a7a622073c01ea5 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-14  Arpita Bahuguna  <arpitabahuguna@gmail.com>
+
+        Caret positioned at the end of a text line (followed by an empty block) in vertical writing mode disappears when pressing the right/down arrow key.
+        https://bugs.webkit.org/show_bug.cgi?id=106452
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode-expected.txt: Added.
+        * editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html: Added.
+        Layout test case added for verifying that pressing the down or the right arrow
+        key at the end of the text line in vertical writing mode will not make the caret
+        dissapear.
+        Caret positions at the start, the end, and after pressing the right and the down
+        arrow keys at the end of the text line, are compared for verification. 
+
 2013-02-14  Simon Fraser  <simon.fraser@apple.com>
 
         Reverting r142861. Hit testing inside of style recalc is fundamentally wrong
diff --git a/LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode-expected.txt b/LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode-expected.txt
new file mode 100644 (file)
index 0000000..ba3ec20
--- /dev/null
@@ -0,0 +1,11 @@
+Testcase for bug 106452: Caret positioned at the end of a text line (followed by an empty block) in vertical writing mode disappears when pressing the right/down arrow key. To manually verify the issue, place the caret at the end of the text line and then press either the down or the right arrow key.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS caretRectAtEnd.width is caretRectAtStart.width
+PASS caretRectAtEnd.height is caretRectAtStart.height
+PASS caretRectRightKey.width is caretRectAtEnd.width
+PASS caretRectRightKey.height is caretRectAtEnd.height
+PASS caretRectDownKey.width is caretRectAtEnd.width
+PASS caretRectDownKey.height is caretRectAtEnd.height
+
diff --git a/LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html b/LayoutTests/editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html
new file mode 100644 (file)
index 0000000..1efb972
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#textDiv {
+    height: 200px;
+    width: 200px;
+    border: 1px solid black;
+    -webkit-writing-mode: vertical-rl;
+}
+</style>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script>
+function runTest() {
+    description('Testcase for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=106452">106452</a>:  Caret positioned at the end of a text line (followed by an empty block) in vertical writing mode disappears when pressing the right/down arrow key.\nTo manually verify the issue, place the caret at the end of the text line and then press either the down or the right arrow key.');
+
+    if (window.internals) {
+        var testDiv = document.getElementById('textDiv');
+
+        eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+        caretRectAtStart = internals.absoluteCaretBounds(document);
+
+        eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop + testDiv.offsetHeight - 5);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+        caretRectAtEnd = internals.absoluteCaretBounds(document);
+
+        eventSender.keyDown("rightArrow");
+        caretRectRightKey = internals.absoluteCaretBounds(document);
+
+        eventSender.keyDown("downArrow");
+        caretRectDownKey = internals.absoluteCaretBounds(document);
+
+        shouldBe("caretRectAtEnd.width", "caretRectAtStart.width");
+        shouldBe("caretRectAtEnd.height", "caretRectAtStart.height");
+        shouldBe("caretRectRightKey.width", "caretRectAtEnd.width");
+        shouldBe("caretRectRightKey.height", "caretRectAtEnd.height");
+        shouldBe("caretRectDownKey.width", "caretRectAtEnd.width");
+        shouldBe("caretRectDownKey.height", "caretRectAtEnd.height");
+
+        testDiv.style.display = 'none';
+    }
+}
+</script>
+</head>
+<body onload="runTest();">
+<div id="textDiv" contenteditable="true">Some text.<p></p></div>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
index 18b5fa22cd6d21987f74ab09a0d06a50a6695a80..195179f5a2bd28c389ebdf0a52b2968584aa5d8e 100644 (file)
@@ -1,3 +1,34 @@
+2013-02-14  Arpita Bahuguna  <arpitabahuguna@gmail.com>
+
+        Caret positioned at the end of a text line (followed by an empty block) in vertical writing mode disappears when pressing the right/down arrow key.
+        https://bugs.webkit.org/show_bug.cgi?id=106452
+
+        Reviewed by Ryosuke Niwa.
+
+        Pressing the down or the right arrow key at the end of a text line in
+        vertical writing mode would make the caret dissapear. This occurs only
+        when the text line is followed by an empty block.
+
+        When trying to compute the next position for placing the caret (for
+        down/right key), we try to ascertain whether the renderer (in this
+        case the empty block) is a valid candidate or not. For blockFlow
+        elements we check against their height.
+        In vertical writing mode though we would fail such a check since we
+        should instead be comparing against the renderer's width and not
+        it's height. Thus, a valid position for the placement of the caret
+        was not found in such a case.
+
+        Test: editing/selection/caret-at-end-of-text-line-followed-by-empty-block-in-vertical-mode.html
+
+        * dom/Position.cpp:
+        (WebCore::Position::isCandidate):
+        * dom/PositionIterator.cpp:
+        (WebCore::PositionIterator::isCandidate):
+        Instead of checking against the height(), check against the
+        logicalHeight() of the renderer has been added. logicalHeight()
+        on blockFlow renderer's returns a value in accordance with
+        the writing mode.
+
 2013-02-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         Windows build fix after r142957.
index f5e4dee784389f40e01c73bc0de21fd0df7f1d7d..55bc3903c50d79d54a9b3f24d2caa71abc2cd7c5 100644 (file)
@@ -933,7 +933,7 @@ bool Position::isCandidate() const
         return false;
         
     if (renderer->isBlockFlow()) {
-        if (toRenderBlock(renderer)->height() || m_anchorNode->hasTagName(bodyTag)) {
+        if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
             if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
                 return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode());
             return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
index 3c1bbd605852fe68ae827b983d8b59eb404fdc25..9a0b974c6cb78209c12ec16c2be4cbd9d9535550 100644 (file)
@@ -160,7 +160,7 @@ bool PositionIterator::isCandidate() const
         return (atStartOfNode() || atEndOfNode()) && !Position::nodeIsUserSelectNone(m_anchorNode->parentNode());
 
     if (!m_anchorNode->hasTagName(htmlTag) && renderer->isBlockFlow()) {
-        if (toRenderBlock(renderer)->height() || m_anchorNode->hasTagName(bodyTag)) {
+        if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
             if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
                 return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anchorNode);
             return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).atEditingBoundary();