Title: [136225] trunk
Revision
136225
Author
[email protected]
Date
2012-11-30 04:32:15 -0800 (Fri, 30 Nov 2012)

Log Message

Caret is painted horizontally in vertical writing mode when there are no visible text
https://bugs.webkit.org/show_bug.cgi?id=102359

Patch by Arpita Bahuguna <[email protected]> on 2012-11-30
Reviewed by Ryosuke Niwa.

Source/WebCore:

In the vertical writing mode the caret rect on an empty editable box or
an empty line is rendered as per the horizontal writing mode.

This changes though when any text is added; the caret is then displayed
in accordance with the vertical writing mode.

Test: editing/selection/caret-alignment-for-vertical-text.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::localCaretRect):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::localCaretRectForEmptyElement):
The caret rect should be transposed for the vertical writing mode. Its
width and height values need to be interchanged for it to be oriented
as per the vertical text.

LayoutTests:

* editing/selection/caret-alignment-for-vertical-text-expected.txt: Added.
* editing/selection/caret-alignment-for-vertical-text.html: Added.
Test to verify that the orientation of the caret on an empty vertical text
line or container is same as that for a non-empty container.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136224 => 136225)


--- trunk/LayoutTests/ChangeLog	2012-11-30 12:01:39 UTC (rev 136224)
+++ trunk/LayoutTests/ChangeLog	2012-11-30 12:32:15 UTC (rev 136225)
@@ -1,3 +1,15 @@
+2012-11-30  Arpita Bahuguna  <[email protected]>
+
+        Caret is painted horizontally in vertical writing mode when there are no visible text
+        https://bugs.webkit.org/show_bug.cgi?id=102359
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/selection/caret-alignment-for-vertical-text-expected.txt: Added.
+        * editing/selection/caret-alignment-for-vertical-text.html: Added.
+        Test to verify that the orientation of the caret on an empty vertical text
+        line or container is same as that for a non-empty container.
+
 2012-11-30  Nandor Huszka  <[email protected]>
 
         [Qt] Unreviewed gardening.

Added: trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text-expected.txt (0 => 136225)


--- trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text-expected.txt	2012-11-30 12:32:15 UTC (rev 136225)
@@ -0,0 +1,16 @@
+
+this is some vertical text
+Testcase for bug 102359: Caret is painted horizontally in vertical writing mode when there are no visible text.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+The carets on the empty editable boxes should have the same orientation as that on the editable box containing some text. We thus compare the width and the height of the caret rects for verification. Width and height for all the three caret rects should be the same for the test to pass.
+PASS emptyDivCaretRect.width is textDivCaretRect.width
+PASS emptyDivCaretRect.height is textDivCaretRect.height
+PASS emptyLineCaretRect.width is textDivCaretRect.width
+PASS emptyLineCaretRect.height is textDivCaretRect.height
+To verify the test manually on the browser, compare the orientation of the carets in all the boxes; it should be the same for all three.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text.html (0 => 136225)


--- trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/caret-alignment-for-vertical-text.html	2012-11-30 12:32:15 UTC (rev 136225)
@@ -0,0 +1,55 @@
+<!DOCTYPE html> 
+<html>
+<head>
+<style>
+.editableDiv {
+    height: 200px;
+    width: 200px;
+    border: 1px solid black;
+    -webkit-writing-mode: vertical-rl;
+    font-family: ahem;
+}
+</style>
+<script src=""
+<script>
+function runTest() {
+    description('Testcase for bug <a href="" Caret is painted horizontally in vertical writing mode when there are no visible text.');
+
+    /* Caret rect for the empty container. */
+    document.getElementById('emptyDiv').focus();
+    if (window.internals)
+        emptyDivCaretRect = internals.absoluteCaretBounds(document);
+        
+    /* Caret rect for am empty line. */
+    document.getElementById('emptyLineDiv').focus();
+    if (window.internals)
+        emptyLineCaretRect = internals.absoluteCaretBounds(document);
+        
+    /* Caret rect for the container with some text. */
+    document.getElementById('textDiv').focus();
+    if (window.internals)
+        textDivCaretRect = internals.absoluteCaretBounds(document);
+        
+    debug("The carets on the empty editable boxes should have the same orientation as that on the editable box containing some text. We thus compare the width and the height of the caret rects for verification. Width and height for all the three caret rects should be the same for the test to pass.")
+    
+    if (window.internals) {
+        shouldBe("emptyDivCaretRect.width", "textDivCaretRect.width");
+        shouldBe("emptyDivCaretRect.height", "textDivCaretRect.height");
+        shouldBe("emptyLineCaretRect.width", "textDivCaretRect.width");
+        shouldBe("emptyLineCaretRect.height", "textDivCaretRect.height");        
+    }
+    
+    debug("To verify the test manually on the browser, compare the orientation of the carets in all the boxes; it should be the same for all three.");
+   
+    isSuccessfullyParsed();
+}
+</script>
+</head>
+<body _onload_="runTest();">
+<div style="float: left;" contenteditable="true" class="editableDiv" id="emptyDiv"></div>
+<div style="float: left;" contenteditable="true" class="editableDiv" id="emptyLineDiv"><div><br></div></div>
+<div contenteditable="true" class="editableDiv" id="textDiv">this is some vertical text</div>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136224 => 136225)


--- trunk/Source/WebCore/ChangeLog	2012-11-30 12:01:39 UTC (rev 136224)
+++ trunk/Source/WebCore/ChangeLog	2012-11-30 12:32:15 UTC (rev 136225)
@@ -1,3 +1,26 @@
+2012-11-30  Arpita Bahuguna  <[email protected]>
+
+        Caret is painted horizontally in vertical writing mode when there are no visible text
+        https://bugs.webkit.org/show_bug.cgi?id=102359
+
+        Reviewed by Ryosuke Niwa.
+
+        In the vertical writing mode the caret rect on an empty editable box or
+        an empty line is rendered as per the horizontal writing mode.
+
+        This changes though when any text is added; the caret is then displayed
+        in accordance with the vertical writing mode.
+
+        Test: editing/selection/caret-alignment-for-vertical-text.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::localCaretRect):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::localCaretRectForEmptyElement):
+        The caret rect should be transposed for the vertical writing mode. Its
+        width and height values need to be interchanged for it to be oriented
+        as per the vertical text.
+
 2012-11-30  Sankeerth V S  <[email protected]>
 
         Web Inspector: [Timeline] JS error when clicking in Memory Statistics view

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (136224 => 136225)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-11-30 12:01:39 UTC (rev 136224)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-11-30 12:32:15 UTC (rev 136225)
@@ -3624,6 +3624,10 @@
 
     // Move to local coords
     rect.moveBy(-location());
+
+    if (!isHorizontalWritingMode())
+        return rect.transposedRect();
+
     return rect;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (136224 => 136225)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-11-30 12:01:39 UTC (rev 136224)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-11-30 12:32:15 UTC (rev 136225)
@@ -2758,7 +2758,7 @@
 
     LayoutUnit y = paddingTop() + borderTop();
 
-    return LayoutRect(x, y, caretWidth, height);
+    return currentStyle->isHorizontalWritingMode() ? LayoutRect(x, y, caretWidth, height) : LayoutRect(y, x, height, caretWidth);
 }
 
 bool RenderBoxModelObject::shouldAntialiasLines(GraphicsContext* context)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to