Title: [114461] trunk
- Revision
- 114461
- Author
- yi.4.s...@nokia.com
- Date
- 2012-04-17 16:10:21 -0700 (Tue, 17 Apr 2012)
Log Message
Caret is not rendered properly inside an input element with text-indent
https://bugs.webkit.org/show_bug.cgi?id=82688
Reviewed by Ryosuke Niwa.
For an empty input element, there is no RenderText. Instead, RenderBlock::localCaretRect provides
the caret position for rendering the caret in the empty input element. To get correct caret rect,
textIndentOffset() should be used to adjust the caret's position.
Source/WebCore:
Test: editing/style/text-indent.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::localCaretRect):
LayoutTests:
* editing/style/text-indent-expected.txt: Added.
* editing/style/text-indent.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (114460 => 114461)
--- trunk/LayoutTests/ChangeLog 2012-04-17 23:08:05 UTC (rev 114460)
+++ trunk/LayoutTests/ChangeLog 2012-04-17 23:10:21 UTC (rev 114461)
@@ -1,3 +1,17 @@
+2012-04-17 Yi Shen <yi.4.s...@nokia.com>
+
+ Caret is not rendered properly inside an input element with text-indent
+ https://bugs.webkit.org/show_bug.cgi?id=82688
+
+ Reviewed by Ryosuke Niwa.
+
+ For an empty input element, there is no RenderText. Instead, RenderBlock::localCaretRect provides
+ the caret position for rendering the caret in the empty input element. To get correct caret rect,
+ textIndentOffset() should be used to adjust the caret's position.
+
+ * editing/style/text-indent-expected.txt: Added.
+ * editing/style/text-indent.html: Added.
+
2012-04-17 Vincent Scheib <sch...@chromium.org>
[Chromium] Mark test failing IMAGE: svg/transforms/transform-origin-css-property.xhtml
Added: trunk/LayoutTests/editing/style/text-indent-expected.txt (0 => 114461)
--- trunk/LayoutTests/editing/style/text-indent-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/style/text-indent-expected.txt 2012-04-17 23:10:21 UTC (rev 114461)
@@ -0,0 +1,9 @@
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions of empty&nonempty input field were the same.
+Success. The caret's x positions was set to desired position when the text-align is center.
+Success. The caret's x positions was set to desired position when the text-align is center.
+
Added: trunk/LayoutTests/editing/style/text-indent.html (0 => 114461)
--- trunk/LayoutTests/editing/style/text-indent.html (rev 0)
+++ trunk/LayoutTests/editing/style/text-indent.html 2012-04-17 23:10:21 UTC (rev 114461)
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+</body>
+<script>
+function testTextIndent(testContent, characterIndex)
+{
+ document.body.innerHTML = testContent;
+ var editor = document.getElementById('textIndentTest');
+ editor.focus();
+
+ var caretRect = textInputController.firstRectForCharacterRange(0, 0);
+ var caretXPosition_withoutTextRender = caretRect[0];
+
+ editor.setSelectionRange(0, 0);
+ document.execCommand('InsertText', false, 'a');
+
+ caretRect = textInputController.firstRectForCharacterRange(characterIndex, 0);
+ var caretXPosition_withTextRender = caretRect[0];
+
+ if (caretXPosition_withoutTextRender == caretXPosition_withTextRender)
+ return "Success. The caret's x positions of empty&nonempty input field were the same.\n";
+ else
+ return "Failure. The caret's x position of empty input field was " + caretXPosition_withoutTextRender + ", should have been " + caretXPosition_withTextRender + ".\n";
+}
+
+function testTextIndentWhenTextAlignsToCenter(textIndent)
+{
+ document.body.innerHTML = "<input id='textIndentTest' type='text' style='text-align:center;'>";
+ var editor = document.getElementById('textIndentTest');
+ editor.focus();
+
+ var caretRect = textInputController.firstRectForCharacterRange(0, 0);
+ var caretXPosition_withoutTextIndent = caretRect[0];
+
+ editor.blur();
+ editor.style.textIndent = textIndent + "px";
+ editor.focus();
+
+ caretRect = textInputController.firstRectForCharacterRange(0, 0);
+ var caretXPosition_withTextIndent = caretRect[0];
+
+ var desiredCaretXPosition = caretXPosition_withoutTextIndent + textIndent / 2;
+ if (desiredCaretXPosition == caretXPosition_withTextIndent)
+ return "Success. The caret's x positions was set to desired position when the text-align is center.\n";
+ else
+ return "Failure. The caret's x position of input field was " + caretXPosition_withTextIndent + ", should have been " + desiredCaretXPosition + ".\n";
+}
+
+if (window.layoutTestController)
+ window.layoutTestController.dumpAsText();
+
+var output = "";
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;'></input>", 0);
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:-30px;'>", 0);
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:left'>", 0);
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;text-align:right'>", 1);
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;'>", 0);
+output += testTextIndent("<input id='textIndentTest' type='text' style='text-indent:30px;direction:rtl;text-align:right;'>", 0);
+output += testTextIndentWhenTextAlignsToCenter(30);
+output += testTextIndentWhenTextAlignsToCenter(-30);
+document.body.innerText = output;
+</script>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (114460 => 114461)
--- trunk/Source/WebCore/ChangeLog 2012-04-17 23:08:05 UTC (rev 114460)
+++ trunk/Source/WebCore/ChangeLog 2012-04-17 23:10:21 UTC (rev 114461)
@@ -1,3 +1,19 @@
+2012-04-17 Yi Shen <yi.4.s...@nokia.com>
+
+ Caret is not rendered properly inside an input element with text-indent
+ https://bugs.webkit.org/show_bug.cgi?id=82688
+
+ Reviewed by Ryosuke Niwa.
+
+ For an empty input element, there is no RenderText. Instead, RenderBlock::localCaretRect provides
+ the caret position for rendering the caret in the empty input element. To get correct caret rect,
+ textIndentOffset() should be used to adjust the caret's position.
+
+ Test: editing/style/text-indent.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::localCaretRect):
+
2012-04-17 Filip Pizlo <fpi...@apple.com>
It should be possible to create an inheritorID for the global this object without crashing
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (114460 => 114461)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-04-17 23:08:05 UTC (rev 114460)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-04-17 23:10:21 UTC (rev 114461)
@@ -6482,14 +6482,23 @@
switch (alignment) {
case alignLeft:
+ if (currentStyle->isLeftToRightDirection())
+ x += textIndentOffset();
break;
case alignCenter:
x = (x + w - (borderRight() + paddingRight())) / 2;
+ if (currentStyle->isLeftToRightDirection())
+ x += textIndentOffset() / 2;
+ else
+ x -= textIndentOffset() / 2;
break;
case alignRight:
x = w - (borderRight() + paddingRight()) - caretWidth;
+ if (!currentStyle->isLeftToRightDirection())
+ x -= textIndentOffset();
break;
}
+ x = min(x, w - borderRight() - paddingRight() - caretWidth);
if (extraWidthToEndOfLine) {
if (isRenderBlock()) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes