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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 2805103003: Optimize collapsed border calculation (step 2) (Closed)
Patch Set: - Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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, 2008, 2009, 2010, 2013 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 LayoutTableBoxComponent::StyleDidChange(diff, old_style); 124 LayoutTableBoxComponent::StyleDidChange(diff, old_style);
125 PropagateStyleToAnonymousChildren(); 125 PropagateStyleToAnonymousChildren();
126 126
127 if (!old_style) 127 if (!old_style)
128 return; 128 return;
129 129
130 LayoutTable* table = this->Table(); 130 LayoutTable* table = this->Table();
131 if (!table) 131 if (!table)
132 return; 132 return;
133 133
134 LayoutTableBoxComponent::InvalidateCollapsedBordersOnStyleChange( 134 if (LayoutTableBoxComponent::NeedsInvalidateCollapsedBordersOnStyleChange(
135 *this, *table, diff, *old_style); 135 *this, *table, diff, *old_style))
136 InvalidateCollapsedBordersOfAffectedCells();
136 137
137 if (LayoutTableBoxComponent::DoCellsHaveDirtyWidth(*this, *table, diff, 138 if (LayoutTableBoxComponent::DoCellsHaveDirtyWidth(*this, *table, diff,
138 *old_style)) 139 *old_style))
139 MarkAllCellsWidthsDirtyAndOrNeedsLayout( 140 MarkAllCellsWidthsDirtyAndOrNeedsLayout(
140 LayoutTable::kMarkDirtyAndNeedsLayout); 141 LayoutTable::kMarkDirtyAndNeedsLayout);
141 } 142 }
142 143
143 void LayoutTableSection::WillBeRemovedFromTree() { 144 void LayoutTableSection::WillBeRemovedFromTree() {
144 LayoutTableBoxComponent::WillBeRemovedFromTree(); 145 LayoutTableBoxComponent::WillBeRemovedFromTree();
145 146
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 2166
2166 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() 2167 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize()
2167 const { 2168 const {
2168 // LayoutTableSection paints background from columns. 2169 // LayoutTableSection paints background from columns.
2169 if (Table()->HasColElements()) 2170 if (Table()->HasColElements())
2170 return false; 2171 return false;
2171 return LayoutTableBoxComponent:: 2172 return LayoutTableBoxComponent::
2172 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2173 PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
2173 } 2174 }
2174 2175
2176 void LayoutTableSection::InvalidateCellCollapsedBordersIntersectingRow(
2177 unsigned row_index) {
2178 auto& row_struct = grid_[row_index].row;
2179 for (auto& cell_struct : row_struct) {
2180 if (cell_struct.in_col_span)
2181 continue;
2182 if (auto* cell = cell_struct.PrimaryCell())
2183 cell->InvalidateCollapsedBorderValues();
2184 }
2185 }
2186
2187 void LayoutTableSection::InvalidateCollapsedBordersOfAffectedCells() {
2188 auto* table = this->Table();
2189 DCHECK(table->CollapseBorders());
2190 if (table->NeedsInvalidateCollapsedBordersForAllCells())
2191 return;
2192
2193 table->RecalcSectionsIfNeeded();
2194 table->InvalidateCollapsedBorders();
2195
2196 if (NumRows()) {
2197 // Invalidate cells intersecting the top row.
2198 InvalidateCellCollapsedBordersIntersectingRow(0);
2199 // Invalidate cells intersecting the bottom row.
2200 if (NumRows() > 1)
2201 InvalidateCellCollapsedBordersIntersectingRow(NumRows() - 1);
2202
2203 // Invalidate cell in start and end columns.
2204 auto num_effective_columns = this->NumEffectiveColumns();
2205 for (unsigned r = 0; r < NumRows(); ++r) {
2206 if (auto* cell = PrimaryCellAt(r, 0))
2207 cell->InvalidateCollapsedBorderValues();
2208 if (auto* cell = PrimaryCellAt(r, num_effective_columns - 1))
2209 cell->InvalidateCollapsedBorderValues();
2210 }
2211 }
2212
2213 // Invalidate cells in the row above the top row.
2214 if (auto* section = table->SectionAbove(this, kSkipEmptySections)) {
2215 section->InvalidateCellCollapsedBordersIntersectingRow(section->NumRows() -
2216 1);
2217 }
2218 // Invalidate cells in the row below the bottom row.
2219 if (auto* section = table->SectionBelow(this, kSkipEmptySections)) {
2220 section->InvalidateCellCollapsedBordersIntersectingRow(0);
2221 }
2222 }
2223
2224 LayoutTableCell* LayoutTableSection::PrimaryCellAboveInTable(
2225 unsigned row,
2226 unsigned effective_column) {
2227 DCHECK(PrimaryCellAt(row, effective_column)->RowIndex() == row);
2228 if (row)
2229 return PrimaryCellAt(row - 1, effective_column);
2230 if (auto* section_above = Table()->SectionAbove(this, kSkipEmptySections)) {
2231 return section_above->PrimaryCellAt(section_above->NumRows() - 1,
2232 effective_column);
2233 }
2234 return nullptr;
2235 }
2236
2237 LayoutTableCell* LayoutTableSection::PrimaryCellBelowInTable(
2238 unsigned row,
2239 unsigned effective_column) {
2240 DCHECK(PrimaryCellAt(row, effective_column)->RowIndex() == row);
2241 unsigned row_below = row + PrimaryCellAt(row, effective_column)->RowSpan();
2242 if (row_below < NumRows())
2243 return PrimaryCellAt(row_below, effective_column);
2244 if (auto* section_below = Table()->SectionBelow(this, kSkipEmptySections))
2245 return section_below->PrimaryCellAt(0, effective_column);
2246 return nullptr;
2247 }
2248
2175 } // namespace blink 2249 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698