Changeset 279504 in webkit
- Timestamp:
- Jul 2, 2021, 8:28:05 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
layout/formattingContexts/table/TableFormattingContext.cpp (modified) (6 diffs)
-
layout/formattingContexts/table/TableFormattingGeometry.cpp (modified) (1 diff)
-
layout/formattingContexts/table/TableGrid.cpp (modified) (1 diff)
-
layout/formattingContexts/table/TableGrid.h (modified) (3 diffs)
-
layout/formattingContexts/table/TableLayout.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r279503 r279504 1 2021-07-02 Alan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] TableGrid::Column holds both the computed and the used width values 4 https://bugs.webkit.org/show_bug.cgi?id=227488 5 6 Reviewed by Antti Koivisto. 7 8 This patch cleans up TableGrid::Column interface to ensure we don't confused 9 the computed and the used widths for columns. 10 This is also in prepartion for adding mixed width type support. 11 12 * layout/formattingContexts/table/TableFormattingContext.cpp: 13 (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells): 14 (WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns): 15 (WebCore::Layout::TableFormattingContext::computeAndDistributeExtraSpace): 16 * layout/formattingContexts/table/TableFormattingGeometry.cpp: 17 (WebCore::Layout::TableFormattingGeometry::horizontalSpaceForCellContent const): 18 * layout/formattingContexts/table/TableGrid.cpp: 19 (WebCore::Layout::TableGrid::Column::setLogicalWidth): Deleted. 20 (WebCore::Layout::TableGrid::Column::logicalWidth const): Deleted. 21 (WebCore::Layout::TableGrid::Column::setLogicalLeft): Deleted. 22 (WebCore::Layout::TableGrid::Column::logicalLeft const): Deleted. 23 * layout/formattingContexts/table/TableGrid.h: 24 (WebCore::Layout::TableGrid::Column::usedLogicalRight const): 25 (WebCore::Layout::TableGrid::Column::computedLogicalWidth const): 26 (WebCore::Layout::TableGrid::Columns::logicalWidth const): 27 (WebCore::Layout::TableGrid::Column::setComputedLogicalWidth): 28 (WebCore::Layout::TableGrid::Column::setUsedLogicalWidth): 29 (WebCore::Layout::TableGrid::Column::usedLogicalWidth const): 30 (WebCore::Layout::TableGrid::Column::setUsedLogicalLeft): 31 (WebCore::Layout::TableGrid::Column::usedLogicalLeft const): 32 (WebCore::Layout::TableGrid::Column::logicalRight const): Deleted. 33 (WebCore::Layout::TableGrid::Column::fixedWidth const): Deleted. 34 (WebCore::Layout::TableGrid::Column::percent const): Deleted. 35 (WebCore::Layout::TableGrid::Column::setFixedWidth): Deleted. 36 (WebCore::Layout::TableGrid::Column::setPercent): Deleted. 37 * layout/formattingContexts/table/TableLayout.cpp: 38 (WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): 39 1 40 2021-07-02 Commit Queue <commit-queue@webkit.org> 2 41 -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp
r278869 r279504 102 102 cellBoxGeometry.setPadding(formattingGeometry.computedPadding(cellBox, availableHorizontalSpace)); 103 103 cellBoxGeometry.setLogicalTop(rowList[cell->startRow()].logicalTop() - sectionOffset); 104 cellBoxGeometry.setLogicalLeft(columnList[cell->startColumn()]. logicalLeft());104 cellBoxGeometry.setLogicalLeft(columnList[cell->startColumn()].usedLogicalLeft()); 105 105 cellBoxGeometry.setContentBoxWidth(formattingGeometry.horizontalSpaceForCellContent(*cell)); 106 106 … … 337 337 }(); 338 338 if (fixedWidth) 339 column.set FixedWidth(*fixedWidth);339 column.setComputedLogicalWidth({ *fixedWidth, LengthType::Fixed }); 340 340 } 341 341 … … 361 361 if (auto fixedWidth = formattingGeometry.fixedValue(cellBox.style().logicalWidth())) { 362 362 *fixedWidth += horizontalBorderAndPaddingWidth; 363 columnList[cellPosition.column].setFixedWidth(std::max(*fixedWidth, columnList[cellPosition.column].fixedWidth().value_or(0))); 363 auto& column = columnList[cellPosition.column]; 364 if (*fixedWidth > column.computedLogicalWidth().value()) 365 column.setComputedLogicalWidth({ *fixedWidth, LengthType::Fixed }); 364 366 } 365 367 // Collect the percent values so that we can compute the maximum values per column. … … 388 390 } 389 391 auto widthConstraints = slot.widthConstraints(); 390 if (auto column FixedWidth = columnList[columnIndex].fixedWidth())391 widthConstraints.maximum = std::max( *columnFixedWidth, widthConstraints.minimum);392 if (auto columnLogicalWidth = columnList[columnIndex].computedLogicalWidth(); columnLogicalWidth.isFixed()) 393 widthConstraints.maximum = std::max(LayoutUnit { columnLogicalWidth.value() }, widthConstraints.minimum); 392 394 393 395 columnIntrinsicWidths[columnIndex].minimum = std::max(widthConstraints.minimum, columnIntrinsicWidths[columnIndex].minimum); … … 443 445 } 444 446 ASSERT(*percent > 0); 445 columnList[columnIndex].setPercent(std::min(remainingPercent, *percent)); 446 percentMaximumWidth = std::max(percentMaximumWidth, LayoutUnit { columnIntrinsicWidths[columnIndex].maximum * 100.0f / *columnList[columnIndex].percent() }); 447 remainingPercent -= *columnList[columnIndex].percent(); 447 percent = std::min(*percent, remainingPercent); 448 columnList[columnIndex].setComputedLogicalWidth({ *percent, LengthType::Percent }); 449 percentMaximumWidth = std::max(percentMaximumWidth, LayoutUnit { columnIntrinsicWidths[columnIndex].maximum * 100.0f / *percent }); 450 remainingPercent -= *percent; 448 451 } 449 452 … … 473 476 for (size_t columnIndex = 0; columnIndex < columns.size(); ++columnIndex) { 474 477 auto& column = columns[columnIndex]; 475 column.set LogicalLeft(columnLogicalLeft);476 column.set LogicalWidth(distributedHorizontalSpaces[columnIndex]);478 column.setUsedLogicalLeft(columnLogicalLeft); 479 column.setUsedLogicalWidth(distributedHorizontalSpaces[columnIndex]); 477 480 columnLogicalLeft += distributedHorizontalSpaces[columnIndex] + grid.horizontalSpacing(); 478 481 } -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.cpp
r278537 r279504 153 153 auto logicalWidth = LayoutUnit { }; 154 154 for (auto columnIndex = cell.startColumn(); columnIndex < cell.endColumn(); ++columnIndex) 155 logicalWidth += columnList.at(columnIndex). logicalWidth();155 logicalWidth += columnList.at(columnIndex).usedLogicalWidth(); 156 156 // No column spacing when spanning. 157 157 logicalWidth += (cell.columnSpan() - 1) * grid.horizontalSpacing(); -
trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp
r278537 r279504 39 39 : m_layoutBox(makeWeakPtr(columnBox)) 40 40 { 41 }42 43 void TableGrid::Column::setLogicalWidth(LayoutUnit computedLogicalWidth)44 {45 #if ASSERT_ENABLED46 m_hasComputedWidth = true;47 #endif48 m_computedLogicalWidth = computedLogicalWidth;49 }50 51 LayoutUnit TableGrid::Column::logicalWidth() const52 {53 ASSERT(m_hasComputedWidth);54 return m_computedLogicalWidth;55 }56 57 void TableGrid::Column::setLogicalLeft(LayoutUnit computedLogicalLeft)58 {59 #if ASSERT_ENABLED60 m_hasComputedLeft = true;61 #endif62 m_computedLogicalLeft = computedLogicalLeft;63 }64 65 LayoutUnit TableGrid::Column::logicalLeft() const66 {67 ASSERT(m_hasComputedLeft);68 return m_computedLogicalLeft;69 41 } 70 42 -
trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h
r278605 r279504 68 68 Column(const ContainerBox*); 69 69 70 void setLogicalLeft(LayoutUnit); 71 LayoutUnit logicalLeft() const; 72 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } 73 void setLogicalWidth(LayoutUnit); 74 LayoutUnit logicalWidth() const; 75 76 void setFixedWidth(LayoutUnit fixedValue); 77 std::optional<LayoutUnit> fixedWidth() const { return m_fixedWidth; } 78 79 void setPercent(float); 80 std::optional<float> percent() const { return m_percent; } 70 void setUsedLogicalLeft(LayoutUnit); 71 LayoutUnit usedLogicalLeft() const; 72 LayoutUnit usedLogicalRight() const { return usedLogicalLeft() + usedLogicalWidth(); } 73 void setUsedLogicalWidth(LayoutUnit); 74 LayoutUnit usedLogicalWidth() const; 75 76 void setComputedLogicalWidth(Length&&); 77 const Length& computedLogicalWidth() const { return m_computedLogicalWidth; } 81 78 82 79 const ContainerBox* box() const { return m_layoutBox.get(); } 83 80 84 81 private: 85 LayoutUnit m_computedLogicalWidth; 86 LayoutUnit m_computedLogicalLeft; 87 std::optional<LayoutUnit> m_fixedWidth; 88 std::optional<float> m_percent; 82 LayoutUnit m_usedLogicalWidth; 83 LayoutUnit m_usedLogicalLeft; 84 Length m_computedLogicalWidth; 89 85 WeakPtr<const ContainerBox> m_layoutBox; 90 86 91 87 #if ASSERT_ENABLED 92 bool m_has ComputedWidth { false };93 bool m_has ComputedLeft { false };88 bool m_hasUsedWidth { false }; 89 bool m_hasUsedLeft { false }; 94 90 #endif 95 91 }; … … 105 101 void addAnonymousColumn(); 106 102 107 LayoutUnit logicalWidth() const { return m_columnList.last(). logicalRight() - m_columnList.first().logicalLeft(); }103 LayoutUnit logicalWidth() const { return m_columnList.last().usedLogicalRight() - m_columnList.first().usedLogicalLeft(); } 108 104 109 105 private: … … 235 231 }; 236 232 237 238 inline void TableGrid::Column::setFixedWidth(LayoutUnit fixedValue) 239 { 240 ASSERT(!m_percent); 241 m_fixedWidth = fixedValue; 242 } 243 244 inline void TableGrid::Column::setPercent(float percent) 245 { 246 ASSERT(!m_fixedWidth); 247 m_percent = percent; 248 } 249 250 } 251 } 252 253 #endif 233 inline void TableGrid::Column::setComputedLogicalWidth(Length&& computedLogicalWidth) 234 { 235 ASSERT(computedLogicalWidth.type() == LengthType::Fixed || computedLogicalWidth.type() == LengthType::Percent || computedLogicalWidth.type() == LengthType::Relative); 236 m_computedLogicalWidth = WTFMove(computedLogicalWidth); 237 } 238 239 inline void TableGrid::Column::setUsedLogicalWidth(LayoutUnit usedLogicalWidth) 240 { 241 #if ASSERT_ENABLED 242 m_hasUsedWidth = true; 243 #endif 244 m_usedLogicalWidth = usedLogicalWidth; 245 } 246 247 inline LayoutUnit TableGrid::Column::usedLogicalWidth() const 248 { 249 ASSERT(m_hasUsedWidth); 250 return m_usedLogicalWidth; 251 } 252 253 inline void TableGrid::Column::setUsedLogicalLeft(LayoutUnit usedLogicalLeft) 254 { 255 #if ASSERT_ENABLED 256 m_hasUsedLeft = true; 257 #endif 258 m_usedLogicalLeft = usedLogicalLeft; 259 } 260 261 inline LayoutUnit TableGrid::Column::usedLogicalLeft() const 262 { 263 ASSERT(m_hasUsedLeft); 264 return m_usedLogicalLeft; 265 } 266 267 } 268 } 269 270 #endif -
trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp
r279318 r279504 295 295 auto columnWidth = std::optional<float> { }; 296 296 auto type = GridSpace::Type::Auto; 297 if (auto fixedWidth = column.fixedWidth()) { 298 columnWidth = *fixedWidth; 297 298 auto& computedLogicalWidth = column.computedLogicalWidth(); 299 switch (computedLogicalWidth.type()) { 300 case LengthType::Fixed: 301 columnWidth = computedLogicalWidth.value(); 299 302 type = GridSpace::Type::Fixed; 300 } else if (auto percent = column.percent()) { 301 columnWidth = *percent * availableHorizontalSpace / 100.0f; 303 break; 304 case LengthType::Percent: 305 columnWidth = computedLogicalWidth.value() * availableHorizontalSpace / 100.0f; 302 306 type = GridSpace::Type::Percent; 307 break; 308 case LengthType::Relative: 309 ASSERT_NOT_IMPLEMENTED_YET(); 310 break; 311 default: 312 break; 303 313 } 304 314
Note:
See TracChangeset
for help on using the changeset viewer.