WebKit Bugzilla
Attachment 340310 Details for
Bug 185598
: [LFC] Implement width 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-185598-20180514071347.patch (text/plain), 9.77 KB, created by
zalan
on 2018-05-14 07:13:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-14 07:13:48 PDT
Size:
9.77 KB
patch
obsolete
>Subversion Revision: 231735 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 80c27c853b14578ce5b3ff68c07bfaef9dae5d76..3beddc8e3d9d580346c423f7a63625b4fe16b659 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-13 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement width computation for non-replaced out of flow elements. >+ https://bugs.webkit.org/show_bug.cgi?id=185598 >+ >+ Reviewed by Antti Koivisto. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeWidth const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowWidth const): >+ (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowNonReplacedWidth const): >+ (WebCore::Layout::FormattingContext::shrinkToFitWidth const): >+ * layout/FormattingContext.h: >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::layout const): >+ * 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..10f41f3b1fadd02ddc1abe7760886f70fc4d8651 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" >@@ -59,10 +60,10 @@ void FormattingContext::computeOutOfFlowPosition(const Box&, Display::Box&) cons > { > } > >-void FormattingContext::computeWidth(const Box& layoutBox, Display::Box& displayBox) const >+void FormattingContext::computeWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > if (layoutBox.isOutOfFlowPositioned()) >- return computeOutOfFlowWidth(layoutBox, displayBox); >+ return computeOutOfFlowWidth(layoutContext, layoutBox, displayBox); > if (layoutBox.isFloatingPositioned()) > return computeFloatingWidth(layoutBox, displayBox); > return computeInFlowWidth(layoutBox, displayBox); >@@ -77,8 +78,13 @@ void FormattingContext::computeHeight(LayoutContext& layoutContext, const Box& l > return computeInFlowHeight(layoutContext, layoutBox, displayBox); > } > >-void FormattingContext::computeOutOfFlowWidth(const Box&, Display::Box&) const >+void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { >+ if (!layoutBox.isReplaced()) { >+ computeOutOfFlowNonReplacedWidth(layoutContext, layoutBox, displayBox); >+ return; >+ } >+ ASSERT_NOT_REACHED(); > } > > void FormattingContext::computeFloatingWidth(const Box&, Display::Box&) const >@@ -126,7 +132,7 @@ void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext) > auto& displayBox = layoutContext.createDisplayBox(layoutBox); > > computeOutOfFlowPosition(layoutBox, displayBox); >- computeOutOfFlowWidth(layoutBox, displayBox); >+ computeOutOfFlowWidth(layoutContext, layoutBox, displayBox); > > ASSERT(layoutBox.establishesFormattingContext()); > auto formattingContext = layoutContext.formattingContext(layoutBox); >@@ -136,6 +142,61 @@ void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext) > } > } > >+void FormattingContext::computeOutOfFlowNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ // 'left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' + 'right' >+ // = width of containing block >+ >+ // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. >+ // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static >+ // position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. >+ >+ // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' >+ // 2. 'left' and 'right' are 'auto' and 'width' is not 'auto', then if the 'direction' property of the element establishing the static-position >+ // containing block is 'ltr' set 'left' to the static position, otherwise set 'right' to the static position. >+ // Then solve for 'left' (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). >+ // 3. 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' >+ // 4. 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' >+ // 5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' >+ // 6. 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' >+ auto& style = layoutBox.style(); >+ auto left = style.logicalLeft(); >+ auto right = style.logicalRight(); >+ auto width = style.logicalWidth(); >+ >+ auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); >+ LayoutUnit computedWidthValue; >+ >+ if ((left.isAuto() && width.isAuto() && right.isAuto()) >+ || (left.isAuto() && width.isAuto() && !right.isAuto()) >+ || (!left.isAuto() && width.isAuto() && right.isAuto())) { >+ // All auto (#1), #1 and #3 >+ computedWidthValue = shrinkToFitWidth(layoutContext, layoutBox); >+ } else if (!left.isAuto() && width.isAuto() && !right.isAuto()) { >+ // #5 >+ auto marginLeft = style.marginLeft().isAuto() ? LayoutUnit() : valueForLength(style.marginLeft(), containingBlockWidth); >+ auto marginRight = style.marginRight().isAuto() ? LayoutUnit() : valueForLength(style.marginRight(), containingBlockWidth); >+ >+ auto paddingLeft = valueForLength(style.paddingTop(), containingBlockWidth); >+ auto paddingRight = valueForLength(style.paddingBottom(), containingBlockWidth); >+ >+ auto borderLeftWidth = style.borderStartWidth(); >+ auto borderRightWidth = style.borderEndWidth(); >+ >+ computedWidthValue = containingBlockWidth - (left.value() + marginLeft + borderLeftWidth + paddingLeft + paddingRight + borderRightWidth + marginRight + right.value()); >+ } else if (!width.isAuto()) >+ computedWidthValue = valueForLength(width, containingBlockWidth); >+ else >+ ASSERT_NOT_REACHED(); >+ >+ displayBox.setWidth(computedWidthValue); >+} >+ >+LayoutUnit FormattingContext::shrinkToFitWidth(LayoutContext&, const Box&) const >+{ >+ return 0; >+} >+ > } > } > #endif >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 3e5e87061c179999ae626b3fc3a9c6e9469f8d34..ba83b85580bd3118fa0a778c4ca8eda3f8f1c536 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -68,10 +68,10 @@ protected: > virtual void computeInFlowPositionedPosition(const Box&, Display::Box&) const; > virtual void computeOutOfFlowPosition(const Box&, Display::Box&) const; > >- virtual void computeWidth(const Box&, Display::Box&) const; >+ virtual void computeWidth(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeHeight(LayoutContext&, const Box&, Display::Box&) const; > >- virtual void computeOutOfFlowWidth(const Box&, Display::Box&) const; >+ virtual void computeOutOfFlowWidth(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeFloatingWidth(const Box&, Display::Box&) const; > virtual void computeInFlowWidth(const Box&, Display::Box&) const = 0; > >@@ -88,6 +88,9 @@ protected: > void layoutOutOfFlowDescendants(LayoutContext&s) const; > > private: >+ void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; >+ LayoutUnit shrinkToFitWidth(LayoutContext&, const Box&) const; >+ > WeakPtr<Box> m_root; > }; > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index e2c9c2dae4cae4aec87378fea7c72b5e00f6508f..05421361b1ce0586550a896dafcfc15b1aa4b724 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -74,7 +74,7 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat > auto& layoutBox = layoutPair.layoutBox; > auto& displayBox = layoutPair.displayBox; > >- computeWidth(layoutBox, displayBox); >+ computeWidth(layoutContext, layoutBox, displayBox); > computeStaticPosition(layoutContext, layoutBox, layoutPair.displayBox); > if (layoutBox.establishesFormattingContext()) { > auto formattingContext = layoutContext.formattingContext(layoutBox); >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 185598
:
340286
| 340310