Title: [151518] trunk
Revision
151518
Author
[email protected]
Date
2013-06-12 12:20:33 -0700 (Wed, 12 Jun 2013)

Log Message

Source/WebCore: Whitespace between inlines with nowrap and a shrink-to-fit parent gets a line-break when it shouldn't
https://bugs.webkit.org/show_bug.cgi?id=117370

Reviewed by David Hyatt.

Test: fast/text/whitespace/inline-whitespace-wrapping-8.html

A no-wrap inline shouldn't include trailing space when deciding whether it fits on a line.
Likewise when we finish iterating through the objects on a line we should clear our linebreak
if the only thing that prevents us fitting on the line is our collapsed trailing whitespace.

Removing the trailing space from this measurement means we need to watch out for potential
breaks between no-wrap inlines, in particular if we leave a no-wrap inline ignoring spaces
and enter an autowrap inline then we need to mark the beginning of the autowrap inline
as a potential linebreak. The test fast/text/whitespace/inline-whitespace-wrapping-5.html
is an example of such a case.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::LineWidth::LineWidth):
(WebCore::LineWidth::fitsOnLine):
(WebCore::LineWidth::fitsOnLineExcludingTrailingWhitespace):
(WebCore::LineWidth::fitsOnLineExcludingTrailingCollapsedWhitespace):
(WebCore::LineWidth::setTrailingWhitespaceWidth):
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):

LayoutTests: Whitespace between inlines with nowrap and a shrink-to-fit parent line-break incorrectly
https://bugs.webkit.org/show_bug.cgi?id=117370

Reviewed by David Hyatt.

* fast/text/whitespace/inline-whitespace-wrapping-8-expected.html: Added.
* fast/text/whitespace/inline-whitespace-wrapping-8.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (151517 => 151518)


--- trunk/LayoutTests/ChangeLog	2013-06-12 18:59:58 UTC (rev 151517)
+++ trunk/LayoutTests/ChangeLog	2013-06-12 19:20:33 UTC (rev 151518)
@@ -1,3 +1,13 @@
+2013-06-12  Robert Hogan  <[email protected]>
+
+        Whitespace between inlines with nowrap and a shrink-to-fit parent line-break incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=117370
+
+        Reviewed by David Hyatt.
+
+        * fast/text/whitespace/inline-whitespace-wrapping-8-expected.html: Added.
+        * fast/text/whitespace/inline-whitespace-wrapping-8.html: Added.
+
 2013-06-12  Bem Jones-Bey  <[email protected]>
 
         [CSS Shapes] rectangle and inset-rectangle do not properly handle rx and ry

Added: trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8-expected.html (0 => 151518)


--- trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8-expected.html	2013-06-12 19:20:33 UTC (rev 151518)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<style>
+    #container {
+        float: right;
+    }
+</style>
+</head>
+<body>
+<p> webkit.org/b/117370: Ignore trailing space when deciding whether text fits on a line.</p> 
+<div id="container">
+        <a href=""
+        <a href=""
+</div>
+</body>

Added: trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8.html (0 => 151518)


--- trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-8.html	2013-06-12 19:20:33 UTC (rev 151518)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<style>
+    #container {
+        float: right;
+    }
+    .link
+    {
+        white-space: nowrap;
+    }
+</style>
+</head>
+<body>
+<p> webkit.org/b/117370: Ignore trailing space when deciding whether text fits on a line.</p> 
+<div id="container">
+        <a href="" class="link">A</a>
+        <a href="" class="link">B </a></div>
+</div>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (151517 => 151518)


--- trunk/Source/WebCore/ChangeLog	2013-06-12 18:59:58 UTC (rev 151517)
+++ trunk/Source/WebCore/ChangeLog	2013-06-12 19:20:33 UTC (rev 151518)
@@ -1,3 +1,30 @@
+2013-06-12  Robert Hogan  <[email protected]>
+
+        Whitespace between inlines with nowrap and a shrink-to-fit parent gets a line-break when it shouldn't
+        https://bugs.webkit.org/show_bug.cgi?id=117370
+
+        Reviewed by David Hyatt.
+
+        Test: fast/text/whitespace/inline-whitespace-wrapping-8.html
+
+        A no-wrap inline shouldn't include trailing space when deciding whether it fits on a line. 
+        Likewise when we finish iterating through the objects on a line we should clear our linebreak
+        if the only thing that prevents us fitting on the line is our collapsed trailing whitespace.
+         
+        Removing the trailing space from this measurement means we need to watch out for potential
+        breaks between no-wrap inlines, in particular if we leave a no-wrap inline ignoring spaces
+        and enter an autowrap inline then we need to mark the beginning of the autowrap inline
+        as a potential linebreak. The test fast/text/whitespace/inline-whitespace-wrapping-5.html 
+        is an example of such a case.
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::LineWidth::LineWidth):
+        (WebCore::LineWidth::fitsOnLine):
+        (WebCore::LineWidth::fitsOnLineExcludingTrailingWhitespace):
+        (WebCore::LineWidth::fitsOnLineExcludingTrailingCollapsedWhitespace):
+        (WebCore::LineWidth::setTrailingWhitespaceWidth):
+        (WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
+
 2013-06-12  Bem Jones-Bey  <[email protected]>
 
         [CSS Shapes] rectangle and inset-rectangle do not properly handle rx and ry

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (151517 => 151518)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-12 18:59:58 UTC (rev 151517)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-12 19:20:33 UTC (rev 151518)
@@ -103,6 +103,7 @@
         , m_committedWidth(0)
         , m_overhangWidth(0)
         , m_trailingWhitespaceWidth(0)
+        , m_trailingCollapsedWhitespaceWidth(0)
         , m_left(0)
         , m_right(0)
         , m_availableWidth(0)
@@ -119,16 +120,15 @@
 #endif
         updateAvailableWidth();
     }
