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

Unified Diff: third_party/WebKit/Source/core/paint/TableCellPainter.cpp

Issue 2791433003: Fix Border collapsing with colpsan / rowspan cells
Patch Set: bug 2902 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/TableCellPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
index 685a18d52ffce671316053813a537d6aede801e3..115e67ac67bbda392255604c40c671286b95967e 100644
--- a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
@@ -15,61 +15,11 @@
namespace blink {
-static const CollapsedBorderValue& CollapsedLeftBorder(
- const ComputedStyle& style_for_cell_flow,
- const LayoutTableCell::CollapsedBorderValues& values) {
- if (style_for_cell_flow.IsHorizontalWritingMode()) {
- return style_for_cell_flow.IsLeftToRightDirection() ? values.StartBorder()
- : values.EndBorder();
- }
- return style_for_cell_flow.IsFlippedBlocksWritingMode()
- ? values.AfterBorder()
- : values.BeforeBorder();
-}
-
-static const CollapsedBorderValue& CollapsedRightBorder(
- const ComputedStyle& style_for_cell_flow,
- const LayoutTableCell::CollapsedBorderValues& values) {
- if (style_for_cell_flow.IsHorizontalWritingMode()) {
- return style_for_cell_flow.IsLeftToRightDirection() ? values.EndBorder()
- : values.StartBorder();
- }
- return style_for_cell_flow.IsFlippedBlocksWritingMode()
- ? values.BeforeBorder()
- : values.AfterBorder();
-}
-
-static const CollapsedBorderValue& CollapsedTopBorder(
- const ComputedStyle& style_for_cell_flow,
- const LayoutTableCell::CollapsedBorderValues& values) {
- if (style_for_cell_flow.IsHorizontalWritingMode())
- return values.BeforeBorder();
- return style_for_cell_flow.IsLeftToRightDirection() ? values.StartBorder()
- : values.EndBorder();
-}
-
-static const CollapsedBorderValue& CollapsedBottomBorder(
- const ComputedStyle& style_for_cell_flow,
- const LayoutTableCell::CollapsedBorderValues& values) {
- if (style_for_cell_flow.IsHorizontalWritingMode())
- return values.AfterBorder();
- return style_for_cell_flow.IsLeftToRightDirection() ? values.EndBorder()
- : values.StartBorder();
-}
-
void TableCellPainter::Paint(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
BlockPainter(layout_table_cell_).Paint(paint_info, paint_offset);
}
-static EBorderStyle CollapsedBorderStyle(EBorderStyle style) {
- if (style == kBorderStyleOutset)
- return kBorderStyleGroove;
- if (style == kBorderStyleInset)
- return kBorderStyleRidge;
- return style;
-}
-
const DisplayItemClient& TableCellPainter::DisplayItemClientForBorders() const {
// TODO(wkorman): We may need to handle PaintInvalidationDelayedFull.
// http://crbug.com/657186
@@ -79,105 +29,6 @@ const DisplayItemClient& TableCellPainter::DisplayItemClientForBorders() const {
: layout_table_cell_;
}
-void TableCellPainter::PaintCollapsedBorders(
- const PaintInfo& paint_info,
- const LayoutPoint& paint_offset,
- const CollapsedBorderValue& current_border_value) {
- if (layout_table_cell_.Style()->Visibility() != EVisibility::kVisible)
- return;
-
- LayoutPoint adjusted_paint_offset =
- paint_offset + layout_table_cell_.Location();
- if (!BlockPainter(layout_table_cell_)
- .IntersectsPaintRect(paint_info, adjusted_paint_offset))
- return;
-
- const LayoutTableCell::CollapsedBorderValues* values =
- layout_table_cell_.GetCollapsedBorderValues();
- if (!values)
- return;
-
- const ComputedStyle& style_for_cell_flow =
- layout_table_cell_.StyleForCellFlow();
- const CollapsedBorderValue& left_border_value =
- CollapsedLeftBorder(style_for_cell_flow, *values);
- const CollapsedBorderValue& right_border_value =
- CollapsedRightBorder(style_for_cell_flow, *values);
- const CollapsedBorderValue& top_border_value =
- CollapsedTopBorder(style_for_cell_flow, *values);
- const CollapsedBorderValue& bottom_border_value =
- CollapsedBottomBorder(style_for_cell_flow, *values);
-
- int display_item_type = DisplayItem::kTableCollapsedBorderBase;
- if (top_border_value.ShouldPaint(current_border_value))
- display_item_type |= DisplayItem::kTableCollapsedBorderTop;
- if (bottom_border_value.ShouldPaint(current_border_value))
- display_item_type |= DisplayItem::kTableCollapsedBorderBottom;
- if (left_border_value.ShouldPaint(current_border_value))
- display_item_type |= DisplayItem::kTableCollapsedBorderLeft;
- if (right_border_value.ShouldPaint(current_border_value))
- display_item_type |= DisplayItem::kTableCollapsedBorderRight;
- if (display_item_type == DisplayItem::kTableCollapsedBorderBase)
- return;
-
- int top_width = top_border_value.Width();
- int bottom_width = bottom_border_value.Width();
- int left_width = left_border_value.Width();
- int right_width = right_border_value.Width();
-
- // Adjust our x/y/width/height so that we paint the collapsed borders at the
- // correct location.
- LayoutRect paint_rect =
- PaintRectNotIncludingVisualOverflow(adjusted_paint_offset);
- IntRect border_rect = PixelSnappedIntRect(
- paint_rect.X() - left_width / 2, paint_rect.Y() - top_width / 2,
- paint_rect.Width() + left_width / 2 + (right_width + 1) / 2,
- paint_rect.Height() + top_width / 2 + (bottom_width + 1) / 2);
-
- GraphicsContext& graphics_context = paint_info.context;
- const DisplayItemClient& client = DisplayItemClientForBorders();
- if (DrawingRecorder::UseCachedDrawingIfPossible(
- graphics_context, client,
- static_cast<DisplayItem::Type>(display_item_type)))
- return;
-
- DrawingRecorder recorder(graphics_context, client,
- static_cast<DisplayItem::Type>(display_item_type),
- border_rect);
- Color cell_color = layout_table_cell_.ResolveColor(CSSPropertyColor);
-
- // We never paint diagonals at the joins. We simply let the border with the
- // highest precedence paint on top of borders with lower precedence.
- if (display_item_type & DisplayItem::kTableCollapsedBorderTop) {
- ObjectPainter::DrawLineForBoxSide(
- graphics_context, border_rect.X(), border_rect.Y(), border_rect.MaxX(),
- border_rect.Y() + top_width, kBSTop,
- top_border_value.GetColor().Resolve(cell_color),
- CollapsedBorderStyle(top_border_value.Style()), 0, 0, true);
- }
- if (display_item_type & DisplayItem::kTableCollapsedBorderBottom) {
- ObjectPainter::DrawLineForBoxSide(
- graphics_context, border_rect.X(), border_rect.MaxY() - bottom_width,
- border_rect.MaxX(), border_rect.MaxY(), kBSBottom,
- bottom_border_value.GetColor().Resolve(cell_color),
- CollapsedBorderStyle(bottom_border_value.Style()), 0, 0, true);
- }
- if (display_item_type & DisplayItem::kTableCollapsedBorderLeft) {
- ObjectPainter::DrawLineForBoxSide(
- graphics_context, border_rect.X(), border_rect.Y(),
- border_rect.X() + left_width, border_rect.MaxY(), kBSLeft,
- left_border_value.GetColor().Resolve(cell_color),
- CollapsedBorderStyle(left_border_value.Style()), 0, 0, true);
- }
- if (display_item_type & DisplayItem::kTableCollapsedBorderRight) {
- ObjectPainter::DrawLineForBoxSide(
- graphics_context, border_rect.MaxX() - right_width, border_rect.Y(),
- border_rect.MaxX(), border_rect.MaxY(), kBSRight,
- right_border_value.GetColor().Resolve(cell_color),
- CollapsedBorderStyle(right_border_value.Style()), 0, 0, true);
- }
-}
-
void TableCellPainter::PaintContainerBackgroundBehindCell(
const PaintInfo& paint_info,
const LayoutPoint& paint_offset,

Powered by Google App Engine
This is Rietveld 408576698