- Revision
- 252816
- Author
- [email protected]
- Date
- 2019-11-22 16:38:04 -0800 (Fri, 22 Nov 2019)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (252815 => 252816)
--- trunk/Source/WebCore/ChangeLog 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/ChangeLog 2019-11-23 00:38:04 UTC (rev 252816)
@@ -1,3 +1,30 @@
+2019-11-22 Zalan Bujtas <[email protected]>
+
+ [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):
+
2019-11-22 Chris Dumez <[email protected]>
HTTPHeaderMap's operator== is not fully correct
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (252815 => 252816)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-23 00:38:04 UTC (rev 252816)
@@ -145,7 +145,7 @@
auto textContext = *m_initialInlineRun.textContext();
auto length = textContext.length() + m_expandedLength;
- textContext.expand(m_initialInlineRun.layoutBox().textContext().content.substring(textContext.start(), length), length);
+ textContext.expand(m_initialInlineRun.layoutBox().textContext()->content.substring(textContext.start(), length), length);
if (m_textIsAlignJustify) {
// FIXME: This is a very simple expansion merge. We should eventually switch over to FontCascade::expansionOpportunityCount.
@@ -565,7 +565,7 @@
auto collapsedRun = inlineItem.isCollapsible() && inlineItem.length() > 1;
auto contentStart = inlineItem.start();
auto contentLength = collapsedRun ? 1 : inlineItem.length();
- auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext().content.substring(contentStart, contentLength) });
+ auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, inlineItem.layoutBox().textContext()->content.substring(contentStart, contentLength) });
auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
if (collapsesToZeroAdvanceWidth)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (252815 => 252816)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-11-23 00:38:04 UTC (rev 252816)
@@ -82,7 +82,7 @@
void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const Box& inlineBox)
{
- auto text = inlineBox.textContext().content;
+ auto text = inlineBox.textContext()->content;
if (!text.length())
return inlineContent.append(InlineTextItem::createEmptyItem(inlineBox));
@@ -91,7 +91,7 @@
unsigned currentPosition = 0;
auto inlineItemWidth = [&](auto startPosition, auto length) -> Optional<LayoutUnit> {
- if (!inlineBox.textContext().canUseSimplifiedContentMeasuring)
+ if (!inlineBox.textContext()->canUseSimplifiedContentMeasuring)
return { };
return TextUtil::width(inlineBox, startPosition, startPosition + length);
};
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (252815 => 252816)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2019-11-23 00:38:04 UTC (rev 252816)
@@ -46,7 +46,7 @@
if (!font.size() || from == to)
return 0;
- auto& textContext = inlineBox.textContext();
+ auto& textContext = *inlineBox.textContext();
auto& text = textContext.content;
ASSERT(to <= text.length());
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (252815 => 252816)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2019-11-23 00:38:04 UTC (rev 252816)
@@ -57,7 +57,8 @@
Box::Box(TextContext&& textContext, RenderStyle&& style)
: Box({ }, WTFMove(style), BaseTypeFlag::BoxFlag)
{
- setTextContext(WTFMove(textContext));
+ ASSERT(isInlineLevelBox());
+ m_textContext = makeUnique<TextContext>(WTFMove(textContext));
}
Box::~Box()
@@ -386,25 +387,6 @@
&& !isTableColumn();
}
-void Box::setTextContext(TextContext&& textContext)
-{
- ASSERT(isInlineLevelBox());
- ensureRareData().textContext = WTFMove(textContext);
-}
-
-bool Box::hasTextContent() const
-{
- ASSERT(isInlineLevelBox());
- return hasRareData() && !rareData().textContext.content.isNull();
-}
-
-const TextContext& Box::textContext() const
-{
- ASSERT(hasRareData());
- ASSERT(isInlineLevelBox());
- return rareData().textContext;
-}
-
const Replaced* Box::replaced() const
{
return const_cast<Box*>(this)->replaced();
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (252815 => 252816)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2019-11-23 00:38:04 UTC (rev 252816)
@@ -143,8 +143,8 @@
const Replaced* replaced() const;
// FIXME: Temporary until after intrinsic size change is tracked by Replaced.
Replaced* replaced();
- bool hasTextContent() const;
- const TextContext& textContext() const;
+ bool hasTextContent() const { return !!m_textContext; }
+ const TextContext* textContext() const { return m_textContext.get(); }
// FIXME: Find a better place for random DOM things.
void setRowSpan(unsigned);
@@ -166,14 +166,11 @@
Box(Optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
private:
- void setTextContext(TextContext&&);
-
class BoxRareData {
WTF_MAKE_FAST_ALLOCATED;
public:
BoxRareData() = default;
- TextContext textContext;
std::unique_ptr<Replaced> replaced;
unsigned rowSpan { 1 };
unsigned columnSpan { 1 };
@@ -196,6 +193,8 @@
Container* m_parent { nullptr };
Box* m_previousSibling { nullptr };
Box* m_nextSibling { nullptr };
+
+ std::unique_ptr<const TextContext> m_textContext;
unsigned m_baseTypeFlags : 6;
bool m_hasRareData : 1;
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (252815 => 252816)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-11-23 00:15:01 UTC (rev 252815)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2019-11-23 00:38:04 UTC (rev 252816)
@@ -388,7 +388,7 @@
stream << " at (" << displayBox->left() << "," << displayBox->top() << ") size " << displayBox->width() << "x" << displayBox->height();
stream << " layout box->(" << &layoutBox << ")";
if (layoutBox.isInlineLevelBox() && layoutBox.isAnonymous())
- stream << " text content [\"" << layoutBox.textContext().content.utf8().data() << "\"]";
+ stream << " text content [\"" << layoutBox.textContext()->content.utf8().data() << "\"]";
stream.nextLine();
}