Commit aa3b99aa authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Fieldset NG: Fix mask painting

PaintMask() should take care of the rendered legend.

- NGBoxFragmentPainter::PaintMask() checks if the fragment is a fieldset
  container, and delegate to NGFieldsetPainter if so.
- NGFieldsetPainter::PaintMask() creates FieldsetPaintInfo, and adjust
  the paint rectangle.

- NGFieldsetPainter now has CreateFieldsetPaintInfo() to share
  FieldsetPaintInfo creation logic between PaintMask() and
  PaintBoxDecorationBackground().
- Merge NGFieldsetPainter::PaintFieldsetDecorationBackground() into
  PaintDecorationBackground().

Bug: 875235
Change-Id: If6f7e709db538f99d699458938f5a1b2db9a8e47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348229
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796808}
parent c0ac7e51
......@@ -905,6 +905,12 @@ void NGBoxFragmentPainter::PaintMask(const PaintInfo& paint_info,
paint_info.context, GetDisplayItemClient(), paint_info.phase))
return;
if (physical_box_fragment.IsFieldsetContainer()) {
NGFieldsetPainter(box_fragment_)
.PaintMask(paint_info, paint_offset, BorderEdges());
return;
}
// TODO(eae): Switch to LayoutNG version of BackgroundImageGeometry.
BackgroundImageGeometry geometry(*static_cast<const LayoutBoxModelObject*>(
box_fragment_.GetLayoutObject()));
......
......@@ -20,38 +20,15 @@
namespace blink {
void NGFieldsetPainter::PaintBoxDecorationBackground(
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
FieldsetPaintInfo NGFieldsetPainter::CreateFieldsetPaintInfo() const {
const NGLink* legend = nullptr;
if (!fieldset_.Children().empty()) {
const auto& first_child = fieldset_.Children().front();
if (first_child->IsRenderedLegend())
legend = &first_child;
}
// Paint the fieldset (background, other decorations, and) border, with the
// cutout hole for the legend.
PaintFieldsetDecorationBackground(legend, paint_info, paint_offset);
}
void NGFieldsetPainter::PaintFieldsetDecorationBackground(
const NGLink* legend,
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
PhysicalSize fieldset_size(fieldset_.Size());
PhysicalRect paint_rect(paint_offset, fieldset_size);
const PhysicalSize fieldset_size(fieldset_.Size());
const auto& fragment = fieldset_;
BoxDecorationData box_decoration_data(paint_info, fragment);
// TODO(crbug.com/786475): Fieldset should not scroll.
DCHECK(!box_decoration_data.IsPaintingScrollingBackground());
if (!box_decoration_data.ShouldPaint())
return;
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, *fieldset_.GetLayoutObject(), paint_info.phase))
return;
LayoutRectOutsets fieldset_borders = fragment.Borders().ToLayoutRectOutsets();
const ComputedStyle& style = fieldset_.Style();
PhysicalRect legend_border_box;
......@@ -85,8 +62,29 @@ void NGFieldsetPainter::PaintFieldsetDecorationBackground(
legend_border_box.offset = legend_logical_offset.ConvertToPhysical(
writing_direction, fieldset_size, legend_border_box.size);
}
FieldsetPaintInfo fieldset_paint_info(style, fieldset_size, fieldset_borders,
legend_border_box);
return FieldsetPaintInfo(style, fieldset_size, fieldset_borders,
legend_border_box);
}
// Paint the fieldset (background, other decorations, and) border, with the
// cutout hole for the legend.
void NGFieldsetPainter::PaintBoxDecorationBackground(
const PaintInfo& paint_info,
const PhysicalOffset& paint_offset) {
PhysicalSize fieldset_size(fieldset_.Size());
PhysicalRect paint_rect(paint_offset, fieldset_size);
BoxDecorationData box_decoration_data(paint_info, fieldset_);
// TODO(crbug.com/786475): Fieldset should not scroll.
DCHECK(!box_decoration_data.IsPaintingScrollingBackground());
if (!box_decoration_data.ShouldPaint())
return;
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, *fieldset_.GetLayoutObject(), paint_info.phase))
return;
const ComputedStyle& style = fieldset_.Style();
FieldsetPaintInfo fieldset_paint_info = CreateFieldsetPaintInfo();
PhysicalRect contracted_rect(paint_rect);
contracted_rect.Contract(fieldset_paint_info.border_outsets);
......@@ -128,4 +126,22 @@ void NGFieldsetPainter::PaintFieldsetDecorationBackground(
}
}
void NGFieldsetPainter::PaintMask(const PaintInfo& paint_info,
const PhysicalOffset& paint_offset,
const NGBorderEdges& border_edges) {
// TODO(eae): Switch to LayoutNG version of BackgroundImageGeometry.
const LayoutObject& layout_object = *fieldset_.GetLayoutObject();
BackgroundImageGeometry geometry(
static_cast<const LayoutBoxModelObject&>(layout_object));
NGBoxFragmentPainter ng_box_painter(fieldset_);
DrawingRecorder recorder(paint_info.context, layout_object, paint_info.phase,
ng_box_painter.VisualRect(paint_offset));
PhysicalRect paint_rect(paint_offset, fieldset_.Size());
paint_rect.Contract(CreateFieldsetPaintInfo().border_outsets);
ng_box_painter.PaintMaskImages(paint_info, paint_rect, layout_object,
geometry, border_edges.line_left,
border_edges.line_right);
}
} // namespace blink
......@@ -10,7 +10,8 @@
namespace blink {
class NGPhysicalBoxFragment;
struct NGLink;
struct FieldsetPaintInfo;
struct NGBorderEdges;
struct PaintInfo;
struct PhysicalOffset;
......@@ -22,11 +23,10 @@ class NGFieldsetPainter {
: fieldset_(fieldset) {}
void PaintBoxDecorationBackground(const PaintInfo&, const PhysicalOffset&);
void PaintMask(const PaintInfo&, const PhysicalOffset&, const NGBorderEdges&);
private:
void PaintFieldsetDecorationBackground(const NGLink* legend,
const PaintInfo&,
const PhysicalOffset&);
FieldsetPaintInfo CreateFieldsetPaintInfo() const;
const NGPhysicalBoxFragment& fieldset_;
};
......
......@@ -1283,8 +1283,6 @@ virtual/layout_ng_fragment_traversal/external/wpt/css/CSS2/text/* [ Skip ]
# Size containment
crbug.com/875235 external/wpt/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-014.html [ Failure ]
# Mask paiting area
crbug.com/875235 paint/masks/fieldset-mask.html [ Failure ]
# ====== LayoutNG-only failures until here ======
......
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