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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTable.h

Issue 2400863005: Reformat comments in core/layout up until LayoutTableRow (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 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, 2009, 2010 Apple Inc. All rights reserv ed. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Apple Inc.
8 * All rights reserved.
8 * 9 *
9 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 11 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 13 * version 2 of the License, or (at your option) any later version.
13 * 14 *
14 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 18 * Library General Public License for more details.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // over effectiveColumns() and effectiveColumnPositions(). 130 // over effectiveColumns() and effectiveColumnPositions().
130 // 131 //
131 // See absoluteColumnToEffectiveColumn() for converting an absolute column 132 // See absoluteColumnToEffectiveColumn() for converting an absolute column
132 // index into an index into effectiveColumns() and effectiveColumnPositions(). 133 // index into an index into effectiveColumns() and effectiveColumnPositions().
133 134
134 class CORE_EXPORT LayoutTable final : public LayoutBlock { 135 class CORE_EXPORT LayoutTable final : public LayoutBlock {
135 public: 136 public:
136 explicit LayoutTable(Element*); 137 explicit LayoutTable(Element*);
137 ~LayoutTable() override; 138 ~LayoutTable() override;
138 139
139 // Per CSS 3 writing-mode: "The first and second values of the 'border-spacing ' property represent spacing between columns 140 // Per CSS 3 writing-mode: "The first and second values of the
140 // and rows respectively, not necessarily the horizontal and vertical spacing respectively". 141 // 'border-spacing' property represent spacing between columns and rows
142 // respectively, not necessarily the horizontal and vertical spacing
143 // respectively".
141 int hBorderSpacing() const { return m_hSpacing; } 144 int hBorderSpacing() const { return m_hSpacing; }
142 int vBorderSpacing() const { return m_vSpacing; } 145 int vBorderSpacing() const { return m_vSpacing; }
143 146
144 bool collapseBorders() const { return style()->borderCollapse(); } 147 bool collapseBorders() const { return style()->borderCollapse(); }
145 148
146 int borderStart() const override { return m_borderStart; } 149 int borderStart() const override { return m_borderStart; }
147 int borderEnd() const override { return m_borderEnd; } 150 int borderEnd() const override { return m_borderEnd; }
148 int borderBefore() const override; 151 int borderBefore() const override;
149 int borderAfter() const override; 152 int borderAfter() const override;
150 153
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 recalcSections(); 235 recalcSections();
233 } 236 }
234 237
235 const Vector<ColumnStruct>& effectiveColumns() const { 238 const Vector<ColumnStruct>& effectiveColumns() const {
236 return m_effectiveColumns; 239 return m_effectiveColumns;
237 } 240 }
238 const Vector<int>& effectiveColumnPositions() const { 241 const Vector<int>& effectiveColumnPositions() const {
239 return m_effectiveColumnPositions; 242 return m_effectiveColumnPositions;
240 } 243 }
241 void setEffectiveColumnPosition(unsigned index, int position) { 244 void setEffectiveColumnPosition(unsigned index, int position) {
242 // Note that if our horizontal border-spacing changed, our position will cha nge but not 245 // Note that if our horizontal border-spacing changed, our position will
243 // our column's width. In practice, horizontal border-spacing won't change o ften. 246 // change but not our column's width. In practice, horizontal border-spacing
247 // won't change often.
244 m_columnLogicalWidthChanged |= 248 m_columnLogicalWidthChanged |=
245 m_effectiveColumnPositions[index] != position; 249 m_effectiveColumnPositions[index] != position;
246 m_effectiveColumnPositions[index] = position; 250 m_effectiveColumnPositions[index] = position;
247 } 251 }
248 252
249 LayoutTableSection* header() const { return m_head; } 253 LayoutTableSection* header() const { return m_head; }
250 LayoutTableSection* footer() const { return m_foot; } 254 LayoutTableSection* footer() const { return m_foot; }
251 LayoutTableSection* firstBody() const { return m_firstBody; } 255 LayoutTableSection* firstBody() const { return m_firstBody; }
252 256
253 // This function returns 0 if the table has no section. 257 // This function returns 0 if the table has no section.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 306 }
303 307
304 // The collapsing border model dissallows paddings on table, which is why we 308 // The collapsing border model dissallows paddings on table, which is why we
305 // override those functions. 309 // override those functions.
306 // See http://www.w3.org/TR/CSS2/tables.html#collapsing-borders. 310 // See http://www.w3.org/TR/CSS2/tables.html#collapsing-borders.
307 LayoutUnit paddingTop() const override; 311 LayoutUnit paddingTop() const override;
308 LayoutUnit paddingBottom() const override; 312 LayoutUnit paddingBottom() const override;
309 LayoutUnit paddingLeft() const override; 313 LayoutUnit paddingLeft() const override;
310 LayoutUnit paddingRight() const override; 314 LayoutUnit paddingRight() const override;
311 315
312 // Override paddingStart/End to return pixel values to match behavor of Layout TableCell. 316 // Override paddingStart/End to return pixel values to match behavor of
317 // LayoutTableCell.
313 LayoutUnit paddingEnd() const override { 318 LayoutUnit paddingEnd() const override {
314 return LayoutUnit(LayoutBlock::paddingEnd().toInt()); 319 return LayoutUnit(LayoutBlock::paddingEnd().toInt());
315 } 320 }
316 LayoutUnit paddingStart() const override { 321 LayoutUnit paddingStart() const override {
317 return LayoutUnit(LayoutBlock::paddingStart().toInt()); 322 return LayoutUnit(LayoutBlock::paddingStart().toInt());
318 } 323 }
319 324
320 LayoutUnit bordersPaddingAndSpacingInRowDirection() const { 325 LayoutUnit bordersPaddingAndSpacingInRowDirection() const {
321 // 'border-spacing' only applies to separate borders (see 17.6.1 The separat ed borders model). 326 // 'border-spacing' only applies to separate borders (see 17.6.1 The
327 // separated borders model).
322 return borderStart() + borderEnd() + 328 return borderStart() + borderEnd() +
323 (collapseBorders() ? LayoutUnit() : (paddingStart() + paddingEnd() + 329 (collapseBorders() ? LayoutUnit() : (paddingStart() + paddingEnd() +
324 borderSpacingInRowDirection())); 330 borderSpacingInRowDirection()));
325 } 331 }
326 332
327 // Return the first column or column-group. 333 // Return the first column or column-group.
328 LayoutTableCol* firstColumn() const; 334 LayoutTableCol* firstColumn() const;
329 335
330 struct ColAndColGroup { 336 struct ColAndColGroup {
331 ColAndColGroup() 337 ColAndColGroup()
332 : col(nullptr), 338 : col(nullptr),
333 colgroup(nullptr), 339 colgroup(nullptr),
334 adjoinsStartBorderOfColGroup(false), 340 adjoinsStartBorderOfColGroup(false),
335 adjoinsEndBorderOfColGroup(false) {} 341 adjoinsEndBorderOfColGroup(false) {}
336 LayoutTableCol* col; 342 LayoutTableCol* col;
337 LayoutTableCol* colgroup; 343 LayoutTableCol* colgroup;
338 bool adjoinsStartBorderOfColGroup; 344 bool adjoinsStartBorderOfColGroup;
339 bool adjoinsEndBorderOfColGroup; 345 bool adjoinsEndBorderOfColGroup;
340 LayoutTableCol* innermostColOrColGroup() { return col ? col : colgroup; } 346 LayoutTableCol* innermostColOrColGroup() { return col ? col : colgroup; }
341 }; 347 };
342 ColAndColGroup colElementAtAbsoluteColumn( 348 ColAndColGroup colElementAtAbsoluteColumn(
343 unsigned absoluteColumnIndex) const { 349 unsigned absoluteColumnIndex) const {
344 // The common case is to not have col/colgroup elements, make that case fast . 350 // The common case is to not have col/colgroup elements, make that case
351 // fast.
345 if (!m_hasColElements) 352 if (!m_hasColElements)
346 return ColAndColGroup(); 353 return ColAndColGroup();
347 return slowColElementAtAbsoluteColumn(absoluteColumnIndex); 354 return slowColElementAtAbsoluteColumn(absoluteColumnIndex);
348 } 355 }
349 356
350 bool needsSectionRecalc() const { return m_needsSectionRecalc; } 357 bool needsSectionRecalc() const { return m_needsSectionRecalc; }
351 void setNeedsSectionRecalc() { 358 void setNeedsSectionRecalc() {
352 if (documentBeingDestroyed()) 359 if (documentBeingDestroyed())
353 return; 360 return;
354 m_needsSectionRecalc = true; 361 m_needsSectionRecalc = true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 ASSERT(m_collapsedBordersValid); 409 ASSERT(m_collapsedBordersValid);
403 return m_collapsedBorders; 410 return m_collapsedBorders;
404 } 411 }
405 412
406 void subtractCaptionRect(LayoutRect&) const; 413 void subtractCaptionRect(LayoutRect&) const;
407 414
408 bool isLogicalWidthAuto() const; 415 bool isLogicalWidthAuto() const;
409 416
410 const char* name() const override { return "LayoutTable"; } 417 const char* name() const override { return "LayoutTable"; }
411 418
412 // Whether a table has opaque foreground depends on many factors, e.g. border spacing, missing cells, etc. 419 // Whether a table has opaque foreground depends on many factors, e.g. border
413 // For simplicity, just conservatively assume foreground of all tables are not opaque. 420 // spacing, missing cells, etc. For simplicity, just conservatively assume
421 // foreground of all tables are not opaque.
414 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect&, 422 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect&,
415 unsigned) const override { 423 unsigned) const override {
416 return false; 424 return false;
417 } 425 }
418 426
419 enum WhatToMarkAllCells { MarkDirtyOnly, MarkDirtyAndNeedsLayout }; 427 enum WhatToMarkAllCells { MarkDirtyOnly, MarkDirtyAndNeedsLayout };
420 void markAllCellsWidthsDirtyAndOrNeedsLayout(WhatToMarkAllCells); 428 void markAllCellsWidthsDirtyAndOrNeedsLayout(WhatToMarkAllCells);
421 429
422 protected: 430 protected:
423 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override; 431 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 479
472 void addOverflowFromChildren() override; 480 void addOverflowFromChildren() override;
473 481
474 void recalcSections() const; 482 void recalcSections() const;
475 void layoutCaption(LayoutTableCaption&); 483 void layoutCaption(LayoutTableCaption&);
476 484
477 void distributeExtraLogicalHeight(int extraLogicalHeight); 485 void distributeExtraLogicalHeight(int extraLogicalHeight);
478 486
479 void recalcCollapsedBordersIfNeeded(); 487 void recalcCollapsedBordersIfNeeded();
480 488
481 // TODO(layout-dev): All mutables in this class are lazily updated by recalcSe ctions() 489 // TODO(layout-dev): All mutables in this class are lazily updated by
482 // which is called by various getter methods (e.g. borderBefore(), borderAfter ()). 490 // recalcSections() which is called by various getter methods (e.g.
483 // They allow dirty layout even after DocumentLifecycle::LayoutClean which see ms not proper. crbug.com/538236. 491 // borderBefore(), borderAfter()).
492 // They allow dirty layout even after DocumentLifecycle::LayoutClean which
493 // seems not proper. crbug.com/538236.
484 494
485 // Holds spans (number of absolute columns) of effective columns. 495 // Holds spans (number of absolute columns) of effective columns.
486 // See "absolute column index vs effective column index" in comments of Layout Table. 496 // See "absolute column index vs effective column index" in comments of
497 // LayoutTable.
487 mutable Vector<ColumnStruct> m_effectiveColumns; 498 mutable Vector<ColumnStruct> m_effectiveColumns;
488 499
489 // Holds the logical layout positions of effective columns, and the last item (whose index 500 // Holds the logical layout positions of effective columns, and the last item
490 // is numEffectiveColumns()) holds the position of the imaginary column after the last column. 501 // (whose index is numEffectiveColumns()) holds the position of the imaginary
491 // Because of the last item, m_effectiveColumnPositions.size() is always numEf fectiveColumns() + 1. 502 // column after the last column.
503 // Because of the last item, m_effectiveColumnPositions.size() is always
504 // numEffectiveColumns() + 1.
492 mutable Vector<int> m_effectiveColumnPositions; 505 mutable Vector<int> m_effectiveColumnPositions;
493 506
494 // The captions associated with this object. 507 // The captions associated with this object.
495 mutable Vector<LayoutTableCaption*> m_captions; 508 mutable Vector<LayoutTableCaption*> m_captions;
496 509
497 // Holds pointers to LayoutTableCol objects for <col>s and <colgroup>s under t his table. 510 // Holds pointers to LayoutTableCol objects for <col>s and <colgroup>s under
498 // There is no direct relationship between the size of and index into this vec tor and 511 // this table.
499 // those of m_effectiveColumns because they hold different things. 512 // There is no direct relationship between the size of and index into this
513 // vector and those of m_effectiveColumns because they hold different things.
500 mutable Vector<LayoutTableCol*> m_columnLayoutObjects; 514 mutable Vector<LayoutTableCol*> m_columnLayoutObjects;
501 515
502 mutable LayoutTableSection* m_head; 516 mutable LayoutTableSection* m_head;
503 mutable LayoutTableSection* m_foot; 517 mutable LayoutTableSection* m_foot;
504 mutable LayoutTableSection* m_firstBody; 518 mutable LayoutTableSection* m_firstBody;
505 519
506 // The layout algorithm used by this table. 520 // The layout algorithm used by this table.
507 // 521 //
508 // CSS 2.1 defines 2 types of table layouts toggled with 'table-layout': 522 // CSS 2.1 defines 2 types of table layouts toggled with 'table-layout':
509 // fixed (TableLayoutAlgorithmFixed) and auto (TableLayoutAlgorithmAuto). 523 // fixed (TableLayoutAlgorithmFixed) and auto (TableLayoutAlgorithmAuto).
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if (m_firstBody) 566 if (m_firstBody)
553 return m_firstBody; 567 return m_firstBody;
554 return m_foot; 568 return m_foot;
555 } 569 }
556 570
557 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTable, isTable()); 571 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTable, isTable());
558 572
559 } // namespace blink 573 } // namespace blink
560 574
561 #endif // LayoutTable_h 575 #endif // LayoutTable_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698