| OLD | NEW |
| 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 Loading... |
| 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 #define BITS_OF_ABSOLUTE_COLUMN_INDEX 27 |
| 39 static const unsigned kMaxColumnIndex = 0x1FFFFFFE; // 536,870,910 | 39 static const unsigned kUnsetColumnIndex = |
| 40 | 40 (1u << BITS_OF_ABSOLUTE_COLUMN_INDEX) - 1; |
| 41 enum IncludeBorderColorOrNot { kDoNotIncludeBorderColor, kIncludeBorderColor }; | 41 static const unsigned kMaxColumnIndex = kUnsetColumnIndex - 1; |
| 42 | 42 |
| 43 class SubtreeLayoutScope; | 43 class SubtreeLayoutScope; |
| 44 | 44 |
| 45 // LayoutTableCell is used to represent a table cell (display: table-cell). | 45 // LayoutTableCell is used to represent a table cell (display: table-cell). |
| 46 // | 46 // |
| 47 // Because rows are as tall as the tallest cell, cells need to be aligned into | 47 // 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 | 48 // the enclosing row space. To achieve this, LayoutTableCell introduces the |
| 49 // concept of 'intrinsic padding'. Those 2 paddings are used to shift the box | 49 // concept of 'intrinsic padding'. Those 2 paddings are used to shift the box |
| 50 // into the row as follows: | 50 // into the row as follows: |
| 51 // | 51 // |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 private: | 320 private: |
| 321 const LayoutTableCell& layout_table_cell_; | 321 const LayoutTableCell& layout_table_cell_; |
| 322 CollapsedBorderValue start_border_; | 322 CollapsedBorderValue start_border_; |
| 323 CollapsedBorderValue end_border_; | 323 CollapsedBorderValue end_border_; |
| 324 CollapsedBorderValue before_border_; | 324 CollapsedBorderValue before_border_; |
| 325 CollapsedBorderValue after_border_; | 325 CollapsedBorderValue after_border_; |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 bool UsesCompositedCellDisplayItemClients() const; | 328 bool UsesCompositedCellDisplayItemClients() const; |
| 329 const CollapsedBorderValues* GetCollapsedBorderValues() const { | 329 const CollapsedBorderValues* GetCollapsedBorderValues() const { |
| 330 DCHECK(collapsed_border_values_valid_); |
| 330 return collapsed_border_values_.get(); | 331 return collapsed_border_values_.get(); |
| 331 } | 332 } |
| 333 void InvalidateCollapsedBorderValues() { |
| 334 collapsed_border_values_valid_ = false; |
| 335 } |
| 332 | 336 |
| 333 LayoutRect DebugRect() const override; | 337 LayoutRect DebugRect() const override; |
| 334 | 338 |
| 335 void AdjustChildDebugRect(LayoutRect&) const override; | 339 void AdjustChildDebugRect(LayoutRect&) const override; |
| 336 | 340 |
| 337 // A table cell's location is relative to its containing section. | 341 // A table cell's location is relative to its containing section. |
| 338 LayoutBox* LocationContainer() const override { return Section(); } | 342 LayoutBox* LocationContainer() const override { return Section(); } |
| 339 | 343 |
| 340 bool HasLineIfEmpty() const override; | 344 bool HasLineIfEmpty() const override; |
| 341 | 345 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // column, column group). | 401 // column, column group). |
| 398 // TODO(jchaffraix): It should be easier to compute all the borders in | 402 // 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. | 403 // physical coordinates. However this is not the design of the current code. |
| 400 // | 404 // |
| 401 // Blink's support for mixed directionality is currently partial. We only | 405 // Blink's support for mixed directionality is currently partial. We only |
| 402 // support the directionality up to |styleForCellFlow|. See comment on the | 406 // support the directionality up to |styleForCellFlow|. See comment on the |
| 403 // function above for more details. | 407 // function above for more details. |
| 404 // See also https://code.google.com/p/chromium/issues/detail?id=128227 for | 408 // See also https://code.google.com/p/chromium/issues/detail?id=128227 for |
| 405 // some history. | 409 // some history. |
| 406 // | 410 // |
| 407 // Those functions are called when the cache (m_collapsedBorders) is | 411 // Those functions are called during UpdateCollapsedBorderValues(). |
| 408 // invalidated on LayoutTable. | 412 inline CSSPropertyID ResolveBorderProperty(CSSPropertyID) const; |
| 409 CollapsedBorderValue ComputeCollapsedStartBorder( | 413 CollapsedBorderValue ComputeCollapsedStartBorder() const; |
| 410 IncludeBorderColorOrNot = kIncludeBorderColor) const; | 414 CollapsedBorderValue ComputeCollapsedEndBorder() const; |
| 411 CollapsedBorderValue ComputeCollapsedEndBorder( | 415 CollapsedBorderValue ComputeCollapsedBeforeBorder() const; |
| 412 IncludeBorderColorOrNot = kIncludeBorderColor) const; | 416 CollapsedBorderValue ComputeCollapsedAfterBorder() const; |
| 413 CollapsedBorderValue ComputeCollapsedBeforeBorder( | 417 |
| 414 IncludeBorderColorOrNot = kIncludeBorderColor) const; | 418 void UpdateCollapsedBorderValues() const; |
| 415 CollapsedBorderValue ComputeCollapsedAfterBorder( | |
| 416 IncludeBorderColorOrNot = kIncludeBorderColor) const; | |
| 417 | 419 |
| 418 Length LogicalWidthFromColumns(LayoutTableCol* first_col_for_this_cell, | 420 Length LogicalWidthFromColumns(LayoutTableCol* first_col_for_this_cell, |
| 419 Length width_from_style) const; | 421 Length width_from_style) const; |
| 420 | 422 |
| 421 void UpdateColAndRowSpanFlags(); | 423 void UpdateColAndRowSpanFlags(); |
| 422 | 424 |
| 423 unsigned ParseRowSpanFromDOM() const; | 425 unsigned ParseRowSpanFromDOM() const; |
| 424 unsigned ParseColSpanFromDOM() const; | 426 unsigned ParseColSpanFromDOM() const; |
| 425 | 427 |
| 426 void NextSibling() const = delete; | 428 void NextSibling() const = delete; |
| 427 void PreviousSibling() const = delete; | 429 void PreviousSibling() const = delete; |
| 428 | 430 |
| 431 unsigned absolute_column_index_ : BITS_OF_ABSOLUTE_COLUMN_INDEX; |
| 432 |
| 433 // When adding or removing bits here, we should also adjust |
| 434 // BITS_OF_ABSOLUTE_COLUMN_INDEX to use remaining bits of a 32-bit word. |
| 429 // Note MSVC will only pack members if they have identical types, hence we use | 435 // Note MSVC will only pack members if they have identical types, hence we use |
| 430 // unsigned instead of bool here. | 436 // unsigned instead of bool here. |
| 431 unsigned absolute_column_index_ : 29; | |
| 432 unsigned cell_width_changed_ : 1; | 437 unsigned cell_width_changed_ : 1; |
| 433 unsigned has_col_span_ : 1; | 438 unsigned has_col_span_ : 1; |
| 434 unsigned has_row_span_ : 1; | 439 unsigned has_row_span_ : 1; |
| 435 | 440 |
| 441 // This is set when collapsed_border_values_ needs recalculation. |
| 442 mutable unsigned collapsed_border_values_valid_ : 1; |
| 443 // This is set by UpdateCollapsedBorderValues() if the newly calculated |
| 444 // collapsed borders are visually different from the previous values. |
| 445 mutable unsigned collapsed_borders_visually_changed_ : 1; |
| 446 mutable std::unique_ptr<CollapsedBorderValues> collapsed_border_values_; |
| 447 |
| 436 // The intrinsic padding. | 448 // The intrinsic padding. |
| 437 // See class comment for what they are. | 449 // See class comment for what they are. |
| 438 // | 450 // |
| 439 // Note: Those fields are using non-subpixel units (int) | 451 // Note: Those fields are using non-subpixel units (int) |
| 440 // because we don't do fractional arithmetic on tables. | 452 // because we don't do fractional arithmetic on tables. |
| 441 int intrinsic_padding_before_; | 453 int intrinsic_padding_before_; |
| 442 int intrinsic_padding_after_; | 454 int intrinsic_padding_after_; |
| 443 | |
| 444 std::unique_ptr<CollapsedBorderValues> collapsed_border_values_; | |
| 445 }; | 455 }; |
| 446 | 456 |
| 447 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableCell, IsTableCell()); | 457 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableCell, IsTableCell()); |
| 448 | 458 |
| 449 inline LayoutTableCell* LayoutTableCell::PreviousCell() const { | 459 inline LayoutTableCell* LayoutTableCell::PreviousCell() const { |
| 450 return ToLayoutTableCell(LayoutObject::PreviousSibling()); | 460 return ToLayoutTableCell(LayoutObject::PreviousSibling()); |
| 451 } | 461 } |
| 452 | 462 |
| 453 inline LayoutTableCell* LayoutTableCell::NextCell() const { | 463 inline LayoutTableCell* LayoutTableCell::NextCell() const { |
| 454 return ToLayoutTableCell(LayoutObject::NextSibling()); | 464 return ToLayoutTableCell(LayoutObject::NextSibling()); |
| 455 } | 465 } |
| 456 | 466 |
| 457 inline LayoutTableCell* LayoutTableRow::FirstCell() const { | 467 inline LayoutTableCell* LayoutTableRow::FirstCell() const { |
| 458 return ToLayoutTableCell(FirstChild()); | 468 return ToLayoutTableCell(FirstChild()); |
| 459 } | 469 } |
| 460 | 470 |
| 461 inline LayoutTableCell* LayoutTableRow::LastCell() const { | 471 inline LayoutTableCell* LayoutTableRow::LastCell() const { |
| 462 return ToLayoutTableCell(LastChild()); | 472 return ToLayoutTableCell(LastChild()); |
| 463 } | 473 } |
| 464 | 474 |
| 465 } // namespace blink | 475 } // namespace blink |
| 466 | 476 |
| 467 #endif // LayoutTableCell_h | 477 #endif // LayoutTableCell_h |
| OLD | NEW |