WebKit Bugzilla
Attachment 361151 Details for
Bug 194269
: [LFC][IFC] collectInlineContent should use pre-computed margins, paddings and borders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194269-20190204192017.patch (text/plain), 8.87 KB, created by
zalan
on 2019-02-04 19:20:34 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-02-04 19:20:34 PST
Size:
8.87 KB
patch
obsolete
>Subversion Revision: 240946 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0cf299f3fe9709f00a54a5c80ca1c00546d42cfc..047b6e702ea47b0a9d7917b9ccbfa94ec940a74d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2019-02-04 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] collectInlineContent should use pre-computed margins, paddings and borders >+ https://bugs.webkit.org/show_bug.cgi?id=194269 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In this patch we pre-compute the margins padding and borders for formatting context roots, replaced boxes and non-replaced containers. >+ These property values are input to collectInlineContent's inline item detaching logic. >+ >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::nextInPreOrder): >+ (WebCore::Layout::InlineFormattingContext::layout const): >+ (WebCore::Layout::InlineFormattingContext::computeMarginBorderAndPadding const): >+ (WebCore::Layout::InlineFormattingContext::collectInlineContent const): >+ * layout/inlineformatting/InlineFormattingContext.h: >+ * layout/layouttree/LayoutBox.h: ran out bits. >+ > 2019-02-04 Justin Fan <justin_fan@apple.com> > > [Web GPU] Code clean-up for RenderPipeline backend >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index 78f34f8c68993d39ed6abad9fbb0f62b8a52bde0..1d1ca9ecc7f2aaf662b6887e40e703daf476b584 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -53,30 +53,42 @@ InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoo > { > } > >+static inline const Box* nextInPreOrder(const Box& layoutBox, const Container& root) >+{ >+ const Box* nextInPreOrder = nullptr; >+ if (!layoutBox.establishesFormattingContext() && is<Container>(layoutBox) && downcast<Container>(layoutBox).hasInFlowOrFloatingChild()) >+ return downcast<Container>(layoutBox).firstInFlowOrFloatingChild(); >+ >+ for (nextInPreOrder = &layoutBox; nextInPreOrder && nextInPreOrder != &root; nextInPreOrder = nextInPreOrder->parent()) { >+ if (auto* nextSibling = nextInPreOrder->nextInFlowOrFloatingSibling()) >+ return nextSibling; >+ } >+ return nullptr; >+} >+ > void InlineFormattingContext::layout() const > { > if (!is<Container>(root())) > return; > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")"); >+ auto& root = downcast<Container>(this->root()); >+ auto* layoutBox = root.firstInFlowOrFloatingChild(); >+ // Compute width/height for non-text content and margin/border/padding for inline containers. >+ while (layoutBox) { >+ if (layoutBox->establishesFormattingContext()) >+ layoutFormattingContextRoot(*layoutBox); >+ else if (is<Container>(*layoutBox)) >+ computeMarginBorderAndPadding(downcast<InlineContainer>(*layoutBox)); >+ else if (layoutBox->isReplaced()) >+ computeWidthAndHeightForReplacedInlineBox(*layoutBox); >+ layoutBox = nextInPreOrder(*layoutBox, root); >+ } > > InlineRunProvider inlineRunProvider; > collectInlineContent(inlineRunProvider); >- // Compute width/height for non-text content. >- for (auto& inlineRun : inlineRunProvider.runs()) { >- if (inlineRun.isText()) >- continue; >- >- auto& layoutBox = inlineRun.inlineItem().layoutBox(); >- if (layoutBox.establishesFormattingContext()) { >- layoutFormattingContextRoot(layoutBox); >- continue; >- } >- computeWidthAndHeightForReplacedInlineBox(layoutBox); >- } >- > layoutInlineContent(inlineRunProvider); >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> formatting root(" << &root() << ")"); >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> formatting root(" << &root << ")"); > } > > static bool isTrimmableContent(const InlineLineBreaker::Run& run) >@@ -329,6 +341,19 @@ void InlineFormattingContext::layoutInlineContent(const InlineRunProvider& inlin > closeLine(line, IsLastLine::Yes); > } > >+void InlineFormattingContext::computeMarginBorderAndPadding(const InlineContainer& inlineContainer) const >+{ >+ // Non-replaced, non-formatting root containers (<span></span>) don't have width property -> non width computation. >+ ASSERT(!inlineContainer.replaced()); >+ ASSERT(!inlineContainer.establishesFormattingContext()); >+ >+ computeBorderAndPadding(inlineContainer); >+ auto& displayBox = layoutState().displayBoxForLayoutBox(inlineContainer); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState(), inlineContainer); >+ displayBox.setHorizontalComputedMargin(computedHorizontalMargin); >+ displayBox.setHorizontalMargin({ computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) }); >+} >+ > void InlineFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > { > auto& layoutState = this->layoutState(); >@@ -470,14 +495,10 @@ void InlineFormattingContext::collectInlineContent(InlineRunProvider& inlineRunP > > enum class NonBreakableWidthType { Start, End }; > auto nonBreakableWidth = [&](auto& container, auto type) { >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, container); >- auto horizontalMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) }; >- auto border = Geometry::computedBorder(layoutState, container); >- auto padding = Geometry::computedPadding(layoutState, container); >- >+ auto& displayBox = layoutState.displayBoxForLayoutBox(container); > if (type == NonBreakableWidthType::Start) >- return border.horizontal.left + horizontalMargin.start + (padding ? padding->horizontal.left : LayoutUnit()); >- return border.horizontal.right + horizontalMargin.end + (padding ? padding->horizontal.right : LayoutUnit()); >+ return displayBox.marginStart() + displayBox.borderLeft() + displayBox.paddingLeft().valueOr(0); >+ return displayBox.marginEnd() + displayBox.borderRight() + displayBox.paddingRight().valueOr(0); > }; > > LayoutQueue layoutQueue; >@@ -496,9 +517,9 @@ void InlineFormattingContext::collectInlineContent(InlineRunProvider& inlineRunP > if (container.establishesFormattingContext()) { > // Formatting contexts are treated as leaf nodes. > auto& inlineItem = createAndAppendInlineItem(inlineRunProvider, inlineContent, container); >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, container); >- auto currentNonBreakableStartWidth = nonBreakableStartWidth.valueOr(0) + computedHorizontalMargin.start.valueOr(0) + nonBreakableEndWidth.valueOr(0); >- addDetachingRules(inlineItem, currentNonBreakableStartWidth, computedHorizontalMargin.end); >+ auto& displayBox = layoutState.displayBoxForLayoutBox(container); >+ auto currentNonBreakableStartWidth = nonBreakableStartWidth.valueOr(0) + displayBox.marginStart() + nonBreakableEndWidth.valueOr(0); >+ addDetachingRules(inlineItem, currentNonBreakableStartWidth, displayBox.marginEnd()); > nonBreakableStartWidth = { }; > nonBreakableEndWidth = { }; > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index 3f7cd3f5324744a249a8b46e2ea117a58904ddcb..97f8ed6bac731cc02a2bfa0fa3c5c60555defbad 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -35,6 +35,7 @@ > namespace WebCore { > namespace Layout { > >+class InlineContainer; > class InlineFormattingState; > class InlineRunProvider; > >@@ -112,6 +113,7 @@ private: > > void layoutFormattingContextRoot(const Box&) const; > void computeWidthAndHeightForReplacedInlineBox(const Box&) const; >+ void computeMarginBorderAndPadding(const InlineContainer&) const; > void computeHeightAndMargin(const Box&) const; > void computeWidthAndMargin(const Box&) const; > void computeFloatPosition(const FloatingContext&, Line&, const Box&) const; >diff --git a/Source/WebCore/layout/layouttree/LayoutBox.h b/Source/WebCore/layout/layouttree/LayoutBox.h >index ba05392d81ce266bd7a6d32d18f373b66be2da56..62fb0d148081c1b4c3f28d07e098b7a65bba8121 100644 >--- a/Source/WebCore/layout/layouttree/LayoutBox.h >+++ b/Source/WebCore/layout/layouttree/LayoutBox.h >@@ -155,7 +155,7 @@ private: > > std::unique_ptr<Replaced> m_replaced; > >- unsigned m_baseTypeFlags : 4; >+ unsigned m_baseTypeFlags : 5; > }; > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194269
: 361151