WebKit Bugzilla
Attachment 340468 Details for
Bug 185672
: [LFC] Implement width computation for replaced inflow elements.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185672-20180515215515.patch (text/plain), 10.32 KB, created by
zalan
on 2018-05-15 21:55:15 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-15 21:55:15 PDT
Size:
10.32 KB
patch
obsolete
>Subversion Revision: 231799 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6d21088ad2451132a141aad6aca8177ecd0a92c3..ec0ce7df601e04ee24f7b744b0bcf413e367fc59 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2018-05-15 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement width computation for replaced inflow elements. >+ https://bugs.webkit.org/show_bug.cgi?id=185672 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Replaced width for block, inline and float elements compute the same way. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeWidth const): >+ (WebCore::Layout::FormattingContext::computeFloatingWidth const): >+ (WebCore::Layout::FormattingContext::computeInFlowReplacedWidth const): >+ * layout/FormattingContext.h: >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeInFlowWidth const): >+ * layout/layouttree/LayoutBox.cpp: >+ (WebCore::Layout::Box::hasIntrinsicWidth const): >+ (WebCore::Layout::Box::hasIntrinsicHeight const): >+ (WebCore::Layout::Box::hasIntrinsicRatio const): >+ (WebCore::Layout::Box::intrinsicWidth const): >+ (WebCore::Layout::Box::intrinsicHeight const): >+ (WebCore::Layout::Box::intrinsicRatio const): >+ * layout/layouttree/LayoutBox.h: >+ > 2018-05-15 Dirk Schulze <krit@webkit.org> > > Add new SVGDOM SVGFEBLEND constants >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 094959823f1a8fa1e9b64694cea096b180db079a..8df9dff435225825983cd906239a56db6181fd1d 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -65,7 +65,7 @@ void FormattingContext::computeWidth(LayoutContext& layoutContext, const Box& la > if (layoutBox.isOutOfFlowPositioned()) > return computeOutOfFlowWidth(layoutContext, layoutBox, displayBox); > if (layoutBox.isFloatingPositioned()) >- return computeFloatingWidth(layoutBox, displayBox); >+ return computeFloatingWidth(layoutContext, layoutBox, displayBox); > return computeInFlowWidth(layoutContext, layoutBox, displayBox); > } > >@@ -87,8 +87,13 @@ void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, cons > ASSERT_NOT_REACHED(); > } > >-void FormattingContext::computeFloatingWidth(const Box&, Display::Box&) const >+void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { >+ if (!layoutBox.isReplaced()) { >+ ASSERT_NOT_REACHED(); >+ return; >+ } >+ computeInFlowReplacedWidth(layoutContext, layoutBox, displayBox); > } > > void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >@@ -203,6 +208,55 @@ void FormattingContext::computeOutOfFlowNonReplacedHeight(LayoutContext& layoutC > displayBox.setHeight(computedHeightValue); > } > >+void FormattingContext::computeInFlowReplacedWidth(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ // 10.3.4 Block-level, replaced elements in normal flow: The used value of 'width' is determined as for inline replaced elements >+ // 10.3.6 Floating, replaced elements: The used value of 'width' is determined as for inline replaced elements. >+ >+ // 10.3.2 Inline, replaced elements >+ // >+ // 1. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'. >+ // >+ // 2. If 'height' and 'width' both have computed values of 'auto' and the element has no intrinsic width, but does have an intrinsic height and intrinsic ratio; >+ // or if 'width' has a computed value of 'auto', 'height' has some other computed value, and the element does have an intrinsic ratio; >+ // then the used value of 'width' is: (used height) * (intrinsic ratio) >+ // >+ // 3. If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, >+ // then the used value of 'width' is undefined in CSS 2.2. However, it is suggested that, if the containing block's width does not itself depend on the replaced >+ // element's width, then the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow. >+ // >+ // 4. Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'. >+ // >+ // 5. Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. >+ // 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 width = style.logicalWidth(); >+ auto height = style.logicalHeight(); >+ >+ LayoutUnit computedWidthValue; >+ >+ if (width.isAuto() && height.isAuto() && layoutBox.hasIntrinsicWidth()) { >+ // #1 >+ computedWidthValue = layoutBox.intrinsicWidth(); >+ } else if (width.isAuto() && (height.isCalculated() || layoutBox.hasIntrinsicHeight()) && layoutBox.hasIntrinsicRatio()) { >+ // #2 >+ auto usedHeight = height.isCalculated() ? LayoutUnit(height.value()) : layoutBox.intrinsicHeight(); >+ computedWidthValue = usedHeight * layoutBox.intrinsicRatio(); >+ } else if (width.isAuto() && height.isAuto() && layoutBox.hasIntrinsicRatio()) { >+ // #3 >+ // FIXME: undefined but surely doable. >+ ASSERT_NOT_REACHED(); >+ } else if (width.isAuto() && layoutBox.hasIntrinsicWidth()) { >+ // #4 >+ computedWidthValue = layoutBox.intrinsicWidth(); >+ } else { >+ // #5 >+ computedWidthValue = 300; >+ } >+ >+ displayBox.setWidth(computedWidthValue); >+} >+ > LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContext& layoutContext, const Box& layoutBox) const > { > ASSERT(layoutBox.style().logicalHeight().isAuto()); >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 2424b1a1d12f6f78afd937a959ae23fd4f707d6f..2fbff65f35e3e58e3b17bee870fae3293b9732b3 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -72,7 +72,7 @@ protected: > virtual void computeHeight(LayoutContext&, const Box&, Display::Box&) const; > > virtual void computeOutOfFlowWidth(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeFloatingWidth(const Box&, Display::Box&) const; >+ virtual void computeFloatingWidth(LayoutContext&, const Box&, Display::Box&) const; > virtual void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const = 0; > > virtual void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const; >@@ -87,6 +87,8 @@ protected: > void placeInFlowPositionedChildren(const Container&) const; > void layoutOutOfFlowDescendants(LayoutContext&s) const; > >+ void computeInFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; >+ > private: > void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; > void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 4c3f41b5c49c17c3c73583151365580fa1869745..e78b592a8a180d1e6672a132f326d3dbeba449f0 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -149,7 +149,7 @@ void BlockFormattingContext::computeInFlowWidth(LayoutContext& layoutContext, co > computeInFlowNonReplacedWidth(layoutContext, layoutBox, displayBox); > return; > } >- ASSERT_NOT_REACHED(); >+ computeInFlowReplacedWidth(layoutContext, layoutBox, displayBox); > } > > void BlockFormattingContext::computeInFlowNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >diff --git a/Source/WebCore/layout/layouttree/LayoutBox.cpp b/Source/WebCore/layout/layouttree/LayoutBox.cpp >index fe0d5caee28ef5a5f845dd95b0561af7dfec19c8..940f908a903a08f238f685454c499ee2da213517 100644 >--- a/Source/WebCore/layout/layouttree/LayoutBox.cpp >+++ b/Source/WebCore/layout/layouttree/LayoutBox.cpp >@@ -230,6 +230,39 @@ bool Box::isOverflowVisible() const > return m_style.overflowX() == OVISIBLE || m_style.overflowY() == OVISIBLE; > } > >+bool Box::hasIntrinsicWidth() const >+{ >+ return false; >+} >+ >+bool Box::hasIntrinsicHeight() const >+{ >+ return false; >+} >+ >+bool Box::hasIntrinsicRatio() const >+{ >+ return false; >+} >+ >+LayoutUnit Box::intrinsicWidth() const >+{ >+ ASSERT(hasIntrinsicWidth()); >+ return { }; >+} >+ >+LayoutUnit Box::intrinsicHeight() const >+{ >+ ASSERT(hasIntrinsicHeight()); >+ return { }; >+} >+ >+LayoutUnit Box::intrinsicRatio() const >+{ >+ ASSERT(hasIntrinsicRatio()); >+ return { }; >+} >+ > } > } > >diff --git a/Source/WebCore/layout/layouttree/LayoutBox.h b/Source/WebCore/layout/layouttree/LayoutBox.h >index 23af846149179cc07ad08e8be7e4ce123e670167..70437c99b635e3024c7e726613701e25292584c5 100644 >--- a/Source/WebCore/layout/layouttree/LayoutBox.h >+++ b/Source/WebCore/layout/layouttree/LayoutBox.h >@@ -72,7 +72,6 @@ public: > bool isInlineBlockBox() const; > bool isBlockContainerBox() const; > bool isInitialContainingBlock() const; >- bool isReplaced() const; > > const Container* parent() const { return m_parent; } > const Box* nextSibling() const { return m_nextSibling; } >@@ -91,6 +90,15 @@ public: > const RenderStyle& style() const { return m_style; } > auto& weakPtrFactory() const { return m_weakFactory; } > >+ bool isReplaced() const; >+ // FIXME: find out how to not pollute the Box interface >+ bool hasIntrinsicWidth() const; >+ bool hasIntrinsicHeight() const; >+ bool hasIntrinsicRatio() const; >+ LayoutUnit intrinsicWidth() const; >+ LayoutUnit intrinsicHeight() const; >+ LayoutUnit intrinsicRatio() const; >+ > protected: > enum BaseTypeFlag { > ContainerFlag = 1 << 0,
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 185672
: 340468