Changeset 249172 in webkit
- Timestamp:
- Aug 27, 2019, 2:24:40 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContextGeometry.cpp (modified) (3 diffs)
-
layout/blockformatting/BlockFormattingContext.h (modified) (1 diff)
-
layout/blockformatting/BlockFormattingContextGeometry.cpp (modified) (1 diff)
-
layout/tableformatting/TableFormattingContext.cpp (modified) (6 diffs)
-
layout/tableformatting/TableFormattingContext.h (modified) (1 diff)
-
layout/tableformatting/TableGrid.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249170 r249172 1 2019-08-27 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Align table formatting context code with the existing layout logic. 4 https://bugs.webkit.org/show_bug.cgi?id=201168 5 <rdar://problem/54732633> 6 7 Reviewed by Antti Koivisto. 8 9 Let's make the TFC go through the exisint shrink-to-fit computation. Tables behave slightly different from 10 other shrink-to-fit boxes as they are streched to their minimum width(MIN) even when 'width' is non-auto and computed to less than MIN. 11 12 * layout/FormattingContextGeometry.cpp: 13 (WebCore::Layout::contentHeightForFormattingContextRoot): 14 * layout/blockformatting/BlockFormattingContext.h: 15 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 16 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin): 17 * layout/tableformatting/TableFormattingContext.cpp: 18 (WebCore::Layout::TableFormattingContext::layout const): 19 (WebCore::Layout::TableFormattingContext::computedIntrinsicWidthConstraints const): 20 (WebCore::Layout::TableFormattingContext::computedTableWidth const): 21 (WebCore::Layout::TableFormattingContext::computeTableWidth const): Deleted. 22 (WebCore::Layout::TableFormattingContext::computeTableHeight const): Deleted. 23 (WebCore::Layout::TableFormattingContext::distributeAvailableHeight const): Deleted. 24 * layout/tableformatting/TableFormattingContext.h: 25 * layout/tableformatting/TableGrid.h: 26 1 27 2019-08-27 Simon Fraser <simon.fraser@apple.com> 2 28 -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r248262 r249172 32 32 #include "FormattingState.h" 33 33 #include "InlineFormattingState.h" 34 #include "TableFormattingState.h" 35 #include "TableGrid.h" 34 36 35 37 namespace WebCore { … … 102 104 // into account, e.g., floats inside absolutely positioned descendants or other floats are not. 103 105 if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild()) 104 return 0;106 return { }; 105 107 106 108 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); … … 122 124 bottom = lastDisplayBox.rectWithMargin().bottom(); 123 125 } 124 } 126 } else if (formattingRootContainer.establishesTableFormattingContext()) { 127 auto& rowList = downcast<TableFormattingState>(layoutState.establishedFormattingState(formattingRootContainer)).tableGrid().rows(); 128 ASSERT(!rowList.isEmpty()); 129 top += rowList.first().offset; 130 auto& lastRow = rowList.last(); 131 bottom += lastRow.offset + lastRow.height; 132 } else 133 ASSERT_NOT_REACHED(); 125 134 126 135 auto* formattingContextRoot = &layoutBox; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r248262 r249172 77 77 public: 78 78 static HeightAndMargin inFlowHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 79 static WidthAndMargin inFlowWidthAndMargin( constLayoutState&, const Box&, UsedHorizontalValues);79 static WidthAndMargin inFlowWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues); 80 80 81 81 static Point staticPosition(const LayoutState&, const Box&); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r248262 r249172 277 277 } 278 278 279 WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin( constLayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues)279 WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 280 280 { 281 281 ASSERT(layoutBox.isInFlow()); 282 282 283 if (!layoutBox.replaced()) 283 if (!layoutBox.replaced()) { 284 if (layoutBox.establishesTableFormattingContext()) { 285 // This is a special table "fit-content size" behavior handling. Not in the spec though. 286 // Table returns its final width as min/max. Use this final width value to computed horizontal margins etc. 287 usedValues.width = Geometry::shrinkToFitWidth(layoutState, layoutBox, usedValues); 288 } 284 289 return inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 290 } 285 291 return inFlowReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 286 292 } -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r248834 r249172 38 38 WTF_MAKE_ISO_ALLOCATED_IMPL(TableFormattingContext); 39 39 40 // https://www.w3.org/TR/css-tables-3/#table-layout-algorithm 40 41 TableFormattingContext::TableFormattingContext(const Box& formattingContextRoot, TableFormattingState& formattingState) 41 42 : FormattingContext(formattingContextRoot, formattingState) … … 45 46 void TableFormattingContext::layout() const 46 47 { 47 // https://www.w3.org/TR/css-tables-3/#table-layout-algorithm 48 // To layout a table, user agents must apply the following actions: 48 ASSERT(!formattingState().tableGrid().cells().isEmpty()); 49 } 50 51 FormattingContext::IntrinsicWidthConstraints TableFormattingContext::computedIntrinsicWidthConstraints() const 52 { 53 // Tables have a slighty different concept of shrink to fit. It's really only different with non-auto "width" values, where 54 // a generic shrink-to fit block level box like a float box would be just sized to the computed value of "width", tables 55 // can actually be streched way over. 49 56 50 57 // 1. Ensure each cell slot is occupied by at least one cell. … … 53 60 computePreferredWidthForColumns(); 54 61 // 3. Compute the width of the table. 55 computeTableWidth(); 56 // 4. Compute the height of the table. 57 computeTableHeight(); 58 // 5. Distribute the height of the table among rows. 59 distributeAvailableHeight(); 60 } 61 62 FormattingContext::IntrinsicWidthConstraints TableFormattingContext::computedIntrinsicWidthConstraints() const 63 { 64 return { }; 62 auto width = computedTableWidth(); 63 // This is the actual computed table width that we want to present as min/max width. 64 return { width, width }; 65 65 } 66 66 … … 121 121 } 122 122 123 void TableFormattingContext::computeTableWidth() const123 LayoutUnit TableFormattingContext::computedTableWidth() const 124 124 { 125 125 // Column and caption widths influence the final table width as follows: … … 165 165 } 166 166 167 auto& tableDisplayBox = layoutState().displayBoxForLayoutBox(tableWrapperBox); 168 tableDisplayBox.setContentBoxWidth(usedWidth); 167 return usedWidth; 169 168 } 170 169 … … 180 179 } 181 180 182 void TableFormattingContext::computeTableHeight() const183 {184 }185 186 void TableFormattingContext::distributeAvailableHeight() const187 {188 }189 190 181 } 191 182 } -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h
r248834 r249172 45 45 private: 46 46 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override; 47 LayoutUnit computedTableWidth() const; 47 48 48 49 void ensureTableGrid() const; 49 50 void computePreferredWidthForColumns() const; 50 void computeTableWidth() const;51 51 void distributeAvailableWidth(LayoutUnit extraHorizontalSpace) const; 52 void computeTableHeight() const;53 void distributeAvailableHeight() const;54 52 55 53 TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); } -
trunk/Source/WebCore/layout/tableformatting/TableGrid.h
r248834 r249172 102 102 103 103 struct Row { 104 LayoutUnit offset; 104 105 LayoutUnit height; 105 106 };
Note:
See TracChangeset
for help on using the changeset viewer.