WebKit Bugzilla
Attachment 342271 Details for
Bug 186432
: [LFC] Add vertical margin computation for inline, block-level, inline-block and floating replaced elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186432-20180608084227.patch (text/plain), 10.19 KB, created by
zalan
on 2018-06-08 08:42:28 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-06-08 08:42:28 PDT
Size:
10.19 KB
patch
obsolete
>Subversion Revision: 232581 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 824dd7c68f90b3c1c1aedc51828116256727cb2d..4835594ded6e50c15b9a283eddf97ae87e18a30f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2018-06-08 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Add vertical margin computation for inline, block-level, inline-block and floating replaced elements >+ https://bugs.webkit.org/show_bug.cgi?id=186432 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * layout/FormattingContext.h: >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin): Use the computed non-auto values when margin is not auto. >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue): >+ > 2018-06-07 Zalan Bujtas <zalan@apple.com> > > [LFC] Merge height and vertical margin computation >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 736376ca9d4878ca88dbe367b6f5767aae2e6f14..9d230f21888d0b65aa4520e3ea1f6c7a3da5e03b 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -106,6 +106,9 @@ protected: > static Display::Box::Edges computedBorder(LayoutContext&, const Box&); > static std::optional<Display::Box::Edges> computedPadding(LayoutContext&, const Box&); > >+ static Display::Box::HorizontalEdges computedNonCollapsedHorizontalMarginValue(const LayoutContext&, const Box&); >+ static Display::Box::VerticalEdges computedNonCollapsedVerticalMarginValue(const LayoutContext&, const Box&); >+ > private: > static HeightAndMargin outOfFlowReplacedHeightAndMargin(LayoutContext&, const Box&); > static WidthAndMargin outOfFlowReplacedWidthAndMargin(LayoutContext&, const Box&); >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index 6a4fff0cfcefe818f416e0e67b28e75237c10c78..a40c43d07b23aeadd755079fc1ac022c2f63efd0 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -226,21 +226,11 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin > // 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width. > auto& style = layoutBox.style(); > auto width = style.logicalWidth(); >- LayoutUnit computedMarginLeftValue; >- LayoutUnit computedMarginRightValue; >- >- { >- auto marginLeft = style.marginLeft(); >- auto marginRight = style.marginRight(); >- auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >- // #1 >- computedMarginLeftValue = marginLeft.isAuto() ? LayoutUnit(0) : valueForLength(marginLeft, containingBlockWidth); >- computedMarginRightValue = marginRight.isAuto() ? LayoutUnit(0) : valueForLength(marginRight, containingBlockWidth); >- } >- >+ // #1 >+ auto computedNonCollapsedHorizontalMarginValues = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); > // #2 > auto computedWidthValue = width.isAuto() ? shrinkToFitWidth(layoutContext, layoutBox) : LayoutUnit(width.value()); >- return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue } }; >+ return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, computedNonCollapsedHorizontalMarginValues }; > } > > FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox) >@@ -258,16 +248,8 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin > // > // 1. If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'. > // 2. The used value of 'width' is determined as for inline replaced elements. >- auto& style = layoutBox.style(); >- std::optional<LayoutUnit> computedMarginLeftValue; >- std::optional<LayoutUnit> computedMarginRightValue; >- >- if (style.marginLeft().isAuto()) >- computedMarginLeftValue = LayoutUnit { 0 }; >- if (style.marginRight().isAuto()) >- computedMarginRightValue = LayoutUnit { 0 }; >- >- return inlineReplacedWidthAndMargin(layoutContext, layoutBox, computedMarginLeftValue, computedMarginRightValue); >+ auto computedNonCollapsedHorizontalMarginValues = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); >+ return inlineReplacedWidthAndMargin(layoutContext, layoutBox, computedNonCollapsedHorizontalMarginValues.left, computedNonCollapsedHorizontalMarginValues.right); > } > > static LayoutPoint outOfFlowNonReplacedPosition(LayoutContext& layoutContext, const Box& layoutBox) >@@ -503,46 +485,46 @@ LayoutPoint FormattingContext::Geometry::outOfFlowPosition(LayoutContext& layout > return outOfFlowReplacedPosition(layoutContext, layoutBox); > } > >-FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext&, const Box& layoutBox) >+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox) > { > ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); > // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements > // >- // 1. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. >- // >- // 2. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: >+ // 1. If 'margin-top', or 'margin-bottom' are 'auto', their used value is 0. >+ // 2. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. >+ // 3. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: > // (used width) / (intrinsic ratio) >- // >- // 3. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. >- // >- // 4. Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to >+ // 4. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. >+ // 5. Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to > // the height of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width. >+ >+ // #1 >+ auto computedNonCollapsedVerticalMarginValues = computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox); >+ > auto& style = layoutBox.style(); >- auto width = style.logicalWidth(); > auto height = style.logicalHeight(); >- > LayoutUnit computedHeightValue; >- auto replaced = layoutBox.replaced(); >- ASSERT(replaced); >- > if (height.isAuto()) { >+ auto width = style.logicalWidth(); >+ auto replaced = layoutBox.replaced(); >+ > if (width.isAuto() && replaced->hasIntrinsicHeight()) { >- // #1 >+ // #2 > computedHeightValue = replaced->intrinsicHeight(); > } else if (replaced->hasIntrinsicRatio()) { >- // #2 >+ // #3 > computedHeightValue = width.value() / replaced->intrinsicRatio(); > } else if (replaced->hasIntrinsicHeight()) { >- // #3 >+ // #4 > computedHeightValue = replaced->intrinsicHeight(); > } else { >- // #4 >+ // #5 > computedHeightValue = 150; > } > } else > computedHeightValue = height.value(); > >- return { computedHeightValue, { } }; >+ return { computedHeightValue, computedNonCollapsedVerticalMarginValues }; > } > > FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, >@@ -637,6 +619,32 @@ 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 marginLeft = style.marginLeft(); >+ auto marginRight = style.marginRight(); >+ >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ return Display::Box::HorizontalEdges { >+ marginLeft.isAuto() ? LayoutUnit { 0 } : valueForLength(marginLeft, containingBlockWidth), >+ marginRight.isAuto() ? LayoutUnit { 0 } : valueForLength(marginRight, containingBlockWidth) >+ }; >+} >+ >+Display::Box::VerticalEdges FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ auto& style = layoutBox.style(); >+ auto marginTop = style.marginTop(); >+ auto marginBottom = style.marginBottom(); >+ >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ return Display::Box::VerticalEdges { >+ marginTop.isAuto() ? LayoutUnit { 0 } : valueForLength(marginTop, containingBlockWidth), >+ marginBottom.isAuto() ? LayoutUnit { 0 } : valueForLength(marginBottom, containingBlockWidth) >+ }; >+} >+ > } > } > #endif
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 186432
: 342271