Changeset 238400 in webkit


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

[LFC][IFC] Move detaching rules from InlineFormattingState to InlineItem
https://bugs.webkit.org/show_bug.cgi?id=191838

Reviewed by Antti Koivisto.

This is in preparation for adding more context to InlineItem. In addition to
detaching rules it will also hold non-breakable start/end information.

  • layout/inlineformatting/InlineFormattingContext.cpp:

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

  • layout/inlineformatting/InlineFormattingState.cpp:

(WebCore::Layout::InlineFormattingState::addDetachingRule): Deleted.
(WebCore::Layout::InlineFormattingState::detachingRules const): Deleted.

  • layout/inlineformatting/InlineFormattingState.h:

(WebCore::Layout::InlineFormattingState::setDetachingRules): Deleted.

  • layout/inlineformatting/InlineItem.h:

(WebCore::Layout::InlineItem::addDetachingRule):
(WebCore::Layout::InlineItem::detachingRules const):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238399 r238400  
     12018-11-20  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Move detaching rules from InlineFormattingState to InlineItem
     4        https://bugs.webkit.org/show_bug.cgi?id=191838
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for adding more context to InlineItem. In addition to
     9        detaching rules it will also hold non-breakable start/end information.
     10
     11        * layout/inlineformatting/InlineFormattingContext.cpp:
     12        (WebCore::Layout::InlineFormattingContext::splitInlineRunIfNeeded const):
     13        (WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
     14        * layout/inlineformatting/InlineFormattingState.cpp:
     15        (WebCore::Layout::InlineFormattingState::addDetachingRule): Deleted.
     16        (WebCore::Layout::InlineFormattingState::detachingRules const): Deleted.
     17        * layout/inlineformatting/InlineFormattingState.h:
     18        (WebCore::Layout::InlineFormattingState::setDetachingRules): Deleted.
     19        * layout/inlineformatting/InlineItem.h:
     20        (WebCore::Layout::InlineItem::addDetachingRule):
     21        (WebCore::Layout::InlineItem::detachingRules const):
     22
    1232018-11-20  Zalan Bujjtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp

    r238399 r238400  
    173173        // 3. Break at the end of the inline element -> commit what we've got so far including the current element.
    174174        // 4. Break before/after -> requires dedicated run -> commit what we've got so far and also commit the current inline element as a separate inline run.
    175         auto detachingRules = inlineFormattingState().detachingRules(inlineItem.layoutBox());
     175        auto detachingRules = inlineItem.detachingRules();
    176176
    177177        // #1
     
    195195
    196196        // #2
    197         if (detachingRules == InlineFormattingState::DetachingRule::BreakAtStart) {
     197        if (detachingRules == InlineItem::DetachingRule::BreakAtStart) {
    198198            commit();
    199199            firstUncommittedInlineItem = &inlineItem;
     
    203203
    204204        // #3
    205         if (detachingRules == InlineFormattingState::DetachingRule::BreakAtEnd) {
     205        if (detachingRules == InlineItem::DetachingRule::BreakAtEnd) {
    206206            ASSERT(firstUncommittedInlineItem);
    207207            uncommittedLength += currentLength();
     
    461461    if (root.establishesFormattingContext() && &root != &(this->root())) {
    462462        createAndAppendInlineItem();
     463        inlineFormattingState.inlineContent().last()->addDetachingRule({ InlineItem::DetachingRule::BreakAtStart, InlineItem::DetachingRule::BreakAtEnd });
    463464        // Skip formatting root subtree. They are not part of this inline formatting context.
    464         inlineFormattingState.setDetachingRules(root, { InlineFormattingState::DetachingRule::BreakAtStart, InlineFormattingState::DetachingRule::BreakAtEnd });
    465465        return;
    466466    }
     
    505505
    506506        ASSERT(firstDescendantInlineBox);
    507         inlineFormattingState.addDetachingRule(firstDescendantInlineBox->layoutBox(), InlineFormattingState::DetachingRule::BreakAtStart);
     507        firstDescendantInlineBox->addDetachingRule(InlineItem::DetachingRule::BreakAtStart);
    508508    }
    509509
    510510    if (rootBreaksAtEnd())
    511         inlineFormattingState.addDetachingRule(lastDescendantInlineBox->layoutBox(), InlineFormattingState::DetachingRule::BreakAtEnd);
     511        lastDescendantInlineBox->addDetachingRule(InlineItem::DetachingRule::BreakAtEnd);
    512512}
    513513
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp

    r238349 r238400  
    5151}
    5252
    53 void InlineFormattingState::addDetachingRule(const Box& layoutBox, DetachingRule detachingRule)
    54 {
    55     m_detachingRules.add(&layoutBox, DetachingRule { }).iterator->value.add(detachingRule);
    56 }
    57 
    58 OptionSet<InlineFormattingState::DetachingRule> InlineFormattingState::detachingRules(const Box& layoutBox) const
    59 {
    60     auto detachingRules = m_detachingRules.get(&layoutBox);
    61     if (!detachingRules)
    62         return { };
    63 
    64     return detachingRules;
    65 }
    66 
    6753}
    6854}
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h

    r238349 r238400  
    4949    InlineItem* lastInlineItem() const { return m_inlineContent.isEmpty() ? nullptr : m_inlineContent.last().get(); }
    5050
    51     // DetachingRule indicates whether the inline element needs to be wrapped in a dediceted run or break from previous/next runs.
    52     // <span>start</span><span style="position: relative;"> middle </span><span>end</span>
    53     // input to line breaking -> <start middle end>
    54     // output of line breaking (considering infinite constraint) -> <start middle end>
    55     // due to the in-flow positioning, the final runs are: <start>< middle ><end>
    56     // "start" -> n/a
    57     // " middle " -> BreakAtStart and BreakAtEnd
    58     // "end" -> n/a
    59     //
    60     // <span>parent </span><span style="padding: 10px;">start<span> middle </span>end</span><span> parent</span>
    61     // input to line breaking -> <parent start middle end parent>
    62     // output of line breaking (considering infinite constraint) -> <parent start middle end parent>
    63     // due to padding, final runs -> <parent><start middle end><parent>
    64     // "parent" -> n/a
    65     // "start" -> BreakAtStart
    66     // " middle " -> n/a
    67     // "end" -> BreakAtEnd
    68     // "parent" -> n/a
    69     enum class DetachingRule {
    70         BreakAtStart = 1 << 0,
    71         BreakAtEnd = 1 << 1
    72     };
    73     void addDetachingRule(const Box& layoutBox, DetachingRule);
    74 
    75     OptionSet<DetachingRule> detachingRules(const Box& layoutBox) const;
    76     void setDetachingRules(const Box& layoutBox, OptionSet<DetachingRule> detachingRules) { m_detachingRules.set(&layoutBox, detachingRules); }
    77 
    7851    // Temp
    7952    InlineRuns& inlineRuns() { return m_inlineRuns; }
     
    8154
    8255private:
    83     using DetachingRulesForInlineItems = HashMap<const Box*, OptionSet<DetachingRule>>;
    84 
    8556    InlineContent m_inlineContent;
    8657    InlineRuns m_inlineRuns;
    87     DetachingRulesForInlineItems m_detachingRules;
    8858};
    8959
  • trunk/Source/WebCore/layout/inlineformatting/InlineItem.h

    r237286 r238400  
    4444    const RenderStyle& style() const { return m_layoutBox.style(); }
    4545    String textContent() const;
     46    // DetachingRule indicates whether the inline element needs to be wrapped in a dediceted run or break from previous/next runs.
     47    // <span>start</span><span style="position: relative;"> middle </span><span>end</span>
     48    // input to line breaking -> <start middle end>
     49    // output of line breaking (considering infinite constraint) -> <start middle end>
     50    // due to the in-flow positioning, the final runs are: <start>< middle ><end>
     51    // "start" -> n/a
     52    // " middle " -> BreakAtStart and BreakAtEnd
     53    // "end" -> n/a
     54    //
     55    // <span>parent </span><span style="padding: 10px;">start<span> middle </span>end</span><span> parent</span>
     56    // input to line breaking -> <parent start middle end parent>
     57    // output of line breaking (considering infinite constraint) -> <parent start middle end parent>
     58    // due to padding, final runs -> <parent><start middle end><parent>
     59    // "parent" -> n/a
     60    // "start" -> BreakAtStart
     61    // " middle " -> n/a
     62    // "end" -> BreakAtEnd
     63    // "parent" -> n/a
     64    enum class DetachingRule {
     65        BreakAtStart = 1 << 0,
     66        BreakAtEnd = 1 << 1
     67    };
     68    void addDetachingRule(OptionSet<DetachingRule> detachingRule) { m_detachingRules.add(detachingRule); }
     69    OptionSet<DetachingRule> detachingRules() const { return m_detachingRules; }
    4670
    4771private:
    4872    const Box& m_layoutBox;
     73    OptionSet<DetachingRule> m_detachingRules;
    4974};
    5075
Note: See TracChangeset for help on using the changeset viewer.