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

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

Issue 2846563002: Optimize collapsed border calculation (step 1) (Closed)
Patch Set: - Created 3 years, 8 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, 2007, 2009, 2013 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/layout/LayoutBlockFlow.h" 30 #include "core/layout/LayoutBlockFlow.h"
31 #include "core/layout/LayoutTableRow.h" 31 #include "core/layout/LayoutTableRow.h"
32 #include "core/layout/LayoutTableSection.h" 32 #include "core/layout/LayoutTableSection.h"
33 #include "platform/LengthFunctions.h" 33 #include "platform/LengthFunctions.h"
34 #include <memory> 34 #include <memory>
35 35
36 namespace blink { 36 namespace blink {
37 37
38 static const unsigned kUnsetColumnIndex = 0x1FFFFFFF; 38 static const unsigned kUnsetColumnIndex = 0x07FFFFFF;
wkorman 2017/04/27 20:11:15 How are these numbers here and below determined an
Xianzhu 2017/04/28 20:31:45 Changed to self-explanation code: #define BITS_OF_
39 static const unsigned kMaxColumnIndex = 0x1FFFFFFE; // 536,870,910 39 static const unsigned kMaxColumnIndex = 0x07FFFFFE; // 134,217,726
40
41 enum IncludeBorderColorOrNot { kDoNotIncludeBorderColor, kIncludeBorderColor };
42 40
43 class SubtreeLayoutScope; 41 class SubtreeLayoutScope;
44 42
45 // LayoutTableCell is used to represent a table cell (display: table-cell). 43 // LayoutTableCell is used to represent a table cell (display: table-cell).
46 // 44 //
47 // Because rows are as tall as the tallest cell, cells need to be aligned into 45 // Because rows are as tall as the tallest cell, cells need to be aligned into
48 // the enclosing row space. To achieve this, LayoutTableCell introduces the 46 // the enclosing row space. To achieve this, LayoutTableCell introduces the
49 // concept of 'intrinsic padding'. Those 2 paddings are used to shift the box 47 // concept of 'intrinsic padding'. Those 2 paddings are used to shift the box
50 // into the row as follows: 48 // into the row as follows:
51 // 49 //
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 private: 318 private:
321 const LayoutTableCell& layout_table_cell_; 319 const LayoutTableCell& layout_table_cell_;
322 CollapsedBorderValue start_border_; 320 CollapsedBorderValue start_border_;
323 CollapsedBorderValue end_border_; 321 CollapsedBorderValue end_border_;
324 CollapsedBorderValue before_border_; 322 CollapsedBorderValue before_border_;
325 CollapsedBorderValue after_border_; 323 CollapsedBorderValue after_border_;
326 }; 324 };
327 325
328 bool UsesCompositedCellDisplayItemClients() const; 326 bool UsesCompositedCellDisplayItemClients() const;
329 const CollapsedBorderValues* GetCollapsedBorderValues() const { 327 const CollapsedBorderValues* GetCollapsedBorderValues() const {
328 DCHECK(collapsed_border_values_valid_);
330 return collapsed_border_values_.get(); 329 return collapsed_border_values_.get();
331 } 330 }
331 void InvalidateCollapsedBorderValues() {
332 collapsed_border_values_valid_ = false;
wkorman 2017/04/27 20:11:15 When are they valid/invalid? Worth documenting in
Xianzhu 2017/04/28 20:31:45 Done.
333 }
332 334
333 LayoutRect DebugRect() const override; 335 LayoutRect DebugRect() const override;
334 336
335 void AdjustChildDebugRect(LayoutRect&) const override; 337 void AdjustChildDebugRect(LayoutRect&) const override;
336 338
337 // A table cell's location is relative to its containing section. 339 // A table cell's location is relative to its containing section.
338 LayoutBox* LocationContainer() const override { return Section(); } 340 LayoutBox* LocationContainer() const override { return Section(); }
339 341
340 bool HasLineIfEmpty() const override; 342 bool HasLineIfEmpty() const override;
341 343
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // column, column group). 399 // column, column group).
398 // TODO(jchaffraix): It should be easier to compute all the borders in 400 // TODO(jchaffraix): It should be easier to compute all the borders in
399 // physical coordinates. However this is not the design of the current code. 401 // physical coordinates. However this is not the design of the current code.
400 // 402 //
401 // Blink's support for mixed directionality is currently partial. We only 403 // Blink's support for mixed directionality is currently partial. We only
402 // support the directionality up to |styleForCellFlow|. See comment on the 404 // support the directionality up to |styleForCellFlow|. See comment on the
403 // function above for more details. 405 // function above for more details.
404 // See also https://code.google.com/p/chromium/issues/detail?id=128227 for 406 // See also https://code.google.com/p/chromium/issues/detail?id=128227 for
405 // some history. 407 // some history.
406 // 408 //
407 // Those functions are called when the cache (m_collapsedBorders) is 409 // Those functions are called during recalcCollapsedBorderValuesIfNeeded().
408 // invalidated on LayoutTable. 410 CollapsedBorderValue ComputeCollapsedStartBorder() const;
409 CollapsedBorderValue ComputeCollapsedStartBorder( 411 CollapsedBorderValue ComputeCollapsedEndBorder() const;
410 IncludeBorderColorOrNot = kIncludeBorderColor) const; 412 CollapsedBorderValue ComputeCollapsedBeforeBorder() const;
411 CollapsedBorderValue ComputeCollapsedEndBorder( 413 CollapsedBorderValue ComputeCollapsedAfterBorder() const;
412 IncludeBorderColorOrNot = kIncludeBorderColor) const; 414
413 CollapsedBorderValue ComputeCollapsedBeforeBorder( 415 void RecalcCollapsedBorderValuesIfNeeded() const;
414 IncludeBorderColorOrNot = kIncludeBorderColor) const;
415 CollapsedBorderValue ComputeCollapsedAfterBorder(
416 IncludeBorderColorOrNot = kIncludeBorderColor) const;
417 416
418 Length LogicalWidthFromColumns(LayoutTableCol* first_col_for_this_cell, 417 Length LogicalWidthFromColumns(LayoutTableCol* first_col_for_this_cell,
419 Length width_from_style) const; 418 Length width_from_style) const;
420 419
421 void UpdateColAndRowSpanFlags(); 420 void UpdateColAndRowSpanFlags();
422 421
423 unsigned ParseRowSpanFromDOM() const; 422 unsigned ParseRowSpanFromDOM() const;
424 unsigned ParseColSpanFromDOM() const; 423 unsigned ParseColSpanFromDOM() const;
425 424
426 void NextSibling() const = delete; 425 void NextSibling() const = delete;
427 void PreviousSibling() const = delete; 426 void PreviousSibling() const = delete;
428 427
429 // Note MSVC will only pack members if they have identical types, hence we use 428 // Note MSVC will only pack members if they have identical types, hence we use
430 // unsigned instead of bool here. 429 // unsigned instead of bool here.
431 unsigned absolute_column_index_ : 29; 430 unsigned absolute_column_index_ : 27;
432 unsigned cell_width_changed_ : 1; 431 unsigned cell_width_changed_ : 1;
433 unsigned has_col_span_ : 1; 432 unsigned has_col_span_ : 1;
434 unsigned has_row_span_ : 1; 433 unsigned has_row_span_ : 1;
435 434
435 mutable unsigned collapsed_border_values_valid_ : 1;
436 mutable unsigned collapsed_borders_visually_changed_ : 1;
437 mutable std::unique_ptr<CollapsedBorderValues> collapsed_border_values_;
438
436 // The intrinsic padding. 439 // The intrinsic padding.
437 // See class comment for what they are. 440 // See class comment for what they are.
438 // 441 //
439 // Note: Those fields are using non-subpixel units (int) 442 // Note: Those fields are using non-subpixel units (int)
440 // because we don't do fractional arithmetic on tables. 443 // because we don't do fractional arithmetic on tables.
441 int intrinsic_padding_before_; 444 int intrinsic_padding_before_;
442 int intrinsic_padding_after_; 445 int intrinsic_padding_after_;
443
444 std::unique_ptr<CollapsedBorderValues> collapsed_border_values_;
445 }; 446 };
446 447
447 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableCell, IsTableCell()); 448 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableCell, IsTableCell());
448 449
449 inline LayoutTableCell* LayoutTableCell::PreviousCell() const { 450 inline LayoutTableCell* LayoutTableCell::PreviousCell() const {
450 return ToLayoutTableCell(LayoutObject::PreviousSibling()); 451 return ToLayoutTableCell(LayoutObject::PreviousSibling());
451 } 452 }
452 453
453 inline LayoutTableCell* LayoutTableCell::NextCell() const { 454 inline LayoutTableCell* LayoutTableCell::NextCell() const {
454 return ToLayoutTableCell(LayoutObject::NextSibling()); 455 return ToLayoutTableCell(LayoutObject::NextSibling());
455 } 456 }
456 457
457 inline LayoutTableCell* LayoutTableRow::FirstCell() const { 458 inline LayoutTableCell* LayoutTableRow::FirstCell() const {
458 return ToLayoutTableCell(FirstChild()); 459 return ToLayoutTableCell(FirstChild());
459 } 460 }
460 461
461 inline LayoutTableCell* LayoutTableRow::LastCell() const { 462 inline LayoutTableCell* LayoutTableRow::LastCell() const {
462 return ToLayoutTableCell(LastChild()); 463 return ToLayoutTableCell(LastChild());
463 } 464 }
464 465
465 } // namespace blink 466 } // namespace blink
466 467
467 #endif // LayoutTableCell_h 468 #endif // LayoutTableCell_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698