OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
10 * | 10 * |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 m_collapsedBordersValid(false), | 60 m_collapsedBordersValid(false), |
61 m_hasColElements(false), | 61 m_hasColElements(false), |
62 m_needsSectionRecalc(false), | 62 m_needsSectionRecalc(false), |
63 m_columnLogicalWidthChanged(false), | 63 m_columnLogicalWidthChanged(false), |
64 m_columnLayoutObjectsValid(false), | 64 m_columnLayoutObjectsValid(false), |
65 m_noCellColspanAtLeast(0), | 65 m_noCellColspanAtLeast(0), |
66 m_hSpacing(0), | 66 m_hSpacing(0), |
67 m_vSpacing(0), | 67 m_vSpacing(0), |
68 m_borderStart(0), | 68 m_borderStart(0), |
69 m_borderEnd(0) { | 69 m_borderEnd(0) { |
70 ASSERT(!childrenInline()); | 70 DCHECK(!childrenInline()); |
71 m_effectiveColumnPositions.fill(0, 1); | 71 m_effectiveColumnPositions.fill(0, 1); |
72 } | 72 } |
73 | 73 |
74 LayoutTable::~LayoutTable() {} | 74 LayoutTable::~LayoutTable() {} |
75 | 75 |
76 void LayoutTable::styleDidChange(StyleDifference diff, | 76 void LayoutTable::styleDidChange(StyleDifference diff, |
77 const ComputedStyle* oldStyle) { | 77 const ComputedStyle* oldStyle) { |
78 LayoutBlock::styleDidChange(diff, oldStyle); | 78 LayoutBlock::styleDidChange(diff, oldStyle); |
79 | 79 |
80 bool oldFixedTableLayout = oldStyle ? oldStyle->isFixedTableLayout() : false; | 80 bool oldFixedTableLayout = oldStyle ? oldStyle->isFixedTableLayout() : false; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 needsTableSection(beforeChild)) | 208 needsTableSection(beforeChild)) |
209 beforeChild = 0; | 209 beforeChild = 0; |
210 | 210 |
211 LayoutTableSection* section = | 211 LayoutTableSection* section = |
212 LayoutTableSection::createAnonymousWithParent(this); | 212 LayoutTableSection::createAnonymousWithParent(this); |
213 addChild(section, beforeChild); | 213 addChild(section, beforeChild); |
214 section->addChild(child); | 214 section->addChild(child); |
215 } | 215 } |
216 | 216 |
217 void LayoutTable::addCaption(const LayoutTableCaption* caption) { | 217 void LayoutTable::addCaption(const LayoutTableCaption* caption) { |
218 ASSERT(m_captions.find(caption) == kNotFound); | 218 DCHECK_EQ(m_captions.find(caption), kNotFound); |
219 m_captions.push_back(const_cast<LayoutTableCaption*>(caption)); | 219 m_captions.push_back(const_cast<LayoutTableCaption*>(caption)); |
220 } | 220 } |
221 | 221 |
222 void LayoutTable::removeCaption(const LayoutTableCaption* oldCaption) { | 222 void LayoutTable::removeCaption(const LayoutTableCaption* oldCaption) { |
223 size_t index = m_captions.find(oldCaption); | 223 size_t index = m_captions.find(oldCaption); |
224 ASSERT(index != kNotFound); | 224 DCHECK_NE(index, kNotFound); |
225 if (index == kNotFound) | 225 if (index == kNotFound) |
226 return; | 226 return; |
227 | 227 |
228 m_captions.erase(index); | 228 m_captions.erase(index); |
229 } | 229 } |
230 | 230 |
231 void LayoutTable::invalidateCachedColumns() { | 231 void LayoutTable::invalidateCachedColumns() { |
232 m_columnLayoutObjectsValid = false; | 232 m_columnLayoutObjectsValid = false; |
233 m_columnLayoutObjects.resize(0); | 233 m_columnLayoutObjects.resize(0); |
234 } | 234 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 marginValues.m_end, style()->marginStart(), | 347 marginValues.m_end, style()->marginStart(), |
348 style()->marginEnd()); | 348 style()->marginEnd()); |
349 setMarginStart(marginValues.m_start); | 349 setMarginStart(marginValues.m_start); |
350 setMarginEnd(marginValues.m_end); | 350 setMarginEnd(marginValues.m_end); |
351 | 351 |
352 // We should NEVER shrink the table below the min-content logical width, or | 352 // We should NEVER shrink the table below the min-content logical width, or |
353 // else the table can't accommodate its own content which doesn't match CSS | 353 // else the table can't accommodate its own content which doesn't match CSS |
354 // nor what authors expect. | 354 // nor what authors expect. |
355 // FIXME: When we convert to sub-pixel layout for tables we can remove the int | 355 // FIXME: When we convert to sub-pixel layout for tables we can remove the int |
356 // conversion. http://crbug.com/241198 | 356 // conversion. http://crbug.com/241198 |
357 ASSERT(logicalWidth().floor() >= minPreferredLogicalWidth().floor()); | 357 DCHECK_GE(logicalWidth().floor(), minPreferredLogicalWidth().floor()); |
358 } | 358 } |
359 | 359 |
360 // This method takes a ComputedStyle's logical width, min-width, or max-width | 360 // This method takes a ComputedStyle's logical width, min-width, or max-width |
361 // length and computes its actual value. | 361 // length and computes its actual value. |
362 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth( | 362 LayoutUnit LayoutTable::convertStyleLogicalWidthToComputedWidth( |
363 const Length& styleLogicalWidth, | 363 const Length& styleLogicalWidth, |
364 LayoutUnit availableWidth) const { | 364 LayoutUnit availableWidth) const { |
365 if (styleLogicalWidth.isIntrinsic()) | 365 if (styleLogicalWidth.isIntrinsic()) |
366 return computeIntrinsicLogicalWidthUsing( | 366 return computeIntrinsicLogicalWidthUsing( |
367 styleLogicalWidth, availableWidth, | 367 styleLogicalWidth, availableWidth, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // FIXME: Distribute the extra logical height between all table sections | 502 // FIXME: Distribute the extra logical height between all table sections |
503 // instead of giving it all to the first one. | 503 // instead of giving it all to the first one. |
504 if (LayoutTableSection* section = firstBody()) | 504 if (LayoutTableSection* section = firstBody()) |
505 extraLogicalHeight -= | 505 extraLogicalHeight -= |
506 section->distributeExtraLogicalHeightToRows(extraLogicalHeight); | 506 section->distributeExtraLogicalHeightToRows(extraLogicalHeight); |
507 | 507 |
508 // crbug.com/690087: We really would like to enable this ASSERT to ensure that | 508 // crbug.com/690087: We really would like to enable this ASSERT to ensure that |
509 // all the extra space has been distributed. | 509 // all the extra space has been distributed. |
510 // However our current distribution algorithm does not round properly and thus | 510 // However our current distribution algorithm does not round properly and thus |
511 // we can have some remaining height. | 511 // we can have some remaining height. |
512 // ASSERT(!topSection() || !extraLogicalHeight); | 512 // DCHECK(!topSection() || !extraLogicalHeight); |
513 } | 513 } |
514 | 514 |
515 void LayoutTable::simplifiedNormalFlowLayout() { | 515 void LayoutTable::simplifiedNormalFlowLayout() { |
516 // FIXME: We should walk through the items in the tree in tree order to do the | 516 // FIXME: We should walk through the items in the tree in tree order to do the |
517 // layout here instead of walking through individual parts of the tree. | 517 // layout here instead of walking through individual parts of the tree. |
518 // crbug.com/442737 | 518 // crbug.com/442737 |
519 for (auto& caption : m_captions) | 519 for (auto& caption : m_captions) |
520 caption->layoutIfNeeded(); | 520 caption->layoutIfNeeded(); |
521 | 521 |
522 for (LayoutTableSection* section = topSection(); section; | 522 for (LayoutTableSection* section = topSection(); section; |
523 section = sectionBelow(section)) { | 523 section = sectionBelow(section)) { |
524 section->layoutIfNeeded(); | 524 section->layoutIfNeeded(); |
525 section->layoutRows(); | 525 section->layoutRows(); |
526 section->computeOverflowFromCells(); | 526 section->computeOverflowFromCells(); |
527 section->updateLayerTransformAfterLayout(); | 527 section->updateLayerTransformAfterLayout(); |
528 section->addVisualEffectOverflow(); | 528 section->addVisualEffectOverflow(); |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 bool LayoutTable::recalcChildOverflowAfterStyleChange() { | 532 bool LayoutTable::recalcChildOverflowAfterStyleChange() { |
533 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | 533 DCHECK(childNeedsOverflowRecalcAfterStyleChange()); |
534 clearChildNeedsOverflowRecalcAfterStyleChange(); | 534 clearChildNeedsOverflowRecalcAfterStyleChange(); |
535 | 535 |
536 // If the table sections we keep pointers to have gone away then the table | 536 // If the table sections we keep pointers to have gone away then the table |
537 // will be rebuilt and overflow will get recalculated anyway so return early. | 537 // will be rebuilt and overflow will get recalculated anyway so return early. |
538 if (needsSectionRecalc()) | 538 if (needsSectionRecalc()) |
539 return false; | 539 return false; |
540 | 540 |
541 bool childrenOverflowChanged = false; | 541 bool childrenOverflowChanged = false; |
542 for (LayoutTableSection* section = topSection(); section; | 542 for (LayoutTableSection* section = topSection(); section; |
543 section = sectionBelow(section)) { | 543 section = sectionBelow(section)) { |
544 if (!section->childNeedsOverflowRecalcAfterStyleChange()) | 544 if (!section->childNeedsOverflowRecalcAfterStyleChange()) |
545 continue; | 545 continue; |
546 childrenOverflowChanged = section->recalcChildOverflowAfterStyleChange() || | 546 childrenOverflowChanged = section->recalcChildOverflowAfterStyleChange() || |
547 childrenOverflowChanged; | 547 childrenOverflowChanged; |
548 } | 548 } |
549 return recalcPositionedDescendantsOverflowAfterStyleChange() || | 549 return recalcPositionedDescendantsOverflowAfterStyleChange() || |
550 childrenOverflowChanged; | 550 childrenOverflowChanged; |
551 } | 551 } |
552 | 552 |
553 void LayoutTable::layout() { | 553 void LayoutTable::layout() { |
554 ASSERT(needsLayout()); | 554 DCHECK(needsLayout()); |
555 LayoutAnalyzer::Scope analyzer(*this); | 555 LayoutAnalyzer::Scope analyzer(*this); |
556 | 556 |
557 if (simplifiedLayout()) | 557 if (simplifiedLayout()) |
558 return; | 558 return; |
559 | 559 |
560 // Note: LayoutTable is handled differently than other LayoutBlocks and the | 560 // Note: LayoutTable is handled differently than other LayoutBlocks and the |
561 // LayoutScope | 561 // LayoutScope |
562 // must be created before the table begins laying out. | 562 // must be created before the table begins laying out. |
563 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); | 563 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); |
564 | 564 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 m_collapsedBordersValid = true; | 782 m_collapsedBordersValid = true; |
783 m_collapsedBorders.clear(); | 783 m_collapsedBorders.clear(); |
784 for (LayoutObject* section = firstChild(); section; | 784 for (LayoutObject* section = firstChild(); section; |
785 section = section->nextSibling()) { | 785 section = section->nextSibling()) { |
786 if (!section->isTableSection()) | 786 if (!section->isTableSection()) |
787 continue; | 787 continue; |
788 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; | 788 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; |
789 row = row->nextRow()) { | 789 row = row->nextRow()) { |
790 for (LayoutTableCell* cell = row->firstCell(); cell; | 790 for (LayoutTableCell* cell = row->firstCell(); cell; |
791 cell = cell->nextCell()) { | 791 cell = cell->nextCell()) { |
792 ASSERT(cell->table() == this); | 792 DCHECK_EQ(cell->table(), this); |
793 cell->collectBorderValues(m_collapsedBorders); | 793 cell->collectBorderValues(m_collapsedBorders); |
794 } | 794 } |
795 } | 795 } |
796 } | 796 } |
797 LayoutTableCell::sortBorderValues(m_collapsedBorders); | 797 LayoutTableCell::sortBorderValues(m_collapsedBorders); |
798 } | 798 } |
799 | 799 |
800 void LayoutTable::addOverflowFromChildren() { | 800 void LayoutTable::addOverflowFromChildren() { |
801 // Add overflow from borders. | 801 // Add overflow from borders. |
802 // Technically it's odd that we are incorporating the borders into layout | 802 // Technically it's odd that we are incorporating the borders into layout |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 // FIXME: Restructure the table layout code so that we can make this method | 889 // FIXME: Restructure the table layout code so that we can make this method |
890 // const. | 890 // const. |
891 const_cast<LayoutTable*>(this)->m_tableLayout->computeIntrinsicLogicalWidths( | 891 const_cast<LayoutTable*>(this)->m_tableLayout->computeIntrinsicLogicalWidths( |
892 minWidth, maxWidth); | 892 minWidth, maxWidth); |
893 | 893 |
894 // FIXME: We should include captions widths here like we do in | 894 // FIXME: We should include captions widths here like we do in |
895 // computePreferredLogicalWidths. | 895 // computePreferredLogicalWidths. |
896 } | 896 } |
897 | 897 |
898 void LayoutTable::computePreferredLogicalWidths() { | 898 void LayoutTable::computePreferredLogicalWidths() { |
899 ASSERT(preferredLogicalWidthsDirty()); | 899 DCHECK(preferredLogicalWidthsDirty()); |
900 | 900 |
901 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, | 901 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, |
902 m_maxPreferredLogicalWidth); | 902 m_maxPreferredLogicalWidth); |
903 | 903 |
904 int bordersPaddingAndSpacing = | 904 int bordersPaddingAndSpacing = |
905 bordersPaddingAndSpacingInRowDirection().toInt(); | 905 bordersPaddingAndSpacingInRowDirection().toInt(); |
906 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; | 906 m_minPreferredLogicalWidth += bordersPaddingAndSpacing; |
907 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; | 907 m_maxPreferredLogicalWidth += bordersPaddingAndSpacing; |
908 | 908 |
909 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, | 909 m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 | 946 |
947 LayoutTableSection* LayoutTable::topNonEmptySection() const { | 947 LayoutTableSection* LayoutTable::topNonEmptySection() const { |
948 LayoutTableSection* section = topSection(); | 948 LayoutTableSection* section = topSection(); |
949 if (section && !section->numRows()) | 949 if (section && !section->numRows()) |
950 section = sectionBelow(section, SkipEmptySections); | 950 section = sectionBelow(section, SkipEmptySections); |
951 return section; | 951 return section; |
952 } | 952 } |
953 | 953 |
954 void LayoutTable::splitEffectiveColumn(unsigned index, unsigned firstSpan) { | 954 void LayoutTable::splitEffectiveColumn(unsigned index, unsigned firstSpan) { |
955 // We split the column at |index|, taking |firstSpan| cells from the span. | 955 // We split the column at |index|, taking |firstSpan| cells from the span. |
956 ASSERT(m_effectiveColumns[index].span > firstSpan); | 956 DCHECK_GT(m_effectiveColumns[index].span, firstSpan); |
957 m_effectiveColumns.insert(index, firstSpan); | 957 m_effectiveColumns.insert(index, firstSpan); |
958 m_effectiveColumns[index + 1].span -= firstSpan; | 958 m_effectiveColumns[index + 1].span -= firstSpan; |
959 | 959 |
960 // Propagate the change in our columns representation to the sections that | 960 // Propagate the change in our columns representation to the sections that |
961 // don't need cell recalc. If they do, they will be synced up directly with | 961 // don't need cell recalc. If they do, they will be synced up directly with |
962 // m_columns later. | 962 // m_columns later. |
963 for (LayoutObject* child = firstChild(); child; | 963 for (LayoutObject* child = firstChild(); child; |
964 child = child->nextSibling()) { | 964 child = child->nextSibling()) { |
965 if (!child->isTableSection()) | 965 if (!child->isTableSection()) |
966 continue; | 966 continue; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 for (LayoutObject* child = firstChild(); child; | 1008 for (LayoutObject* child = firstChild(); child; |
1009 child = child->nextSibling()) { | 1009 child = child->nextSibling()) { |
1010 if (child->isLayoutTableCol()) | 1010 if (child->isLayoutTableCol()) |
1011 return toLayoutTableCol(child); | 1011 return toLayoutTableCol(child); |
1012 } | 1012 } |
1013 | 1013 |
1014 return nullptr; | 1014 return nullptr; |
1015 } | 1015 } |
1016 | 1016 |
1017 void LayoutTable::updateColumnCache() const { | 1017 void LayoutTable::updateColumnCache() const { |
1018 ASSERT(m_hasColElements); | 1018 DCHECK(m_hasColElements); |
1019 ASSERT(m_columnLayoutObjects.isEmpty()); | 1019 DCHECK(m_columnLayoutObjects.isEmpty()); |
1020 ASSERT(!m_columnLayoutObjectsValid); | 1020 DCHECK(!m_columnLayoutObjectsValid); |
1021 | 1021 |
1022 for (LayoutTableCol* columnLayoutObject = firstColumn(); columnLayoutObject; | 1022 for (LayoutTableCol* columnLayoutObject = firstColumn(); columnLayoutObject; |
1023 columnLayoutObject = columnLayoutObject->nextColumn()) { | 1023 columnLayoutObject = columnLayoutObject->nextColumn()) { |
1024 if (columnLayoutObject->isTableColumnGroupWithColumnChildren()) | 1024 if (columnLayoutObject->isTableColumnGroupWithColumnChildren()) |
1025 continue; | 1025 continue; |
1026 m_columnLayoutObjects.push_back(columnLayoutObject); | 1026 m_columnLayoutObjects.push_back(columnLayoutObject); |
1027 } | 1027 } |
1028 m_columnLayoutObjectsValid = true; | 1028 m_columnLayoutObjectsValid = true; |
1029 } | 1029 } |
1030 | 1030 |
1031 LayoutTable::ColAndColGroup LayoutTable::slowColElementAtAbsoluteColumn( | 1031 LayoutTable::ColAndColGroup LayoutTable::slowColElementAtAbsoluteColumn( |
1032 unsigned absoluteColumnIndex) const { | 1032 unsigned absoluteColumnIndex) const { |
1033 ASSERT(m_hasColElements); | 1033 DCHECK(m_hasColElements); |
1034 | 1034 |
1035 if (!m_columnLayoutObjectsValid) | 1035 if (!m_columnLayoutObjectsValid) |
1036 updateColumnCache(); | 1036 updateColumnCache(); |
1037 | 1037 |
1038 unsigned columnCount = 0; | 1038 unsigned columnCount = 0; |
1039 for (unsigned i = 0; i < m_columnLayoutObjects.size(); i++) { | 1039 for (unsigned i = 0; i < m_columnLayoutObjects.size(); i++) { |
1040 LayoutTableCol* columnLayoutObject = m_columnLayoutObjects[i]; | 1040 LayoutTableCol* columnLayoutObject = m_columnLayoutObjects[i]; |
1041 ASSERT(!columnLayoutObject->isTableColumnGroupWithColumnChildren()); | 1041 DCHECK(!columnLayoutObject->isTableColumnGroupWithColumnChildren()); |
1042 unsigned span = columnLayoutObject->span(); | 1042 unsigned span = columnLayoutObject->span(); |
1043 unsigned startCol = columnCount; | 1043 unsigned startCol = columnCount; |
1044 ASSERT(span >= 1); | 1044 DCHECK_GE(span, 1u); |
1045 unsigned endCol = columnCount + span - 1; | 1045 unsigned endCol = columnCount + span - 1; |
1046 columnCount += span; | 1046 columnCount += span; |
1047 if (columnCount > absoluteColumnIndex) { | 1047 if (columnCount > absoluteColumnIndex) { |
1048 ColAndColGroup colAndColGroup; | 1048 ColAndColGroup colAndColGroup; |
1049 bool isAtStartEdge = startCol == absoluteColumnIndex; | 1049 bool isAtStartEdge = startCol == absoluteColumnIndex; |
1050 bool isAtEndEdge = endCol == absoluteColumnIndex; | 1050 bool isAtEndEdge = endCol == absoluteColumnIndex; |
1051 if (columnLayoutObject->isTableColumnGroup()) { | 1051 if (columnLayoutObject->isTableColumnGroup()) { |
1052 colAndColGroup.colgroup = columnLayoutObject; | 1052 colAndColGroup.colgroup = columnLayoutObject; |
1053 colAndColGroup.adjoinsStartBorderOfColGroup = isAtStartEdge; | 1053 colAndColGroup.adjoinsStartBorderOfColGroup = isAtStartEdge; |
1054 colAndColGroup.adjoinsEndBorderOfColGroup = isAtEndEdge; | 1054 colAndColGroup.adjoinsEndBorderOfColGroup = isAtEndEdge; |
1055 } else { | 1055 } else { |
1056 colAndColGroup.col = columnLayoutObject; | 1056 colAndColGroup.col = columnLayoutObject; |
1057 colAndColGroup.colgroup = columnLayoutObject->enclosingColumnGroup(); | 1057 colAndColGroup.colgroup = columnLayoutObject->enclosingColumnGroup(); |
1058 if (colAndColGroup.colgroup) { | 1058 if (colAndColGroup.colgroup) { |
1059 colAndColGroup.adjoinsStartBorderOfColGroup = | 1059 colAndColGroup.adjoinsStartBorderOfColGroup = |
1060 isAtStartEdge && !colAndColGroup.col->previousSibling(); | 1060 isAtStartEdge && !colAndColGroup.col->previousSibling(); |
1061 colAndColGroup.adjoinsEndBorderOfColGroup = | 1061 colAndColGroup.adjoinsEndBorderOfColGroup = |
1062 isAtEndEdge && !colAndColGroup.col->nextSibling(); | 1062 isAtEndEdge && !colAndColGroup.col->nextSibling(); |
1063 } | 1063 } |
1064 } | 1064 } |
1065 return colAndColGroup; | 1065 return colAndColGroup; |
1066 } | 1066 } |
1067 } | 1067 } |
1068 return ColAndColGroup(); | 1068 return ColAndColGroup(); |
1069 } | 1069 } |
1070 | 1070 |
1071 void LayoutTable::recalcSections() const { | 1071 void LayoutTable::recalcSections() const { |
1072 ASSERT(m_needsSectionRecalc); | 1072 DCHECK(m_needsSectionRecalc); |
1073 | 1073 |
1074 m_head = nullptr; | 1074 m_head = nullptr; |
1075 m_foot = nullptr; | 1075 m_foot = nullptr; |
1076 m_firstBody = nullptr; | 1076 m_firstBody = nullptr; |
1077 m_hasColElements = false; | 1077 m_hasColElements = false; |
1078 | 1078 |
1079 // We need to get valid pointers to caption, head, foot and first body again | 1079 // We need to get valid pointers to caption, head, foot and first body again |
1080 LayoutObject* nextSibling; | 1080 LayoutObject* nextSibling; |
1081 for (LayoutObject* child = firstChild(); child; child = nextSibling) { | 1081 for (LayoutObject* child = firstChild(); child; child = nextSibling) { |
1082 nextSibling = child->nextSibling(); | 1082 nextSibling = child->nextSibling(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 unsigned sectionCols = section->numEffectiveColumns(); | 1128 unsigned sectionCols = section->numEffectiveColumns(); |
1129 if (sectionCols > maxCols) | 1129 if (sectionCols > maxCols) |
1130 maxCols = sectionCols; | 1130 maxCols = sectionCols; |
1131 } | 1131 } |
1132 } | 1132 } |
1133 | 1133 |
1134 m_effectiveColumns.resize(maxCols); | 1134 m_effectiveColumns.resize(maxCols); |
1135 m_effectiveColumnPositions.resize(maxCols + 1); | 1135 m_effectiveColumnPositions.resize(maxCols + 1); |
1136 m_noCellColspanAtLeast = calcNoCellColspanAtLeast(); | 1136 m_noCellColspanAtLeast = calcNoCellColspanAtLeast(); |
1137 | 1137 |
1138 ASSERT(selfNeedsLayout()); | 1138 DCHECK(selfNeedsLayout()); |
1139 | 1139 |
1140 m_needsSectionRecalc = false; | 1140 m_needsSectionRecalc = false; |
1141 } | 1141 } |
1142 | 1142 |
1143 int LayoutTable::calcBorderStart() const { | 1143 int LayoutTable::calcBorderStart() const { |
1144 if (!collapseBorders()) | 1144 if (!collapseBorders()) |
1145 return LayoutBlock::borderStart().toInt(); | 1145 return LayoutBlock::borderStart().toInt(); |
1146 | 1146 |
1147 // Determined by the first cell of the first row. See the CSS 2.1 spec, | 1147 // Determined by the first cell of the first row. See the CSS 2.1 spec, |
1148 // section 17.6.2. | 1148 // section 17.6.2. |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 unsigned r = cell->rowIndex(); | 1454 unsigned r = cell->rowIndex(); |
1455 LayoutTableSection* section = nullptr; | 1455 LayoutTableSection* section = nullptr; |
1456 unsigned rAbove = 0; | 1456 unsigned rAbove = 0; |
1457 if (r > 0) { | 1457 if (r > 0) { |
1458 // cell is not in the first row, so use the above row in its own section | 1458 // cell is not in the first row, so use the above row in its own section |
1459 section = cell->section(); | 1459 section = cell->section(); |
1460 rAbove = r - 1; | 1460 rAbove = r - 1; |
1461 } else { | 1461 } else { |
1462 section = sectionAbove(cell->section(), SkipEmptySections); | 1462 section = sectionAbove(cell->section(), SkipEmptySections); |
1463 if (section) { | 1463 if (section) { |
1464 ASSERT(section->numRows()); | 1464 DCHECK(section->numRows()); |
1465 rAbove = section->numRows() - 1; | 1465 rAbove = section->numRows() - 1; |
1466 } | 1466 } |
1467 } | 1467 } |
1468 | 1468 |
1469 // Look up the cell in the section's grid, which requires effective col index | 1469 // Look up the cell in the section's grid, which requires effective col index |
1470 if (section) { | 1470 if (section) { |
1471 unsigned effCol = | 1471 unsigned effCol = |
1472 absoluteColumnToEffectiveColumn(cell->absoluteColumnIndex()); | 1472 absoluteColumnToEffectiveColumn(cell->absoluteColumnIndex()); |
1473 return section->primaryCellAt(rAbove, effCol); | 1473 return section->primaryCellAt(rAbove, effCol); |
1474 } | 1474 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 | 1519 |
1520 unsigned effCol = absoluteColumnToEffectiveColumn( | 1520 unsigned effCol = absoluteColumnToEffectiveColumn( |
1521 cell->absoluteColumnIndex() + cell->colSpan()); | 1521 cell->absoluteColumnIndex() + cell->colSpan()); |
1522 return cell->section()->primaryCellAt(cell->rowIndex(), effCol); | 1522 return cell->section()->primaryCellAt(cell->rowIndex(), effCol); |
1523 } | 1523 } |
1524 | 1524 |
1525 int LayoutTable::baselinePosition(FontBaseline baselineType, | 1525 int LayoutTable::baselinePosition(FontBaseline baselineType, |
1526 bool firstLine, | 1526 bool firstLine, |
1527 LineDirectionMode direction, | 1527 LineDirectionMode direction, |
1528 LinePositionMode linePositionMode) const { | 1528 LinePositionMode linePositionMode) const { |
1529 ASSERT(linePositionMode == PositionOnContainingLine); | 1529 DCHECK_EQ(linePositionMode, PositionOnContainingLine); |
1530 int baseline = firstLineBoxBaseline(); | 1530 int baseline = firstLineBoxBaseline(); |
1531 if (baseline != -1) { | 1531 if (baseline != -1) { |
1532 if (isInline()) | 1532 if (isInline()) |
1533 return beforeMarginInLineDirection(direction) + baseline; | 1533 return beforeMarginInLineDirection(direction) + baseline; |
1534 return baseline; | 1534 return baseline; |
1535 } | 1535 } |
1536 | 1536 |
1537 return LayoutBox::baselinePosition(baselineType, firstLine, direction, | 1537 return LayoutBox::baselinePosition(baselineType, firstLine, direction, |
1538 linePositionMode); | 1538 linePositionMode); |
1539 } | 1539 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 parent->styleRef(), | 1647 parent->styleRef(), |
1648 parent->isLayoutInline() ? EDisplay::kInlineTable : EDisplay::kTable); | 1648 parent->isLayoutInline() ? EDisplay::kInlineTable : EDisplay::kTable); |
1649 LayoutTable* newTable = new LayoutTable(nullptr); | 1649 LayoutTable* newTable = new LayoutTable(nullptr); |
1650 newTable->setDocumentForAnonymous(&parent->document()); | 1650 newTable->setDocumentForAnonymous(&parent->document()); |
1651 newTable->setStyle(std::move(newStyle)); | 1651 newTable->setStyle(std::move(newStyle)); |
1652 return newTable; | 1652 return newTable; |
1653 } | 1653 } |
1654 | 1654 |
1655 const BorderValue& LayoutTable::tableStartBorderAdjoiningCell( | 1655 const BorderValue& LayoutTable::tableStartBorderAdjoiningCell( |
1656 const LayoutTableCell* cell) const { | 1656 const LayoutTableCell* cell) const { |
1657 ASSERT(cell->isFirstOrLastCellInRow()); | 1657 #if DCHECK_IS_ON() |
| 1658 DCHECK(cell->isFirstOrLastCellInRow()); |
| 1659 #endif |
1658 if (hasSameDirectionAs(cell->row())) | 1660 if (hasSameDirectionAs(cell->row())) |
1659 return style()->borderStart(); | 1661 return style()->borderStart(); |
1660 | 1662 |
1661 return style()->borderEnd(); | 1663 return style()->borderEnd(); |
1662 } | 1664 } |
1663 | 1665 |
1664 const BorderValue& LayoutTable::tableEndBorderAdjoiningCell( | 1666 const BorderValue& LayoutTable::tableEndBorderAdjoiningCell( |
1665 const LayoutTableCell* cell) const { | 1667 const LayoutTableCell* cell) const { |
1666 ASSERT(cell->isFirstOrLastCellInRow()); | 1668 #if DCHECK_IS_ON() |
| 1669 DCHECK(cell->isFirstOrLastCellInRow()); |
| 1670 #endif |
1667 if (hasSameDirectionAs(cell->row())) | 1671 if (hasSameDirectionAs(cell->row())) |
1668 return style()->borderEnd(); | 1672 return style()->borderEnd(); |
1669 | 1673 |
1670 return style()->borderStart(); | 1674 return style()->borderStart(); |
1671 } | 1675 } |
1672 | 1676 |
1673 void LayoutTable::ensureIsReadyForPaintInvalidation() { | 1677 void LayoutTable::ensureIsReadyForPaintInvalidation() { |
1674 LayoutBlock::ensureIsReadyForPaintInvalidation(); | 1678 LayoutBlock::ensureIsReadyForPaintInvalidation(); |
1675 recalcCollapsedBordersIfNeeded(); | 1679 recalcCollapsedBordersIfNeeded(); |
1676 } | 1680 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 } | 1715 } |
1712 | 1716 |
1713 LayoutUnit LayoutTable::paddingRight() const { | 1717 LayoutUnit LayoutTable::paddingRight() const { |
1714 if (collapseBorders()) | 1718 if (collapseBorders()) |
1715 return LayoutUnit(); | 1719 return LayoutUnit(); |
1716 | 1720 |
1717 return LayoutBlock::paddingRight(); | 1721 return LayoutBlock::paddingRight(); |
1718 } | 1722 } |
1719 | 1723 |
1720 } // namespace blink | 1724 } // namespace blink |
OLD | NEW |