WebKit Bugzilla
Attachment 342891 Details for
Bug 186744
: [LFC] DisplayBox API should be more clear about height/width vs. contentBoxHeight/width
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186744-20180616144649.patch (text/plain), 34.46 KB, created by
zalan
on 2018-06-16 14:46:50 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-06-16 14:46:50 PDT
Size:
34.46 KB
patch
obsolete
>Subversion Revision: 232876 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 93e51bcecc112ea23f1c49888f9191d6b809255d..06b40c43ea25db8ed6bfb7582afe3ffc0a76a0ce 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,76 @@ >+2018-06-16 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] DisplayBox API should be more clear about height/width vs. contentBoxHeight/width >+ https://bugs.webkit.org/show_bug.cgi?id=186744 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Display::Box::height/width -> border box size. >+ Display::Box::contentBoxHeight/width -> content box size. >+ Display::Box::top/left/bottom/right -> border box position in the containing box's coordinate system. >+ Display::Box::marginBox/borderBox/paddingBox/contentBox -> relative to border box (border box is { 0, 0 }) >+ >+ (This patch also removes the box-sizing logic from Display::Box. FormattingContext::Geometry should set the >+ correct contentBoxSize/borderBoxSize based on the CSS property.) >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const): >+ (WebCore::Layout::FormattingContext::computeFloatingWidthAndMargin const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const): >+ (WebCore::Layout::FormattingContext::validateGeometryConstraintsAfterLayout const): >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::computedPadding): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue): >+ * layout/LayoutContext.cpp: >+ (WebCore::Layout::LayoutContext::initializeRoot): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const): >+ (WebCore::Layout::BlockFormattingContext::computeInFlowWidthAndMargin const): >+ * layout/blockformatting/BlockFormattingContextGeometry.cpp: >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): >+ (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition): >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition): >+ * layout/displaytree/DisplayBox.cpp: >+ (WebCore::Display::Box::marginBox const): >+ (WebCore::Display::Box::borderBox const): >+ (WebCore::Display::Box::paddingBox const): >+ (WebCore::Display::Box::contentBox const): >+ * layout/displaytree/DisplayBox.h: >+ (WebCore::Display::Box::top const): >+ (WebCore::Display::Box::left const): >+ (WebCore::Display::Box::bottom const): >+ (WebCore::Display::Box::right const): >+ (WebCore::Display::Box::topLeft const): >+ (WebCore::Display::Box::bottomRight const): >+ (WebCore::Display::Box::size const): >+ (WebCore::Display::Box::width const): >+ (WebCore::Display::Box::height const): >+ (WebCore::Display::Box::rect const): >+ (WebCore::Display::Box::setTopLeft): >+ (WebCore::Display::Box::setTop): >+ (WebCore::Display::Box::setLeft): >+ (WebCore::Display::Box::moveHorizontally): >+ (WebCore::Display::Box::moveVertically): >+ (WebCore::Display::Box::setHasValidContentHeight): >+ (WebCore::Display::Box::setHasValidContentWidth): >+ (WebCore::Display::Box::setContentBoxHeight): >+ (WebCore::Display::Box::setContentBoxWidth): >+ (WebCore::Display::Box::contentBoxHeight const): >+ (WebCore::Display::Box::contentBoxWidth const): >+ (WebCore::Display::Box::setWidth): Deleted. >+ (WebCore::Display::Box::setHeight): Deleted. >+ (WebCore::Display::Box::setSize): Deleted. >+ > 2018-06-15 Zalan Bujtas <zalan@apple.com> > > [LFC] Fix static position left/top >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 2f95bab85bb03f14d606010b29c0cbdd2c9d3702..43ba27a5bef45d2cc38b5874754998a65b7a0bf8 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -54,7 +54,7 @@ FormattingContext::~FormattingContext() > void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > auto heightAndMargin = Geometry::floatingHeightAndMargin(layoutContext, layoutBox); >- displayBox.setHeight(heightAndMargin.height); >+ displayBox.setContentBoxHeight(heightAndMargin.height); > displayBox.moveVertically(heightAndMargin.margin.top); > displayBox.setVerticalMargin(heightAndMargin.margin); > } >@@ -62,7 +62,7 @@ void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutCont > void FormattingContext::computeFloatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > auto widthAndMargin = Geometry::floatingWidthAndMargin(layoutContext, layoutBox); >- displayBox.setWidth(widthAndMargin.width); >+ displayBox.setContentBoxWidth(widthAndMargin.width); > displayBox.moveHorizontally(widthAndMargin.margin.left); > displayBox.setHorizontalMargin(widthAndMargin.margin); > } >@@ -71,7 +71,7 @@ void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutContext& layout > { > auto horizontalGeometry = Geometry::outOfFlowHorizontalGeometry(layoutContext, layoutBox); > displayBox.setLeft(horizontalGeometry.left); >- displayBox.setWidth(horizontalGeometry.widthAndMargin.width); >+ displayBox.setContentBoxWidth(horizontalGeometry.widthAndMargin.width); > ASSERT(horizontalGeometry.left + horizontalGeometry.widthAndMargin.width == horizontalGeometry.right); > displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.margin); > } >@@ -80,7 +80,7 @@ void FormattingContext::computeOutOfFlowVerticalGeometry(LayoutContext& layoutCo > { > auto verticalGeometry = Geometry::outOfFlowVerticalGeometry(layoutContext, layoutBox); > displayBox.setTop(verticalGeometry.top); >- displayBox.setHeight(verticalGeometry.heightAndMargin.height); >+ displayBox.setContentBoxHeight(verticalGeometry.heightAndMargin.height); > ASSERT(verticalGeometry.top + verticalGeometry.heightAndMargin.height == verticalGeometry.bottom); > displayBox.setVerticalMargin(verticalGeometry.heightAndMargin.margin); > } >@@ -144,9 +144,9 @@ void FormattingContext::validateGeometryConstraintsAfterLayout(const LayoutConte > for (auto& layoutBox : descendantsOfType<Box>(formattingContextRoot)) { > if (&layoutBox.formattingContextRoot() != &formattingContextRoot) > continue; >- auto* containingBlock = layoutBox.containingBlock(); >- ASSERT(containingBlock); >- auto containingBlockSize = layoutContext.displayBoxForLayoutBox(*containingBlock)->size(); >+ auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()); >+ auto containingBlockHeight = containingBlockDisplayBox.contentBoxHeight(); >+ auto containingBlockWidth = containingBlockDisplayBox.contentBoxWidth(); > auto* displayBox = layoutContext.displayBoxForLayoutBox(layoutBox); > ASSERT(displayBox); > >@@ -154,15 +154,15 @@ void FormattingContext::validateGeometryConstraintsAfterLayout(const LayoutConte > // 10.3.7 Absolutely positioned, non-replaced elements > if ((layoutBox.isBlockLevelBox() || layoutBox.isOutOfFlowPositioned()) && !layoutBox.replaced()) { > // margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right = width of containing block >- ASSERT(displayBox->marginLeft() + displayBox->borderLeft() + displayBox->paddingLeft() + displayBox->width() >- + displayBox->paddingRight() + displayBox->borderRight() + displayBox->marginRight() == containingBlockSize.width()); >+ ASSERT(displayBox->marginLeft() + displayBox->borderLeft() + displayBox->paddingLeft() + displayBox->contentBoxWidth() >+ + displayBox->paddingRight() + displayBox->borderRight() + displayBox->marginRight() == containingBlockWidth); > } > > // 10.6.4 Absolutely positioned, non-replaced elements > if (layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced()) { > // top + margin-top + border-top-width + padding-top + height + padding-bottom + border-bottom-width + margin-bottom + bottom = height of containing block >- ASSERT(displayBox->top() + displayBox->marginTop() + displayBox->borderTop() + displayBox->paddingTop() >- + displayBox->paddingBottom() + displayBox->borderBottom() + displayBox->marginBottom() == containingBlockSize.height()); >+ ASSERT(displayBox->top() + displayBox->marginTop() + displayBox->borderTop() + displayBox->paddingTop() + displayBox->contentBoxHeight() >+ + displayBox->paddingBottom() + displayBox->borderBottom() + displayBox->marginBottom() == containingBlockHeight); > } > } > } >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index 6443c09e374c454eb406cf4ff96e00914387623f..c76843995af566a6ebe33389ec49f8f077a3f8a2 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -224,7 +224,7 @@ FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::out > auto& style = layoutBox.style(); > auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); > auto& containingBlock = *layoutBox.containingBlock(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->contentBoxWidth(); > auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection(); > > auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); >@@ -349,9 +349,9 @@ FormattingContext::Geometry::VerticalGeometry FormattingContext::Geometry::outOf > > auto& style = layoutBox.style(); > auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); >- auto& containingBlock = *layoutBox.containingBlock(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->width(); >- auto containingBlockHeight = layoutContext.displayBoxForLayoutBox(containingBlock)->height(); >+ auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()); >+ auto containingBlockHeight = containingBlockDisplayBox.height(); >+ auto containingBlockWidth = containingBlockDisplayBox.width(); > > auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); > auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); >@@ -423,7 +423,7 @@ FormattingContext::Geometry::HorizontalGeometry FormattingContext::Geometry::out > auto& style = layoutBox.style(); > auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); > auto& containingBlock = *layoutBox.containingBlock(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->contentBoxWidth(); > auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection(); > > auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); >@@ -513,10 +513,12 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floati > auto& style = layoutBox.style(); > auto& containingBlock = *layoutBox.containingBlock(); > auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); >+ auto containingBlockHeight = containingBlockDisplayBox.contentBoxHeight(); >+ auto containingBlockWidth = containingBlockDisplayBox.contentBoxWidth(); > >- auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockDisplayBox.height()); >- auto marginTop = computedValueIfNotAuto(style.marginTop(), containingBlockDisplayBox.width()); >- auto marginBottom = computedValueIfNotAuto(style.marginBottom(), containingBlockDisplayBox.width()); >+ auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockHeight); >+ auto marginTop = computedValueIfNotAuto(style.marginTop(), containingBlockWidth); >+ auto marginBottom = computedValueIfNotAuto(style.marginBottom(), containingBlockWidth); > > // #1 > marginTop = marginTop.value_or(0); >@@ -539,12 +541,12 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin > // 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width. > > auto& containingBlock = *layoutBox.containingBlock(); >- auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->contentBoxWidth(); > > // #1 > auto margin = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); > // #2 >- auto width = computedValueIfNotAuto(layoutBox.style().logicalWidth(), containingBlockDisplayBox.width()); >+ auto width = computedValueIfNotAuto(layoutBox.style().logicalWidth(), containingBlockWidth); > if (!width) > width = shrinkToFitWidth(layoutContext, layoutBox); > >@@ -631,10 +633,12 @@ FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inline > > auto& style = layoutBox.style(); > auto replaced = layoutBox.replaced(); >- auto& containingBlock = *layoutBox.containingBlock(); >- auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); >- auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockDisplayBox.height()); >- auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockDisplayBox.width()); >+ auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()); >+ auto containingBlockHeight = containingBlockDisplayBox.height(); >+ auto containingBlockWidth = containingBlockDisplayBox.width(); >+ >+ auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockHeight); >+ auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockWidth); > > if (!height && !width && replaced->hasIntrinsicHeight()) { > // #2 >@@ -681,20 +685,21 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineR > // If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead. > > auto& style = layoutBox.style(); >- auto& containingBlock = *layoutBox.containingBlock(); >- auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); >+ auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()); >+ auto containingBlockHeight = containingBlockDisplayBox.height(); >+ auto containingBlockWidth = containingBlockDisplayBox.width(); > > auto computeMarginRight = [&]() { > if (precomputedMarginRight) > return precomputedMarginRight.value(); >- auto marginRight = computedValueIfNotAuto(style.marginRight(), containingBlockDisplayBox.width()); >+ auto marginRight = computedValueIfNotAuto(style.marginRight(), containingBlockWidth); > return marginRight.value_or(LayoutUnit { 0 }); > }; > > auto computeMarginLeft = [&]() { > if (precomputedMarginLeft) > return precomputedMarginLeft.value(); >- auto marginLeft = computedValueIfNotAuto(style.marginLeft(), containingBlockDisplayBox.width()); >+ auto marginLeft = computedValueIfNotAuto(style.marginLeft(), containingBlockWidth); > return marginLeft.value_or(LayoutUnit { 0 }); > }; > >@@ -702,8 +707,8 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineR > LayoutUnit marginRight = computeMarginRight(); > > auto replaced = layoutBox.replaced(); >- auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockDisplayBox.height()); >- auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockDisplayBox.width()); >+ auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockHeight); >+ auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockWidth); > > ASSERT(replaced); > >@@ -747,7 +752,7 @@ std::optional<Display::Box::Edges> FormattingContext::Geometry::computedPadding( > return std::nullopt; > > auto& style = layoutBox.style(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth(); > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Padding] -> layoutBox: " << &layoutBox); > return Display::Box::Edges { > { valueForLength(style.paddingLeft(), containingBlockWidth), valueForLength(style.paddingRight(), containingBlockWidth) }, >@@ -758,7 +763,7 @@ std::optional<Display::Box::Edges> FormattingContext::Geometry::computedPadding( > Display::Box::HorizontalEdges FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox) > { > auto& style = layoutBox.style(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth(); > > auto marginLeft = computedValueIfNotAuto(style.marginLeft(), containingBlockWidth).value_or(LayoutUnit { 0 }); > auto marginRight = computedValueIfNotAuto(style.marginRight(), containingBlockWidth).value_or(LayoutUnit { 0 }); >@@ -770,7 +775,7 @@ Display::Box::HorizontalEdges FormattingContext::Geometry::computedNonCollapsedH > Display::Box::VerticalEdges FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox) > { > auto& style = layoutBox.style(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBoxWidth(); > > auto marginTop = computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(LayoutUnit { 0 }); > auto marginBottom = computedValueIfNotAuto(style.marginBottom(), containingBlockWidth).value_or(LayoutUnit { 0 }); >diff --git a/Source/WebCore/layout/LayoutContext.cpp b/Source/WebCore/layout/LayoutContext.cpp >index 9308b2019774868955ab053148b7197ba34e05bb..97379982447753a8e02f67102fb6ad2273dd7fe6 100644 >--- a/Source/WebCore/layout/LayoutContext.cpp >+++ b/Source/WebCore/layout/LayoutContext.cpp >@@ -55,23 +55,15 @@ void LayoutContext::initializeRoot(const Container& root, const LayoutSize& cont > > m_root = makeWeakPtr(const_cast<Container&>(root)); > auto& displayBox = createDisplayBox(root); >- // Root is always at 0 0 with no margin >- displayBox.setTopLeft({ }); >- displayBox.setSize(containerSize); >- displayBox.setHorizontalMargin({ }); >- displayBox.setVerticalMargin({ }); > >- auto& style = root.style(); > // FIXME: m_root could very well be a formatting context root with ancestors and resolvable border and padding (as opposed to the topmost root) >- displayBox.setBorder({ >- { style.borderLeft().boxModelWidth(), style.borderRight().boxModelWidth() }, >- { style.borderTop().boxModelWidth(), style.borderBottom().boxModelWidth() } >- }); >- >- displayBox.setPadding({ >- { valueForLength(style.paddingLeft(), containerSize.width()), valueForLength(style.paddingRight(), containerSize.width()) }, >- { valueForLength(style.paddingTop(), containerSize.width()), valueForLength(style.paddingBottom(), containerSize.width()) } >- }); >+ displayBox.setHorizontalMargin({ }); >+ displayBox.setVerticalMargin({ }); >+ displayBox.setBorder({ }); >+ displayBox.setPadding({ }); >+ displayBox.setContentBoxHeight(containerSize.height()); >+ displayBox.setContentBoxWidth(containerSize.width()); >+ displayBox.setTopLeft({ }); > > m_formattingContextRootListForLayout.add(&root); > } >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index a0cba501b9265f9d9daff1cff0e38f99cc822041..3125f241431d36148da1f60820a54250f59b9b0c 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -171,7 +171,7 @@ void BlockFormattingContext::computeHeightAndMargin(LayoutContext& layoutContext > void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox); >- displayBox.setHeight(heightAndMargin.height); >+ displayBox.setContentBoxHeight(heightAndMargin.height); > displayBox.moveVertically(heightAndMargin.margin.top); > displayBox.setVerticalMargin(heightAndMargin.margin); > } >@@ -179,7 +179,7 @@ void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutC > void BlockFormattingContext::computeInFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > auto widthAndMargin = Geometry::inFlowWidthAndMargin(layoutContext, layoutBox); >- displayBox.setWidth(widthAndMargin.width); >+ displayBox.setContentBoxWidth(widthAndMargin.width); > displayBox.moveHorizontally(widthAndMargin.margin.left); > displayBox.setHorizontalMargin(widthAndMargin.margin); > } >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >index 45dcb543d4bfc097f1aae6caad29bf83795d9a1b..1ff34f0ea1e816cf36d69e46fcbe96a2fabfd471 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >@@ -120,7 +120,7 @@ FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::i > return { height, { marginTop, marginBottom } }; > } > >- auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().height(); >+ auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBoxHeight(); > // Stretch but never overstretch with the margins. > if (height + marginTop + marginBottom < initialContainingBlockHeight) > height = initialContainingBlockHeight - marginTop - marginBottom; >@@ -158,7 +158,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in > auto& style = layoutBox.style(); > auto width = precomputedWidth ? Length { precomputedWidth.value(), Fixed } : style.logicalWidth(); > auto* containingBlock = layoutBox.containingBlock(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*containingBlock)->width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*containingBlock)->contentBoxWidth(); > auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); > > LayoutUnit computedWidthValue; >@@ -234,7 +234,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in > return widthAndMargin; > } > >- auto initialContainingBlockWidth = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().width(); >+ auto initialContainingBlockWidth = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBoxWidth(); > auto horizontalMargins = widthAndMargin.margin.left + widthAndMargin.margin.right; > // Stretch but never overstretch with the margins. > if (widthAndMargin.width + horizontalMargins < initialContainingBlockWidth) >@@ -270,10 +270,9 @@ FormattingContext::Geometry::Position BlockFormattingContext::Geometry::staticPo > // Vertical margins between adjacent block-level boxes in a block formatting context collapse. > // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). > >- auto containingBlockContentBox = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBox(); > // Start from the top of the container's content box. >- auto top = containingBlockContentBox.top(); >- auto left = containingBlockContentBox.left(); >+ LayoutUnit top = { }; >+ LayoutUnit left = { }; > if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) { > auto& previousInFlowDisplayBox = *layoutContext.displayBoxForLayoutBox(*previousInFlowSibling); > top = previousInFlowDisplayBox.bottom() + previousInFlowDisplayBox.marginBottom(); >@@ -298,8 +297,7 @@ FormattingContext::Geometry::Position BlockFormattingContext::Geometry::inFlowPo > auto& style = layoutBox.style(); > auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); > auto& containingBlock = *layoutBox.containingBlock(); >- auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); >- auto containingBlockWidth = containingBlockDisplayBox.width(); >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(containingBlock)->contentBoxWidth(); > > auto top = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); > auto bottom = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.cpp b/Source/WebCore/layout/displaytree/DisplayBox.cpp >index 88758ed8bf1c1ce3865cfa2fb2df3d2038b15d0c..505da27b9f6d35b526dbb6d397a2a6d4d83509c5 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.cpp >+++ b/Source/WebCore/layout/displaytree/DisplayBox.cpp >@@ -52,63 +52,45 @@ Box::Style::Style(const RenderStyle& style) > > Box::Rect Box::marginBox() const > { >- ASSERT(m_hasValidHorizontalMargin); >- ASSERT(m_hasValidVerticalMargin); >- auto marginBox = borderBox(); >- >- marginBox.shiftLeftTo(marginBox.left() - m_margin.horizontal.left); >- marginBox.shiftTopTo(marginBox.top() - m_margin.vertical.top); >- marginBox.shiftRightTo(marginBox.right() + m_margin.horizontal.right); >- marginBox.shiftBottomTo(marginBox.bottom() + m_margin.vertical.bottom); >+ auto borderBox = this->borderBox(); > >+ Rect marginBox; >+ marginBox.setTop(borderBox.top() - marginTop()); >+ marginBox.setLeft(borderBox.left() - marginLeft()); >+ marginBox.setHeight(borderBox.height() + marginTop() + marginBottom()); >+ marginBox.setWidth(borderBox.width() + marginLeft() + marginRight()); > return marginBox; > } > > Box::Rect Box::borderBox() const > { >- auto rect = m_rect.clone(); >- rect.setTopLeft({ }); >- >- if (m_style.boxSizing == BoxSizing::BorderBox) >- return rect; >- >- // Width is content box. >- ASSERT(m_hasValidBorder); >- ASSERT(m_hasValidPadding); >- rect.expand(borderLeft() + paddingLeft() + paddingRight() + borderRight(), borderTop() + paddingTop() + paddingBottom() + borderBottom()); >- return rect; >+ Rect borderBox; >+ borderBox.setTopLeft({ }); >+ borderBox.setSize({ width(), height() }); >+ return borderBox; > } > > Box::Rect Box::paddingBox() const > { >- ASSERT(m_hasValidBorder); >- auto paddingBox = borderBox(); >- >- paddingBox.shiftLeftTo(paddingBox.left() + m_border.horizontal.left); >- paddingBox.shiftTopTo(paddingBox.top() + m_border.vertical.top); >- paddingBox.shiftRightTo(paddingBox.right() - m_border.horizontal.right); >- paddingBox.shiftBottomTo(paddingBox.bottom() - m_border.vertical.bottom); >+ auto borderBox = this->borderBox(); > >+ Rect paddingBox; >+ paddingBox.setTop(borderBox.top() + borderTop()); >+ paddingBox.setLeft(borderBox.left() + borderLeft()); >+ paddingBox.setHeight(borderBox.bottom() - borderTop() - borderBottom()); >+ paddingBox.setWidth(borderBox.width() - borderLeft() - borderRight()); > return paddingBox; > } > > Box::Rect Box::contentBox() const > { >- if (m_style.boxSizing == BoxSizing::ContentBox) { >- auto rect = m_rect.clone(); >- rect.setTopLeft({ }); >- return rect; >- } >- >- // Width is border box. >- ASSERT(m_hasValidPadding); >- auto contentBox = paddingBox(); >- >- contentBox.shiftLeftTo(contentBox.left() + m_padding.horizontal.left); >- contentBox.shiftTopTo(contentBox.top() + m_padding.vertical.top); >- contentBox.shiftRightTo(contentBox.right() - m_padding.horizontal.right); >- contentBox.shiftBottomTo(contentBox.bottom() - m_padding.vertical.bottom); >+ auto paddingBox = this->paddingBox(); > >+ Rect contentBox; >+ contentBox.setTop(paddingBox.top() + paddingTop()); >+ contentBox.setLeft(paddingBox.left() + paddingLeft()); >+ contentBox.setWidth(m_contentWidth); >+ contentBox.setHeight(m_contentHeight); > return contentBox; > } > >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.h b/Source/WebCore/layout/displaytree/DisplayBox.h >index eacd26f4f044ceb6a317667e0993332ce1251dae..359c72d70cbe18e096367bc4852c74058728b715 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.h >+++ b/Source/WebCore/layout/displaytree/DisplayBox.h >@@ -113,19 +113,18 @@ public: > > ~Box(); > >- Rect rect() const { return m_rect; } >+ LayoutUnit top() const { return m_topLeft.y(); } >+ LayoutUnit left() const { return m_topLeft.x(); } >+ LayoutUnit bottom() const { return top() + height(); } >+ LayoutUnit right() const { return left() + width(); } > >- LayoutUnit top() const { return m_rect.top(); } >- LayoutUnit left() const { return m_rect.left(); } >- LayoutUnit bottom() const { return m_rect.bottom(); } >- LayoutUnit right() const { return m_rect.right(); } >+ LayoutPoint topLeft() const { return m_topLeft; } >+ LayoutPoint bottomRight() const { return { right(), bottom() }; } > >- LayoutPoint topLeft() const { return m_rect.topLeft(); } >- LayoutPoint bottomRight() const { return m_rect.bottomRight(); } >- >- LayoutSize size() const { return m_rect.size(); } >- LayoutUnit width() const { return m_rect.width(); } >- LayoutUnit height() const { return m_rect.height(); } >+ LayoutSize size() const { return { width(), height() }; } >+ LayoutUnit width() const { return borderLeft() + paddingLeft() + contentBoxWidth() + paddingRight() + borderRight(); } >+ LayoutUnit height() const { return borderTop() + paddingTop() + contentBoxHeight() + paddingBottom() + borderBottom(); } >+ LayoutRect rect() const { return { left(), top(), width(), height() }; } > > LayoutUnit marginTop() const; > LayoutUnit marginLeft() const; >@@ -142,6 +141,9 @@ public: > LayoutUnit paddingBottom() const; > LayoutUnit paddingRight() const; > >+ LayoutUnit contentBoxHeight() const; >+ LayoutUnit contentBoxWidth() const; >+ > Rect marginBox() const; > Rect borderBox() const; > Rect paddingBox() const; >@@ -156,14 +158,14 @@ private: > BoxSizing boxSizing { BoxSizing::ContentBox }; > }; > >- void setTopLeft(const LayoutPoint& topLeft) { m_rect.setTopLeft(topLeft); } >- void setTop(LayoutUnit top) { m_rect.setTop(top); } >- void setLeft(LayoutUnit left) { m_rect.setLeft(left); } >- void moveHorizontally(LayoutUnit offset) { m_rect.moveHorizontally(offset); } >- void moveVertically(LayoutUnit offset) { m_rect.moveVertically(offset); } >- void setWidth(LayoutUnit width) { m_rect.setWidth(width); } >- void setHeight(LayoutUnit height) { m_rect.setHeight(height); } >- void setSize(const LayoutSize& size) { m_rect.setSize(size); } >+ void setTopLeft(const LayoutPoint& topLeft) { m_topLeft = topLeft; } >+ void setTop(LayoutUnit top) { m_topLeft.setY(top); } >+ void setLeft(LayoutUnit left) { m_topLeft.setX(left); } >+ void moveHorizontally(LayoutUnit offset) { m_topLeft.move(offset, { }); } >+ void moveVertically(LayoutUnit offset) { m_topLeft.move({ }, offset); } >+ >+ void setContentBoxHeight(LayoutUnit); >+ void setContentBoxWidth(LayoutUnit); > > struct HorizontalEdges { > LayoutUnit left; >@@ -195,11 +197,16 @@ private: > > void setHasValidBorder() { m_hasValidBorder = true; } > void setHasValidPadding() { m_hasValidPadding = true; } >+ >+ void setHasValidContentHeight() { m_hasValidContentHeight = true; } >+ void setHasValidContentWidth() { m_hasValidContentWidth = true; } > #endif > > const Style m_style; > >- Rect m_rect; >+ LayoutPoint m_topLeft; >+ LayoutUnit m_contentWidth; >+ LayoutUnit m_contentHeight; > > Edges m_margin; > Edges m_border; >@@ -210,6 +217,8 @@ private: > bool m_hasValidVerticalMargin { false }; > bool m_hasValidBorder { false }; > bool m_hasValidPadding { false }; >+ bool m_hasValidContentHeight { false }; >+ bool m_hasValidContentWidth { false }; > #endif > }; > >@@ -402,6 +411,34 @@ inline Box::Rect::operator LayoutRect() const > return m_rect; > } > >+inline void Box::setContentBoxHeight(LayoutUnit height) >+{ >+#if !ASSERT_DISABLED >+ setHasValidContentHeight(); >+#endif >+ m_contentHeight = height; >+} >+ >+inline void Box::setContentBoxWidth(LayoutUnit width) >+{ >+#if !ASSERT_DISABLED >+ setHasValidContentWidth(); >+#endif >+ m_contentWidth = width; >+} >+ >+inline LayoutUnit Box::contentBoxHeight() const >+{ >+ ASSERT(m_hasValidContentHeight); >+ return m_contentHeight; >+} >+ >+inline LayoutUnit Box::contentBoxWidth() const >+{ >+ ASSERT(m_hasValidContentWidth); >+ return m_contentWidth; >+} >+ > inline void Box::setHorizontalMargin(HorizontalEdges margin) > { > #if !ASSERT_DISABLED
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 186744
:
342890
| 342891