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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 2890543002: Improve LayoutTable outer collapsed border calculation (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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
index 8818174333d8c7f1919c86b9828c49c0b86756d7..9f33002234582d0a62c3ae6c3c992a7aa1b01236 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -90,10 +90,6 @@ LayoutTableSection::LayoutTableSection(Element* element)
: LayoutTableBoxComponent(element),
c_col_(0),
c_row_(0),
- outer_border_start_(0),
- outer_border_end_(0),
- outer_border_before_(0),
- outer_border_after_(0),
needs_cell_recalc_(false),
force_full_paint_(false),
has_multiple_cell_levels_(false),
@@ -1343,147 +1339,6 @@ void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout(
}
}
-int LayoutTableSection::CalcBlockDirectionOuterBorder(
- BlockBorderSide side) const {
- // TODO(wangxianzhu): There are several issues in this function:
- // 1. Row borders are not respected;
- // 2. Column borders should be ignored if this section is not at the top or
- // the bottom.
- // 3. It's unnecessarily complex.
- // I think we should just use cell's calculated collapsed border values to
- // avoid all of the problems.
- if (!grid_.size() || !Table()->NumEffectiveColumns())
- return 0;
-
- int border_width = 0;
-
- const BorderValue& sb =
- side == kBorderBefore ? Style()->BorderBefore() : Style()->BorderAfter();
- if (sb.Style() == kBorderStyleHidden)
- return -1;
- if (sb.Style() > kBorderStyleHidden)
- border_width = sb.Width();
-
- const BorderValue& rb = side == kBorderBefore
- ? FirstRow()->Style()->BorderBefore()
- : LastRow()->Style()->BorderAfter();
- if (rb.Style() == kBorderStyleHidden)
- return -1;
- if (rb.Style() > kBorderStyleHidden && rb.Width() > border_width)
- border_width = rb.Width();
-
- bool all_hidden = true;
- unsigned r = side == kBorderBefore ? 0 : grid_.size() - 1;
- unsigned n_cols = NumEffectiveColumns(r);
- for (unsigned c = 0; c < n_cols; c++) {
- const auto& grid_cell = GridCellAt(r, c);
- if (grid_cell.InColSpan() || !grid_cell.HasCells())
- continue;
- const ComputedStyle& primary_cell_style =
- grid_cell.PrimaryCell()->StyleRef();
- // FIXME: Make this work with perpendicular and flipped cells.
- const BorderValue& cb = side == kBorderBefore
- ? primary_cell_style.BorderBefore()
- : primary_cell_style.BorderAfter();
- // FIXME: Don't repeat for the same col group
- LayoutTableCol* col =
- Table()->ColElementAtEffectiveColumn(c).InnermostColOrColGroup();
- if (col) {
- const BorderValue& gb = side == kBorderBefore
- ? col->Style()->BorderBefore()
- : col->Style()->BorderAfter();
- if (gb.Style() == kBorderStyleHidden || cb.Style() == kBorderStyleHidden)
- continue;
- all_hidden = false;
- if (gb.Style() > kBorderStyleHidden && gb.Width() > border_width)
- border_width = gb.Width();
- if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width)
- border_width = cb.Width();
- } else {
- if (cb.Style() == kBorderStyleHidden)
- continue;
- all_hidden = false;
- if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width)
- border_width = cb.Width();
- }
- }
- if (all_hidden)
- return -1;
-
- if (side == kBorderAfter)
- border_width++; // Distribute rounding error
- return border_width / 2;
-}
-
-int LayoutTableSection::CalcInlineDirectionOuterBorder(
- InlineBorderSide side) const {
- unsigned total_cols = Table()->NumEffectiveColumns();
- if (!grid_.size() || !total_cols)
- return 0;
- unsigned col_index = side == kBorderStart ? 0 : total_cols - 1;
-
- int border_width = 0;
-
- const BorderValue& sb =
- side == kBorderStart ? Style()->BorderStart() : Style()->BorderEnd();
- if (sb.Style() == kBorderStyleHidden)
- return -1;
- if (sb.Style() > kBorderStyleHidden)
- border_width = sb.Width();
-
- if (LayoutTableCol* col = Table()
- ->ColElementAtEffectiveColumn(col_index)
- .InnermostColOrColGroup()) {
- const BorderValue& gb = side == kBorderStart ? col->Style()->BorderStart()
- : col->Style()->BorderEnd();
- if (gb.Style() == kBorderStyleHidden)
- return -1;
- if (gb.Style() > kBorderStyleHidden && gb.Width() > border_width)
- border_width = gb.Width();
- }
-
- bool all_hidden = true;
- for (unsigned r = 0; r < grid_.size(); r++) {
- if (col_index >= NumEffectiveColumns(r))
- continue;
- const auto& grid_cell = GridCellAt(r, col_index);
- if (!grid_cell.HasCells())
- continue;
- // FIXME: Don't repeat for the same cell
- const ComputedStyle& primary_cell_style =
- grid_cell.PrimaryCell()->StyleRef();
- const ComputedStyle& primary_cell_parent_style =
- grid_cell.PrimaryCell()->Parent()->StyleRef();
- // FIXME: Make this work with perpendicular and flipped cells.
- const BorderValue& cb = side == kBorderStart
- ? primary_cell_style.BorderStart()
- : primary_cell_style.BorderEnd();
- const BorderValue& rb = side == kBorderStart
- ? primary_cell_parent_style.BorderStart()
- : primary_cell_parent_style.BorderEnd();
- if (cb.Style() == kBorderStyleHidden || rb.Style() == kBorderStyleHidden)
- continue;
- all_hidden = false;
- if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width)
- border_width = cb.Width();
- if (rb.Style() > kBorderStyleHidden && rb.Width() > border_width)
- border_width = rb.Width();
- }
- if (all_hidden)
- return -1;
-
- if ((side == kBorderStart) != Table()->Style()->IsLeftToRightDirection())
- border_width++; // Distribute rounding error
- return border_width / 2;
-}
-
-void LayoutTableSection::RecalcOuterBorder() {
- outer_border_before_ = CalcBlockDirectionOuterBorder(kBorderBefore);
- outer_border_after_ = CalcBlockDirectionOuterBorder(kBorderAfter);
- outer_border_start_ = CalcInlineDirectionOuterBorder(kBorderStart);
- outer_border_end_ = CalcInlineDirectionOuterBorder(kBorderEnd);
-}
-
int LayoutTableSection::FirstLineBoxBaseline() const {
if (!grid_.size())
return -1;

Powered by Google App Engine
This is Rietveld 408576698