Changeset 191195 in webkit


Ignore:
Timestamp:
Oct 16, 2015 12:53:04 PM (9 years ago)
Author:
Alan Bujtas
Message:

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.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191192 r191195  
     12015-10-16  Zalan Bujtas  <zalan@apple.com>
     2
     3        First line box in paragraph using initial-letter overflows.
     4        https://bugs.webkit.org/show_bug.cgi?id=147977
     5        <rdar://problem/22901553>
     6
     7        Reviewed by David Hyatt.
     8
     9        When initial-letter float is present, we should shrink the first
     10        line even if it's not intersected with the block's current height.
     11        This is because of the sunken behaviour of initial-letter.
     12
     13        * fast/css-generated-content/initial-letter-first-line-wrapping-expected.html: Added.
     14        * fast/css-generated-content/initial-letter-first-line-wrapping.html: Added.
     15        * platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt: progression.
     16
    1172015-10-16  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    218
  • trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-basic-expected.txt

    r177774 r191195  
    88          RenderText {#text} at (0,-17) size 51x82
    99            text run at (0,-17) width 51: "A"
    10         RenderText {#text} at (54,0) size 454x90
    11           text run at (54,0) width 400: "n example of first-letter. This letter should span 3 lines of text,"
    12           text run at (54,18) width 312: "and so it should align itself cleanly with the cap-"
    13           text run at (54,36) width 326: "height of the A lining up with the cap-height of the"
    14           text run at (0,54) width 394: "first line, and the baseline of the A lining up with the baseline"
    15           text run at (0,72) width 104: "of the third line."
     10        RenderText {#text} at (54,0) size 394x90
     11          text run at (54,0) width 316: "n example of first-letter. This letter should span 3"
     12          text run at (54,18) width 340: "lines of text, and so it should align itself cleanly with"
     13          text run at (54,36) width 337: "the cap-height of the A lining up with the cap-height"
     14          text run at (0,54) width 378: "of the first line, and the baseline of the A lining up with the"
     15          text run at (0,72) width 160: "baseline of the third line."
    1616      RenderBlock {SPAN} at (0,106) size 784x90
    1717        RenderBlock {DIV} at (368,0) size 400x90
     
    1919            RenderText {#text} at (0,-17) size 51x82
    2020              text run at (0,-17) width 51: "A"
    21           RenderText {#text} at (-53,0) size 454x90
    22             text run at (-53,0) width 399: "n RTL example of first-letter. This letter should span 3 lines of"
    23             text run at (2,18) width 344: "text, and so it should align itself cleanly with the cap-"
    24             text run at (20,36) width 326: "height of the A lining up with the cap-height of the"
    25             text run at (6,54) width 394: "first line, and the baseline of the A lining up with the baseline"
    26             text run at (296,72) width 5 RTL: "."
    27             text run at (300,72) width 100: "of the third line"
     21          RenderText {#text} at (9,0) size 399x90
     22            text run at (9,0) width 337: "n RTL example of first-letter. This letter should span"
     23            text run at (26,18) width 320: "3 lines of text, and so it should align itself cleanly"
     24            text run at (17,36) width 329: "with the cap-height of the A lining up with the cap-"
     25            text run at (1,54) width 399: "height of the first line, and the baseline of the A lining up with"
     26            text run at (216,72) width 5 RTL: "."
     27            text run at (220,72) width 180: "the baseline of the third line"
  • trunk/Source/WebCore/ChangeLog

    r191188 r191195  
     12015-10-16  Zalan Bujtas  <zalan@apple.com>
     2
     3        First line box in paragraph using initial-letter overflows.
     4        https://bugs.webkit.org/show_bug.cgi?id=147977
     5        <rdar://problem/22901553>
     6
     7        Reviewed by David Hyatt.
     8
     9        When initial-letter float is present, we should shrink the first
     10        line even if it's not intersected with the block's current height.
     11        This is because of the sunken behaviour of initial-letter.
     12
     13        Test: fast/css-generated-content/initial-letter-first-line-wrapping.html
     14
     15        * rendering/RenderBlockFlow.h:
     16        * rendering/RenderBlockLineLayout.cpp:
     17        (WebCore::RenderBlockFlow::positionNewFloatOnLine):
     18        * rendering/line/BreakingContext.h:
     19        (WebCore::BreakingContext::handleFloat):
     20        * rendering/line/LineBreaker.cpp:
     21        (WebCore::LineBreaker::skipLeadingWhitespace):
     22        * rendering/line/LineBreaker.h:
     23        (WebCore::LineBreaker::positionNewFloatOnLine):
     24        * rendering/line/LineWidth.cpp:
     25        (WebCore::newFloatShrinksLine):
     26        (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
     27        * rendering/line/LineWidth.h:
     28
    1292015-10-16  Keith Rollin  <krollin@apple.com>
    230
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r189817 r191195  
    583583    // Positions new floats and also adjust all floats encountered on the line if any of them
    584584    // have to move to the next page/column.
    585     bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
     585    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
    586586    // 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
    587587    // region/page/column that has a different available line width than the old one. Used to know when you have to dirty a
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r191014 r191195  
    20602060}
    20612061
    2062 bool RenderBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
     2062bool RenderBlockFlow::positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
    20632063{
    20642064    if (!positionNewFloats())
     
    20702070    // the line and the previous line had a hard break (so this line is either the first in the block
    20712071    // or follows a <br>).
    2072     if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
     2072    if (!newFloat.paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
    20732073        return true;
    20742074
    20752075    const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
    2076     ASSERT(floatingObjectSet.last().get() == newFloat);
    2077 
    2078     LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat);
    2079     LayoutUnit paginationStrut = newFloat->paginationStrut();
     2076    ASSERT(floatingObjectSet.last().get() == &newFloat);
     2077
     2078    LayoutUnit floatLogicalTop = logicalTopForFloat(&newFloat);
     2079    LayoutUnit paginationStrut = newFloat.paginationStrut();
    20802080
    20812081    if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPaginationStrut())
  • trunk/Source/WebCore/rendering/line/BreakingContext.h

    r191014 r191195  
    450450    // it after moving to next line (in clearFloats() func)
    451451    if (m_floatsFitOnLine && m_width.fitsOnLineExcludingTrailingWhitespace(m_block.logicalWidthForFloat(floatingObject))) {
    452         m_lineBreaker.positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousLine, m_lineInfo, m_width);
     452        m_lineBreaker.positionNewFloatOnLine(*floatingObject, m_lastFloatFromPreviousLine, m_lineInfo, m_width);
    453453        if (m_lineBreakHistory.renderer() == m_current.renderer()) {
    454454            ASSERT(!m_lineBreakHistory.offset());
  • trunk/Source/WebCore/rendering/line/LineBreaker.cpp

    r189817 r191195  
    6767            }
    6868        } else if (object.isFloating())
    69             m_block.positionNewFloatOnLine(m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
     69            m_block.positionNewFloatOnLine(*m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
    7070        else if (object.style().hasTextCombine() && is<RenderCombineText>(object)) {
    7171            downcast<RenderCombineText>(object).combineText();
  • trunk/Source/WebCore/rendering/line/LineBreaker.h

    r189817 r191195  
    6666
    6767    FloatingObject* insertFloatingObject(RenderBox& floatBox) { return m_block.insertFloatingObject(floatBox); }
    68     bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
     68    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
    6969    {
    7070        return m_block.positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width);
  • trunk/Source/WebCore/rendering/line/LineWidth.cpp

    r189540 r191195  
    7777}
    7878
    79 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat)
    80 {
    81     LayoutUnit height = m_block.logicalHeight();
    82     if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logicalBottomForFloat(newFloat))
     79static bool newFloatShrinksLine(const FloatingObject& newFloat, const RenderBlockFlow& block, bool isFirstLine)
     80{
     81    LayoutUnit blockOffset = block.logicalHeight();
     82    if (blockOffset >= block.logicalTopForFloat(&newFloat) && blockOffset < block.logicalBottomForFloat(&newFloat))
     83        return true;
     84
     85    // initial-letter float always shrinks the first line.
     86    const auto& style = newFloat.renderer().style();
     87    if (isFirstLine && style.styleType() == FIRST_LETTER && !style.initialLetter().isEmpty())
     88        return true;
     89    return false;
     90}
     91
     92void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject& newFloat)
     93{
     94    if (!newFloatShrinksLine(newFloat, m_block, m_isFirstLine))
    8395        return;
    84 
    8596#if ENABLE(CSS_SHAPES)
    8697    ShapeOutsideDeltas shapeDeltas;
    87     if (ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer().shapeOutsideInfo()) {
     98    if (ShapeOutsideInfo* shapeOutsideInfo = newFloat.renderer().shapeOutsideInfo()) {
    8899        LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
    89         shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_block, *newFloat, m_block.logicalHeight(), lineHeight);
    90     }
    91 #endif
    92 
    93     if (newFloat->type() == FloatingObject::FloatLeft) {
    94         float newLeft = m_block.logicalRightForFloat(newFloat);
     100        shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_block, newFloat, m_block.logicalHeight(), lineHeight);
     101    }
     102#endif
     103
     104    if (newFloat.type() == FloatingObject::FloatLeft) {
     105        float newLeft = m_block.logicalRightForFloat(&newFloat);
    95106        if (shouldIndentText() && m_block.style().isLeftToRightDirection())
    96107            newLeft += floorToInt(m_block.textIndentOffset());
     
    105116        m_left = std::max<float>(m_left, newLeft);
    106117    } else {
    107         float newRight = m_block.logicalLeftForFloat(newFloat);
     118        float newRight = m_block.logicalLeftForFloat(&newFloat);
    108119        if (shouldIndentText() && !m_block.style().isLeftToRightDirection())
    109120            newRight -= floorToInt(m_block.textIndentOffset());
  • trunk/Source/WebCore/rendering/line/LineWidth.h

    r189540 r191195  
    6363
    6464    void updateAvailableWidth(LayoutUnit minimumHeight = 0);
    65     void shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject*);
     65    void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&);
    6666    void addUncommittedWidth(float delta)
    6767    {
Note: See TracChangeset for help on using the changeset viewer.