WebKit Bugzilla
Attachment 341723 Details for
Bug 186172
: [LFC] Push FormattingContext::computeWidth/computeHeight logic from the base to the subclasses.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186172-20180531185910.patch (text/plain), 19.43 KB, created by
zalan
on 2018-05-31 18:59:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-31 18:59:11 PDT
Size:
19.43 KB
patch
obsolete
>Subversion Revision: 232374 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index cc8fc7bef6ccc6a72f3202d990c3f6641eff4c82..93d77e086246bb9a16e1e43c389547ef3c003364 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,43 @@ >+2018-05-31 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Push FormattingContext::computeWidth/computeHeight logic from the base to the subclasses. >+ https://bugs.webkit.org/show_bug.cgi?id=186172 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ FormattingContext::computeWidth/computeHeight virtual functions have very little benefit and in the long run >+ it's better if we keep the number of virtual functions to the minimum necessary. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeFloatingWidth const): >+ (WebCore::Layout::FormattingContext::computeStaticPosition const): Deleted. >+ (WebCore::Layout::FormattingContext::computeInFlowPositionedPosition const): Deleted. >+ (WebCore::Layout::FormattingContext::computeWidth const): Deleted. >+ (WebCore::Layout::FormattingContext::computeHeight const): Deleted. >+ (WebCore::Layout::FormattingContext::computeMargin const): Deleted. >+ * layout/FormattingContext.h: >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeight): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedWidth): >+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeight): >+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidth): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeight): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidth): >+ (WebCore::Layout::FormattingContext::Geometry::replacedHeight): Deleted. >+ (WebCore::Layout::FormattingContext::Geometry::replacedWidth): Deleted. >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeWidth const): >+ (WebCore::Layout::BlockFormattingContext::computeHeight const): >+ (WebCore::Layout::BlockFormattingContext::computeInFlowHeight const): >+ (WebCore::Layout::BlockFormattingContext::computeInFlowWidth const): >+ * layout/blockformatting/BlockFormattingContext.h: >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::InlineFormattingContext::computeStaticPosition const): >+ (WebCore::Layout::InlineFormattingContext::computeInFlowPositionedPosition const): >+ (WebCore::Layout::InlineFormattingContext::computeInFlowWidth const): Deleted. >+ (WebCore::Layout::InlineFormattingContext::computeInFlowHeight const): Deleted. >+ * layout/inlineformatting/InlineFormattingContext.h: >+ > 2018-05-31 Megan Gardner <megan_gardner@apple.com> > > Add setting to allow override screen size to be disabled. >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index e235a33f1bcf48875bd642a0cbc30acafea76917..ba577203edcd6ee4b34baa5c70feb8519c830676 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -49,14 +49,6 @@ FormattingContext::~FormattingContext() > { > } > >-void FormattingContext::computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const >-{ >-} >- >-void FormattingContext::computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const >-{ >-} >- > void FormattingContext::computeOutOfFlowPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > LayoutPoint computedTopLeft; >@@ -69,24 +61,6 @@ void FormattingContext::computeOutOfFlowPosition(LayoutContext& layoutContext, c > displayBox.setTopLeft(computedTopLeft); > } > >-void FormattingContext::computeWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >-{ >- if (layoutBox.isOutOfFlowPositioned()) >- return computeOutOfFlowWidth(layoutContext, layoutBox, displayBox); >- if (layoutBox.isFloatingPositioned()) >- return computeFloatingWidth(layoutContext, layoutBox, displayBox); >- return computeInFlowWidth(layoutContext, layoutBox, displayBox); >-} >- >-void FormattingContext::computeHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >-{ >- if (layoutBox.isOutOfFlowPositioned()) >- return computeOutOfFlowHeight(layoutContext, layoutBox, displayBox); >- if (layoutBox.isFloatingPositioned()) >- return computeFloatingHeight(layoutContext, layoutBox, displayBox); >- return computeInFlowHeight(layoutContext, layoutBox, displayBox); >-} >- > void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > LayoutUnit computedWidth; >@@ -99,18 +73,6 @@ void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, cons > displayBox.setWidth(computedWidth); > } > >-void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >-{ >- LayoutUnit computedWidth; >- >- if (layoutBox.replaced()) >- computedWidth = Geometry::floatingReplacedWidth(layoutContext, layoutBox); >- else >- computedWidth = Geometry::floatingNonReplacedWidth(layoutContext, layoutBox); >- >- displayBox.setWidth(computedWidth); >-} >- > void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > LayoutUnit computedHeight; >@@ -135,9 +97,16 @@ void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, cons > displayBox.setHeight(computedHeight); > } > >-void FormattingContext::computeMargin(LayoutContext&, const Box&, Display::Box& displayBox) const >+void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { >- displayBox.setMargin({ 0, 0, 0, 0 }); >+ LayoutUnit computedWidth; >+ >+ if (layoutBox.replaced()) >+ computedWidth = Geometry::floatingReplacedWidth(layoutContext, layoutBox); >+ else >+ computedWidth = Geometry::floatingNonReplacedWidth(layoutContext, layoutBox); >+ >+ displayBox.setWidth(computedWidth); > } > > void FormattingContext::computeBorderAndPadding(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 143292b4bb23b3d8928065f809a786f6ed1053a8..f58b9af087cfcbfa6b3de763be1498378881a1be 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -63,22 +63,12 @@ protected: > > const Box& root() const { return *m_root; } > >- virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeOutOfFlowPosition(LayoutContext&, const Box&, Display::Box&) const; >+ virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const = 0; >+ virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const = 0; > >- virtual void computeWidth(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeHeight(LayoutContext&, const Box&, Display::Box&) const; >+ void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const; >+ void computeFloatingWidth(LayoutContext&, const Box&, Display::Box&) const; > >- virtual void computeOutOfFlowWidth(LayoutContext&, 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; >- virtual void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const = 0; >- >- virtual void computeMargin(LayoutContext&, const Box&, Display::Box&) const; > void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const; > > void placeInFlowPositionedChildren(LayoutContext&, const Container&) const; >@@ -106,14 +96,18 @@ protected: > static LayoutPoint outOfFlowNonReplacedPosition(LayoutContext&, const Box&); > static LayoutPoint outOfFlowReplacedPosition(LayoutContext&, const Box&); > >- static LayoutUnit replacedHeight(LayoutContext&, const Box&); >- static LayoutUnit replacedWidth(LayoutContext&, const Box&); >+ static LayoutUnit inlineReplacedHeight(LayoutContext&, const Box&); >+ static LayoutUnit inlineReplacedWidth(LayoutContext&, const Box&); > > static Display::Box::Edges computedBorder(LayoutContext&, const Box&); > static std::optional<Display::Box::Edges> computedPadding(LayoutContext&, const Box&); > }; > > private: >+ void computeOutOfFlowPosition(LayoutContext&, const Box&, Display::Box&) const; >+ void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const; >+ void computeOutOfFlowWidth(LayoutContext&, const Box&, Display::Box&) const; >+ > WeakPtr<Box> m_root; > }; > >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index 789ff1a92610414595c41f53b14535a468ff53ba..4ab97e39fa3bc395d4e6d1f4d38594a64538b76c 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -192,7 +192,7 @@ LayoutUnit FormattingContext::Geometry::outOfFlowReplacedHeight(LayoutContext& l > // 10.6.5 Absolutely positioned, replaced elements > // > // The used value of 'height' is determined as for inline replaced elements. >- return replacedHeight(layoutContext, layoutBox); >+ return inlineReplacedHeight(layoutContext, layoutBox); > } > > LayoutUnit FormattingContext::Geometry::outOfFlowReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox) >@@ -201,7 +201,7 @@ LayoutUnit FormattingContext::Geometry::outOfFlowReplacedWidth(LayoutContext& la > // 10.3.8 Absolutely positioned, replaced elements > // > // The used value of 'width' is determined as for inline replaced elements. >- return replacedWidth(layoutContext, layoutBox); >+ return inlineReplacedWidth(layoutContext, layoutBox); > } > > LayoutUnit FormattingContext::Geometry::floatingNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox) >@@ -231,7 +231,7 @@ LayoutUnit FormattingContext::Geometry::floatingReplacedHeight(LayoutContext& la > ASSERT(layoutBox.isFloatingPositioned() && 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 >- return replacedHeight(layoutContext, layoutBox); >+ return inlineReplacedHeight(layoutContext, layoutBox); > } > > LayoutUnit FormattingContext::Geometry::floatingReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox) >@@ -240,7 +240,7 @@ LayoutUnit FormattingContext::Geometry::floatingReplacedWidth(LayoutContext& lay > // 10.3.6 Floating, replaced elements > // > // The used value of 'width' is determined as for inline replaced elements. >- return replacedWidth(layoutContext, layoutBox); >+ return inlineReplacedWidth(layoutContext, layoutBox); > } > > LayoutPoint FormattingContext::Geometry::outOfFlowNonReplacedPosition(LayoutContext& layoutContext, const Box& layoutBox) >@@ -427,11 +427,9 @@ LayoutPoint FormattingContext::Geometry::outOfFlowReplacedPosition(LayoutContext > return { computedLeftValue, computedTopValue }; > } > >-LayoutUnit FormattingContext::Geometry::replacedHeight(LayoutContext&, const Box& layoutBox) >+LayoutUnit FormattingContext::Geometry::inlineReplacedHeight(LayoutContext&, const Box& layoutBox) > { > 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'. >@@ -471,14 +469,9 @@ LayoutUnit FormattingContext::Geometry::replacedHeight(LayoutContext&, const Box > return computedHeightValue; > } > >-LayoutUnit FormattingContext::Geometry::replacedWidth(LayoutContext&, const Box& layoutBox) >+LayoutUnit FormattingContext::Geometry::inlineReplacedWidth(LayoutContext&, const Box& layoutBox) > { > ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); >- >- // 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.8 Absolutely positioned, 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'. >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 5c06a65408a0b0b4f3256125f0599eac0c031f1a..abc9354da0fa237a30ccd045cfa2deb9a954d0cc 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -141,6 +141,28 @@ void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layo > displayBox.setTopLeft(topLeft); > } > >+void BlockFormattingContext::computeWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ if (layoutBox.isInFlow()) >+ return computeInFlowWidth(layoutContext, layoutBox, displayBox); >+ >+ if (layoutBox.isFloatingPositioned()) >+ return computeFloatingWidth(layoutContext, layoutBox, displayBox); >+ >+ ASSERT_NOT_REACHED(); >+} >+ >+void BlockFormattingContext::computeHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ if (layoutBox.isInFlow()) >+ return computeInFlowHeight(layoutContext, layoutBox, displayBox); >+ >+ if (layoutBox.isFloatingPositioned()) >+ return computeFloatingHeight(layoutContext, layoutBox, displayBox); >+ >+ ASSERT_NOT_REACHED(); >+} >+ > void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > LayoutUnit computedHeight; >@@ -148,7 +170,7 @@ void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, c > if (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 >- computedHeight = FormattingContext::Geometry::replacedHeight(layoutContext, layoutBox); >+ computedHeight = FormattingContext::Geometry::inlineReplacedHeight(layoutContext, layoutBox); > } else > computedHeight = Geometry::inFlowNonReplacedHeight(layoutContext, layoutBox); > >@@ -162,7 +184,7 @@ void BlockFormattingContext::computeInFlowWidth(LayoutContext& layoutContext, co > if (layoutBox.replaced()) { > // 10.3.4 Block-level, replaced elements in normal flow > // The used value of 'width' is determined as for inline replaced elements >- computedWidth = FormattingContext::Geometry::replacedWidth(layoutContext, layoutBox); >+ computedWidth = FormattingContext::Geometry::inlineReplacedWidth(layoutContext, layoutBox); > } else > computedWidth = Geometry::inFlowNonReplacedWidth(layoutContext, layoutBox); > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index 7111d26d05cd96edc7fc10d47f9f5e8e855d2a06..6e895f19175f6343db20d10355e192340257c27a 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -51,11 +51,14 @@ public: > Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override; > > private: >+ void computeWidth(LayoutContext&, const Box&, Display::Box&) const; >+ void computeHeight(LayoutContext&, const Box&, Display::Box&) const; >+ > void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override; > void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override; >- void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const override; >- void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const override; >- void computeMargin(LayoutContext&, const Box&, Display::Box&) const override; >+ void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const; >+ void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const; >+ void computeMargin(LayoutContext&, const Box&, Display::Box&) const; > > // This class implements positioning and sizing for boxes participating in a block formatting context. > class Geometry { >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index b7ab20322ec7484a446b38f804b656f943684af6..caa004d161ae5797912a3c0365e45216239ec841 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -66,11 +66,11 @@ Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState(LayoutCont > return formattingState.floatingState(); > } > >-void InlineFormattingContext::computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const >+void InlineFormattingContext::computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const > { > } > >-void InlineFormattingContext::computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const >+void InlineFormattingContext::computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const > { > } > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index 1f5a8ecb37e2229690b696d1f74a29f0f63bc1d2..135626f556cedf107be16f4fd62c42f69075da4c 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -48,8 +48,8 @@ public: > Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override; > > private: >- void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const override; >- void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const override; >+ void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override; >+ void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override; > > }; >
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 186172
: 341723