WebKit Bugzilla
Attachment 340255 Details for
Bug 185585
: [LFC] Implement height computation for non-replaced out of flow elements.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185585-20180512222502.patch (text/plain), 11.52 KB, created by
zalan
on 2018-05-12 22:25:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-12 22:25:03 PDT
Size:
11.52 KB
patch
obsolete
>Subversion Revision: 231735 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 80c27c853b14578ce5b3ff68c07bfaef9dae5d76..47b5661a14501eb967c38307fbc65dcaa3bdda2c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-05-12 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement height computation for non-replaced out of flow elements. >+ https://bugs.webkit.org/show_bug.cgi?id=185585 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeHeight const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const): >+ (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowNonReplacedHeight const): >+ (WebCore::Layout::FormattingContext::computeHeightForBlockFormattingContextRootWithAutoHeight const): >+ * layout/FormattingContext.h: >+ * layout/blockformatting/BlockFormattingContext.h: >+ * layout/displaytree/DisplayBox.h: >+ > 2018-05-12 Zalan Bujtas <zalan@apple.com> > > Use WeakPtr for m_enclosingPaginationLayer in RenderLayer >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 3c1189cad8037eabc196f22e68cdc9fa312f5808..1c48c303270fe7665eefae94f6f6e69e91ca8a42 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -28,6 +28,7 @@ > > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > >+#include "DisplayBox.h" > #include "LayoutBox.h" > #include "LayoutContainer.h" > #include "LayoutContext.h" >@@ -71,7 +72,7 @@ void FormattingContext::computeWidth(const Box& layoutBox, Display::Box& display > void FormattingContext::computeHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > if (layoutBox.isOutOfFlowPositioned()) >- return computeOutOfFlowHeight(layoutBox, displayBox); >+ return computeOutOfFlowHeight(layoutContext, layoutBox, displayBox); > if (layoutBox.isFloatingPositioned()) > return computeFloatingHeight(layoutBox, displayBox); > return computeInFlowHeight(layoutContext, layoutBox, displayBox); >@@ -85,8 +86,13 @@ void FormattingContext::computeFloatingWidth(const Box&, Display::Box&) const > { > } > >-void FormattingContext::computeOutOfFlowHeight(const Box&, Display::Box&) const >+void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { >+ if (!layoutBox.isReplaced()) { >+ computeOutOfFlowNonReplacedHeight(layoutContext, layoutBox, displayBox); >+ return; >+ } >+ ASSERT_NOT_REACHED(); > } > > void FormattingContext::computeFloatingHeight(const Box&, Display::Box&) const >@@ -132,8 +138,100 @@ void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext) > auto formattingContext = layoutContext.formattingContext(layoutBox); > formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext)); > >- computeOutOfFlowHeight(layoutBox, displayBox); >+ computeOutOfFlowHeight(layoutContext, layoutBox, displayBox); >+ } >+} >+ >+void FormattingContext::computeOutOfFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ // For absolutely positioned elements, the used values of the vertical dimensions must satisfy this constraint: >+ // 'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' + 'bottom' >+ // = height of containing block >+ >+ // If all three of 'top', 'height', and 'bottom' are auto, set 'top' to the static position and apply rule number three below. >+ >+ // If none of the three are 'auto': If both 'margin-top' and 'margin-bottom' are 'auto', solve the equation under the extra >+ // constraint that the two margins get equal values. If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value. >+ // If the values are over-constrained, ignore the value for 'bottom' and solve for that value. >+ >+ // Otherwise, pick the one of the following six rules that applies. >+ >+ // 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then the height is based on the content per 10.6.7, >+ // set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top' >+ // 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then set 'top' to the static position, set 'auto' values for >+ // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' >+ // 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then the height is based on the content per 10.6.7, set 'auto' >+ // values for 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' >+ // 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', then set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top' >+ // 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', then 'auto' values for 'margin-top' and 'margin-bottom' are set to 0 and solve for 'height' >+ // 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', then set 'auto' values for 'margin-top' and 'margin-bottom' to 0 and solve for 'bottom' >+ auto& style = layoutBox.style(); >+ auto top = style.logicalTop(); >+ auto bottom = style.logicalBottom(); >+ auto height = style.logicalHeight(); >+ >+ // All auto (#3), #1 and #3 >+ if ((top.isAuto() && height.isAuto() && bottom.isAuto()) >+ || (top.isAuto() && height.isAuto() && !bottom.isAuto()) >+ || (height.isAuto() && bottom.isAuto() && !top.isAuto())) { >+ computeHeightForBlockFormattingContextRootWithAutoHeight(layoutContext, layoutBox, displayBox); >+ return; >+ } >+ >+ auto containingBlockHeight = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->height(); >+ LayoutUnit computedHeightValue; >+ >+ // #5 >+ if (height.isAuto() && !bottom.isAuto() && !top.isAuto()) { >+ auto marginTop = style.marginTop().isAuto() ? LayoutUnit() : valueForLength(style.marginTop(), containingBlockHeight); >+ auto marginBottom = style.marginBottom().isAuto() ? LayoutUnit() : valueForLength(style.marginBottom(), containingBlockHeight); >+ >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ auto paddingTop = valueForLength(style.paddingTop(), containingBlockWidth); >+ auto paddingBottom = valueForLength(style.paddingBottom(), containingBlockWidth); >+ >+ auto borderTopWidth = style.borderBeforeWidth(); >+ auto borderBottomWidth = style.borderAfterWidth(); >+ >+ computedHeightValue = containingBlockHeight - (top.value() + marginTop + borderTopWidth + paddingTop + paddingBottom + borderBottomWidth + marginBottom + bottom.value()); >+ } else if (!height.isAuto()) >+ computedHeightValue = valueForLength(height, containingBlockHeight); >+ else >+ ASSERT_NOT_REACHED(); >+ >+ displayBox.setHeight(computedHeightValue); >+} >+ >+void FormattingContext::computeHeightForBlockFormattingContextRootWithAutoHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ ASSERT(layoutBox.style().logicalHeight().isAuto()); >+ if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild()) { >+ displayBox.setHeight(0); >+ return; > } >+ >+ auto& formattingRootContainer = downcast<Container>(layoutBox); >+ // 10.6.7 'Auto' heights for block formatting context roots >+ >+ // If it only has inline-level children, the height is the distance between the top of the topmost line box and the bottom of the bottommost line box. >+ // If it has block-level children, the height is the distance between the top margin-edge of the topmost block-level >+ // child box and the bottom margin-edge of the bottommost block-level child box. >+ >+ // In addition, if the element has any floating descendants whose bottom margin edge is below the element's bottom content edge, >+ // then the height is increased to include those edges. Only floats that participate in this block formatting context are taken >+ // into account, e.g., floats inside absolutely positioned descendants or other floats are not. >+ if (formattingRootContainer.establishesInlineFormattingContext()) { >+ displayBox.setHeight(0); >+ return; >+ } >+ >+ auto* firstDisplayBox = layoutContext.displayBoxForLayoutBox(*formattingRootContainer.firstInFlowChild()); >+ auto* lastDisplayBox = layoutContext.displayBoxForLayoutBox(*formattingRootContainer.lastInFlowChild()); >+ >+ auto top = firstDisplayBox->marginBox().y(); >+ auto bottom = lastDisplayBox->marginBox().maxY(); >+ // FIXME: add floating support. >+ displayBox.setHeight(bottom - top); > } > > } >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 3e5e87061c179999ae626b3fc3a9c6e9469f8d34..928cfc8fea141e460e8694bdc82863fce9ba8b93 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -75,7 +75,7 @@ protected: > virtual void computeFloatingWidth(const Box&, Display::Box&) const; > virtual void computeInFlowWidth(const Box&, Display::Box&) const = 0; > >- virtual void computeOutOfFlowHeight(const Box&, Display::Box&) const; >+ virtual void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeFloatingHeight(const Box&, Display::Box&) const; > virtual void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const = 0; > >@@ -88,6 +88,9 @@ protected: > void layoutOutOfFlowDescendants(LayoutContext&s) const; > > private: >+ void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; >+ void computeHeightForBlockFormattingContextRootWithAutoHeight(LayoutContext&, const Box&, Display::Box&) const; >+ > WeakPtr<Box> m_root; > }; > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index e2ac84a027af5b24fec28981dfdf7c158f3d1739..f01b2f425f3791213bd08641080ce31b047c1061 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -49,6 +49,9 @@ public: > std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&) const override; > Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override; > >+protected: >+ void computeHeightForRootWithAutoHeight(LayoutContext&, const Box&, Display::Box&) const; >+ > private: > void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override; > void computeInFlowWidth(const Box&, Display::Box&) const override; >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.h b/Source/WebCore/layout/displaytree/DisplayBox.h >index 3cdfb1c5d08fe1c3bf2112679170123efad17b9b..49a1d10541fe73d2200d302fd2a08d2e4f2a5326 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.h >+++ b/Source/WebCore/layout/displaytree/DisplayBox.h >@@ -35,8 +35,9 @@ > namespace WebCore { > > namespace Layout { >-class LayoutContext; > class BlockFormattingContext; >+class FormattingContext; >+class LayoutContext; > } > > namespace Display { >@@ -45,6 +46,7 @@ class Box { > WTF_MAKE_ISO_ALLOCATED(Box); > public: > friend class Layout::LayoutContext; >+ friend class Layout::FormattingContext; > friend class Layout::BlockFormattingContext; > > ~Box();
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 185585
:
340255
|
340278
|
340282
|
340318