Commit 66a7be19 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

Change BoxModelObjectPainter to not store flow size

Refactor BoxPainterBase and BoxModelObjectPainter to supply flowbox size
as parameter to PaintFillLayer instead of storing it as a private field.

This will in turn help with code re-use between InlineFlowBoxPainter and
the LayoutNG equivalent.

Bug: 714962
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I342c51c87eb253e2d6420f2b11440b77c564f67d
Reviewed-on: https://chromium-review.googlesource.com/1054133Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557738}
parent 71d5be1f
...@@ -49,8 +49,7 @@ LayoutSize LogicalOffsetOnLine(const InlineFlowBox& flow_box) { ...@@ -49,8 +49,7 @@ LayoutSize LogicalOffsetOnLine(const InlineFlowBox& flow_box) {
} // anonymous namespace } // anonymous namespace
BoxModelObjectPainter::BoxModelObjectPainter(const LayoutBoxModelObject& box, BoxModelObjectPainter::BoxModelObjectPainter(const LayoutBoxModelObject& box,
const InlineFlowBox* flow_box, const InlineFlowBox* flow_box)
const LayoutSize& flow_box_size)
: BoxPainterBase(box, : BoxPainterBase(box,
&box.GetDocument(), &box.GetDocument(),
box.StyleRef(), box.StyleRef(),
...@@ -59,8 +58,7 @@ BoxModelObjectPainter::BoxModelObjectPainter(const LayoutBoxModelObject& box, ...@@ -59,8 +58,7 @@ BoxModelObjectPainter::BoxModelObjectPainter(const LayoutBoxModelObject& box,
box.PaddingOutsets(), box.PaddingOutsets(),
box.Layer()), box.Layer()),
box_model_(box), box_model_(box),
flow_box_(flow_box), flow_box_(flow_box) {}
flow_box_size_(flow_box_size) {}
bool BoxModelObjectPainter:: bool BoxModelObjectPainter::
IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
...@@ -98,14 +96,16 @@ void BoxModelObjectPainter::PaintTextClipMask(GraphicsContext& context, ...@@ -98,14 +96,16 @@ void BoxModelObjectPainter::PaintTextClipMask(GraphicsContext& context,
FloatRoundedRect BoxModelObjectPainter::GetBackgroundRoundedRect( FloatRoundedRect BoxModelObjectPainter::GetBackgroundRoundedRect(
const LayoutRect& border_rect, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const { bool include_logical_right_edge) const {
FloatRoundedRect border = BoxPainterBase::GetBackgroundRoundedRect( FloatRoundedRect border = BoxPainterBase::GetBackgroundRoundedRect(
border_rect, include_logical_left_edge, include_logical_right_edge); border_rect, flow_box_size, include_logical_left_edge,
include_logical_right_edge);
if (flow_box_ && (flow_box_->NextForSameLayoutObject() || if (flow_box_ && (flow_box_->NextForSameLayoutObject() ||
flow_box_->PrevForSameLayoutObject())) { flow_box_->PrevForSameLayoutObject())) {
FloatRoundedRect segment_border = box_model_.StyleRef().GetRoundedBorderFor( FloatRoundedRect segment_border = box_model_.StyleRef().GetRoundedBorderFor(
LayoutRect(LayoutPoint(), LayoutSize(FlooredIntSize(flow_box_size_))), LayoutRect(LayoutPoint(), LayoutSize(FlooredIntSize(flow_box_size))),
include_logical_left_edge, include_logical_right_edge); include_logical_left_edge, include_logical_right_edge);
border.SetRadii(segment_border.GetRadii()); border.SetRadii(segment_border.GetRadii());
} }
......
...@@ -25,8 +25,7 @@ class BoxModelObjectPainter : public BoxPainterBase { ...@@ -25,8 +25,7 @@ class BoxModelObjectPainter : public BoxPainterBase {
public: public:
BoxModelObjectPainter(const LayoutBoxModelObject&, BoxModelObjectPainter(const LayoutBoxModelObject&,
const InlineFlowBox* = nullptr, const InlineFlowBox* = nullptr);
const LayoutSize& flow_box_size = LayoutSize());
static bool IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( static bool IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
const LayoutBoxModelObject*, const LayoutBoxModelObject*,
...@@ -45,14 +44,14 @@ class BoxModelObjectPainter : public BoxPainterBase { ...@@ -45,14 +44,14 @@ class BoxModelObjectPainter : public BoxPainterBase {
const BoxPainterBase::FillLayerInfo&, const BoxPainterBase::FillLayerInfo&,
const LayoutRect&) override; const LayoutRect&) override;
FloatRoundedRect GetBackgroundRoundedRect( FloatRoundedRect GetBackgroundRoundedRect(
const LayoutRect&, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const override; bool include_logical_right_edge) const override;
private: private:
const LayoutBoxModelObject& box_model_; const LayoutBoxModelObject& box_model_;
const InlineFlowBox* flow_box_; const InlineFlowBox* flow_box_;
const LayoutSize flow_box_size_;
}; };
} // namespace blink } // namespace blink
......
...@@ -271,6 +271,7 @@ bool BoxPainterBase::CalculateFillLayerOcclusionCulling( ...@@ -271,6 +271,7 @@ bool BoxPainterBase::CalculateFillLayerOcclusionCulling(
FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance( FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance(
const LayoutRect& border_rect, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
BackgroundBleedAvoidance bleed_avoidance, BackgroundBleedAvoidance bleed_avoidance,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const { bool include_logical_right_edge) const {
...@@ -304,7 +305,8 @@ FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance( ...@@ -304,7 +305,8 @@ FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance(
edges[static_cast<unsigned>(BoxSide::kLeft)].Width()); edges[static_cast<unsigned>(BoxSide::kLeft)].Width());
FloatRoundedRect background_rounded_rect = GetBackgroundRoundedRect( FloatRoundedRect background_rounded_rect = GetBackgroundRoundedRect(
border_rect, include_logical_left_edge, include_logical_right_edge); border_rect, flow_box_size, include_logical_left_edge,
include_logical_right_edge);
FloatRect inset_rect(background_rounded_rect.Rect()); FloatRect inset_rect(background_rounded_rect.Rect());
inset_rect.Expand(insets); inset_rect.Expand(insets);
FloatRoundedRect::Radii inset_radii(background_rounded_rect.GetRadii()); FloatRoundedRect::Radii inset_radii(background_rounded_rect.GetRadii());
...@@ -313,7 +315,8 @@ FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance( ...@@ -313,7 +315,8 @@ FloatRoundedRect BoxPainterBase::BackgroundRoundedRectAdjustedForBleedAvoidance(
return FloatRoundedRect(inset_rect, inset_radii); return FloatRoundedRect(inset_rect, inset_radii);
} }
return GetBackgroundRoundedRect(border_rect, include_logical_left_edge, return GetBackgroundRoundedRect(border_rect, flow_box_size,
include_logical_left_edge,
include_logical_right_edge); include_logical_right_edge);
} }
...@@ -513,6 +516,7 @@ LayoutRectOutsets BoxPainterBase::PaddingOutsets( ...@@ -513,6 +516,7 @@ LayoutRectOutsets BoxPainterBase::PaddingOutsets(
FloatRoundedRect BoxPainterBase::GetBackgroundRoundedRect( FloatRoundedRect BoxPainterBase::GetBackgroundRoundedRect(
const LayoutRect& border_rect, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const { bool include_logical_right_edge) const {
return style_.GetRoundedBorderFor(border_rect, include_logical_left_edge, return style_.GetRoundedBorderFor(border_rect, include_logical_left_edge,
...@@ -525,7 +529,8 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info, ...@@ -525,7 +529,8 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info,
const LayoutRect& rect, const LayoutRect& rect,
BackgroundBleedAvoidance bleed_avoidance, BackgroundBleedAvoidance bleed_avoidance,
BackgroundImageGeometry& geometry, BackgroundImageGeometry& geometry,
SkBlendMode op) { SkBlendMode op,
const LayoutSize flow_box_size) {
GraphicsContext& context = paint_info.context; GraphicsContext& context = paint_info.context;
if (rect.IsEmpty()) if (rect.IsEmpty())
return; return;
...@@ -563,8 +568,9 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info, ...@@ -563,8 +568,9 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info,
} }
LayoutRectOutsets border_padding_insets = -(border_ + padding_); LayoutRectOutsets border_padding_insets = -(border_ + padding_);
FloatRoundedRect border_rect = RoundedBorderRectForClip( FloatRoundedRect border_rect =
info, bg_layer, rect, bleed_avoidance, border_padding_insets); RoundedBorderRectForClip(info, bg_layer, rect, flow_box_size,
bleed_avoidance, border_padding_insets);
// Fast path for drawing simple color backgrounds. // Fast path for drawing simple color backgrounds.
if (PaintFastBottomLayer(display_item_, node_, paint_info, info, rect, if (PaintFastBottomLayer(display_item_, node_, paint_info, info, rect,
...@@ -650,18 +656,19 @@ FloatRoundedRect BoxPainterBase::RoundedBorderRectForClip( ...@@ -650,18 +656,19 @@ FloatRoundedRect BoxPainterBase::RoundedBorderRectForClip(
const BoxPainterBase::FillLayerInfo& info, const BoxPainterBase::FillLayerInfo& info,
const FillLayer& bg_layer, const FillLayer& bg_layer,
const LayoutRect& rect, const LayoutRect& rect,
const LayoutSize& flow_box_size,
BackgroundBleedAvoidance bleed_avoidance, BackgroundBleedAvoidance bleed_avoidance,
LayoutRectOutsets border_padding_insets) const { LayoutRectOutsets border_padding_insets) const {
if (!info.is_rounded_fill) if (!info.is_rounded_fill)
return FloatRoundedRect(); return FloatRoundedRect();
FloatRoundedRect border = FloatRoundedRect border =
info.is_border_fill info.is_border_fill ? BackgroundRoundedRectAdjustedForBleedAvoidance(
? BackgroundRoundedRectAdjustedForBleedAvoidance( rect, flow_box_size, bleed_avoidance,
rect, bleed_avoidance, info.include_left_edge, info.include_left_edge, info.include_right_edge)
info.include_right_edge) : GetBackgroundRoundedRect(rect, flow_box_size,
: GetBackgroundRoundedRect(rect, info.include_left_edge, info.include_left_edge,
info.include_right_edge); info.include_right_edge);
// Clip to the padding or content boxes as necessary. // Clip to the padding or content boxes as necessary.
if (bg_layer.Clip() == EFillBox::kContent) { if (bg_layer.Clip() == EFillBox::kContent) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BOX_PAINTER_BASE_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BOX_PAINTER_BASE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BOX_PAINTER_BASE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_BOX_PAINTER_BASE_H_
#include "base/optional.h"
#include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h" #include "third_party/blink/renderer/core/layout/background_bleed_avoidance.h"
#include "third_party/blink/renderer/core/style/style_image.h" #include "third_party/blink/renderer/core/style/style_image.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect_outsets.h" #include "third_party/blink/renderer/platform/geometry/layout_rect_outsets.h"
...@@ -62,7 +63,8 @@ class BoxPainterBase { ...@@ -62,7 +63,8 @@ class BoxPainterBase {
const LayoutRect&, const LayoutRect&,
BackgroundBleedAvoidance, BackgroundBleedAvoidance,
BackgroundImageGeometry&, BackgroundImageGeometry&,
SkBlendMode = SkBlendMode::kSrcOver); SkBlendMode = SkBlendMode::kSrcOver,
const LayoutSize flow_box_size = LayoutSize());
void PaintMaskImages(const PaintInfo&, void PaintMaskImages(const PaintInfo&,
const LayoutRect&, const LayoutRect&,
...@@ -142,6 +144,7 @@ class BoxPainterBase { ...@@ -142,6 +144,7 @@ class BoxPainterBase {
protected: protected:
FloatRoundedRect BackgroundRoundedRectAdjustedForBleedAvoidance( FloatRoundedRect BackgroundRoundedRectAdjustedForBleedAvoidance(
const LayoutRect& border_rect, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
BackgroundBleedAvoidance, BackgroundBleedAvoidance,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const; bool include_logical_right_edge) const;
...@@ -149,6 +152,7 @@ class BoxPainterBase { ...@@ -149,6 +152,7 @@ class BoxPainterBase {
const FillLayerInfo&, const FillLayerInfo&,
const FillLayer&, const FillLayer&,
const LayoutRect&, const LayoutRect&,
const LayoutSize& flow_box_size,
BackgroundBleedAvoidance, BackgroundBleedAvoidance,
LayoutRectOutsets border_padding_insets) const; LayoutRectOutsets border_padding_insets) const;
...@@ -179,6 +183,7 @@ class BoxPainterBase { ...@@ -179,6 +183,7 @@ class BoxPainterBase {
BackgroundBleedAvoidance) const = 0; BackgroundBleedAvoidance) const = 0;
virtual FloatRoundedRect GetBackgroundRoundedRect( virtual FloatRoundedRect GetBackgroundRoundedRect(
const LayoutRect& border_rect, const LayoutRect& border_rect,
const LayoutSize& flow_box_size,
bool include_logical_left_edge, bool include_logical_left_edge,
bool include_logical_right_edge) const; bool include_logical_right_edge) const;
......
...@@ -74,22 +74,23 @@ void InlineFlowBoxPainter::PaintFillLayer(const PaintInfo& paint_info, ...@@ -74,22 +74,23 @@ void InlineFlowBoxPainter::PaintFillLayer(const PaintInfo& paint_info,
BackgroundImageGeometry geometry(*box_model); BackgroundImageGeometry geometry(*box_model);
StyleImage* img = fill_layer.GetImage(); StyleImage* img = fill_layer.GetImage();
bool has_fill_image = img && img->CanRender(); bool has_fill_image = img && img->CanRender();
BoxModelObjectPainter box_model_painter(*box_model, &inline_flow_box_, BoxModelObjectPainter box_model_painter(*box_model, &inline_flow_box_);
rect.Size());
if ((!has_fill_image && if ((!has_fill_image &&
!inline_flow_box_.GetLineLayoutItem().Style()->HasBorderRadius()) || !inline_flow_box_.GetLineLayoutItem().Style()->HasBorderRadius()) ||
(!inline_flow_box_.PrevForSameLayoutObject() && (!inline_flow_box_.PrevForSameLayoutObject() &&
!inline_flow_box_.NextForSameLayoutObject()) || !inline_flow_box_.NextForSameLayoutObject()) ||
!inline_flow_box_.Parent()) { !inline_flow_box_.Parent()) {
box_model_painter.PaintFillLayer(paint_info, c, fill_layer, rect, box_model_painter.PaintFillLayer(paint_info, c, fill_layer, rect,
kBackgroundBleedNone, geometry, op); kBackgroundBleedNone, geometry, op,
rect.Size());
} else if (inline_flow_box_.GetLineLayoutItem() } else if (inline_flow_box_.GetLineLayoutItem()
.Style() .Style()
->BoxDecorationBreak() == EBoxDecorationBreak::kClone) { ->BoxDecorationBreak() == EBoxDecorationBreak::kClone) {
GraphicsContextStateSaver state_saver(paint_info.context); GraphicsContextStateSaver state_saver(paint_info.context);
paint_info.context.Clip(PixelSnappedIntRect(rect)); paint_info.context.Clip(PixelSnappedIntRect(rect));
box_model_painter.PaintFillLayer(paint_info, c, fill_layer, rect, box_model_painter.PaintFillLayer(paint_info, c, fill_layer, rect,
kBackgroundBleedNone, geometry, op); kBackgroundBleedNone, geometry, op,
rect.Size());
} else { } else {
// We have a fill image that spans multiple lines. // We have a fill image that spans multiple lines.
// FIXME: frameSize ought to be the same as rect.size(). // FIXME: frameSize ought to be the same as rect.size().
...@@ -100,9 +101,9 @@ void InlineFlowBoxPainter::PaintFillLayer(const PaintInfo& paint_info, ...@@ -100,9 +101,9 @@ void InlineFlowBoxPainter::PaintFillLayer(const PaintInfo& paint_info,
GraphicsContextStateSaver state_saver(paint_info.context); GraphicsContextStateSaver state_saver(paint_info.context);
// TODO(chrishtr): this should likely be pixel-snapped. // TODO(chrishtr): this should likely be pixel-snapped.
paint_info.context.Clip(PixelSnappedIntRect(rect)); paint_info.context.Clip(PixelSnappedIntRect(rect));
box_model_painter.PaintFillLayer(paint_info, c, fill_layer, box_model_painter.PaintFillLayer(
image_strip_paint_rect, paint_info, c, fill_layer, image_strip_paint_rect, kBackgroundBleedNone,
kBackgroundBleedNone, geometry, op); geometry, op, rect.Size());
} }
} }
......
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