Changeset 238401 in webkit


Ignore:
Timestamp:
Nov 20, 2018 7:52:28 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Introduce InlineItem::nonBreakableStart/End
https://bugs.webkit.org/show_bug.cgi?id=191839

Reviewed by Antti Koivisto.

Non-breakable start/end marks margin/padding/border space (even when it does not directly come from the associated layout box)

<span style="padding: 5px"><span>nested content with padding parent</span</span>
<nested content with padding parent> <- inline run has 5px non-breakable start/end.

<span style="border: 5px solid green"><span style="padding-right: 10px; margin-right: 1px">1</span>2</span><span> 3</span>
<1> <- inline run has 5px non-breakable start and 11px non-breakable end.
<2> <- inline run has 0px non-breakable start and 5px non-breakable end.
<3> <- no non-breakable values.

This is what the runs look like (input to line breaking)
< 1 2 >
< > (whitespace)
<3>
The line breaking treats the paddding/border etc space as part of the run and as non-breaking opportunity.
With the given runs the first position where we can break the line is at the whitespace.

  • layout/inlineformatting/InlineFormattingContext.cpp:

(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):

  • layout/inlineformatting/InlineItem.h:

(WebCore::Layout::InlineItem::nonBreakableStart const):
(WebCore::Layout::InlineItem::nonBreakableEnd const):
(WebCore::Layout::InlineItem::addNonBreakableStart):
(WebCore::Layout::InlineItem::addNonBreakableEnd):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238400 r238401  
     12018-11-20  Zalan Butjas  <zalan@apple.com>
     2
     3        [LFC][IFC] Introduce InlineItem::nonBreakableStart/End
     4        https://bugs.webkit.org/show_bug.cgi?id=191839
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Non-breakable start/end marks margin/padding/border space (even when it does not directly come from the associated layout box)
     9
     10        <span style="padding: 5px"><span>nested content with padding parent</span</span>
     11        <nested content with padding parent> <- inline run has 5px non-breakable start/end.
     12
     13        <span style="border: 5px solid green"><span style="padding-right: 10px; margin-right: 1px">1</span>2</span><span>    3</span>
     14        <1> <- inline run has 5px non-breakable start and 11px non-breakable end.
     15        <2> <- inline run has 0px non-breakable start and 5px non-breakable end.
     16        <3> <- no non-breakable values.
     17
     18        This is what the runs look like (input to line breaking)
     19        <     1           2     >
     20        < > (whitespace)
     21        <3>
     22        The line breaking treats the paddding/border etc space as part of the run and as non-breaking opportunity.
     23        With the given runs the first position where we can break the line is at the whitespace.
     24
     25        * layout/inlineformatting/InlineFormattingContext.cpp:
     26        (WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
     27        * layout/inlineformatting/InlineItem.h:
     28        (WebCore::Layout::InlineItem::nonBreakableStart const):
     29        (WebCore::Layout::InlineItem::nonBreakableEnd const):
     30        (WebCore::Layout::InlineItem::addNonBreakableStart):
     31        (WebCore::Layout::InlineItem::addNonBreakableEnd):
     32
    1332018-11-20  Zalan Bujtas  <zalan@apple.com>
    234
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp

    r238400 r238401  
    478478    }
    479479
     480    // FIXME: Revisit this when we figured out how inline boxes fit the display tree.
     481    auto padding = Geometry::computedPadding(layoutState(), root);
    480482    // Setup breaking boundaries for this subtree.
    481483    auto* lastDescendantInlineBox = inlineFormattingState.lastInlineItem();
     
    486488    auto rootBreaksAtStart = [&] {
    487489        // FIXME: add padding-inline-start, margin-inline-start etc.
     490        if (padding && padding->horizontal.left)
     491            return true;
    488492        return root.isPositioned();
    489493    };
     
    491495    auto rootBreaksAtEnd = [&] {
    492496        // FIXME: add padding-inline-end, margin-inline-end etc.
     497        if (padding && padding->horizontal.right)
     498            return true;
    493499        return root.isPositioned();
    494500    };
     
    506512        ASSERT(firstDescendantInlineBox);
    507513        firstDescendantInlineBox->addDetachingRule(InlineItem::DetachingRule::BreakAtStart);
    508     }
    509 
    510     if (rootBreaksAtEnd())
     514        if (padding && padding->horizontal.left)
     515            firstDescendantInlineBox->addNonBreakableStart(padding->horizontal.left);
     516    }
     517
     518    if (rootBreaksAtEnd()) {
    511519        lastDescendantInlineBox->addDetachingRule(InlineItem::DetachingRule::BreakAtEnd);
     520        if (padding && padding->horizontal.right)
     521            lastDescendantInlineBox->addNonBreakableEnd(padding->horizontal.right);
     522    }
    512523}
    513524
  • trunk/Source/WebCore/layout/inlineformatting/InlineItem.h

    r238400 r238401  
    6969    OptionSet<DetachingRule> detachingRules() const { return m_detachingRules; }
    7070
     71    // Non-breakable start/end marks margin/padding/border space (even when it does not directly come from the associated layout box)
     72    // <span style="padding: 5px"><span>nested content with padding parent</span</span>
     73    // <nested content with padding parent> inline run has 5px non-breakable start/end.
     74    LayoutUnit nonBreakableStart() const { return m_nonBreakableStart; }
     75    LayoutUnit nonBreakableEnd() const { return m_nonBreakableEnd; }
     76    void addNonBreakableStart(LayoutUnit value) { m_nonBreakableStart += value; }
     77    void addNonBreakableEnd(LayoutUnit value) { m_nonBreakableEnd += value; }
     78
    7179private:
    7280    const Box& m_layoutBox;
    7381    OptionSet<DetachingRule> m_detachingRules;
     82    LayoutUnit m_nonBreakableStart;
     83    LayoutUnit m_nonBreakableEnd;
    7484};
    7585
Note: See TracChangeset for help on using the changeset viewer.