Changeset 249439 in webkit
- Timestamp:
- Sep 3, 2019 12:53:49 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249438 r249439 1 2019-09-03 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] FloatingState should not need to query for display boxes. 4 https://bugs.webkit.org/show_bug.cgi?id=201408 5 <rdar://problem/54958348> 6 7 Reviewed by Antti Koivisto. 8 9 This is in preparation for transitioning the floating codebase to use the formatting context for 10 retrieving display boxes. 11 FloatingContext should be responsible for adding/removing the new/existing float boxes to the state. 12 13 * layout/blockformatting/BlockFormattingContext.cpp: 14 (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot): 15 * layout/floats/FloatingContext.cpp: 16 (WebCore::Layout::FloatingContext::append): 17 (WebCore::Layout::FloatingContext::remove): 18 * layout/floats/FloatingContext.h: 19 * layout/floats/FloatingState.cpp: 20 (WebCore::Layout::FloatingState::append): 21 (WebCore::Layout::belongsToThisFloatingContext): Deleted. 22 * layout/floats/FloatingState.h: 23 (WebCore::Layout::FloatingState::FloatItem::horizontalMargin const): 24 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 25 (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns const): 26 1 27 2019-09-03 Zalan Bujtas <zalan@apple.com> 2 28 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r249433 r249439 181 181 if (layoutBox.isFloatingPositioned()) { 182 182 computeFloatingPosition(floatingContext, layoutBox); 183 floatingContext. floatingState().append(layoutBox);183 floatingContext.append(layoutBox); 184 184 } else if (layoutBox.establishesBlockFormattingContext()) 185 185 computePositionToAvoidFloats(floatingContext, layoutBox); -
trunk/Source/WebCore/layout/floats/FloatingContext.cpp
r249437 r249439 342 342 } 343 343 344 void FloatingContext::append(const Box& floatBox) 345 { 346 floatingState().append(FloatingState::FloatItem { floatBox, FormattingContext::mapBoxToAncestor(layoutState(), floatBox, downcast<Container>(floatingState().root())) }); 347 } 348 349 void FloatingContext::remove(const Box& floatBox) 350 { 351 floatingState().remove(floatBox); 352 } 353 344 354 static FloatPair::LeftRightIndex findAvailablePosition(FloatAvoider& floatAvoider, const FloatingState::FloatList& floats) 345 355 { -
trunk/Source/WebCore/layout/floats/FloatingContext.h
r249433 r249439 67 67 }; 68 68 Constraints constraints(PositionInContextRoot verticalPosition) const; 69 void append(const Box&); 70 void remove(const Box&); 69 71 70 72 private: -
trunk/Source/WebCore/layout/floats/FloatingState.cpp
r249438 r249439 52 52 } 53 53 54 #ifndef NDEBUG55 static bool belongsToThisFloatingContext(const Box& layoutBox, const Box& floatingStateRoot)56 {57 auto& formattingContextRoot = layoutBox.formattingContextRoot();58 if (&formattingContextRoot == &floatingStateRoot)59 return true;60 61 // Maybe the layout box belongs to an inline formatting context that inherits the floating state from the parent (block) formatting context.62 if (!formattingContextRoot.establishesInlineFormattingContext())63 return false;64 65 return &formattingContextRoot.formattingContextRoot() == &floatingStateRoot;66 }67 #endif68 69 54 void FloatingState::remove(const Box& layoutBox) 70 55 { … … 78 63 } 79 64 80 void FloatingState::append( const Box& layoutBox)65 void FloatingState::append(FloatItem floatItem) 81 66 { 82 67 ASSERT(is<Container>(*m_formattingContextRoot)); 83 ASSERT(belongsToThisFloatingContext(layoutBox, *m_formattingContextRoot));84 ASSERT(is<Container>(*m_formattingContextRoot));85 68 86 auto newFloatItem = FloatItem { layoutBox, FormattingContext::mapBoxToAncestor(layoutState(), layoutBox, downcast<Container>(root()))};87 69 if (m_floats.isEmpty()) 88 return m_floats.append( newFloatItem);70 return m_floats.append(floatItem); 89 71 90 auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox); 91 auto isLeftPositioned = layoutBox.isLeftFloatingPositioned(); 72 auto isLeftPositioned = floatItem.isLeftPositioned(); 92 73 // When adding a new float item to the list, we have to ensure that it is definitely the left(right)-most item. 93 74 // Normally it is, but negative horizontal margins can push the float box beyond another float box. 94 75 // Float items in m_floats list should stay in horizontal position order (left/right edge) on the same vertical position. 95 auto hasNegativeHorizontalMargin = (isLeftPositioned && displayBox.marginStart() < 0) || (!isLeftPositioned && displayBox.marginEnd() < 0); 76 auto horizontalMargin = floatItem.horizontalMargin(); 77 auto hasNegativeHorizontalMargin = (isLeftPositioned && horizontalMargin.start < 0) || (!isLeftPositioned && horizontalMargin.end < 0); 96 78 if (!hasNegativeHorizontalMargin) 97 return m_floats.append( newFloatItem);79 return m_floats.append(floatItem); 98 80 99 81 for (int i = m_floats.size() - 1; i >= 0; --i) { … … 101 83 if (isLeftPositioned != floatItem.isLeftPositioned()) 102 84 continue; 103 if ( newFloatItem.rectWithMargin().top() < floatItem.rectWithMargin().bottom())85 if (floatItem.rectWithMargin().top() < floatItem.rectWithMargin().bottom()) 104 86 continue; 105 if ((isLeftPositioned && newFloatItem.rectWithMargin().right() >= floatItem.rectWithMargin().right())106 || (!isLeftPositioned && newFloatItem.rectWithMargin().left() <= floatItem.rectWithMargin().left()))107 return m_floats.insert(i + 1, newFloatItem);87 if ((isLeftPositioned && floatItem.rectWithMargin().right() >= floatItem.rectWithMargin().right()) 88 || (!isLeftPositioned && floatItem.rectWithMargin().left() <= floatItem.rectWithMargin().left())) 89 return m_floats.insert(i + 1, floatItem); 108 90 } 109 return m_floats.insert(0, newFloatItem);91 return m_floats.insert(0, floatItem); 110 92 } 111 93 -
trunk/Source/WebCore/layout/floats/FloatingState.h
r249438 r249439 39 39 namespace Layout { 40 40 41 class FloatingContext; 41 42 class FormattingState; 42 43 class LayoutState; … … 47 48 public: 48 49 static Ref<FloatingState> create(LayoutState& layoutState, const Box& formattingContextRoot) { return adoptRef(*new FloatingState(layoutState, formattingContextRoot)); } 49 50 void append(const Box& layoutBox);51 void remove(const Box& layoutBox);52 50 53 51 const Box& root() const { return *m_formattingContextRoot; } … … 68 66 69 67 Display::Rect rectWithMargin() const { return m_absoluteDisplayBox.rectWithMargin(); } 68 UsedHorizontalMargin horizontalMargin() const { return m_absoluteDisplayBox.horizontalMargin(); } 70 69 PositionInContextRoot bottom() const { return { m_absoluteDisplayBox.bottom() }; } 71 70 … … 81 80 friend class FloatingContext; 82 81 FloatingState(LayoutState&, const Box& formattingContextRoot); 82 83 void append(FloatItem); 84 void remove(const Box& layoutBox); 83 85 84 86 LayoutState& layoutState() const { return m_layoutState; } -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r249433 r249439 365 365 auto& formattingContext = this->formattingContext(); 366 366 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(formattingRoot())); 367 auto& floatingState = formattingState.floatingState(); 368 auto floatingContext = FloatingContext { formattingRoot(), floatingState }; 367 auto floatingContext = FloatingContext { formattingRoot(), formattingState.floatingState() }; 369 368 370 369 // Move floats to their final position. … … 377 376 // Float it. 378 377 displayBox.setTopLeft(floatingContext.positionForFloat(floatBox)); 379 floating State.append(floatBox);378 floatingContext.append(floatBox); 380 379 } 381 380
Note: See TracChangeset
for help on using the changeset viewer.