Title: [161404] trunk
Revision
161404
Author
[email protected]
Date
2014-01-06 21:40:47 -0800 (Mon, 06 Jan 2014)

Log Message

REGRESSION(r157851): trailing space inside an editable region could be erroneously collapsed
https://bugs.webkit.org/show_bug.cgi?id=126549

Reviewed by Sam Weinig.

Source/WebCore:

The regression was caused by erroneous use of m_currentCharacterIsSpace in place of m_currentCharacterIsWS.

See the following two lines before the refactoring:
http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp?rev=157850#L3074
http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp?rev=157850#L3198

I've also cross-checked other places where m_currentCharacterIsSpace and m_currentCharacterIsWS are used.

Test: editing/inserting/inserting-trailing-space-and-letter.html

* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::BreakingContext::handleText):

LayoutTests:

Added a regression test and reverted the erroneous rebaseline in r157851.

* editing/inserting/inserting-trailing-space-and-letter-expected.html: Added.
* editing/inserting/inserting-trailing-space-and-letter.html: Added.
* platform/mac/editing/selection/after-line-wrap-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161403 => 161404)


--- trunk/LayoutTests/ChangeLog	2014-01-07 05:24:37 UTC (rev 161403)
+++ trunk/LayoutTests/ChangeLog	2014-01-07 05:40:47 UTC (rev 161404)
@@ -1,3 +1,16 @@
+2014-01-06  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r157851): trailing space inside an editable region could be erroneously collapsed
+        https://bugs.webkit.org/show_bug.cgi?id=126549
+
+        Reviewed by Sam Weinig.
+
+        Added a regression test and reverted the erroneous rebaseline in r157851.
+
+        * editing/inserting/inserting-trailing-space-and-letter-expected.html: Added.
+        * editing/inserting/inserting-trailing-space-and-letter.html: Added.
+        * platform/mac/editing/selection/after-line-wrap-expected.txt:
+
 2014-01-06  Brent Fulgham  <[email protected]>
 
         [WebGL] Unreviewed build fix for Mountain Lion drivers.

Added: trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter-expected.html (0 => 161404)


--- trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter-expected.html	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter-expected.html	2014-01-07 05:40:47 UTC (rev 161404)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#editor {
+    width: 160px;
+    height: 100px;
+    font-family: Ahem;
+    font-size: 50px;
+    border: 1px solid black;
+}
+</style>
+</head>
+<body>
+<p>This tests inserting a character after the collapsed space at the end of a line.<br>
+There should be a space between the last two boxes below, and there should be two boxes on the first line and exactly one box on the second line.</p>
+<div id="editor" contenteditable>a b c</div>
+</body>
+</html>

Added: trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter.html (0 => 161404)


--- trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter.html	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/inserting-trailing-space-and-letter.html	2014-01-07 05:40:47 UTC (rev 161404)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#editor {
+    width: 160px;
+    height: 100px;
+    font-family: Ahem;
+    font-size: 50px;
+    border: 1px solid black;
+}
+</style>
+</head>
+<body>
+<p>This tests inserting a character after the collapsed space at the end of a line.<br>
+There should be a space between the last two boxes below, and there should be two boxes on the first line and exactly one box on the second line.</p>
+<div id="editor" contenteditable>a b</div>
+<script>
+
+var editor = document.getElementById('editor');
+editor.focus();
+getSelection().collapse(editor.firstChild, 3);
+
+document.execCommand('insertText', false, ' ');
+document.execCommand('insertText', false, 'c');
+
+editor.blur();
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/editing/selection/after-line-wrap-expected.txt (161403 => 161404)


--- trunk/LayoutTests/platform/mac/editing/selection/after-line-wrap-expected.txt	2014-01-07 05:24:37 UTC (rev 161403)
+++ trunk/LayoutTests/platform/mac/editing/selection/after-line-wrap-expected.txt	2014-01-07 05:40:47 UTC (rev 161404)
@@ -29,9 +29,9 @@
           text run at (0,18) width 285: "after a line wrap can be selected successfully."
       RenderBlock {P} at (0,104) size 784x0
       RenderBlock {DIV} at (16,104) size 752x38 [border: (1px solid #000000)]
-        RenderText {#text} at (1,1) size 749x18
+        RenderText {#text} at (1,1) size 750x18
           text run at (1,1) width 93: "don't select me"
-          text run at (94,1) width 656: "                                                                                                                                                                    "
+          text run at (94,1) width 657: "                                                                                                                                                                                                                                                                                                                                                             "
         RenderInline {I} at (0,0) size 150x18
           RenderText {#text} at (1,19) size 150x18
             text run at (1,19) width 150: "try to select just this text"

Modified: trunk/Source/WebCore/ChangeLog (161403 => 161404)


--- trunk/Source/WebCore/ChangeLog	2014-01-07 05:24:37 UTC (rev 161403)
+++ trunk/Source/WebCore/ChangeLog	2014-01-07 05:40:47 UTC (rev 161404)
@@ -1,3 +1,23 @@
+2014-01-06  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r157851): trailing space inside an editable region could be erroneously collapsed
+        https://bugs.webkit.org/show_bug.cgi?id=126549
+
+        Reviewed by Sam Weinig.
+
+        The regression was caused by erroneous use of m_currentCharacterIsSpace in place of m_currentCharacterIsWS.
+
+        See the following two lines before the refactoring:
+        http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp?rev=157850#L3074
+        http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp?rev=157850#L3198
+
+        I've also cross-checked other places where m_currentCharacterIsSpace and m_currentCharacterIsWS are used.
+
+        Test: editing/inserting/inserting-trailing-space-and-letter.html
+
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::BreakingContext::handleText):
+
 2014-01-06  Seokju Kwon  <[email protected]>
 
         Web Inspector: Remove canOverrideDeviceMetrics and setDeviceMetricsOverride from protocol

Modified: trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h (161403 => 161404)


--- trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2014-01-07 05:24:37 UTC (rev 161403)
+++ trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2014-01-07 05:40:47 UTC (rev 161404)
@@ -799,7 +799,7 @@
                 // If we break only after white-space, consider the current character
                 // as candidate width for this line.
                 bool lineWasTooWide = false;
-                if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_currentStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) {
+                if (m_width.fitsOnLine() && m_currentCharacterIsWS && m_currentStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) {
                     float charWidth = textWidth(renderText, m_current.offset(), 1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0);
                     // Check if line is too big even without the extra space
                     // at the end of the line. If it is not, do nothing.
@@ -927,7 +927,7 @@
             }
         }
 
-        if (!m_currentCharacterIsSpace && previousCharacterIsWS) {
+        if (!m_currentCharacterIsWS && previousCharacterIsWS) {
             if (m_autoWrap && m_currentStyle->breakOnlyAfterWhiteSpace())
                 m_lineBreak.moveTo(m_current.renderer(), m_current.offset(), m_current.nextBreakablePosition());
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to