Title: [151855] trunk
Revision
151855
Author
[email protected]
Date
2013-06-21 14:04:21 -0700 (Fri, 21 Jun 2013)

Log Message

Ignoring padding-right of inline elements in containers with undefined width
https://bugs.webkit.org/show_bug.cgi?id=76451

Reviewed by David Hyatt.

Source/WebCore:

Collapsed trailing space on a normal wrap line should not cause a line-break
if it is the difference between fitting on the line and breaking. Likewise, on a line that
has a mix of auto-wrap and no-wrap inlines we don't want a trailing space at the end of a no-wrap inline
to be the difference between that no-wrap inline fitting or breaking the line. This latter
scenario is covered already by inline-whitespace-wrapping-8.html.

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

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

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (151854 => 151855)


--- trunk/LayoutTests/ChangeLog	2013-06-21 20:57:26 UTC (rev 151854)
+++ trunk/LayoutTests/ChangeLog	2013-06-21 21:04:21 UTC (rev 151855)
@@ -1,3 +1,13 @@
+2013-06-21  Robert Hogan  <[email protected]>
+
+        Ignoring padding-right of inline elements in containers with undefined width
+        https://bugs.webkit.org/show_bug.cgi?id=76451
+
+        Reviewed by David Hyatt.
+
+        * fast/text/whitespace/inline-whitespace-wrapping-9-expected.html: Added.
+        * fast/text/whitespace/inline-whitespace-wrapping-9.html: Added.
+
 2013-06-21  James Craig  <[email protected]>
 
         AX: audio/video playback control timers (elapsed and remaining) should be exposed as ApplicationTimerRole

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


--- trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-9-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-9-expected.html	2013-06-21 21:04:21 UTC (rev 151855)
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+<head>
+    <style>
+    body {padding: 0; margin: 0; height: 100%;}
+    #cont {position: absolute;}
+    #outer {background-color: blue; padding-right: 20px}
+    </style>
+</head>
+<body>
+    <p>webkit.org/b/76451: Don't allow collapsed trailing space to force a line break and thus ignore padding after 'Text' in the 'inside' span.</p>
+    <div id="cont">
+        <span id="outer"><span id="inside">Text</span></span>
+    </div>
+</body>
+</html>

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


--- trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-9.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/whitespace/inline-whitespace-wrapping-9.html	2013-06-21 21:04:21 UTC (rev 151855)
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+<head>
+    <style>
+    body {padding: 0; margin: 0; height: 100%;}
+    #cont {position: absolute;}
+    #outer {background-color: blue; padding-right: 20px}
+    </style>
+</head>
+<body>
+    <p>webkit.org/b/76451: Don't allow collapsed trailing space to force a line break and thus ignore padding after 'Text' in the 'inside' span.</p>
+    <div id="cont">
+        <span id="outer">
+            <span id="inside">Text</span>
+        </span>
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (151854 => 151855)


--- trunk/Source/WebCore/ChangeLog	2013-06-21 20:57:26 UTC (rev 151854)
+++ trunk/Source/WebCore/ChangeLog	2013-06-21 21:04:21 UTC (rev 151855)
@@ -1,3 +1,26 @@
+2013-06-21  Robert Hogan  <[email protected]>
+
+        Ignoring padding-right of inline elements in containers with undefined width
+        https://bugs.webkit.org/show_bug.cgi?id=76451
+
+        Reviewed by David Hyatt.
+
+        Collapsed trailing space on a normal wrap line should not cause a line-break 
+        if it is the difference between fitting on the line and breaking. Likewise, on a line that
+        has a mix of auto-wrap and no-wrap inlines we don't want a trailing space at the end of a no-wrap inline
+        to be the difference between that no-wrap inline fitting or breaking the line. This latter
+        scenario is covered already by inline-whitespace-wrapping-8.html.
+
+        Test: fast/text/whitespace/inline-whitespace-wrapping-9.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::LineWidth::fitsOnLine):
+        (WebCore::LineWidth::fitsOnLineIncludingExtraWidth):
+        (WebCore::LineWidth::fitsOnLineExcludingTrailingWhitespace):
+        (WebCore::LineWidth::currentWidth):
+        (WebCore::LineWidth::fitsOnLineExcludingTrailingCollapsedWhitespace):
+        (WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
+
 2013-06-21  Alex Christensen  <[email protected]>
 
         Added WebGL source files to Windows build and made Windows build successfully with them.

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (151854 => 151855)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-21 20:57:26 UTC (rev 151854)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-21 21:04:21 UTC (rev 151855)
@@ -120,11 +120,14 @@
 #endif
         updateAvailableWidth();
     }
-    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; }
+    bool fitsOnLine(bool ignoringTrailingSpace = false)
+    {
+        return ignoringTrailingSpace ? fitsOnLineExcludingTrailingCollapsedWhitespace() : fitsOnLineIncludingExtraWidth(0);
+    }
+    bool fitsOnLineIncludingExtraWidth(float extra) const { return currentWidth() + extra <= m_availableWidth; }
+    bool fitsOnLineExcludingTrailingWhitespace(float extra) const { return currentWidth() - m_trailingWhitespaceWidth + 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; }
@@ -149,6 +152,7 @@
     {
         m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth;
     }
+    bool fitsOnLineExcludingTrailingCollapsedWhitespace() const { return currentWidth() - m_trailingCollapsedWhitespaceWidth <= m_availableWidth; }
 
 private:
     RenderBlock* m_block;
@@ -3241,7 +3245,7 @@
                             // If the line needs the extra whitespace to be too long,
                             // then move the line break to the space and skip all
                             // additional whitespace.
-                            if (!width.fitsOnLine(charWidth)) {
+                            if (!width.fitsOnLineIncludingExtraWidth(charWidth)) {
                                 lineWasTooWide = true;
                                 lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
                                 skipTrailingWhitespace(lBreak, lineInfo);
@@ -3405,7 +3409,7 @@
             ASSERT_NOT_REACHED();
 
         bool checkForBreak = autoWrap;
-        if (width.committedWidth() && !width.fitsOnLineExcludingTrailingCollapsedWhitespace() && lBreak.m_obj && currWS == NOWRAP)
+        if (width.committedWidth() && !width.fitsOnLine(currentCharacterIsSpace) && 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)
@@ -3431,7 +3435,7 @@
             }
         }
 
-        if (checkForBreak && !width.fitsOnLine()) {
+        if (checkForBreak && !width.fitsOnLine(ignoringSpaces)) {
             // if we have floats, try to get below them.
             if (currentCharacterIsSpace && !ignoringSpaces && currentStyle->collapseWhiteSpace())
                 trailingObjects.clear();
@@ -3444,7 +3448,7 @@
             // |width| may have been adjusted because we got shoved down past a float (thus
             // giving us more room), so we need to retest, and only jump to
             // the end label if we still don't fit on the line. -dwh
-            if (!width.fitsOnLine())
+            if (!width.fitsOnLine(ignoringSpaces))
                 goto end;
         } else if (blockStyle->autoWrap() && !width.fitsOnLine() && !width.committedWidth()) {
             // If the container autowraps but the current child does not then we still need to ensure that it
@@ -3469,7 +3473,7 @@
         atStart = false;
     }
 
-    if (width.fitsOnLineExcludingTrailingCollapsedWhitespace() || lastWS == NOWRAP)
+    if (width.fitsOnLine(true) || lastWS == NOWRAP)
         lBreak.clear();
 
  end:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to