Changeset 252816 in webkit


Ignore:
Timestamp:
Nov 22, 2019 4:38:04 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Text content is not exactly rare data.
https://bugs.webkit.org/show_bug.cgi?id=204539
<rdar://problem/57442263>

Reviewed by Antti Koivisto.

If it turns out to be a memory consumption issue, we can always subclass Layout::Box. Let's go with the m_textContext member for now.

  • layout/inlineformatting/InlineLine.cpp:

(WebCore::Layout::ContinousContent::close):
(WebCore::Layout::Line::appendTextContent):

  • layout/inlineformatting/InlineTextItem.cpp:

(WebCore::Layout::InlineTextItem::createAndAppendTextItems):

  • layout/inlineformatting/text/TextUtil.cpp:

(WebCore::Layout::TextUtil::width):

  • layout/layouttree/LayoutBox.cpp:

(WebCore::Layout::Box::setTextContext): Deleted.
(WebCore::Layout::Box::hasTextContent const): Deleted.
(WebCore::Layout::Box::textContext const): Deleted.

  • layout/layouttree/LayoutBox.h:

(WebCore::Layout::Box::hasTextContent const):
(WebCore::Layout::Box::textContext const):

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::outputLayoutBox):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252813 r252816  
     12019-11-22  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Text content is not exactly rare data.
     4        https://bugs.webkit.org/show_bug.cgi?id=204539
     5        <rdar://problem/57442263>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        If it turns out to be a memory consumption issue, we can always subclass Layout::Box. Let's go with the m_textContext member for now.
     10
     11        * layout/inlineformatting/InlineLine.cpp:
     12        (WebCore::Layout::ContinousContent::close):
     13        (WebCore::Layout::Line::appendTextContent):
     14        * layout/inlineformatting/InlineTextItem.cpp:
     15        (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
     16        * layout/inlineformatting/text/TextUtil.cpp:
     17        (WebCore::Layout::TextUtil::width):
     18        * layout/layouttree/LayoutBox.cpp:
     19        (WebCore::Layout::Box::setTextContext): Deleted.
     20        (WebCore::Layout::Box::hasTextContent const): Deleted.
     21        (WebCore::Layout::Box::textContext const): Deleted.
     22        * layout/layouttree/LayoutBox.h:
     23        (WebCore::Layout::Box::hasTextContent const):
     24        (WebCore::Layout::Box::textContext const):
     25        * layout/layouttree/LayoutTreeBuilder.cpp:
     26        (WebCore::Layout::outputLayoutBox):
     27
    1282019-11-22  Chris Dumez  <cdumez@apple.com>
    229
  • trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp

    r252807 r252816  
    146146    auto textContext = *m_initialInlineRun.textContext();
    147147    auto length = textContext.length() + m_expandedLength;
    148     textContext.expand(m_initialInlineRun.layoutBox().textContext().content.substring(textContext.start(), length), length);
     148    textContext.expand(m_initialInlineRun.layoutBox().textContext()->content.substring(textContext.start(), length), length);
    149149
    150150    if (m_textIsAlignJustify) {
     
    566566    auto contentStart = inlineItem.start();
    567567    auto contentLength =  collapsedRun ? 1 : inlineItem.length();
    568     auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext().content.substring(contentStart, contentLength) });
     568    auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext()->content.substring(contentStart, contentLength) });
    569569
    570570    auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
  • trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp

    r252696 r252816  
    8383void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const Box& inlineBox)
    8484{
    85     auto text = inlineBox.textContext().content;
     85    auto text = inlineBox.textContext()->content;
    8686    if (!text.length())
    8787        return inlineContent.append(InlineTextItem::createEmptyItem(inlineBox));
     
    9292
    9393    auto inlineItemWidth = [&](auto startPosition, auto length) -> Optional<LayoutUnit> {
    94         if (!inlineBox.textContext().canUseSimplifiedContentMeasuring)
     94        if (!inlineBox.textContext()->canUseSimplifiedContentMeasuring)
    9595            return { };
    9696        return TextUtil::width(inlineBox, startPosition, startPosition + length);
  • trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp

    r252686 r252816  
    4747        return 0;
    4848
    49     auto& textContext = inlineBox.textContext();
     49    auto& textContext = *inlineBox.textContext();
    5050    auto& text = textContext.content;
    5151    ASSERT(to <= text.length());
  • trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp

    r252686 r252816  
    5858    : Box({ }, WTFMove(style), BaseTypeFlag::BoxFlag)
    5959{
    60     setTextContext(WTFMove(textContext));
     60    ASSERT(isInlineLevelBox());
     61    m_textContext = makeUnique<TextContext>(WTFMove(textContext));
    6162}
    6263
     
    387388}
    388389
    389 void Box::setTextContext(TextContext&& textContext)
    390 {
    391     ASSERT(isInlineLevelBox());
    392     ensureRareData().textContext = WTFMove(textContext);
    393 }
    394 
    395 bool Box::hasTextContent() const
    396 {
    397     ASSERT(isInlineLevelBox());
    398     return hasRareData() && !rareData().textContext.content.isNull();
    399 }
    400 
    401 const TextContext& Box::textContext() const
    402 {
    403     ASSERT(hasRareData());
    404     ASSERT(isInlineLevelBox());
    405     return rareData().textContext;
    406 }
    407 
    408390const Replaced* Box::replaced() const
    409391{
  • trunk/Source/WebCore/layout/layouttree/LayoutBox.h

    r252686 r252816  
    144144    // FIXME: Temporary until after intrinsic size change is tracked by Replaced.
    145145    Replaced* replaced();
    146     bool hasTextContent() const;
    147     const TextContext& textContext() const;
     146    bool hasTextContent() const { return !!m_textContext; }
     147    const TextContext* textContext() const { return m_textContext.get(); }
    148148
    149149    // FIXME: Find a better place for random DOM things.
     
    167167
    168168private:
    169     void setTextContext(TextContext&&);
    170 
    171169    class BoxRareData {
    172170        WTF_MAKE_FAST_ALLOCATED;
     
    174172        BoxRareData() = default;
    175173
    176         TextContext textContext;
    177174        std::unique_ptr<Replaced> replaced;
    178175        unsigned rowSpan { 1 };
     
    197194    Box* m_previousSibling { nullptr };
    198195    Box* m_nextSibling { nullptr };
     196   
     197    std::unique_ptr<const TextContext> m_textContext;
    199198
    200199    unsigned m_baseTypeFlags : 6;
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r252686 r252816  
    389389    stream << " layout box->(" << &layoutBox << ")";
    390390    if (layoutBox.isInlineLevelBox() && layoutBox.isAnonymous())
    391         stream << " text content [\"" << layoutBox.textContext().content.utf8().data() << "\"]";
     391        stream << " text content [\"" << layoutBox.textContext()->content.utf8().data() << "\"]";
    392392
    393393    stream.nextLine();
Note: See TracChangeset for help on using the changeset viewer.