WebKit Bugzilla
Attachment 340675 Details for
Bug 185756
: [LFC] Implement height computation for replaced elements.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185756-20180517205841.patch (text/plain), 9.29 KB, created by
zalan
on 2018-05-17 20:58:42 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-17 20:58:42 PDT
Size:
9.29 KB
patch
obsolete
>Subversion Revision: 231912 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index aee4d4f348d6b067799c2d555f31eaab2efada89..0b113380905233f415c1c2bbff241139d4cb5fd2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2018-05-17 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement height computation for replaced elements. >+ https://bugs.webkit.org/show_bug.cgi?id=185756 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeHeight const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowWidth const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const): >+ (WebCore::Layout::FormattingContext::computeFloatingHeight const): >+ (WebCore::Layout::FormattingContext::computeReplacedHeight const): >+ (WebCore::Layout::FormattingContext::computeReplacedWidth const): >+ (WebCore::Layout::FormattingContext::computeOutOfFlowReplacedHeight const): >+ * layout/FormattingContext.h: >+ > 2018-05-17 Chris Dumez <cdumez@apple.com> > > Cross-Origin-Options: deny/allow-postmessage should prevent getting navigated by cross-origin scripts >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 180c0a66b5a7845cd0eef2985821c2d8d11b0b06..cbf1759681e4162753c5dcb7aeb3d950d0f84777 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -74,7 +74,7 @@ void FormattingContext::computeHeight(LayoutContext& layoutContext, const Box& l > if (layoutBox.isOutOfFlowPositioned()) > return computeOutOfFlowHeight(layoutContext, layoutBox, displayBox); > if (layoutBox.isFloatingPositioned()) >- return computeFloatingHeight(layoutBox, displayBox); >+ return computeFloatingHeight(layoutContext, layoutBox, displayBox); > return computeInFlowHeight(layoutContext, layoutBox, displayBox); > } > >@@ -84,7 +84,7 @@ void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, cons > computeOutOfFlowNonReplacedWidth(layoutContext, layoutBox, displayBox); > return; > } >- ASSERT_NOT_IMPLEMENTED_YET(); >+ computeOutOfFlowReplacedWidth(layoutContext, layoutBox, displayBox); > } > > void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >@@ -102,11 +102,16 @@ void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, con > computeOutOfFlowNonReplacedHeight(layoutContext, layoutBox, displayBox); > return; > } >- ASSERT_NOT_IMPLEMENTED_YET(); >+ computeOutOfFlowReplacedHeight(layoutContext, layoutBox, displayBox); > } > >-void FormattingContext::computeFloatingHeight(const Box&, Display::Box&) const >+void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { >+ if (!layoutBox.replaced()) { >+ ASSERT_NOT_IMPLEMENTED_YET(); >+ return; >+ } >+ computeReplacedHeight(layoutContext, layoutBox, displayBox); > } > > LayoutUnit FormattingContext::marginTop(const Box&) const >@@ -212,6 +217,50 @@ void FormattingContext::computeOutOfFlowNonReplacedHeight(LayoutContext& layoutC > displayBox.setHeight(computedHeightValue); > } > >+void FormattingContext::computeReplacedHeight(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); >+ // 10.6.5 Absolutely positioned, replaced elements. The used value of 'height' is determined as for inline replaced elements. >+ >+ // 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: >+ // (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 >+ // 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. >+ auto& style = layoutBox.style(); >+ auto width = style.logicalWidth(); >+ auto height = style.logicalHeight(); >+ >+ LayoutUnit computedHeightValue; >+ auto replaced = layoutBox.replaced(); >+ ASSERT(replaced); >+ >+ if (height.isAuto()) { >+ if (width.isAuto() && replaced->hasIntrinsicHeight()) { >+ // #1 >+ computedHeightValue = replaced->intrinsicHeight(); >+ } else if (replaced->hasIntrinsicRatio()) { >+ // #2 >+ computedHeightValue = width.value() / replaced->intrinsicRatio(); >+ } else if (replaced->hasIntrinsicHeight()) { >+ // #3 >+ computedHeightValue = replaced->intrinsicHeight(); >+ } else { >+ // #4 >+ computedHeightValue = 150; >+ } >+ } else >+ computedHeightValue = height.value(); >+ >+ displayBox.setHeight(computedHeightValue); >+} >+ > void FormattingContext::computeReplacedWidth(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const > { > ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); >@@ -263,7 +312,7 @@ void FormattingContext::computeReplacedWidth(LayoutContext&, const Box& layoutBo > computedWidthValue = 300; > } > >- displayBox.setWidth(computedWidthValue); >+ displayBox.setWidth(computedWidthValue); > } > > LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContext& layoutContext, const Box& layoutBox) const >@@ -349,6 +398,15 @@ void FormattingContext::computeOutOfFlowNonReplacedWidth(LayoutContext& layoutCo > displayBox.setWidth(computedWidthValue); > } > >+void FormattingContext::computeOutOfFlowReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); >+ // 10.6.5 Absolutely positioned, replaced elements >+ // >+ // The used value of 'height' is determined as for inline replaced elements. >+ computeReplacedHeight(layoutContext, layoutBox, displayBox); >+} >+ > void FormattingContext::computeOutOfFlowReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 913dec9b6e9d9e52f002d826b1230b2570e031cd..2d630271076d9883123bc772596d35c0e89ba98f 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -76,7 +76,7 @@ protected: > virtual void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const = 0; > > virtual void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeFloatingHeight(const Box&, Display::Box&) const; >+ virtual void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const = 0; > > virtual LayoutUnit marginTop(const Box&) const; >@@ -87,11 +87,13 @@ protected: > void placeInFlowPositionedChildren(const Container&) const; > void layoutOutOfFlowDescendants(LayoutContext&s) const; > >+ void computeReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; > void computeReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; > > private: > void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; > void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; >+ void computeOutOfFlowReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; > void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; > > LayoutUnit contentHeightForFormattingContextRoot(LayoutContext&, const Box&) const; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 267172acce748a67f5671d1ca27728cc9dccfbd3..c5dd1444e82ab807c355343729d9f6a894af9534 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -189,7 +189,7 @@ void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, c > computeInFlowNonReplacedHeight(layoutContext, layoutBox, displayBox); > return; > } >- ASSERT_NOT_IMPLEMENTED_YET(); >+ computeReplacedHeight(layoutContext, layoutBox, displayBox); > } > > LayoutUnit BlockFormattingContext::marginTop(const Box& layoutBox) const
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 185756
: 340675 |
340684