Changeset 267700 in webkit
- Timestamp:
- Sep 28, 2020, 8:00:14 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/layoutformattingcontext/float-with-clear-simple-expected.html (added)
-
LayoutTests/fast/layoutformattingcontext/float-with-clear-simple.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/layout/FormattingState.cpp (modified) (1 diff)
-
Source/WebCore/layout/floats/FloatingContext.cpp (modified) (4 diffs)
-
Source/WebCore/layout/floats/FloatingContext.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267696 r267700 1 2020-09-28 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][Floats] Add support for clear on float box 4 https://bugs.webkit.org/show_bug.cgi?id=217045 5 6 Reviewed by Antti Koivisto. 7 8 * fast/layoutformattingcontext/float-with-clear-simple-expected.html: Added. 9 * fast/layoutformattingcontext/float-with-clear-simple.html: Added. 10 1 11 2020-09-28 Angelos Oikonomopoulos <angelos@igalia.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r267699 r267700 1 2020-09-28 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][Floats] Add support for clear on float box 4 https://bugs.webkit.org/show_bug.cgi?id=217045 5 6 Reviewed by Antti Koivisto. 7 8 When the float box also has to clear other floats, we need to adjust the initial 9 vertical position from where we start searching for available space. 10 (This patch also fixes a previous find&replace renaming and addresses a post-landing comment.) 11 12 Test: fast/layoutformattingcontext/float-with-clear-simple.html 13 14 * layout/floats/FloatingContext.cpp: 15 (WebCore::Layout::FloatingContext::positionForFloat const): 16 (WebCore::Layout::FloatingContext::positionForNonFloatingFloatAvoider const): 17 (WebCore::Layout::FloatingContext::absoluteCoordinates const): 18 (WebCore::Layout::FloatingContext::absoluteBoxGeometryCoordinates const): Deleted. 19 * layout/floats/FloatingContext.h: 20 1 21 2020-09-28 Aditya Keerthi <akeerthi@apple.com> 2 22 -
trunk/Source/WebCore/layout/FormattingState.cpp
r267657 r267700 53 53 // Should never need to mutate a display box outside of the formatting context. 54 54 ASSERT(&layoutState().establishedFormattingState(layoutBox.formattingContextRoot()) == this); 55 // Anonymous text wrappers do not need display boxes.55 // Anonymous text wrappers do not need to compute box geometry. They initiate inline runs. 56 56 ASSERT(!layoutBox.isInlineTextBox()); 57 57 return layoutState().ensureGeometryForBox(layoutBox); -
trunk/Source/WebCore/layout/floats/FloatingContext.cpp
r267158 r267700 228 228 if (isEmpty()) { 229 229 auto& boxGeometry = formattingContext().geometryForBox(layoutBox); 230 231 230 auto alignWithContainingBlock = [&]() -> Position { 232 231 // If there is no floating to align with, push the box to the left/right edge of its containing block's content box. 233 232 if (layoutBox.isLeftFloatingPositioned()) 234 233 return { horizontalConstraints.logicalLeft + boxGeometry.marginStart() }; 235 236 234 return { horizontalConstraints.logicalRight() - boxGeometry.marginEnd() - boxGeometry.logicalWidth() }; 237 235 }; 238 239 236 // No float box on the context yet -> align it with the containing block's left/right edge. 240 237 return { alignWithContainingBlock(), boxGeometry.logicalTop() }; … … 243 240 // Find the top most position where the float box fits. 244 241 ASSERT(!isEmpty()); 245 auto previousFloatAbsoluteTop = floatingState().floats().last().rectWithMargin().top(); 246 auto absoluteBoxGeometryCoordinates = this->absoluteBoxGeometryCoordinates(layoutBox); 247 auto absoluteTopLeft = absoluteBoxGeometryCoordinates.topLeft; 248 // Incoming float cannot be placed higher than existing floats (margin box of the last float). 249 // Take the static position (where the box would go if it wasn't floating) and adjust it with the last float. 242 auto absoluteCoordinates = this->absoluteCoordinates(layoutBox); 243 auto absoluteTopLeft = absoluteCoordinates.topLeft; 244 auto verticalPositionCandidate = absoluteTopLeft.y(); 245 250 246 auto& boxGeometry = formattingContext().geometryForBox(layoutBox); 251 if (absoluteTopLeft.y() - boxGeometry.marginBefore() < previousFloatAbsoluteTop) 252 absoluteTopLeft.setY(previousFloatAbsoluteTop + boxGeometry.marginBefore()); 247 if (layoutBox.hasFloatClear()) { 248 // The vertical position candidate needs to clear the existing floats in this context. 249 auto floatBottom = [&]() -> Optional<PositionInContextRoot> { 250 switch (layoutBox.style().clear()) { 251 case Clear::Left: 252 return floatingState().leftBottom(root()); 253 case Clear::Right: 254 return floatingState().rightBottom(root()); 255 case Clear::Both: 256 return floatingState().bottom(root()); 257 default: 258 ASSERT_NOT_REACHED(); 259 } 260 return { }; 261 }; 262 if (auto bottomWithClear = floatBottom()) 263 verticalPositionCandidate = *bottomWithClear + boxGeometry.marginBefore(); 264 } else { 265 // Incoming float cannot be placed higher than existing floats (margin box of the last float). 266 // Take the static position (where the box would go if it wasn't floating) and adjust it with the last float. 267 auto previousFloatAbsoluteTop = floatingState().floats().last().rectWithMargin().top(); 268 if (verticalPositionCandidate - boxGeometry.marginBefore() < previousFloatAbsoluteTop) 269 verticalPositionCandidate = previousFloatAbsoluteTop + boxGeometry.marginBefore(); 270 } 271 absoluteTopLeft.setY(verticalPositionCandidate); 253 272 auto horizontalMargin = computedHorizontalMargin(layoutBox, horizontalConstraints.logicalWidth); 254 273 auto margins = Edges { { *horizontalMargin.start, *horizontalMargin.end }, { boxGeometry.marginBefore(), boxGeometry.marginAfter() } }; 255 auto floatBox = FloatAvoider { layoutBox, absoluteTopLeft, boxGeometry.logicalWidth(), margins, absolute BoxGeometryCoordinates.containingBlockContentBox };274 auto floatBox = FloatAvoider { layoutBox, absoluteTopLeft, boxGeometry.logicalWidth(), margins, absoluteCoordinates.containingBlockContentBox }; 256 275 findAvailablePosition(floatBox, m_floatingState.floats()); 257 // From formatting root coordinate system back to containing block's.258 auto containingBlockTopLeft = absolute BoxGeometryCoordinates.containingBlockTopLeft;276 // Convert box coordinates from formatting root back to containing block. 277 auto containingBlockTopLeft = absoluteCoordinates.containingBlockTopLeft; 259 278 return { floatBox.left() + margins.horizontal.left - containingBlockTopLeft.x(), floatBox.top() + margins.vertical.top - containingBlockTopLeft.y() }; 260 279 } … … 270 289 return formattingContext().geometryForBox(layoutBox).logicalTopLeft(); 271 290 272 auto absolute BoxGeometryCoordinates = this->absoluteBoxGeometryCoordinates(layoutBox);291 auto absoluteCoordinates = this->absoluteCoordinates(layoutBox); 273 292 auto& boxGeometry = formattingContext().geometryForBox(layoutBox); 274 293 auto horizontalMargin = computedHorizontalMargin(layoutBox, horizontalConstraints.logicalWidth); 275 294 auto margins = Edges { { *horizontalMargin.start, *horizontalMargin.end }, { boxGeometry.marginBefore(), boxGeometry.marginAfter() } }; 276 auto floatAvoider = FloatAvoider { layoutBox, absolute BoxGeometryCoordinates.topLeft, boxGeometry.logicalWidth(), margins, absoluteBoxGeometryCoordinates.containingBlockContentBox };295 auto floatAvoider = FloatAvoider { layoutBox, absoluteCoordinates.topLeft, boxGeometry.logicalWidth(), margins, absoluteCoordinates.containingBlockContentBox }; 277 296 findPositionForFormattingContextRoot(floatAvoider); 278 auto containingBlockTopLeft = absolute BoxGeometryCoordinates.containingBlockTopLeft;297 auto containingBlockTopLeft = absoluteCoordinates.containingBlockTopLeft; 279 298 return { floatAvoider.left() - containingBlockTopLeft.x(), floatAvoider.top() - containingBlockTopLeft.y() }; 280 299 } … … 456 475 } 457 476 458 FloatingContext::AbsoluteCoordinateValuesForFloatAvoider FloatingContext::absolute BoxGeometryCoordinates(const Box& floatAvoider) const477 FloatingContext::AbsoluteCoordinateValuesForFloatAvoider FloatingContext::absoluteCoordinates(const Box& floatAvoider) const 459 478 { 460 479 auto& containingBlock = floatAvoider.containingBlock(); -
trunk/Source/WebCore/layout/floats/FloatingContext.h
r267076 r267700 75 75 76 76 struct AbsoluteCoordinateValuesForFloatAvoider; 77 AbsoluteCoordinateValuesForFloatAvoider absolute BoxGeometryCoordinates(const Box&) const;77 AbsoluteCoordinateValuesForFloatAvoider absoluteCoordinates(const Box&) const; 78 78 LayoutPoint mapTopLeftToFloatingStateRoot(const Box&) const; 79 79 Point mapPointFromFormattingContextRootToFloatingStateRoot(Point) const;
Note:
See TracChangeset
for help on using the changeset viewer.