-    bool fitsOnLine() const { return currentWidth() <= m_availableWidth; }
-    bool fitsOnLine(float extra) const { return currentWidth() + extra <= m_availableWidth; }
-    bool fitsOnLine(float extra, bool excludeWhitespace) const { return currentWidth() - (excludeWhitespace ? trailingWhitespaceWidth() : 0) + extra <= m_availableWidth; }
+    bool fitsOnLine(float extra = 0) const { return currentWidth() + extra <= m_availableWidth; }
+    bool fitsOnLineExcludingTrailingWhitespace(float extra = 0) const { return currentWidth() - m_trailingWhitespaceWidth + extra <= m_availableWidth; }
+    bool fitsOnLineExcludingTrailingCollapsedWhitespace(float extra = 0) const { return currentWidth() - m_trailingCollapsedWhitespaceWidth + extra <= m_availableWidth; }
     float currentWidth() const { return m_committedWidth + m_uncommittedWidth; }
 
     // FIXME: We should eventually replace these three functions by ones that work on a higher abstraction.
     float uncommittedWidth() const { return m_uncommittedWidth; }
     float committedWidth() const { return m_committedWidth; }
     float availableWidth() const { return m_availableWidth; }
-    float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; }
 
     void updateAvailableWidth(LayoutUnit minimumHeight = 0);
     void shrinkAvailableWidthForNewFloatIfNeeded(RenderBlock::FloatingObject*);
@@ -140,7 +140,7 @@
     }
     void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer);
     void fitBelowFloats();
-    void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = width; }
+    void setTrailingWhitespaceWidth(float collapsedWhitespace, float borderPaddingMargin = 0) { m_trailingCollapsedWhitespaceWidth = collapsedWhitespace; m_trailingWhitespaceWidth =  collapsedWhitespace + borderPaddingMargin; }
 
     bool shouldIndentText() const { return m_shouldIndentText == IndentText; }
 
@@ -156,6 +156,7 @@
     float m_committedWidth;
     float m_overhangWidth; // The amount by which |m_availableWidth| has been inflated to account for possible contraction due to ruby overhang.
     float m_trailingWhitespaceWidth;
+    float m_trailingCollapsedWhitespaceWidth;
     float m_left;
     float m_right;
     float m_availableWidth;
@@ -2930,7 +2931,7 @@
             // If it does, position it now, otherwise, position
             // it after moving to next line (in newLine() func)
             // FIXME: Bug 110372: Properly position multiple stacked floats with non-rectangular shape outside.
-            if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloat(f), true)) {
+            if (floatsFitOnLine && width.fitsOnLineExcludingTrailingWhitespace(m_block->logicalWidthForFloat(f))) {
                 m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, lineInfo, width);
                 if (lBreak.m_obj == current.m_obj) {
                     ASSERT(!lBreak.m_pos);
@@ -3022,6 +3023,13 @@
             bool isSVGText = t->isSVGInlineText();
 #endif
 
+            // If we have left a no-wrap inline and entered an autowrap inline while ignoring spaces
+            // then we need to mark the start of the autowrap inline as a potential linebreak now. 
+            if (autoWrap && !RenderStyle::autoWrap(lastWS) && ignoringSpaces) {
+                width.commit();
+                lBreak.moveToStartOf(current.m_obj);
+            }
+
             if (t->style()->hasTextCombine() && current.m_obj->isCombineText() && !toRenderCombineText(current.m_obj)->isCombined()) {
                 RenderCombineText* combineRenderer = toRenderCombineText(current.m_obj);
                 combineRenderer->combineText();
@@ -3322,7 +3330,7 @@
             fallbackFonts.clear();
 
             if (collapseWhiteSpace && currentCharacterIsSpace && additionalTempWidth)
-                width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTempWidth);
+                width.setTrailingWhitespaceWidth(additionalTempWidth, inlineLogicalTempWidth);
 
             includeEndWidth = false;
 
@@ -3340,7 +3348,7 @@
             ASSERT_NOT_REACHED();
 
         bool checkForBreak = autoWrap;
-        if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && currWS == NOWRAP)
+        if (width.committedWidth() && !width.fitsOnLineExcludingTrailingCollapsedWhitespace() && lBreak.m_obj && currWS == NOWRAP)
             checkForBreak = true;
         else if (next && current.m_obj->isText() && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap())) {
             if (autoWrap && currentCharacterIsSpace)
@@ -3404,7 +3412,7 @@
         atStart = false;
     }
 
-    if (width.fitsOnLine() || lastWS == NOWRAP)
+    if (width.fitsOnLineExcludingTrailingCollapsedWhitespace() || lastWS == NOWRAP)
         lBreak.clear();
 
  end:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to