Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 2405633002: Reformat comments in core/layout (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
index f270e13e05b6a15b3a7af3e52312c814d022abd2..c97a0a3d38f0b19e81f2fcf038e722652b9cd6f7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -4,7 +4,8 @@
* (C) 1998 Waldo Bastian (bastian@kde.org)
* (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc.
+ * All rights reserved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* This library is free software; you can redistribute it and/or
@@ -41,7 +42,8 @@ namespace blink {
using namespace HTMLNames;
-// This variable is used to balance the memory consumption vs the paint invalidation time on big tables.
+// This variable is used to balance the memory consumption vs the paint
+// invalidation time on big tables.
static unsigned gMinTableSizeToUseFastPaintPathWithOverflowingCell = 75 * 75;
static inline void setRowLogicalHeightToRowStyleLogicalHeight(
@@ -168,8 +170,8 @@ void LayoutTableSection::addChild(LayoutObject* child,
}
}
- // If beforeChild is inside an anonymous cell/row, insert into the cell or into
- // the anonymous row containing it, if there is one.
+ // If beforeChild is inside an anonymous cell/row, insert into the cell or
+ // into the anonymous row containing it, if there is one.
LayoutObject* lastBox = last;
while (lastBox && lastBox->parent()->isAnonymous() &&
!lastBox->isTableRow())
@@ -249,9 +251,10 @@ static inline void checkThatVectorIsDOMOrdered(
}
void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) {
- // We don't insert the cell if we need cell recalc as our internal columns' representation
- // will have drifted from the table's representation. Also recalcCells will call addCell
- // at a later time after sync'ing our columns' with the table's.
+ // We don't insert the cell if we need cell recalc as our internal columns'
+ // representation will have drifted from the table's representation. Also
+ // recalcCells will call addCell at a later time after sync'ing our columns'
+ // with the table's.
if (needsCellRecalc())
return;
@@ -263,7 +266,8 @@ void LayoutTableSection::addCell(LayoutTableCell* cell, LayoutTableRow* row) {
unsigned insertionRow = row->rowIndex();
// ### mozilla still seems to do the old HTML way, even for strict DTD
- // (see the annotation on table cell layouting in the CSS specs and the testcase below:
+ // (see the annotation on table cell layouting in the CSS specs and the
+ // testcase below:
// <TABLE border>
// <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
// <TR><TD colspan="2">5
@@ -354,7 +358,8 @@ void LayoutTableSection::populateSpanningRowsHeightFromCell(
spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing -=
borderSpacingForRow(actualRow);
}
- // We don't span the following row so its border-spacing (if any) should be included.
+ // We don't span the following row so its border-spacing (if any) should be
+ // included.
spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing +=
borderSpacingForRow(rowIndex + rowSpan - 1);
}
@@ -372,8 +377,9 @@ void LayoutTableSection::distributeExtraRowSpanHeightToPercentRows(
float percent = std::min(totalPercent, 100.0f);
const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight;
- // Our algorithm matches Firefox. Extra spanning height would be distributed Only in first percent height rows
- // those total percent is 100. Other percent rows would be uneffected even extra spanning height is remain.
+ // Our algorithm matches Firefox. Extra spanning height would be distributed
+ // Only in first percent height rows those total percent is 100. Other percent
+ // rows would be uneffected even extra spanning height is remain.
int accumulatedPositionIncrease = 0;
for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
if (percent > 0 && extraRowSpanningHeight > 0) {
@@ -404,18 +410,20 @@ static void updatePositionIncreasedWithRowHeight(
// (and trigger asserts) in some layout tests.
double proportionalPositionIncrease =
remainder + (extraHeight * double(rowHeight)) / totalHeight;
- // The epsilon is to push any values that are close to a whole number but aren't due to floating point imprecision.
- // The epsilons are not accumulated, any that aren't necessary are lost in the cast to int.
+ // The epsilon is to push any values that are close to a whole number but
+ // aren't due to floating point imprecision. The epsilons are not accumulated,
+ // any that aren't necessary are lost in the cast to int.
int positionIncreaseInt = proportionalPositionIncrease + 0.000001;
accumulatedPositionIncrease += positionIncreaseInt;
remainder = proportionalPositionIncrease - positionIncreaseInt;
}
-// This is mainly used to distribute whole extra rowspanning height in percent rows when all spanning rows are
-// percent rows.
-// Distributing whole extra rowspanning height in percent rows based on the ratios of percent because this method works
-// same as percent distribution when only percent rows are present and percent is 100. Also works perfectly fine when
-// percent is not equal to 100.
+// This is mainly used to distribute whole extra rowspanning height in percent
+// rows when all spanning rows are percent rows.
+// Distributing whole extra rowspanning height in percent rows based on the
+// ratios of percent because this method works same as percent distribution when
+// only percent rows are present and percent is 100. Also works perfectly fine
+// when percent is not equal to 100.
void LayoutTableSection::distributeWholeExtraRowSpanHeightToPercentRows(
LayoutTableCell* cell,
float totalPercent,
@@ -457,8 +465,9 @@ void LayoutTableSection::distributeExtraRowSpanHeightToAutoRows(
int accumulatedPositionIncrease = 0;
double remainder = 0;
- // Aspect ratios of auto rows should not change otherwise table may look different than user expected.
- // So extra height distributed in auto spanning rows based on their weight in spanning cell.
+ // Aspect ratios of auto rows should not change otherwise table may look
+ // different than user expected. So extra height distributed in auto spanning
+ // rows based on their weight in spanning cell.
for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
if (m_grid[row].logicalHeight.isAuto()) {
updatePositionIncreasedWithRowHeight(
@@ -486,8 +495,9 @@ void LayoutTableSection::distributeExtraRowSpanHeightToRemainingRows(
int accumulatedPositionIncrease = 0;
double remainder = 0;
- // Aspect ratios of the rows should not change otherwise table may look different than user expected.
- // So extra height distribution in remaining spanning rows based on their weight in spanning cell.
+ // Aspect ratios of the rows should not change otherwise table may look
+ // different than user expected. So extra height distribution in remaining
+ // spanning rows based on their weight in spanning cell.
for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) {
if (!m_grid[row].logicalHeight.isPercentOrCalc()) {
updatePositionIncreasedWithRowHeight(
@@ -509,23 +519,26 @@ static bool cellIsFullyIncludedInOtherCell(const LayoutTableCell* cell1,
(cell2->rowIndex() + cell2->rowSpan()));
}
-// To avoid unneeded extra height distributions, we apply the following sorting algorithm:
+// To avoid unneeded extra height distributions, we apply the following sorting
+// algorithm:
static bool compareRowSpanCellsInHeightDistributionOrder(
const LayoutTableCell* cell1,
const LayoutTableCell* cell2) {
- // Sorting bigger height cell first if cells are at same index with same span because we will skip smaller
- // height cell to distribute it's extra height.
+ // Sorting bigger height cell first if cells are at same index with same span
+ // because we will skip smaller height cell to distribute it's extra height.
if (cell1->rowIndex() == cell2->rowIndex() &&
cell1->rowSpan() == cell2->rowSpan())
return (cell1->logicalHeightForRowSizing() >
cell2->logicalHeightForRowSizing());
- // Sorting inner most cell first because if inner spanning cell'e extra height is distributed then outer
- // spanning cell's extra height will adjust accordingly. In reverse order, there is more chances that outer
- // spanning cell's height will exceed than defined by user.
+ // Sorting inner most cell first because if inner spanning cell'e extra height
+ // is distributed then outer spanning cell's extra height will adjust
+ // accordingly. In reverse order, there is more chances that outer spanning
+ // cell's height will exceed than defined by user.
if (cellIsFullyIncludedInOtherCell(cell1, cell2))
return true;
- // Sorting lower row index first because first we need to apply the extra height of spanning cell which
- // comes first in the table so lower rows's position would increment in sequence.
+ // Sorting lower row index first because first we need to apply the extra
+ // height of spanning cell which comes first in the table so lower rows's
+ // position would increment in sequence.
if (!cellIsFullyIncludedInOtherCell(cell2, cell1))
return (cell1->rowIndex() < cell2->rowIndex());
@@ -561,10 +574,11 @@ unsigned LayoutTableSection::calcRowHeightHavingOnlySpanningCells(
const unsigned cellRowIndex = cell->rowIndex();
const unsigned cellRowSpan = cell->rowSpan();
- // As we are going from the top of the table to the bottom to calculate the row
- // heights for rows that only contain spanning cells and all previous rows are
- // processed we only need to find the number of rows with spanning cells from the
- // current cell to the end of the current cells spanning height.
+ // As we are going from the top of the table to the bottom to calculate the
+ // row heights for rows that only contain spanning cells and all previous
+ // rows are processed we only need to find the number of rows with spanning
+ // cells from the current cell to the end of the current cells spanning
+ // height.
unsigned startRowForSpanningCellCount = std::max(cellRowIndex, row);
unsigned endRow = cellRowIndex + cellRowSpan;
unsigned spanningCellsRowsCountHavingZeroHeight =
@@ -622,13 +636,15 @@ void LayoutTableSection::updateRowsHeightHavingOnlySpanningCells(
spanningRowsHeight.totalRowsHeight += accumulatedPositionIncrease;
}
-// Distribute rowSpan cell height in rows those comes in rowSpan cell based on the ratio of row's height if
-// 1. RowSpan cell height is greater than the total height of rows in rowSpan cell
+// Distribute rowSpan cell height in rows those comes in rowSpan cell based on
+// the ratio of row's height if 1 RowSpan cell height is greater than the total
+// height of rows in rowSpan cell.
void LayoutTableSection::distributeRowSpanHeightToRows(
SpanningLayoutTableCells& rowSpanCells) {
ASSERT(rowSpanCells.size());
- // 'rowSpanCells' list is already sorted based on the cells rowIndex in ascending order
+ // 'rowSpanCells' list is already sorted based on the cells rowIndex in
+ // ascending order
// Arrange row spanning cell in the order in which we need to process first.
std::sort(rowSpanCells.begin(), rowSpanCells.end(),
compareRowSpanCellsInHeightDistributionOrder);
@@ -639,7 +655,8 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
Vector<int> rowsCountWithOnlySpanningCells;
- // At this stage, Height of the rows are zero for the one containing only spanning cells.
+ // At this stage, Height of the rows are zero for the one containing only
+ // spanning cells.
int count = 0;
for (unsigned row = 0; row < m_grid.size(); row++) {
if (rowHasOnlySpanningCells(row))
@@ -657,15 +674,16 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
unsigned spanningCellEndIndex = rowIndex + rowSpan;
unsigned lastSpanningCellEndIndex = lastRowIndex + lastRowSpan;
- // Only the highest spanning cell will distribute its extra height in a row if more than one spanning cell
- // is present at the same level.
+ // Only the highest spanning cell will distribute its extra height in a row
+ // if more than one spanning cell is present at the same level.
if (rowIndex == lastRowIndex && rowSpan == lastRowSpan)
continue;
int originalBeforePosition = m_rowPos[spanningCellEndIndex];
- // When 2 spanning cells are ending at same row index then while extra height distribution of first spanning
- // cell updates position of the last row so getting the original position of the last row in second spanning
+ // When 2 spanning cells are ending at same row index then while extra
+ // height distribution of first spanning cell updates position of the last
+ // row so getting the original position of the last row in second spanning
// cell need to reduce the height changed by first spanning cell.
if (spanningCellEndIndex == lastSpanningCellEndIndex)
originalBeforePosition -= extraHeightToPropagate;
@@ -683,18 +701,20 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
populateSpanningRowsHeightFromCell(cell, spanningRowsHeight);
- // Here we are handling only row(s) who have only rowspanning cells and do not have any empty cell.
+ // Here we are handling only row(s) who have only rowspanning cells and do
+ // not have any empty cell.
if (spanningRowsHeight.isAnyRowWithOnlySpanningCells)
updateRowsHeightHavingOnlySpanningCells(cell, spanningRowsHeight,
extraHeightToPropagate,
rowsCountWithOnlySpanningCells);
- // This code handle row(s) that have rowspanning cell(s) and at least one empty cell.
- // Such rows are not handled below and end up having a height of 0. That would mean
- // content overlapping if one of their cells has any content. To avoid the problem, we
- // add all the remaining spanning cells' height to the last spanned row.
- // This means that we could grow a row past its 'height' or break percentage spreading
- // however this is better than overlapping content.
+ // This code handle row(s) that have rowspanning cell(s) and at least one
+ // empty cell. Such rows are not handled below and end up having a height of
+ // 0. That would mean content overlapping if one of their cells has any
+ // content. To avoid the problem, we add all the remaining spanning cells'
+ // height to the last spanned row. This means that we could grow a row past
+ // its 'height' or break percentage spreading however this is better than
+ // overlapping content.
// FIXME: Is there a better algorithm?
if (!spanningRowsHeight.totalRowsHeight) {
if (spanningRowsHeight.spanningCellHeightIgnoringBorderSpacing)
@@ -714,15 +734,18 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
continue;
}
- // Below we are handling only row(s) who have at least one visible cell without rowspan value.
+ // Below we are handling only row(s) who have at least one visible cell
+ // without rowspan value.
float totalPercent = 0;
int totalAutoRowsHeight = 0;
int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight;
- // FIXME: Inner spanning cell height should not change if it have fixed height when it's parent spanning cell
- // is distributing it's extra height in rows.
+ // FIXME: Inner spanning cell height should not change if it have fixed
+ // height when it's parent spanning cell is distributing it's extra height
+ //in rows.
- // Calculate total percentage, total auto rows height and total rows height except percent rows.
+ // Calculate total percentage, total auto rows height and total rows height
+ // except percent rows.
for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (m_grid[row].logicalHeight.isPercent()) {
@@ -740,7 +763,8 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
if (totalPercent < 100 && !totalAutoRowsHeight &&
!totalRemainingRowsHeight) {
- // Distributing whole extra rowspanning height in percent row when only non-percent rows height is 0.
+ // Distributing whole extra rowspanning height in percent row when only
+ // non-percent rows height is 0.
distributeWholeExtraRowSpanHeightToPercentRows(
cell, totalPercent, extraRowSpanningHeight,
spanningRowsHeight.rowHeight);
@@ -764,7 +788,8 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
}
if (extraHeightToPropagate) {
- // Apply changed height by rowSpan cells to rows present at the end of the table
+ // Apply changed height by rowSpan cells to rows present at the end of the
+ // table
for (unsigned row = lastRowIndex + lastRowSpan + 1; row <= m_grid.size();
row++)
m_rowPos[row] += extraHeightToPropagate;
@@ -772,16 +797,17 @@ void LayoutTableSection::distributeRowSpanHeightToRows(
}
// Find out the baseline of the cell
-// If the cell's baseline is more than the row's baseline then the cell's baseline become the row's baseline
-// and if the row's baseline goes out of the row's boundaries then adjust row height accordingly.
+// If the cell's baseline is more than the row's baseline then the cell's
+// baseline become the row's baseline and if the row's baseline goes out of the
+// row's boundaries then adjust row height accordingly.
void LayoutTableSection::updateBaselineForCell(LayoutTableCell* cell,
unsigned row,
int& baselineDescent) {
if (!cell->isBaselineAligned())
return;
- // Ignoring the intrinsic padding as it depends on knowing the row's baseline, which won't be accurate
- // until the end of this function.
+ // Ignoring the intrinsic padding as it depends on knowing the row's baseline,
+ // which won't be accurate until the end of this function.
int baselinePosition =
cell->cellBaselinePosition() - cell->intrinsicPaddingBefore();
if (baselinePosition >
@@ -811,14 +837,15 @@ int LayoutTableSection::calcRowLogicalHeight() {
LayoutTableCell* cell;
- // We may have to forcefully lay out cells here, in which case we need a layout
- // state. Technically, we should also push state for the row, but since rows don't push a
- // coordinate transform, that's not necessary.
+ // We may have to forcefully lay out cells here, in which case we need a
+ // layout state. Technically, we should also push state for the row, but since
+ // rows don't push a coordinate transform, that's not necessary.
LayoutState state(*this, locationOffset());
m_rowPos.resize(m_grid.size() + 1);
- // We ignore the border-spacing on any non-top section as it is already included in the previous section's last row position.
+ // We ignore the border-spacing on any non-top section as it is already
+ // included in the previous section's last row position.
if (this == table()->topSection())
m_rowPos[0] = table()->vBorderSpacing();
else
@@ -834,15 +861,16 @@ int LayoutTableSection::calcRowLogicalHeight() {
int baselineDescent = 0;
if (m_grid[r].logicalHeight.isSpecified()) {
- // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
+ // Our base size is the biggest logical height from our cells' styles
+ // (excluding row spanning cells).
m_rowPos[r + 1] = std::max(
m_rowPos[r] +
minimumValueForLength(m_grid[r].logicalHeight, LayoutUnit())
.round(),
0);
} else {
- // Non-specified lengths are ignored because the row already accounts for the cells
- // intrinsic logical height.
+ // Non-specified lengths are ignored because the row already accounts for
+ // the cells intrinsic logical height.
m_rowPos[r + 1] = std::max(m_rowPos[r], 0);
}
@@ -858,7 +886,8 @@ int LayoutTableSection::calcRowLogicalHeight() {
continue;
if (cell->rowSpan() > 1) {
- // For row spanning cells, we only handle them for the first row they span. This ensures we take their baseline into account.
+ // For row spanning cells, we only handle them for the first row they
+ // span. This ensures we take their baseline into account.
if (lastRowSpanCell != cell && cell->rowIndex() == r) {
#if ENABLE(ASSERT)
ASSERT(!uniqueCells.contains(cell));
@@ -880,7 +909,8 @@ int LayoutTableSection::calcRowLogicalHeight() {
m_rowPos[r + 1] = std::max(
m_rowPos[r + 1], m_rowPos[r] + cell->logicalHeightForRowSizing());
- // Find out the baseline. The baseline is set on the first row in a rowSpan.
+ // Find out the baseline. The baseline is set on the first row in a
+ // rowSpan.
if (cell->rowIndex() == r)
updateBaselineForCell(cell, r, baselineDescent);
}
@@ -905,8 +935,9 @@ void LayoutTableSection::layout() {
RELEASE_ASSERT(!needsCellRecalc());
ASSERT(!table()->needsSectionRecalc());
- // addChild may over-grow m_grid but we don't want to throw away the memory too early as addChild
- // can be called in a loop (e.g during parsing). Doing it now ensures we have a stable-enough structure.
+ // addChild may over-grow m_grid but we don't want to throw away the memory
+ // too early as addChild can be called in a loop (e.g during parsing). Doing
+ // it now ensures we have a stable-enough structure.
m_grid.shrinkToFit();
LayoutState state(*this, locationOffset());
@@ -917,8 +948,9 @@ void LayoutTableSection::layout() {
for (unsigned r = 0; r < m_grid.size(); ++r) {
Row& row = m_grid[r].row;
unsigned cols = row.size();
- // First, propagate our table layout's information to the cells. This will mark the row as needing layout
- // if there was a column logical width change.
+ // First, propagate our table layout's information to the cells. This will
+ // mark the row as needing layout if there was a column logical width
+ // change.
for (unsigned startColumn = 0; startColumn < cols; ++startColumn) {
CellStruct& current = row[startColumn];
LayoutTableCell* cell = current.primaryCell();
@@ -987,7 +1019,8 @@ void LayoutTableSection::distributeExtraLogicalHeightToAutoRows(
int totalLogicalHeightAdded = 0;
for (unsigned r = 0; r < m_grid.size(); ++r) {
if (autoRowsCount > 0 && m_grid[r].logicalHeight.isAuto()) {
- // Recomputing |extraLogicalHeightForRow| guarantees that we properly ditribute round |extraLogicalHeight|.
+ // Recomputing |extraLogicalHeightForRow| guarantees that we properly
+ // ditribute round |extraLogicalHeight|.
int extraLogicalHeightForRow = extraLogicalHeight / autoRowsCount;
totalLogicalHeightAdded += extraLogicalHeightForRow;
extraLogicalHeight -= extraLogicalHeightForRow;
@@ -1065,7 +1098,8 @@ void LayoutTableSection::layoutRows() {
LayoutAnalyzer::Scope analyzer(*this);
- // FIXME: Changing the height without a layout can change the overflow so it seems wrong.
+ // FIXME: Changing the height without a layout can change the overflow so it
+ // seems wrong.
unsigned totalRows = m_grid.size();
@@ -1078,9 +1112,9 @@ void LayoutTableSection::layoutRows() {
if (isPaginated) {
LayoutTableSection* header = table()->header();
- // If we're a table header nested inside a table cell then we want to repeat on each
- // page, but below the header we're nested inside. Note we don't try to match the padding
- // on the cell on each repeated header.
+ // If we're a table header nested inside a table cell then we want to repeat
+ // on each page, but below the header we're nested inside. Note we don't try
+ // to match the padding on the cell on each repeated header.
if (header && header == this)
setOffsetForRepeatingHeader(
view()->layoutState()->heightOffsetForTableHeaders());
@@ -1108,16 +1142,16 @@ void LayoutTableSection::layoutRows() {
AssociateWithLatterPage) ==
pageLogicalHeightForOffset(LayoutUnit(m_rowPos[r]));
if (paginationStrutOnRow || rowIsAtTopOfColumn) {
- // If there isn't room for at least one content row on a page with a header group, then
- // we won't repeat the header on each page.
+ // If there isn't room for at least one content row on a page with a
+ // header group, then we won't repeat the header on each page.
if (!r && table()->header() &&
table()->sectionAbove(this) == table()->header() &&
table()->header()->getPaginationBreakability() != AllowAnyBreaks)
state.setHeightOffsetForTableHeaders(
state.heightOffsetForTableHeaders() -
table()->header()->logicalHeight());
- // If we have a header group we will paint it at the top of each page, move the rows
- // down to accomodate it.
+ // If we have a header group we will paint it at the top of each page,
+ // move the rows down to accomodate it.
paginationStrutOnRow += state.heightOffsetForTableHeaders().toInt();
for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex++)
m_rowPos[rowIndex] += paginationStrutOnRow;
@@ -1155,9 +1189,12 @@ void LayoutTableSection::layoutRows() {
// FIXME: Make pagination work with vertical tables.
if (view()->layoutState()->pageLogicalHeight() &&
cell->logicalHeight() != rHeight) {
- // FIXME: Pagination might have made us change size. For now just shrink or grow the cell to fit without doing a relayout.
- // We'll also do a basic increase of the row height to accommodate the cell if it's bigger, but this isn't quite right
- // either. It's at least stable though and won't result in an infinite # of relayouts that may never stabilize.
+ // FIXME: Pagination might have made us change size. For now just shrink
+ // or grow the cell to fit without doing a relayout.
+ // We'll also do a basic increase of the row height to accommodate the
+ // cell if it's bigger, but this isn't quite right either. It's at least
+ // stable though and won't result in an infinite # of relayouts that may
+ // never stabilize.
LayoutUnit oldLogicalHeight = cell->logicalHeight();
rowHeightIncreaseForPagination =
std::max<int>(rowHeightIncreaseForPagination,
@@ -1168,9 +1205,10 @@ void LayoutTableSection::layoutRows() {
LayoutSize childOffset(cell->location() - oldCellRect.location());
if (childOffset.width() || childOffset.height()) {
- // If the child moved, we have to issue paint invalidations to it as well as any floating/positioned
- // descendants. An exception is if we need a layout. In this case, we know we're going to
- // issue paint invalidations ourselves (and the child) anyway.
+ // If the child moved, we have to issue paint invalidations to it as
+ // well as any floating/positioned descendants. An exception is if we
+ // need a layout. In this case, we know we're going to issue paint
+ // invalidations ourselves (and the child) anyway.
if (!table()->selfNeedsLayout())
cell->setMayNeedPaintInvalidation();
}
@@ -1202,8 +1240,9 @@ void LayoutTableSection::layoutRows() {
int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row,
LayoutUnit logicalOffset) const {
DCHECK(row);
- // Even if the row allows us to break-inside, we will want to put a strut on the row if we have a header
- // group that wants to appear at the top of each page.
+ // Even if the row allows us to break-inside, we will want to put a strut on
+ // the row if we have a header group that wants to appear at the top of each
+ // page.
bool tableHeaderForcesStrut =
table()->header()
? table()->header()->getPaginationBreakability() != AllowAnyBreaks
@@ -1235,8 +1274,8 @@ int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row,
logicalOffset, remainingLogicalHeight, rowLogicalHeight);
if (paginationStrut == remainingLogicalHeight &&
remainingLogicalHeight == pageLogicalHeight) {
- // Don't break if we were at the top of a page, and we failed to fit the content
- // completely. No point in leaving a page completely blank.
+ // Don't break if we were at the top of a page, and we failed to fit the
+ // content completely. No point in leaving a page completely blank.
return 0;
}
// Table layout parts only work on integers, so we have to round. Round up, to
@@ -1282,9 +1321,11 @@ void LayoutTableSection::computeOverflowFromCells(unsigned totalRows,
!m_forceSlowPaintPathWithOverflowingCell) {
m_overflowingCells.add(cell);
if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) {
- // We need to set m_forcesSlowPaintPath only if there is a least one overflowing cells as the hit testing code rely on this information.
+ // We need to set m_forcesSlowPaintPath only if there is a least one
+ // overflowing cells as the hit testing code rely on this information.
m_forceSlowPaintPathWithOverflowingCell = true;
- // The slow path does not make any use of the overflowing cells info, don't hold on to the memory.
+ // The slow path does not make any use of the overflowing cells info,
+ // don't hold on to the memory.
m_overflowingCells.clear();
}
}
@@ -1366,11 +1407,10 @@ int LayoutTableSection::calcBlockDirectionOuterBorder(
if (current.inColSpan || !current.hasCells())
continue;
const ComputedStyle& primaryCellStyle = current.primaryCell()->styleRef();
- const BorderValue& cb =
- side == BorderBefore
- ? primaryCellStyle.borderBefore()
- : primaryCellStyle
- .borderAfter(); // FIXME: Make this work with perpendicular and flipped cells.
+ // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& cb = side == BorderBefore
+ ? primaryCellStyle.borderBefore()
+ : primaryCellStyle.borderAfter();
// FIXME: Don't repeat for the same col group
LayoutTableCol* col =
table()->colElementAtAbsoluteColumn(c).innermostColOrColGroup();
@@ -1437,11 +1477,9 @@ int LayoutTableSection::calcInlineDirectionOuterBorder(
const ComputedStyle& primaryCellStyle = current.primaryCell()->styleRef();
const ComputedStyle& primaryCellParentStyle =
current.primaryCell()->parent()->styleRef();
- const BorderValue& cb =
- side == BorderStart
- ? primaryCellStyle.borderStart()
- : primaryCellStyle
- .borderEnd(); // FIXME: Make this work with perpendicular and flipped cells.
+ // FIXME: Make this work with perpendicular and flipped cells.
+ const BorderValue& cb = side == BorderStart ? primaryCellStyle.borderStart()
+ : primaryCellStyle.borderEnd();
const BorderValue& rb = side == BorderStart
? primaryCellParentStyle.borderStart()
: primaryCellParentStyle.borderEnd();
@@ -1506,7 +1544,8 @@ LayoutRect LayoutTableSection::logicalRectForWritingModeAndDirection(
tableAlignedRect = tableAlignedRect.transposedRect();
const Vector<int>& columnPos = table()->effectiveColumnPositions();
- // FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691).
+ // FIXME: The table's direction should determine our row's direction, not the
+ // section's (see bug 96691).
if (!style()->isLeftToRightDirection())
tableAlignedRect.setX(columnPos[columnPos.size() - 1] -
tableAlignedRect.maxX());
@@ -1523,8 +1562,8 @@ CellSpan LayoutTableSection::dirtiedRows(const LayoutRect& damageRect) const {
CellSpan coveredRows = spannedRows(damageRect);
- // To issue paint invalidations for the border we might need to paint invalidate the first
- // or last row even if they are not spanned themselves.
+ // To issue paint invalidations for the border we might need to paint
+ // invalidate the first or last row even if they are not spanned themselves.
RELEASE_ASSERT(coveredRows.start() < m_rowPos.size());
if (coveredRows.start() == m_rowPos.size() - 1 &&
m_rowPos[m_rowPos.size() - 1] + table()->outerBorderAfter() >=
@@ -1549,8 +1588,9 @@ CellSpan LayoutTableSection::dirtiedEffectiveColumns(
CellSpan coveredColumns = spannedEffectiveColumns(damageRect);
const Vector<int>& columnPos = table()->effectiveColumnPositions();
- // To issue paint invalidations for the border we might need to paint invalidate the first
- // or last column even if they are not spanned themselves.
+ // To issue paint invalidations for the border we might need to paint
+ // invalidate the first or last column even if they are not spanned
+ // themselves.
RELEASE_ASSERT(coveredColumns.start() < columnPos.size());
if (coveredColumns.start() == columnPos.size() - 1 &&
columnPos[columnPos.size() - 1] + table()->outerBorderEnd() >=
@@ -1572,9 +1612,9 @@ CellSpan LayoutTableSection::spannedRows(const LayoutRect& flippedRect) const {
std::upper_bound(m_rowPos.begin(), m_rowPos.end(), flippedRect.y()) -
m_rowPos.begin();
+ // After all rows.
if (nextRow == m_rowPos.size())
- return CellSpan(m_rowPos.size() - 1,
- m_rowPos.size() - 1); // After all rows.
+ return CellSpan(m_rowPos.size() - 1, m_rowPos.size() - 1);
unsigned startRow = nextRow > 0 ? nextRow - 1 : 0;
@@ -1598,10 +1638,10 @@ CellSpan LayoutTableSection::spannedEffectiveColumns(
const Vector<int>& columnPos = table()->effectiveColumnPositions();
// Find the first column that starts after rect left.
- // lower_bound doesn't handle the edge between two cells properly as it would wrongly return the
- // cell on the logical top/left.
- // upper_bound on the other hand properly returns the cell on the logical bottom/right, which also
- // matches the behavior of other browsers.
+ // lower_bound doesn't handle the edge between two cells properly as it would
+ // wrongly return the cell on the logical top/left.
+ // upper_bound on the other hand properly returns the cell on the logical
+ // bottom/right, which also matches the behavior of other browsers.
unsigned nextColumn =
std::upper_bound(columnPos.begin(), columnPos.end(), flippedRect.x()) -
columnPos.begin();
@@ -1629,9 +1669,9 @@ CellSpan LayoutTableSection::spannedEffectiveColumns(
void LayoutTableSection::recalcCells() {
ASSERT(m_needsCellRecalc);
- // We reset the flag here to ensure that |addCell| works. This is safe to do as
- // fillRowsWithDefaultStartingAtPosition makes sure we match the table's columns
- // representation.
+ // We reset the flag here to ensure that |addCell| works. This is safe to do
+ // as fillRowsWithDefaultStartingAtPosition makes sure we match the table's
+ // columns representation.
m_needsCellRecalc = false;
m_cCol = 0;
@@ -1657,7 +1697,8 @@ void LayoutTableSection::recalcCells() {
setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Unknown);
}
-// FIXME: This function could be made O(1) in certain cases (like for the non-most-constrainive cells' case).
+// FIXME: This function could be made O(1) in certain cases (like for the
+// non-most-constrainive cells' case).
void LayoutTableSection::rowLogicalHeightChanged(LayoutTableRow* row) {
if (needsCellRecalc())
return;
@@ -1768,10 +1809,10 @@ bool LayoutTableSection::nodeAtPoint(HitTestResult& result,
if (hasOverflowingCell()) {
for (LayoutTableRow* row = lastRow(); row; row = row->previousRow()) {
- // FIXME: We have to skip over inline flows, since they can show up inside table rows
- // at the moment (a demoted inline <form> for example). If we ever implement a
- // table-specific hit-test method (which we should do for performance reasons anyway),
- // then we can remove this check.
+ // FIXME: We have to skip over inline flows, since they can show up inside
+ // table rows at the moment (a demoted inline <form> for example). If we
+ // ever implement a table-specific hit-test method (which we should do for
+ // performance reasons anyway), then we can remove this check.
if (!row->hasSelfPaintingLayer()) {
LayoutPoint childPoint =
flipForWritingModeForChild(row, adjustedLocation);
@@ -1844,7 +1885,8 @@ void LayoutTableSection::setLogicalPositionForCell(
LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]);
int horizontalBorderSpacing = table()->hBorderSpacing();
- // FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691).
+ // FIXME: The table's direction should determine our row's direction, not the
+ // section's (see bug 96691).
if (!style()->isLeftToRightDirection())
cellLocation.setX(LayoutUnit(
table()->effectiveColumnPositions()[table()->numEffectiveColumns()] -
@@ -1867,15 +1909,15 @@ void LayoutTableSection::relayoutCellIfFlexed(LayoutTableCell& cell,
// This will cause these children to grow to fill the cell.
// FIXME: There is still more work to do here to fully match WinIE (should
// it become necessary to do so). In quirks mode, WinIE behaves like we
- // do, but it will clip the cells that spill out of the table section. In
+ // do, but it will clip the cells that spill out of the table section.
// strict mode, Mozilla and WinIE both regrow the table to accommodate the
// new height of the cell (thus letting the percentages cause growth one
- // time only). We may also not be handling row-spanning cells correctly.
+ // time only). We may also not be handling row-spanning cells correctly.
//
- // Note also the oddity where replaced elements always flex, and yet
- // blocks/tables do not necessarily flex. WinIE is crazy and inconsistent,
- // and we can't hope to match the behavior perfectly, but we'll continue to
- // refine it as we discover new bugs. :)
+ // Note also the oddity where replaced elements always flex, and yet blocks/
+ // tables do not necessarily flex. WinIE is crazy and inconsistent, and we
+ // can't hope to match the behavior perfectly, but we'll continue to refine it
+ // as we discover new bugs. :)
bool cellChildrenFlex = false;
bool flexAllChildren = cell.style()->logicalHeight().isFixed() ||
(!table()->style()->logicalHeight().isAuto() &&
@@ -1933,8 +1975,9 @@ bool LayoutTableSection::isRepeatingHeaderGroup() const {
if (logicalHeight() > pageHeight)
return false;
- // If the first row of the section after the header group doesn't fit on the page, then
- // don't repeat the header on each page. See https://drafts.csswg.org/css-tables-3/#repeated-headers
+ // If the first row of the section after the header group doesn't fit on the
+ // page, then don't repeat the header on each page.
+ // See https://drafts.csswg.org/css-tables-3/#repeated-headers
LayoutTableSection* sectionBelow = table()->sectionBelow(this);
if (sectionBelow && sectionBelow->firstRow() &&
sectionBelow->firstRow()->paginationStrut())
@@ -1949,9 +1992,12 @@ bool LayoutTableSection::mapToVisualRectInAncestorSpace(
VisualRectFlags flags) const {
if (ancestor == this)
return true;
- // Repeating table headers are painted once per fragmentation page/column. This does not go through the regular fragmentation machinery,
- // so we need special code to expand the invalidation rect to contain all positions of the header in all columns.
- // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates.
+ // Repeating table headers are painted once per fragmentation page/column.
+ // This does not go through the regular fragmentation machinery, so we need
+ // special code to expand the invalidation rect to contain all positions of
+ // the header in all columns.
+ // Note that this is in flow thread coordinates, not visual coordinates. The
+ // enclosing LayoutFlowThread will convert to visual coordinates.
if (table()->header() == this && isRepeatingHeaderGroup())
rect.setHeight(table()->logicalHeight());
return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect,
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.h ('k') | third_party/WebKit/Source/core/layout/LayoutTestHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698