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

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

Issue 1781463002: Fix table background painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sample code for improved collapsed border painting Created 3 years, 11 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/LayoutTableCol.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableCol.cpp b/third_party/WebKit/Source/core/layout/LayoutTableCol.cpp
index ab9da43fce5fef66783948fcbd08f5af0ac5076b..39063b1bc18a91c827f3ee5a40214f95f777a893 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableCol.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableCol.cpp
@@ -130,7 +130,13 @@ LayoutRect LayoutTableCol::clippedOverflowRectForPaintInvalidation(const LayoutB
void LayoutTableCol::imageChanged(WrappedImagePtr, const IntRect*)
{
// FIXME: Issue paint invalidation of only the rect the image paints in.
+
setShouldDoFullPaintInvalidation();
+ // This is atotic fix, but I have been unable to find test
+ // case that confirms it. Put it back in once test case is found
+ // Vector<LayoutTableCell*> cells = getColumnCells();
+ // for (auto c = cells.begin(); c != cells.end(); c++)
+ // (*c)->setShouldDoFullPaintInvalidation();
}
void LayoutTableCol::clearPreferredLogicalWidthsDirtyBits()
@@ -160,6 +166,23 @@ LayoutTableCol* LayoutTableCol::enclosingColumnGroup() const
return parentColumnGroup;
}
+
+LayoutTableCol* LayoutTableCol::lastColumnInGroup() const
+{
+ ASSERT(this->isTableColumnGroupWithColumnChildren());
+
+ LayoutTableCol* endCol = nullptr;
+ LayoutTableCol* currentCol = this->nextColumn();
+ // If column has children, traverse the children to find last.
+ if (this->firstChild()) {
+ while (currentCol && currentCol->enclosingColumnGroup() == this) {
+ endCol = currentCol;
+ currentCol = currentCol->nextColumn();
+ }
+ }
+ return endCol;
+}
+
LayoutTableCol* LayoutTableCol::nextColumn() const
{
// If |this| is a column-group, the next column is the colgroup's first child column.
@@ -170,8 +193,10 @@ LayoutTableCol* LayoutTableCol::nextColumn() const
LayoutObject* next = nextSibling();
// Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group.
- if (!next && parent()->isLayoutTableCol())
- next = parent()->nextSibling();
+
+ auto p = parent();
+ if (!next && p && p->isLayoutTableCol())
+ next = p->nextSibling();
for (; next && !next->isLayoutTableCol(); next = next->nextSibling()) { }
@@ -200,4 +225,119 @@ const BorderValue& LayoutTableCol::borderAdjoiningCellAfter(const LayoutTableCel
return style()->borderEnd();
}
+LayoutRect LayoutTableCol::positionByCellSpan(unsigned absoluteColumnIndex) const
+{
+ LayoutTable * table = this->table();
+ LayoutRect position;
+
+ if (!table)
+ return position;
+
+ LayoutTableSection* topSection = table->topNonEmptySection();
+ LayoutTableSection* bottomSection = table->bottomNonEmptySection();
+ if (!topSection || !bottomSection)
+ return position;
+
+ Vector<unsigned> colIndexes = getEffectiveColumnIndexes();
+
+ if (colIndexes.size() == 0)
+ return position;
+
+ unsigned startColumnIndex = colIndexes[0];
+ unsigned endColumnIndex = colIndexes.last();
+
+ // Tricky: if <col> has a span, we need to pick a <col> of width 1
+ // that starts at absoluteColumnIndex
+ if (isTableColumn() && colIndexes.size() > 1) {
+ unsigned wantedEffectiveColumn = table->absoluteColumnToEffectiveColumn(absoluteColumnIndex);
+ size_t wantedIt = colIndexes.find(wantedEffectiveColumn);
+ ASSERT(wantedIt != kNotFound);
+ startColumnIndex = colIndexes[wantedIt];
+ endColumnIndex = startColumnIndex;
+ }
+ position = topSection->getCellPhysicalPosition(0, startColumnIndex);
+ position.moveBy(topSection->location());
+ LayoutRect bottomPosition = bottomSection->getCellPhysicalPosition(bottomSection->numRows() - 1, endColumnIndex);
+ bottomPosition.moveBy(bottomSection->location());
+ position.uniteEvenIfEmpty(bottomPosition);
+ return position;
+}
+
+
+Vector<unsigned> LayoutTableCol::getEffectiveColumnIndexes() const
+{
+ LayoutTable * table = this->table();
+ Vector<unsigned> indexes;
+
+ if (!table)
+ return indexes;
+
+ unsigned lastEffectiveColumn = table->lastEffectiveColumnIndex();
+
+ if (isTableColumn()) {
+ unsigned idx = table->colElementToAbsoluteColumn(this);
+ auto span = this->span();
+ unsigned lastSeenColumn = 0xFFFFFFFF;
+ while (span--) {
+ unsigned effectiveColumn = table->absoluteColumnToEffectiveColumn(idx++);
+ if (effectiveColumn != lastSeenColumn && effectiveColumn <= lastEffectiveColumn) {
+ indexes.append(effectiveColumn);
+ lastSeenColumn = effectiveColumn;
+ }
+ }
+ } else { // isTableColumnGroup
+ if (isTableColumnGroupWithColumnChildren()) {
+ LayoutTableCol* currentCol = nullptr;
+ auto lastCol = lastColumnInGroup();
+ do {
+ currentCol = currentCol ? currentCol->nextColumn() : nextColumn();
+ if (currentCol) {
+ auto colIndexes = currentCol->getEffectiveColumnIndexes();
+ for (auto c = colIndexes.begin(); c != colIndexes.end(); c++)
+ indexes.append(*c);
+ }
+ } while (currentCol && currentCol != lastCol);
+ } else { // tableColumnGroup with no children
+ // its covers span columns
+ unsigned idx = table->colElementToAbsoluteColumn(this);
+ auto span = this->span();
+ unsigned lastSeenColumn = 0xFFFFFFFF;
+ while (span--) {
+ unsigned effectiveColumn = table->absoluteColumnToEffectiveColumn(idx++);
+ if (effectiveColumn != lastSeenColumn && effectiveColumn <= lastEffectiveColumn) {
+ indexes.append(effectiveColumn);
+ lastSeenColumn = effectiveColumn;
+ }
+ }
+ }
+ }
+ return indexes;
+}
+
+// returns all cells inside a column
+Vector<LayoutTableCell*> LayoutTableCol::getColumnCells() const
+{
+ // enumerate all the columns we need
+ LayoutTable * myTable = table();
+ Vector<LayoutTableCell*> cells;
+
+ if (!myTable) // can't do this before table is laid out
+ return cells;
+
+ auto colIndexes = getEffectiveColumnIndexes();
+ auto section = myTable->topSection();
+ // Get all cells from all columns
+ while (section) {
+ for (auto c = colIndexes.begin(); c != colIndexes.end(); c++) {
+ for (unsigned r = 0; r < section->numRows(); r++) {
+ LayoutTableCell * cell = section->primaryCellAt(r, *c);
+ if (cell && cell->hasSetAbsoluteColumnIndex() && cell->absoluteColumnIndex() == *c)
+ cells.append(cell);
+ }
+ }
+ section = myTable->sectionBelow(section, SkipEmptySections);
+ }
+ return cells;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCol.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableRow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698