Changeset 249494 in webkit
- Timestamp:
- Sep 4, 2019 12:53:41 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249493 r249494 1 2019-09-04 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] FormattingContext::map* functions are too generic. 4 https://bugs.webkit.org/show_bug.cgi?id=201447 5 <rdar://problem/55005733> 6 7 Reviewed by Antti Koivisto. 8 9 We don't need such generic mapping functions yet. This patch is also in preparation for 10 asserting on formatting context escaping. 11 12 * layout/FormattingContext.cpp: 13 (WebCore::Layout::FormattingContext::mapTopToFormattingContextRoot const): 14 (WebCore::Layout::FormattingContext::mapLeftToFormattingContextRoot const): 15 (WebCore::Layout::FormattingContext::mapRightToFormattingContextRoot const): 16 (WebCore::Layout::FormattingContext::mapLeftToAncestor const): Deleted. 17 (WebCore::Layout::FormattingContext::mapRightToAncestor const): Deleted. 18 (WebCore::Layout::FormattingContext::mapBoxToAncestor const): Deleted. 19 (WebCore::Layout::FormattingContext::mapTopToAncestor const): Deleted. 20 (WebCore::Layout::FormattingContext::mapPointToAncestor const): Deleted. 21 (WebCore::Layout::FormattingContext::mapPointToDescendent const): Deleted. 22 * layout/FormattingContext.h: 23 * layout/blockformatting/BlockFormattingContext.cpp: 24 (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const): 25 * layout/floats/FloatingContext.cpp: 26 (WebCore::Layout::FloatingContext::positionForFloat const): 27 (WebCore::Layout::FloatingContext::positionForFormattingContextRoot const): 28 (WebCore::Layout::FloatingContext::verticalPositionWithClearance const): 29 (WebCore::Layout::FloatingContext::constraints const): 30 (WebCore::Layout::FloatingContext::append): 31 (WebCore::Layout::FloatingContext::absoluteDisplayBoxCoordinates const): 32 (WebCore::Layout::FloatingContext::mapToFloatingStateRoot const): 33 (WebCore::Layout::FloatingContext::mapTopToFloatingStateRoot const): 34 (WebCore::Layout::FloatingContext::mapPointFromFormattingContextRootToFloatingStateRoot const): 35 (WebCore::Layout::mapToFormattingContextRoot): Deleted. 36 * layout/floats/FloatingContext.h: 37 * page/FrameViewLayoutContext.cpp: 38 (WebCore::layoutUsingFormattingContext): 39 1 40 2019-09-04 Antoine Quint <graouts@apple.com> 2 41 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r249441 r249494 161 161 162 162 // FIXME: turn these into templates. 163 LayoutUnit FormattingContext::map LeftToAncestor(const Box& layoutBox, const Container& ancestor) const163 LayoutUnit FormattingContext::mapTopToFormattingContextRoot(const Box& layoutBox) const 164 164 { 165 165 ASSERT(layoutBox.containingBlock()); 166 return mapHorizontalPositionToAncestor(*this, displayBoxForLayoutBox(layoutBox).left(), *layoutBox.containingBlock(), ancestor); 167 } 168 169 LayoutUnit FormattingContext::mapRightToAncestor(const Box& layoutBox, const Container& ancestor) const 170 { 171 ASSERT(layoutBox.containingBlock()); 172 return mapHorizontalPositionToAncestor(*this, displayBoxForLayoutBox(layoutBox).right(), *layoutBox.containingBlock(), ancestor); 173 } 174 175 Display::Box FormattingContext::mapBoxToAncestor(const Box& layoutBox, const Container& ancestor) const 176 { 177 ASSERT(layoutBox.isContainingBlockDescendantOf(ancestor)); 178 auto& displayBox = displayBoxForLayoutBox(layoutBox); 179 auto topLeft = displayBox.topLeft(); 180 for (auto* containingBlock = layoutBox.containingBlock(); containingBlock && containingBlock != &ancestor; containingBlock = containingBlock->containingBlock()) 181 topLeft.moveBy(displayBoxForLayoutBox(*containingBlock).topLeft()); 182 183 auto mappedDisplayBox = Display::Box(displayBox); 184 mappedDisplayBox.setTopLeft(topLeft); 185 return mappedDisplayBox; 186 } 187 188 LayoutUnit FormattingContext::mapTopToAncestor(const Box& layoutBox, const Container& ancestor) const 189 { 190 ASSERT(layoutBox.isContainingBlockDescendantOf(ancestor)); 166 auto& formattingContextRoot = downcast<Container>(root()); 167 ASSERT(layoutBox.isContainingBlockDescendantOf(formattingContextRoot)); 191 168 auto top = displayBoxForLayoutBox(layoutBox).top(); 192 for (auto* container = layoutBox.containingBlock(); container && container != & ancestor; container = container->containingBlock())169 for (auto* container = layoutBox.containingBlock(); container && container != &formattingContextRoot; container = container->containingBlock()) 193 170 top += displayBoxForLayoutBox(*container).top(); 194 171 return top; 195 172 } 196 173 197 Point FormattingContext::mapPointToAncestor(Point position, const Container& from, const Container& to) const 198 { 199 if (&from == &to) 200 return position; 201 ASSERT(from.isContainingBlockDescendantOf(to)); 202 auto mappedPosition = position; 203 for (auto* container = &from; container && container != &to; container = container->containingBlock()) 204 mappedPosition.moveBy(displayBoxForLayoutBox(*container).topLeft()); 205 return mappedPosition; 206 } 207 208 Point FormattingContext::mapPointToDescendent(Point point, const Container& from, const Container& to) const 209 { 210 // "point" is in the coordinate system of the "from" container. 211 if (&from == &to) 212 return point; 213 ASSERT(to.isContainingBlockDescendantOf(from)); 214 for (auto* container = &to; container && container != &from; container = container->containingBlock()) 215 point.moveBy(displayBoxForLayoutBox(*container).topLeft()); 216 return point; 174 LayoutUnit FormattingContext::mapLeftToFormattingContextRoot(const Box& layoutBox) const 175 { 176 ASSERT(layoutBox.containingBlock()); 177 return mapHorizontalPositionToAncestor(*this, displayBoxForLayoutBox(layoutBox).left(), *layoutBox.containingBlock(), downcast<Container>(root())); 178 } 179 180 LayoutUnit FormattingContext::mapRightToFormattingContextRoot(const Box& layoutBox) const 181 { 182 ASSERT(layoutBox.containingBlock()); 183 return mapHorizontalPositionToAncestor(*this, displayBoxForLayoutBox(layoutBox).right(), *layoutBox.containingBlock(), downcast<Container>(root())); 217 184 } 218 185 -
trunk/Source/WebCore/layout/FormattingContext.h
r249441 r249494 62 62 virtual IntrinsicWidthConstraints computedIntrinsicWidthConstraints() = 0; 63 63 64 Display::Box mapBoxToAncestor(const Box&, const Container& ancestor) const; 65 LayoutUnit mapTopToAncestor(const Box&, const Container& ancestor) const; 66 LayoutUnit mapLeftToAncestor(const Box&, const Container& ancestor) const; 67 LayoutUnit mapRightToAncestor(const Box&, const Container& ancestor) const; 68 Point mapPointToAncestor(Point, const Container& from, const Container& to) const; 69 Point mapPointToDescendent(Point, const Container& from, const Container& to) const; 64 LayoutUnit mapTopToFormattingContextRoot(const Box&) const; 65 LayoutUnit mapLeftToFormattingContextRoot(const Box&) const; 66 LayoutUnit mapRightToFormattingContextRoot(const Box&) const; 70 67 71 68 bool isBlockFormattingContext() const { return root().establishesBlockFormattingContext(); } -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r249441 r249494 128 128 // Vertical static position is not computed yet, so let's just estimate it for now. 129 129 auto& formattingRoot = downcast<Container>(root()); 130 auto verticalPosition = mapTopTo Ancestor(layoutBox, formattingRoot);130 auto verticalPosition = mapTopToFormattingContextRoot(layoutBox); 131 131 auto constraints = floatingContext.constraints({ verticalPosition }); 132 132 if (!constraints.left && !constraints.right) … … 140 140 if (&containingBlock != &formattingRoot) { 141 141 // Move containing block left/right to the root's coordinate system. 142 containingBlockLeft = mapLeftTo Ancestor(containingBlock, formattingRoot);143 containingBlockRight = mapRightTo Ancestor(containingBlock, formattingRoot);142 containingBlockLeft = mapLeftToFormattingContextRoot(containingBlock); 143 containingBlockRight = mapRightToFormattingContextRoot(containingBlock); 144 144 } 145 145 auto containingBlockContentBoxLeft = containingBlockLeft + containingBlockDisplayBox.borderLeft() + containingBlockDisplayBox.paddingLeft().valueOr(0); -
trunk/Source/WebCore/layout/floats/FloatingContext.cpp
r249441 r249494 151 151 #endif 152 152 153 struct AbsoluteCoordinateValuesForFloatAvoider {153 struct FloatingContext::AbsoluteCoordinateValuesForFloatAvoider { 154 154 Display::Box displayBox; 155 155 LayoutPoint containingBlockTopLeft; 156 156 HorizontalEdges containingBlockContentBox; 157 157 }; 158 static AbsoluteCoordinateValuesForFloatAvoider mapToFormattingContextRoot(const Box& layoutBox, const Container& formattingContextRoot, const FormattingContext& formattingContext)159 {160 auto& containingBlock = *layoutBox.containingBlock();161 auto displayBox = formattingContext.mapBoxToAncestor(layoutBox, formattingContextRoot);162 163 if (&containingBlock == &formattingContextRoot) {164 auto containingBlockDisplayBox = formattingContext.displayBoxForLayoutBox(containingBlock);165 return { displayBox, { }, { containingBlockDisplayBox.contentBoxLeft(), containingBlockDisplayBox.contentBoxRight() } };166 }167 auto containingBlockAbsoluteDisplayBox = formattingContext.mapBoxToAncestor(containingBlock, formattingContextRoot);168 auto containingBlockLeft = containingBlockAbsoluteDisplayBox.left();169 return { displayBox, containingBlockAbsoluteDisplayBox.topLeft(), { containingBlockLeft + containingBlockAbsoluteDisplayBox.contentBoxLeft(), containingBlockLeft + containingBlockAbsoluteDisplayBox.contentBoxRight() } };170 }171 158 172 159 FloatingContext::FloatingContext(const FormattingContext& formattingContext, FloatingState& floatingState) … … 199 186 200 187 // Find the top most position where the float box fits. 201 auto absoluteDisplayBoxCoordinates = mapToFormattingContextRoot(layoutBox, downcast<Container>(m_floatingState.root()), formattingContext());188 auto absoluteDisplayBoxCoordinates = this->absoluteDisplayBoxCoordinates(layoutBox); 202 189 203 190 Optional<LayoutUnit> previousFloatAbsoluteTop; … … 219 206 return { }; 220 207 221 auto absoluteDisplayBoxCoordinates = mapToFormattingContextRoot(layoutBox, downcast<Container>(m_floatingState.root()), formattingContext());208 auto absoluteDisplayBoxCoordinates = this->absoluteDisplayBoxCoordinates(layoutBox); 222 209 auto floatAvoider = FloatAvoider { layoutBox, absoluteDisplayBoxCoordinates.displayBox, absoluteDisplayBoxCoordinates.containingBlockTopLeft, absoluteDisplayBoxCoordinates.containingBlockContentBox }; 223 210 findPositionForFormattingContextRoot(floatAvoider); … … 244 231 // 1. The amount necessary to place the border edge of the block even with the bottom outer edge of the lowest float that is to be cleared. 245 232 // 2. The amount necessary to place the top border edge of the block at its hypothetical position. 246 auto rootRelativeTop = formattingContext().mapTopToAncestor(layoutBox, downcast<Container>(m_floatingState.root()));233 auto rootRelativeTop = mapTopToFloatingStateRoot(layoutBox); 247 234 auto clearance = *floatBottom - rootRelativeTop; 248 235 if (clearance <= 0) … … 272 259 return { Position { rootRelativeTop }, clearance }; 273 260 274 auto containingBlockRootRelativeTop = formattingContext().mapTopToAncestor(*layoutBox.containingBlock(), downcast<Container>(m_floatingState.root()));261 auto containingBlockRootRelativeTop = mapTopToFloatingStateRoot(*layoutBox.containingBlock()); 275 262 return { Position { rootRelativeTop - containingBlockRootRelativeTop }, clearance }; 276 263 }; … … 303 290 304 291 if (coordinateMappingIsRequired) { 305 adjustedPosition = formattingContext().mapPointToAncestor(adjustedPosition, root(), downcast<Container>(floatingState().root()));292 adjustedPosition = mapPointFromFormattingContextRootToFloatingStateRoot(adjustedPosition); 306 293 adjustingDelta = { adjustedPosition.x, adjustedPosition.y - verticalPosition }; 307 294 } … … 343 330 void FloatingContext::append(const Box& floatBox) 344 331 { 345 floatingState().append(FloatingState::FloatItem { floatBox, formattingContext().mapBoxToAncestor(floatBox, downcast<Container>(floatingState().root())) });332 floatingState().append(FloatingState::FloatItem { floatBox, mapToFloatingStateRoot(floatBox) }); 346 333 } 347 334 … … 433 420 } 434 421 422 FloatingContext::AbsoluteCoordinateValuesForFloatAvoider FloatingContext::absoluteDisplayBoxCoordinates(const Box& floatAvoider) const 423 { 424 auto& containingBlock = *floatAvoider.containingBlock(); 425 auto displayBox = mapToFloatingStateRoot(floatAvoider); 426 427 if (&containingBlock == &floatingState().root()) { 428 auto containingBlockDisplayBox = formattingContext().displayBoxForLayoutBox(containingBlock); 429 return { displayBox, { }, { containingBlockDisplayBox.contentBoxLeft(), containingBlockDisplayBox.contentBoxRight() } }; 430 } 431 auto containingBlockAbsoluteDisplayBox = mapToFloatingStateRoot(containingBlock); 432 auto containingBlockLeft = containingBlockAbsoluteDisplayBox.left(); 433 return { displayBox, containingBlockAbsoluteDisplayBox.topLeft(), { containingBlockLeft + containingBlockAbsoluteDisplayBox.contentBoxLeft(), containingBlockLeft + containingBlockAbsoluteDisplayBox.contentBoxRight() } }; 434 } 435 436 Display::Box FloatingContext::mapToFloatingStateRoot(const Box& floatBox) const 437 { 438 auto& floatingStateRoot = floatingState().root(); 439 auto& displayBox = formattingContext().displayBoxForLayoutBox(floatBox); 440 auto topLeft = displayBox.topLeft(); 441 for (auto* containingBlock = floatBox.containingBlock(); containingBlock && containingBlock != &floatingStateRoot; containingBlock = containingBlock->containingBlock()) 442 topLeft.moveBy(formattingContext().displayBoxForLayoutBox(*containingBlock).topLeft()); 443 444 auto mappedDisplayBox = Display::Box(displayBox); 445 mappedDisplayBox.setTopLeft(topLeft); 446 return mappedDisplayBox; 447 } 448 449 LayoutUnit FloatingContext::mapTopToFloatingStateRoot(const Box& floatBox) const 450 { 451 auto& floatingStateRoot = floatingState().root(); 452 auto top = formattingContext().displayBoxForLayoutBox(floatBox).top(); 453 for (auto* container = floatBox.containingBlock(); container && container != &floatingStateRoot; container = container->containingBlock()) 454 top += formattingContext().displayBoxForLayoutBox(*container).top(); 455 return top; 456 } 457 458 Point FloatingContext::mapPointFromFormattingContextRootToFloatingStateRoot(Point position) const 459 { 460 auto& from = formattingContext().root(); 461 auto& to = floatingState().root(); 462 if (&from == &to) 463 return position; 464 auto mappedPosition = position; 465 for (auto* container = &from; container && container != &to; container = container->containingBlock()) 466 mappedPosition.moveBy(formattingContext().displayBoxForLayoutBox(*container).topLeft()); 467 return mappedPosition; 468 } 469 435 470 FloatPair::FloatPair(const FloatingState::FloatList& floats) 436 471 : m_floats(floats) -
trunk/Source/WebCore/layout/floats/FloatingContext.h
r249441 r249494 79 79 void findPositionForFormattingContextRoot(FloatAvoider&) const; 80 80 81 struct AbsoluteCoordinateValuesForFloatAvoider; 82 AbsoluteCoordinateValuesForFloatAvoider absoluteDisplayBoxCoordinates(const Box&) const; 83 Display::Box mapToFloatingStateRoot(const Box&) const; 84 LayoutUnit mapTopToFloatingStateRoot(const Box&) const; 85 Point mapPointFromFormattingContextRootToFloatingStateRoot(Point) const; 86 81 87 const FormattingContext& m_formattingContext; 82 88 FloatingState& m_floatingState;
Note: See TracChangeset
for help on using the changeset viewer.