WebKit Bugzilla
Attachment 341172 Details for
Bug 185936
: [LFC] Implement position computation for inflow positioned elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185936-20180523220751.patch (text/plain), 8.02 KB, created by
zalan
on 2018-05-23 22:07:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-05-23 22:07:52 PDT
Size:
8.02 KB
patch
obsolete
>Subversion Revision: 232114 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index de80b8a5dc40242d8edc4b5cac4047d5fb164297..be0e8dbc82ff58b3fae4693bc7d452ea95652d13 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2018-05-23 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement position computation for inflow positioned elements >+ https://bugs.webkit.org/show_bug.cgi?id=185936 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeInFlowPositionedPosition const): >+ * layout/FormattingContext.h: >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeInFlowPositionedPosition const): >+ * layout/blockformatting/BlockFormattingContext.h: >+ * layout/blockformatting/BlockFormattingContextGeometry.cpp: >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition): >+ > 2018-05-23 Zalan Bujtas <zalan@apple.com> > > [LFC] Move sizing/positioning logic to helper classes >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 35c6050f7d2c18b545a7228cecbe39473a3a3b2d..703b02c8097a04bf7ae2833895083c1853c29da7 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -53,7 +53,7 @@ void FormattingContext::computeStaticPosition(LayoutContext&, const Box&, Displa > { > } > >-void FormattingContext::computeInFlowPositionedPosition(const Box&, Display::Box&) const >+void FormattingContext::computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const > { > } > >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index c3d3c9c9a716c2f4cdb1350606bdeba8cd221f18..c6977ac26cb2e578adc30fc128366fd5b6c543cd 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -67,7 +67,7 @@ protected: > const Box& root() const { return *m_root; } > > virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const; >- virtual void computeInFlowPositionedPosition(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 computeWidth(LayoutContext&, const Box&, Display::Box&) const; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index bdec43d580d9ac1023be894f72cab1bec4714619..0b8f1e7d5a39d56188a4c672d4a2e91be7ddb421 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -134,6 +134,12 @@ void BlockFormattingContext::computeStaticPosition(LayoutContext& layoutContext, > displayBox.setTopLeft(topLeft); > } > >+void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const >+{ >+ auto topLeft = Geometry::inFlowPositionedPosition(layoutContext, layoutBox); >+ displayBox.setTopLeft(topLeft); >+} >+ > void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const > { > LayoutUnit computedHeight; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index fed1a601a9befc95a9c282202c27b95acb5677c7..397828cd131e8b86a4f529acc31b4ab122bc5085 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -52,6 +52,7 @@ public: > > private: > 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; > >@@ -65,6 +66,7 @@ private: > static LayoutUnit inFlowNonReplacedWidth(LayoutContext&, const Box&); > > static LayoutPoint staticPosition(LayoutContext&, const Box&); >+ static LayoutPoint inFlowPositionedPosition(LayoutContext&, const Box&); > }; > }; > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >index 6f4cfd1d94fc57504fb3bbe94a977c24ae9634b2..532ae8dceb4bdba50766a5feef46caad033cd388 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >@@ -137,6 +137,68 @@ LayoutPoint BlockFormattingContext::Geometry::staticPosition(LayoutContext& layo > return topLeft; > } > >+LayoutPoint BlockFormattingContext::Geometry::inFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ ASSERT(layoutBox.isInFlowPositioned()); >+ // 9.4.3 Relative positioning >+ // >+ // For relatively positioned elements, 'left' and 'right' move the box(es) horizontally, without changing their size. >+ // 'Left' moves the boxes to the right, and 'right' moves them to the left. >+ // Since boxes are not split or stretched as a result of 'left' or 'right', the used values are always: left = -right. >+ // >+ // 1. If both 'left' and 'right' are 'auto' (their initial values), the used values are '0' (i.e., the boxes stay in their original position). >+ // 2. If 'left' is 'auto', its used value is minus the value of 'right' (i.e., the boxes move to the left by the value of 'right'). >+ // 3. If 'right' is specified as 'auto', its used value is minus the value of 'left'. >+ // 4. If neither 'left' nor 'right' is 'auto', the position is over-constrained, and one of them has to be ignored. >+ // If the 'direction' property of the containing block is 'ltr', the value of 'left' wins and 'right' becomes -'left'. >+ // If 'direction' of the containing block is 'rtl', 'right' wins and 'left' is ignored. >+ // >+ // The 'top' and 'bottom' properties move relatively positioned element(s) up or down without changing their size. >+ // Top' moves the boxes down, and 'bottom' moves them up. Since boxes are not split or stretched as a result of 'top' or 'bottom', the used values are always: top = -bottom. >+ // >+ // 1. If both are 'auto', their used values are both '0'. >+ // 2. If one of them is 'auto', it becomes the negative of the other. >+ // 3. If neither is 'auto', 'bottom' is ignored (i.e., the used value of 'bottom' will be minus the value of 'top'). >+ auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); >+ >+ auto& style = layoutBox.style(); >+ auto top = style.logicalTop(); >+ auto bottom = style.logicalBottom(); >+ >+ LayoutUnit computedTopValue; >+ if (top.isAuto() && bottom.isAuto()) { >+ // #1 >+ computedTopValue = displayBox.top(); >+ } else if (top.isAuto()) { >+ // #2 >+ computedTopValue = displayBox.top() - bottom.value(); >+ } else if (bottom.isAuto()) { >+ // #3 #4 >+ computedTopValue = displayBox.top() + top.value(); >+ } >+ >+ auto left = style.logicalLeft(); >+ auto right = style.logicalRight(); >+ >+ LayoutUnit computedLeftValue; >+ if (left.isAuto() && right.isAuto()) { >+ // #1 >+ computedLeftValue = displayBox.left(); >+ } else if (left.isAuto()) { >+ // #2 >+ computedLeftValue = displayBox.left() - right.value(); >+ } else if (right.isAuto()) { >+ // #3 >+ computedLeftValue = displayBox.left() + left.value(); >+ } else { >+ // #4 >+ // FIXME: take direction into account >+ computedLeftValue = displayBox.left() + left.value(); >+ } >+ >+ return { computedLeftValue, computedTopValue}; >+} >+ > } > } >
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 185936
:
341172
|
341188
|
341195