Changeset 247198 in webkit
- Timestamp:
- Jul 7, 2019 6:47:26 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247195 r247198 1 2019-07-07 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Fix formatting context root for inflow positioned inline containers 4 https://bugs.webkit.org/show_bug.cgi?id=199551 5 <rdar://problem/52728868> 6 7 Reviewed by Antti Koivisto. 8 9 Relatively positioned (inflow) inline container lives in the formatting context where its parent lives unless 10 the parent establishes a formatting context. This is slightly different from the usual behavior which is containing block driven. 11 12 div id=outer style="position: absolute">><div id=inner><span style="position: relative">content</span></div></div> 13 14 While the relatively positioned inline container (span) is placed relative to its containing block "outer", it lives in the inline formatting context established by "inner". 15 16 * layout/FormattingContext.cpp: 17 (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): 18 * layout/layouttree/LayoutBox.cpp: 19 (WebCore::Layout::Box::formattingContextRoot const): 20 * layout/layouttree/LayoutBox.h: 21 * layout/layouttree/LayoutInlineContainer.cpp: 22 (WebCore::Layout::InlineContainer::formattingContextRoot const): 23 * layout/layouttree/LayoutInlineContainer.h: 24 1 25 2019-07-06 Simon Fraser <simon.fraser@apple.com> 2 26 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r246483 r247198 136 136 void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const 137 137 { 138 // Initial containing block by definition is a containing block.139 if (!layoutBox.isPositioned() && !layoutBox.isInitialContainingBlock())140 return;141 142 138 if (!is<Container>(layoutBox)) 143 139 return; -
trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp
r246479 r247198 175 175 const Container& Box::formattingContextRoot() const 176 176 { 177 for (auto* ancestor = containingBlock(); ancestor; ancestor = ancestor->containingBlock()) { 178 if (ancestor->establishesFormattingContext()) 179 return *ancestor; 180 } 181 182 // Initial containing block always establishes a formatting context. 183 if (isInitialContainingBlock()) 184 return downcast<Container>(*this); 185 186 RELEASE_ASSERT_NOT_REACHED(); 177 // We should never need to ask this question on the ICB. 178 ASSERT(!isInitialContainingBlock()); 179 // A box lives in the same formatting context as its containing block unless the containing block establishes a formatting context. 180 auto& containingBlock = *this->containingBlock(); 181 if (containingBlock.establishesFormattingContext()) 182 return containingBlock; 183 return containingBlock.formattingContextRoot(); 187 184 } 188 185 -
trunk/Source/WebCore/layout/layouttree/LayoutBox.h
r246479 r247198 98 98 99 99 const Container* containingBlock() const; 100 const Container& formattingContextRoot() const;100 virtual const Container& formattingContextRoot() const; 101 101 const Container& initialContainingBlock() const; 102 102 -
trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.cpp
r239427 r247198 55 55 } 56 56 57 const Container& InlineContainer::formattingContextRoot() const 58 { 59 // Relatively positioned (inflow) inline container lives in the formatting context where its parent lives unless 60 // the parent establishes a formatting context. This is slightly different from the usual behavior which is containing block driven. 61 // 62 // <div id=outer style="position: absolute">><div id=inner><span style="position: relative">content</span></div></div> 63 // While the relatively positioned inline container (span) is placed relative to its containing block "outer", it lives in the inline 64 // formatting context established by "inner". 65 auto& ancestor = isInFlowPositioned() ? *parent() : *containingBlock(); 66 if (ancestor.establishesFormattingContext()) 67 return ancestor; 68 return ancestor.formattingContextRoot(); 69 } 70 57 71 } 58 72 } -
trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h
r239427 r247198 43 43 44 44 bool establishesInlineFormattingContext() const final; 45 const Container& formattingContextRoot() const final; 45 46 }; 46 47
Note: See TracChangeset
for help on using the changeset viewer.