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

Side by Side Diff: Source/core/rendering/RenderTable.h

Issue 154243002: Optimize RenderTable::colToEffCol() for tables without colspans (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 10 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 | Annotate | Revision Log
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, 2009, 2010 Apple Inc. All rights reserv ed. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Apple Inc. All rights reserv ed.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 unsigned lastColumnIndex() const { return numEffCols() - 1; } 165 unsigned lastColumnIndex() const { return numEffCols() - 1; }
166 166
167 void splitColumn(unsigned position, unsigned firstSpan); 167 void splitColumn(unsigned position, unsigned firstSpan);
168 void appendColumn(unsigned span); 168 void appendColumn(unsigned span);
169 unsigned numEffCols() const { return m_columns.size(); } 169 unsigned numEffCols() const { return m_columns.size(); }
170 unsigned spanOfEffCol(unsigned effCol) const { return m_columns[effCol].span ; } 170 unsigned spanOfEffCol(unsigned effCol) const { return m_columns[effCol].span ; }
171 171
172 unsigned colToEffCol(unsigned column) const 172 unsigned colToEffCol(unsigned column) const
173 { 173 {
174 if (!m_hasCellColspanThatDeterminesTableWidth)
175 return column;
176
174 unsigned effColumn = 0; 177 unsigned effColumn = 0;
175 unsigned numColumns = numEffCols(); 178 unsigned numColumns = numEffCols();
176 for (unsigned c = 0; effColumn < numColumns && c + m_columns[effColumn]. span - 1 < column; ++effColumn) 179 for (unsigned c = 0; effColumn < numColumns && c + m_columns[effColumn]. span - 1 < column; ++effColumn)
177 c += m_columns[effColumn].span; 180 c += m_columns[effColumn].span;
178 return effColumn; 181 return effColumn;
179 } 182 }
180 183
181 unsigned effColToCol(unsigned effCol) const 184 unsigned effColToCol(unsigned effCol) const
182 { 185 {
186 if (!m_hasCellColspanThatDeterminesTableWidth)
187 return effCol;
188
183 unsigned c = 0; 189 unsigned c = 0;
184 for (unsigned i = 0; i < effCol; i++) 190 for (unsigned i = 0; i < effCol; i++)
185 c += m_columns[i].span; 191 c += m_columns[i].span;
186 return c; 192 return c;
187 } 193 }
188 194
189 LayoutUnit borderSpacingInRowDirection() const 195 LayoutUnit borderSpacingInRowDirection() const
190 { 196 {
191 if (unsigned effectiveColumnCount = numEffCols()) 197 if (unsigned effectiveColumnCount = numEffCols())
192 return static_cast<LayoutUnit>(effectiveColumnCount + 1) * hBorderSp acing(); 198 return static_cast<LayoutUnit>(effectiveColumnCount + 1) * hBorderSp acing();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 331
326 CollapsedBorderValues m_collapsedBorders; 332 CollapsedBorderValues m_collapsedBorders;
327 const CollapsedBorderValue* m_currentBorder; 333 const CollapsedBorderValue* m_currentBorder;
328 bool m_collapsedBordersValid : 1; 334 bool m_collapsedBordersValid : 1;
329 335
330 mutable bool m_hasColElements : 1; 336 mutable bool m_hasColElements : 1;
331 mutable bool m_needsSectionRecalc : 1; 337 mutable bool m_needsSectionRecalc : 1;
332 338
333 bool m_columnLogicalWidthChanged : 1; 339 bool m_columnLogicalWidthChanged : 1;
334 mutable bool m_columnRenderersValid: 1; 340 mutable bool m_columnRenderersValid: 1;
341 mutable bool m_hasCellColspanThatDeterminesTableWidth : 1;
342 bool hasCellColspanThatDeterminesTableWidth() const
343 {
344 for (unsigned c = 0; c < numEffCols(); c++) {
345 if (m_columns[c].span > 1)
346 return true;
347 }
348 return false;
349 }
335 350
336 short m_hSpacing; 351 short m_hSpacing;
337 short m_vSpacing; 352 short m_vSpacing;
338 int m_borderStart; 353 int m_borderStart;
339 int m_borderEnd; 354 int m_borderEnd;
340 }; 355 };
341 356
342 inline RenderTableSection* RenderTable::topSection() const 357 inline RenderTableSection* RenderTable::topSection() const
343 { 358 {
344 ASSERT(!needsSectionRecalc()); 359 ASSERT(!needsSectionRecalc());
345 if (m_head) 360 if (m_head)
346 return m_head; 361 return m_head;
347 if (m_firstBody) 362 if (m_firstBody)
348 return m_firstBody; 363 return m_firstBody;
349 return m_foot; 364 return m_foot;
350 } 365 }
351 366
352 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderTable, isTable()); 367 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderTable, isTable());
353 368
354 } // namespace WebCore 369 } // namespace WebCore
355 370
356 #endif // RenderTable_h 371 #endif // RenderTable_h
OLDNEW
« no previous file with comments | « PerformanceTests/Layout/resources/large-table-with-collapsed-borders.js ('k') | Source/core/rendering/RenderTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698