Changeset 249177 in webkit
- Timestamp:
- Aug 27, 2019, 3:21:23 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
- 1 copied
-
ChangeLog (modified) (1 diff)
-
Sources.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
layout/FormattingContext.h (modified) (1 diff)
-
layout/FormattingContextGeometry.cpp (modified) (2 diffs)
-
layout/tableformatting/TableFormattingContext.cpp (modified) (2 diffs)
-
layout/tableformatting/TableFormattingContext.h (modified) (1 diff)
-
layout/tableformatting/TableFormattingContextGeometry.cpp (copied) (copied from trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h ) (1 diff)
-
layout/tableformatting/TableGrid.cpp (modified) (1 diff)
-
layout/tableformatting/TableGrid.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249175 r249177 1 2019-08-27 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Layout and position the cell boxes 4 https://bugs.webkit.org/show_bug.cgi?id=201192 5 <rdar://problem/54758638> 6 7 Reviewed by Antti Koivisto. 8 9 Add a very basic (and faily incomplete) table cell layout logic. This is mostly WIP. 10 11 * Sources.txt: 12 * WebCore.xcodeproj/project.pbxproj: 13 * layout/FormattingContext.h: 14 * layout/FormattingContextGeometry.cpp: 15 (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot): 16 (WebCore::Layout::contentHeightForFormattingContextRoot): Deleted. 17 * layout/tableformatting/TableFormattingContext.cpp: 18 (WebCore::Layout::TableFormattingContext::layout const): 19 (WebCore::Layout::TableFormattingContext::computedTableWidth const): 20 * layout/tableformatting/TableFormattingContext.h: 21 * layout/tableformatting/TableFormattingContextGeometry.cpp: Copied from Source/WebCore/layout/tableformatting/TableFormattingContext.h. 22 (WebCore::Layout::TableFormattingContext::Geometry::tableCellHeightAndMargin): 23 * layout/tableformatting/TableGrid.cpp: 24 (WebCore::Layout::TableGrid::Column::setLogicalLeft): 25 (WebCore::Layout::TableGrid::Column::logicalLeft const): 26 * layout/tableformatting/TableGrid.h: 27 (WebCore::Layout::TableGrid::Column::logicalRight const): 28 (WebCore::Layout::TableGrid::Row::setLogicalTop): 29 (WebCore::Layout::TableGrid::Row::logicalTop const): 30 (WebCore::Layout::TableGrid::Row::setLogicalHeight): 31 (WebCore::Layout::TableGrid::Row::logicalHeight const): 32 (WebCore::Layout::TableGrid::Row::logicalBottom const): 33 1 34 2019-08-27 Mark Lam <mark.lam@apple.com> 2 35 -
trunk/Source/WebCore/Sources.txt
r249084 r249177 1418 1418 layout/layouttree/LayoutTreeBuilder.cpp 1419 1419 layout/tableformatting/TableFormattingContext.cpp 1420 layout/tableformatting/TableFormattingContextGeometry.cpp 1420 1421 layout/tableformatting/TableFormattingState.cpp 1421 1422 layout/tableformatting/TableGrid.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r249084 r249177 5842 5842 11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderFullScreen.cpp; sourceTree = "<group>"; }; 5843 5843 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; }; 5844 11D19C2E23159BAE008F24D3 /* TableFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingContextGeometry.cpp; sourceTree = "<group>"; }; 5844 5845 11E067EB1E62461300162D16 /* SimpleLineLayoutCoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutCoverage.cpp; sourceTree = "<group>"; }; 5845 5846 11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutCoverage.h; sourceTree = "<group>"; }; … … 20454 20455 6FC5CA9422E3599400B13E11 /* TableFormattingContext.cpp */, 20455 20456 6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */, 20457 11D19C2E23159BAE008F24D3 /* TableFormattingContextGeometry.cpp */, 20456 20458 6FC5CA9222E3599300B13E11 /* TableFormattingState.cpp */, 20457 20459 6FC5CA9622E3599500B13E11 /* TableFormattingState.h */, … … 30605 30607 B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */, 30606 30608 AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */, 30609 E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */, 30607 30610 FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */, 30608 30611 FFDBC047183D27B700407109 /* LineWidth.h in Headers */, … … 31923 31926 57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */, 31924 31927 B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */, 31925 E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */,31926 31928 B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */, 31927 31929 9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */, -
trunk/Source/WebCore/layout/FormattingContext.h
r248834 r249177 113 113 static FormattingContext::IntrinsicWidthConstraints constrainByMinMaxWidth(const Box&, IntrinsicWidthConstraints); 114 114 115 static LayoutUnit contentHeightForFormattingContextRoot(const LayoutState&, const Box&); 116 115 117 protected: 116 118 enum class HeightType { Min, Max, Normal }; -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r249172 r249177 90 90 } 91 91 92 static LayoutUnitcontentHeightForFormattingContextRoot(const LayoutState& layoutState, const Box& layoutBox)92 LayoutUnit FormattingContext::Geometry::contentHeightForFormattingContextRoot(const LayoutState& layoutState, const Box& layoutBox) 93 93 { 94 94 ASSERT(isHeightAuto(layoutBox) && (layoutBox.establishesFormattingContext() || layoutBox.isDocumentBox())); … … 127 127 auto& rowList = downcast<TableFormattingState>(layoutState.establishedFormattingState(formattingRootContainer)).tableGrid().rows(); 128 128 ASSERT(!rowList.isEmpty()); 129 top += rowList.first(). offset;129 top += rowList.first().logicalTop(); 130 130 auto& lastRow = rowList.last(); 131 bottom += lastRow. offset + lastRow.height;131 bottom += lastRow.logicalBottom(); 132 132 } else 133 133 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r249172 r249177 46 46 void TableFormattingContext::layout() const 47 47 { 48 ASSERT(!formattingState().tableGrid().cells().isEmpty()); 48 auto& grid = formattingState().tableGrid(); 49 auto& cellList = grid.cells(); 50 ASSERT(!cellList.isEmpty()); 51 // Layout and position each table cell (and compute row height as well). 52 auto& layoutState = this->layoutState(); 53 auto& columnList = grid.columnsContext().columns(); 54 auto& rowList = grid.rows(); 55 for (auto& cell : cellList) { 56 auto& cellLayoutBox = cell->tableCellBox; 57 ASSERT(cellLayoutBox.establishesBlockFormattingContext()); 58 59 auto& cellDisplayBox = layoutState.displayBoxForLayoutBox(cellLayoutBox); 60 // FIXME: Add support for column and row spanning. 61 auto cellPosition = cell->position; 62 auto& row = rowList.at(cellPosition.y()); 63 auto& column = columnList.at(cellPosition.x()); 64 cellDisplayBox.setContentBoxWidth(column.logicalWidth()); 65 // FIXME: Do not use blanks. 66 cellDisplayBox.setBorder({ }); 67 cellDisplayBox.setPadding({ }); 68 cellDisplayBox.setHorizontalMargin({ }); 69 cellDisplayBox.setHorizontalComputedMargin({ }); 70 71 cellDisplayBox.setTopLeft({ column.logicalLeft(), row.logicalTop() }); 72 73 layoutState.createFormattingContext(cellLayoutBox)->layout(); 74 75 // FIXME: This requires a 2 pass layout. 76 auto heightAndMargin = Geometry::tableCellHeightAndMargin(layoutState, cellLayoutBox); 77 cellDisplayBox.setContentBoxHeight(heightAndMargin.height); 78 cellDisplayBox.setVerticalMargin({ heightAndMargin.nonCollapsedMargin, { } }); 79 80 row.setLogicalHeight(std::max(row.logicalHeight(), heightAndMargin.height)); 81 // FIXME: This also requires spanning support/check. 82 if (!cellPosition.x() && cellPosition.y()) { 83 auto& previousRow = rowList.at(cellPosition.y() - 1); 84 row.setLogicalTop(previousRow.logicalBottom()); 85 } 86 } 49 87 } 50 88 … … 164 202 } 165 203 } 166 204 // FIXME: This should also deal with collapsing borders etc. 205 LayoutUnit columnLogicalLeft; 206 auto& columns = columnsContext.columns(); 207 for (auto& column : columns) { 208 column.setLogicalLeft(columnLogicalLeft); 209 columnLogicalLeft += column.logicalWidth(); 210 } 167 211 return usedWidth; 168 212 } -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h
r249172 r249177 44 44 45 45 private: 46 class Geometry : public FormattingContext::Geometry { 47 public: 48 static HeightAndMargin tableCellHeightAndMargin(const LayoutState&, const Box&); 49 }; 50 46 51 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override; 47 52 LayoutUnit computedTableWidth() const; -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp
r249176 r249177 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "TableFormattingContext.h" 27 28 28 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 30 30 31 #include "FormattingContext.h" 31 #include " TableFormattingState.h"32 #include <wtf/IsoMalloc.h>32 #include "LayoutBox.h" 33 #include "LayoutState.h" 33 34 34 35 namespace WebCore { 35 36 namespace Layout { 36 37 37 // This class implements the layout logic for table formatting contexts. 38 // https://www.w3.org/TR/CSS22/tables.html 39 class TableFormattingContext : public FormattingContext { 40 WTF_MAKE_ISO_ALLOCATED(TableFormattingContext); 41 public: 42 TableFormattingContext(const Box& formattingContextRoot, TableFormattingState&); 43 void layout() const override; 38 HeightAndMargin TableFormattingContext::Geometry::tableCellHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox) 39 { 40 ASSERT(layoutBox.isInFlow()); 44 41 45 private: 46 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override;47 LayoutUnit computedTableWidth() const;42 auto height = computedHeightValue(layoutState, layoutBox, HeightType::Normal); 43 if (!height) 44 height = Geometry::contentHeightForFormattingContextRoot(layoutState, layoutBox); 48 45 49 void ensureTableGrid() const; 50 void computePreferredWidthForColumns() const; 51 void distributeAvailableWidth(LayoutUnit extraHorizontalSpace) const; 52 53 TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); } 54 }; 46 // FIXME: Compute vertical margin values. 47 return HeightAndMargin { *height, { } }; 48 } 55 49 56 50 } 57 51 } 52 58 53 #endif -
trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp
r248846 r249177 62 62 ASSERT(m_hasComputedWidth); 63 63 return m_computedLogicalWidth; 64 } 65 66 void TableGrid::Column::setLogicalLeft(LayoutUnit computedLogicalLeft) 67 { 68 #ifndef NDEBUG 69 m_hasComputedLeft = true; 70 #endif 71 m_computedLogicalLeft = computedLogicalLeft; 72 } 73 74 LayoutUnit TableGrid::Column::logicalLeft() const 75 { 76 ASSERT(m_hasComputedLeft); 77 return m_computedLogicalLeft; 64 78 } 65 79 -
trunk/Source/WebCore/layout/tableformatting/TableGrid.h
r249172 r249177 72 72 LayoutUnit logicalWidth() const; 73 73 74 void setLogicalLeft(LayoutUnit); 75 LayoutUnit logicalLeft() const; 76 77 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } 78 74 79 private: 75 80 friend class ColumnsContext; … … 78 83 FormattingContext::IntrinsicWidthConstraints m_widthConstraints; 79 84 LayoutUnit m_computedLogicalWidth; 85 LayoutUnit m_computedLogicalLeft; 80 86 #ifndef NDEBUG 81 87 bool m_hasWidthConstraints { false }; 82 88 bool m_hasComputedWidth { false }; 89 bool m_hasComputedLeft { false }; 83 90 #endif 84 91 }; … … 102 109 103 110 struct Row { 104 LayoutUnit offset; 105 LayoutUnit height; 111 public: 112 void setLogicalTop(LayoutUnit logicalTop) { m_logicalTop = logicalTop; } 113 LayoutUnit logicalTop() const { return m_logicalTop; } 114 115 void setLogicalHeight(LayoutUnit logicalHeight) { m_logicalHeight = logicalHeight; } 116 LayoutUnit logicalHeight() const { return m_logicalHeight; } 117 118 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } 119 120 private: 121 LayoutUnit m_logicalTop; 122 LayoutUnit m_logicalHeight; 106 123 }; 107 124 using RowList = WTF::Vector<Row>;
Note:
See TracChangeset
for help on using the changeset viewer.