Commit ebe018ff authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] When painting collapsed borders, snap size to whole pixels

For now we don't fully support subpixel layout in tables, but may
produce subpixel layout results and different heights for cells in
the same row (crbug.com/838401).

Now use the traditional method to snap size to pixels before
applying paint offset for collapsed borders.

Bug: 834648
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ic8866e1a9d52bb6b60ea96dfda692040af8ecea8
Reviewed-on: https://chromium-review.googlesource.com/1036305Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555171}
parent e56443b0
<!DOCTYPE html>
<style>
td {
width: 300px;
border: 1px solid black;
}
</style>
<div style="height: 50px">
The top and bottom of the two cells should be aligned.
</div>
<table style="border-collapse: collapse">
<tr>
<td></td>
<!-- TODO(crbug.com/377847): the height should be 50px when table cells
support subpixel layout. -->
<td><p style="height: 51px"></p></td>
</tr>
</table>
</div>
<!DOCTYPE html>
<style>
td {
width: 300px;
border: 1px solid black;
}
</style>
<div style="height: 49.6px">
The top and bottom of the two cells should be aligned.
</div>
<table style="border-collapse: collapse">
<tr>
<td></td>
<td><p style="height: 50.6px"></p></td>
</tr>
</table>
......@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/paint/block_painter.h"
#include "third_party/blink/renderer/core/paint/object_painter.h"
#include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/table_cell_painter.h"
namespace blink {
......@@ -349,8 +350,9 @@ void CollapsedBorderPainter::PaintCollapsedBorders(
// Now left=start_, right=end_, before_=top, after_=bottom.
// Collapsed borders are half inside and half outside of |rect|.
IntRect rect =
PixelSnappedIntRect(paint_offset + cell_.Location(), cell_.Size());
IntRect rect = PixelSnappedIntRect(
TableCellPainter(cell_).PaintRectNotIncludingVisualOverflow(
paint_offset + cell_.Location()));
// |paint_rect| covers the whole collapsed borders.
IntRect paint_rect = rect;
paint_rect.Expand(IntRectOutsets(before_.outer_width, end_.outer_width,
......
......@@ -150,6 +150,9 @@ void TableCellPainter::PaintMask(const PaintInfo& paint_info,
BoxPainter(layout_table_cell_).PaintMaskImages(paint_info, paint_rect);
}
// TODO(crbug.com/377847): When table cells fully support subpixel layout, we
// should not snap the size to pixels here. We should remove this function and
// snap to pixels for the rect with paint offset applied.
LayoutRect TableCellPainter::PaintRectNotIncludingVisualOverflow(
const LayoutPoint& paint_offset) {
return LayoutRect(paint_offset,
......
......@@ -33,9 +33,10 @@ class TableCellPainter {
const LayoutPoint& paint_offset);
void PaintMask(const PaintInfo&, const LayoutPoint& paint_offset);
private:
LayoutRect PaintRectNotIncludingVisualOverflow(
const LayoutPoint& paint_offset);
private:
void PaintBackground(const PaintInfo&,
const LayoutRect&,
const LayoutObject& background_object);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment