Title: [191557] releases/WebKitGTK/webkit-2.10
Revision
191557
Author
[email protected]
Date
2015-10-26 00:28:25 -0700 (Mon, 26 Oct 2015)

Log Message

Merge r191195 - First line box in paragraph using initial-letter overflows.
https://bugs.webkit.org/show_bug.cgi?id=147977
<rdar://problem/22901553>

Reviewed by David Hyatt.

When initial-letter float is present, we should shrink the first
line even if it's not intersected with the block's current height.
This is because of the sunken behaviour of initial-letter.

Source/WebCore:

Test: fast/css-generated-content/initial-letter-first-line-wrapping.html

* rendering/RenderBlockFlow.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::positionNewFloatOnLine):
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleFloat):
* rendering/line/LineBreaker.cpp:
(WebCore::LineBreaker::skipLeadingWhitespace):
* rendering/line/LineBreaker.h:
(WebCore::LineBreaker::positionNewFloatOnLine):
* rendering/line/LineWidth.cpp:
(WebCore::newFloatShrinksLine):
(WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
* rendering/line/LineWidth.h:

LayoutTests:

* fast/css-generated-content/initial-letter-first-line-wrapping-expected.html: Added.
* fast/css-generated-content/initial-letter-first-line-wrapping.html: Added.
* platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt: progression.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-10-26 07:28:25 UTC (rev 191557)
@@ -1,3 +1,19 @@
+2015-10-16  Zalan Bujtas  <[email protected]>
+
+        First line box in paragraph using initial-letter overflows.
+        https://bugs.webkit.org/show_bug.cgi?id=147977
+        <rdar://problem/22901553>
+
+        Reviewed by David Hyatt.
+
+        When initial-letter float is present, we should shrink the first
+        line even if it's not intersected with the block's current height.
+        This is because of the sunken behaviour of initial-letter. 
+
+        * fast/css-generated-content/initial-letter-first-line-wrapping-expected.html: Added.
+        * fast/css-generated-content/initial-letter-first-line-wrapping.html: Added.
+        * platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt: progression.
+
 2015-10-15  Dean Jackson  <[email protected]>
 
         CSSKeyframesRule::appendRule is deprecated, but is actually the spec

Added: releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping-expected.html (0 => 191557)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping-expected.html	2015-10-26 07:28:25 UTC (rev 191557)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    body {
+        font-family: Ahem;
+    }
+
+    .container { 
+	    width: 200px; 
+	    border-right: 1px solid red;
+    }
+
+  .float {
+  	width: 80px;
+  	height: 80px;
+  	float: left;
+  }
+</style>
+</head>
+<body>
+<div class=container><div class=float></div>ext should wrap at the red border.</div>
+</body>
+</html>
\ No newline at end of file

Added: releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping.html (0 => 191557)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/fast/css-generated-content/initial-letter-first-line-wrapping.html	2015-10-26 07:28:25 UTC (rev 191557)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    body {
+        font-family: Ahem;
+    }
+
+    div { 
+	    width: 200px; 
+	    border-right: 1px solid red;
+    }
+
+    div::first-letter {
+        -webkit-initial-letter: 5;
+        color: white;
+    }
+</style>
+</head>
+<body>
+<div>Text should wrap at the red border.</div>
+</body>
+</html>
\ No newline at end of file

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt	2015-10-26 07:28:25 UTC (rev 191557)
@@ -7,21 +7,21 @@
         RenderBlock (floating) at (2,3) size 51x48
           RenderText {#text} at (0,-17) size 51x82
             text run at (0,-17) width 51: "A"
-        RenderText {#text} at (54,0) size 454x90
-          text run at (54,0) width 400: "n example of first-letter. This letter should span 3 lines of text,"
-          text run at (54,18) width 312: "and so it should align itself cleanly with the cap-"
-          text run at (54,36) width 326: "height of the A lining up with the cap-height of the"
-          text run at (0,54) width 394: "first line, and the baseline of the A lining up with the baseline"
-          text run at (0,72) width 104: "of the third line."
+        RenderText {#text} at (54,0) size 394x90
+          text run at (54,0) width 316: "n example of first-letter. This letter should span 3"
+          text run at (54,18) width 340: "lines of text, and so it should align itself cleanly with"
+          text run at (54,36) width 337: "the cap-height of the A lining up with the cap-height"
+          text run at (0,54) width 378: "of the first line, and the baseline of the A lining up with the"
+          text run at (0,72) width 160: "baseline of the third line."
       RenderBlock {SPAN} at (0,106) size 784x90
         RenderBlock {DIV} at (368,0) size 400x90
           RenderBlock (floating) at (347,3) size 51x48
             RenderText {#text} at (0,-17) size 51x82
               text run at (0,-17) width 51: "A"
-          RenderText {#text} at (-53,0) size 454x90
-            text run at (-53,0) width 399: "n RTL example of first-letter. This letter should span 3 lines of"
-            text run at (2,18) width 344: "text, and so it should align itself cleanly with the cap-"
-            text run at (20,36) width 326: "height of the A lining up with the cap-height of the"
-            text run at (6,54) width 394: "first line, and the baseline of the A lining up with the baseline"
-            text run at (296,72) width 5 RTL: "."
-            text run at (300,72) width 100: "of the third line"
+          RenderText {#text} at (9,0) size 399x90
+            text run at (9,0) width 337: "n RTL example of first-letter. This letter should span"
+            text run at (26,18) width 320: "3 lines of text, and so it should align itself cleanly"
+            text run at (17,36) width 329: "with the cap-height of the A lining up with the cap-"
+            text run at (1,54) width 399: "height of the first line, and the baseline of the A lining up with"
+            text run at (216,72) width 5 RTL: "."
+            text run at (220,72) width 180: "the baseline of the third line"

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-26 07:28:25 UTC (rev 191557)
@@ -1,3 +1,31 @@
+2015-10-16  Zalan Bujtas  <[email protected]>
+
+        First line box in paragraph using initial-letter overflows.
+        https://bugs.webkit.org/show_bug.cgi?id=147977
+        <rdar://problem/22901553>
+
+        Reviewed by David Hyatt.
+
+        When initial-letter float is present, we should shrink the first
+        line even if it's not intersected with the block's current height.
+        This is because of the sunken behaviour of initial-letter. 
+
+        Test: fast/css-generated-content/initial-letter-first-line-wrapping.html
+
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::positionNewFloatOnLine):
+        * rendering/line/BreakingContext.h:
+        (WebCore::BreakingContext::handleFloat):
+        * rendering/line/LineBreaker.cpp:
+        (WebCore::LineBreaker::skipLeadingWhitespace):
+        * rendering/line/LineBreaker.h:
+        (WebCore::LineBreaker::positionNewFloatOnLine):
+        * rendering/line/LineWidth.cpp:
+        (WebCore::newFloatShrinksLine):
+        (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
+        * rendering/line/LineWidth.h:
+
 2015-10-16  Carlos Garcia Campos  <[email protected]>
 
         [GStreamer] ASSERTION FAILED: !m_adoptionIsRequired in MediaSourceGStreamer::addSourceBuffer

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockFlow.h (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockFlow.h	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockFlow.h	2015-10-26 07:28:25 UTC (rev 191557)
@@ -580,7 +580,7 @@
     void checkLinesForTextOverflow();
     // Positions new floats and also adjust all floats encountered on the line if any of them
     // have to move to the next page/column.
-    bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
+    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
     // This function is called to test a line box that has moved in the block direction to see if it has ended up in a new
     // region/page/column that has a different available line width than the old one. Used to know when you have to dirty a
     // line, i.e., that it can't be re-used.

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockLineLayout.cpp (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-10-26 07:28:25 UTC (rev 191557)
@@ -2030,7 +2030,7 @@
     }
 }
 
-bool RenderBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
+bool RenderBlockFlow::positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
 {
     if (!positionNewFloats())
         return false;
@@ -2040,14 +2040,14 @@
     // We only connect floats to lines for pagination purposes if the floats occur at the start of
     // the line and the previous line had a hard break (so this line is either the first in the block
     // or follows a <br>).
-    if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
+    if (!newFloat.paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
         return true;
 
     const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
-    ASSERT(floatingObjectSet.last().get() == newFloat);
+    ASSERT(floatingObjectSet.last().get() == &newFloat);
 
-    LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat);
-    LayoutUnit paginationStrut = newFloat->paginationStrut();
+    LayoutUnit floatLogicalTop = logicalTopForFloat(&newFloat);
+    LayoutUnit paginationStrut = newFloat.paginationStrut();
 
     if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPaginationStrut())
         return true;

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/BreakingContext.h (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/BreakingContext.h	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/BreakingContext.h	2015-10-26 07:28:25 UTC (rev 191557)
@@ -444,7 +444,7 @@
     // If it does, position it now, otherwise, position
     // it after moving to next line (in clearFloats() func)
     if (m_floatsFitOnLine && m_width.fitsOnLineExcludingTrailingWhitespace(m_block.logicalWidthForFloat(floatingObject))) {
-        m_lineBreaker.positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousLine, m_lineInfo, m_width);
+        m_lineBreaker.positionNewFloatOnLine(*floatingObject, m_lastFloatFromPreviousLine, m_lineInfo, m_width);
         if (m_lineBreakHistory.renderer() == m_current.renderer()) {
             ASSERT(!m_lineBreakHistory.offset());
             m_lineBreakHistory.increment();

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.cpp (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.cpp	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.cpp	2015-10-26 07:28:25 UTC (rev 191557)
@@ -66,7 +66,7 @@
                 lineInfo.incrementRunsFromLeadingWhitespace();
             }
         } else if (object.isFloating())
-            m_block.positionNewFloatOnLine(m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
+            m_block.positionNewFloatOnLine(*m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
         else if (object.style().hasTextCombine() && is<RenderCombineText>(object)) {
             downcast<RenderCombineText>(object).combineText();
             if (downcast<RenderCombineText>(object).isCombined())

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.h (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.h	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineBreaker.h	2015-10-26 07:28:25 UTC (rev 191557)
@@ -65,7 +65,7 @@
     void skipLeadingWhitespace(InlineBidiResolver&, LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
 
     FloatingObject* insertFloatingObject(RenderBox& floatBox) { return m_block.insertFloatingObject(floatBox); }
-    bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
+    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
     {
         return m_block.positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width);
     }

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.cpp (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.cpp	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.cpp	2015-10-26 07:28:25 UTC (rev 191557)
@@ -76,22 +76,33 @@
     computeAvailableWidthFromLeftAndRight();
 }
 
-void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat)
+static bool newFloatShrinksLine(const FloatingObject& newFloat, const RenderBlockFlow& block, bool isFirstLine)
 {
-    LayoutUnit height = m_block.logicalHeight();
-    if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logicalBottomForFloat(newFloat))
+    LayoutUnit blockOffset = block.logicalHeight();
+    if (blockOffset >= block.logicalTopForFloat(&newFloat) && blockOffset < block.logicalBottomForFloat(&newFloat))
+        return true;
+
+    // initial-letter float always shrinks the first line.
+    const auto& style = newFloat.renderer().style();
+    if (isFirstLine && style.styleType() == FIRST_LETTER && !style.initialLetter().isEmpty())
+        return true;
+    return false;
+}
+
+void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject& newFloat)
+{
+    if (!newFloatShrinksLine(newFloat, m_block, m_isFirstLine))
         return;
-
 #if ENABLE(CSS_SHAPES)
     ShapeOutsideDeltas shapeDeltas;
-    if (ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer().shapeOutsideInfo()) {
+    if (ShapeOutsideInfo* shapeOutsideInfo = newFloat.renderer().shapeOutsideInfo()) {
         LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
-        shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_block, *newFloat, m_block.logicalHeight(), lineHeight);
+        shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_block, newFloat, m_block.logicalHeight(), lineHeight);
     }
 #endif
 
-    if (newFloat->type() == FloatingObject::FloatLeft) {
-        float newLeft = m_block.logicalRightForFloat(newFloat);
+    if (newFloat.type() == FloatingObject::FloatLeft) {
+        float newLeft = m_block.logicalRightForFloat(&newFloat);
         if (shouldIndentText() && m_block.style().isLeftToRightDirection())
             newLeft += floorToInt(m_block.textIndentOffset());
 #if ENABLE(CSS_SHAPES)
@@ -104,7 +115,7 @@
 #endif
         m_left = std::max<float>(m_left, newLeft);
     } else {
-        float newRight = m_block.logicalLeftForFloat(newFloat);
+        float newRight = m_block.logicalLeftForFloat(&newFloat);
         if (shouldIndentText() && !m_block.style().isLeftToRightDirection())
             newRight -= floorToInt(m_block.textIndentOffset());
 #if ENABLE(CSS_SHAPES)

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.h (191556 => 191557)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.h	2015-10-26 07:13:57 UTC (rev 191556)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/rendering/line/LineWidth.h	2015-10-26 07:28:25 UTC (rev 191557)
@@ -62,7 +62,7 @@
     bool hasCommitted() const { return m_committedWidth > 0 || m_hasCommittedReplaced; }
 
     void updateAvailableWidth(LayoutUnit minimumHeight = 0);
-    void shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject*);
+    void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&);
     void addUncommittedWidth(float delta)
     {
         m_uncommittedWidth += delta;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to