WebKit Bugzilla
Attachment 348484 Details for
Bug 189145
: [LFC][Floating] Move containing block constraint logic from FloatAvoider to FloatingContext
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
Patch.txt (text/plain), 5.24 KB, created by
zalan
on 2018-08-29 21:47:21 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-08-29 21:47:21 PDT
Size:
5.24 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e6f86c7287d..55f699f1d04 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2018-08-29 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][Floating] Move containing block constraint logic from FloatAvoider to FloatingContext >+ https://bugs.webkit.org/show_bug.cgi?id=189145 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When the float avoider is constrained horizontally, simply align it with the left/right edge of its containing block (with the combination of the constraints) >+ and check the overflow as part of the FloatingContext::floatingPosition() logic. It simplifies the constraint logic/helps implementing the non-float avoider >+ case. >+ >+ * layout/floats/FloatAvoider.cpp: >+ (WebCore::Layout::FloatAvoider::setHorizontalConstraints): >+ (WebCore::Layout::FloatAvoider::overflowsContainingBlock const): >+ * layout/floats/FloatAvoider.h: >+ * layout/floats/FloatingContext.cpp: >+ (WebCore::Layout::FloatingContext::floatingPosition const): >+ > 2018-08-29 Zalan Bujtas <zalan@apple.com> > > [LFC][Floating] Use non-computed horizontal margins when intersecting floats with float avoiders. >diff --git a/Source/WebCore/layout/floats/FloatAvoider.cpp b/Source/WebCore/layout/floats/FloatAvoider.cpp >index af52d344685..e965df3a1f2 100644 >--- a/Source/WebCore/layout/floats/FloatAvoider.cpp >+++ b/Source/WebCore/layout/floats/FloatAvoider.cpp >@@ -59,13 +59,12 @@ void FloatAvoider::setHorizontalConstraints(HorizontalConstraints horizontalCons > // Horizontal position is constrained by the containing block's content box. > // Compute the horizontal position for the new floating by taking both the contining block and the current left/right floats into account. > auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft(); >- auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth(); >- // Align it with the containing block's left edge first. >- left = std::max(containingBlockContentBoxLeft + marginLeft(), left); >- // Make sure it does not overflow the containing block on the right. >- left = std::min(left, containingBlockContentBoxRight - marginBoxWidth() + marginLeft()); >+ if (isLeftAligned()) >+ return std::max(containingBlockContentBoxLeft + marginLeft(), left); > >- return left; >+ // Make sure it does not overflow the containing block on the right. >+ auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth(); >+ return std::min(left, containingBlockContentBoxRight - marginBoxWidth() + marginLeft()); > }; > > auto positionCandidate = horizontalPositionCandidate(horizontalConstraints); >@@ -104,6 +103,20 @@ PositionInContextRoot FloatAvoider::initialHorizontalPosition() const > return left; > } > >+bool FloatAvoider::overflowsContainingBlock() const >+{ >+ auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft(); >+ auto left = displayBox().left() - marginLeft(); >+ >+ if (containingBlockContentBoxLeft > left) >+ return true; >+ >+ auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth(); >+ auto right = displayBox().right() + marginRight(); >+ >+ return containingBlockContentBoxRight < right; >+} >+ > Display::Box::Rect FloatAvoider::rectInContainingBlock() const > { > // From formatting root coordinate system back to containing block's. >diff --git a/Source/WebCore/layout/floats/FloatAvoider.h b/Source/WebCore/layout/floats/FloatAvoider.h >index ce91d9c91c1..dcfb173f633 100644 >--- a/Source/WebCore/layout/floats/FloatAvoider.h >+++ b/Source/WebCore/layout/floats/FloatAvoider.h >@@ -56,6 +56,8 @@ public: > void setHorizontalConstraints(HorizontalConstraints); > void setVerticalConstraint(PositionInContextRoot); > >+ bool overflowsContainingBlock() const; >+ > void resetPosition(); > > protected: >diff --git a/Source/WebCore/layout/floats/FloatingContext.cpp b/Source/WebCore/layout/floats/FloatingContext.cpp >index f15d68dadfd..24b55325fb6 100644 >--- a/Source/WebCore/layout/floats/FloatingContext.cpp >+++ b/Source/WebCore/layout/floats/FloatingContext.cpp >@@ -230,8 +230,11 @@ void FloatingContext::floatingPosition(FloatAvoider& floatAvoider) const > // 2. or with the containing block's content box if there's no float to align with at this vertical position. > floatAvoider.setHorizontalConstraints(floats.horizontalConstraints()); > floatAvoider.setVerticalConstraint(floats.verticalConstraint()); >- // Check if the box fits at this position. >- if (!floats.intersects(floatAvoider.rect())) >+ >+ // Ensure that the float avoider >+ // 1. does not overflow its containing block with the current horiztonal constraints >+ // 2. avoids floats on both sides. >+ if (!floatAvoider.overflowsContainingBlock() && !floats.intersects(floatAvoider.rect())) > return; > > bottomMost = floats.bottom();
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
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189145
: 348484