Commit b76265c2 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

Move LayoutObject::CanRenderBorderImage to ComputedStyle

Move the CanRenderBorderImage method from LayoutObject to ComputedStyle.
It only depends on information from ComputedStyle and it is not virtual.

Change-Id: I175d4b21b8d1e4f2f8e5535fc063dc65be0b841f
Reviewed-on: https://chromium-review.googlesource.com/565655Reviewed-by: default avatarWalter Korman <wkorman@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485455}
parent 0f8982ef
......@@ -5729,7 +5729,7 @@ bool LayoutBox::MustInvalidateBackgroundOrBorderPaintOnWidthChange() const {
return true;
// Our fill layers are ok. Let's check border.
if (Style()->HasBorderDecoration() && CanRenderBorderImage())
if (Style()->CanRenderBorderImage())
return true;
return false;
......@@ -5748,20 +5748,12 @@ bool LayoutBox::MustInvalidateBackgroundOrBorderPaintOnHeightChange() const {
return true;
// Our fill layers are ok. Let's check border.
if (Style()->HasBorderDecoration() && CanRenderBorderImage())
if (Style()->CanRenderBorderImage())
return true;
return false;
}
bool LayoutBox::CanRenderBorderImage() const {
if (!Style()->HasBorderDecoration())
return false;
StyleImage* border_image = Style()->BorderImage().GetImage();
return border_image && border_image->CanRender() && border_image->IsLoaded();
}
ShapeOutsideInfo* LayoutBox::GetShapeOutsideInfo() const {
return ShapeOutsideInfo::IsEnabledFor(*this) ? ShapeOutsideInfo::Info(*this)
: nullptr;
......
......@@ -21,7 +21,13 @@ BoxDecorationData::BoxDecorationData(const LayoutBox& layout_box) {
DCHECK(has_background == layout_box.Style()->HasBackground());
has_border_decoration = layout_box.Style()->HasBorderDecoration();
has_appearance = layout_box.Style()->HasAppearance();
bleed_avoidance = DetermineBackgroundBleedAvoidance(layout_box);
if (layout_box.IsDocumentElement()) {
bleed_avoidance = kBackgroundBleedNone;
} else {
bleed_avoidance = DetermineBackgroundBleedAvoidance(
layout_box.GetDocument(), layout_box.StyleRef(),
layout_box.BackgroundShouldAlwaysBeClipped());
}
}
namespace {
......@@ -41,37 +47,34 @@ bool BorderObscuresBackgroundEdge(const ComputedStyle& style) {
} // anonymous namespace
BackgroundBleedAvoidance BoxDecorationData::DetermineBackgroundBleedAvoidance(
const LayoutBox& layout_box) {
if (layout_box.IsDocumentElement())
return kBackgroundBleedNone;
const Document& document,
const ComputedStyle& style,
bool background_should_always_be_clipped) {
if (!has_background)
return kBackgroundBleedNone;
const ComputedStyle& box_style = layout_box.StyleRef();
const bool has_border_radius = box_style.HasBorderRadius();
const bool has_border_radius = style.HasBorderRadius();
if (!has_border_decoration || !has_border_radius ||
layout_box.CanRenderBorderImage()) {
if (layout_box.BackgroundShouldAlwaysBeClipped())
style.CanRenderBorderImage()) {
if (background_should_always_be_clipped)
return kBackgroundBleedClipOnly;
// Border radius clipping may require layer bleed avoidance if we are going
// to draw an image over something else, because we do not want the
// antialiasing to lead to bleeding
if (box_style.HasBackgroundImage() && has_border_radius) {
if (style.HasBackgroundImage() && has_border_radius) {
// But if the top layer is opaque for the purposes of background painting,
// we do not need the bleed avoidance because we will not paint anything
// behind the top layer. But only if we need to draw something
// underneath.
const FillLayer& fill_layer = layout_box.Style()->BackgroundLayers();
const FillLayer& fill_layer = style.BackgroundLayers();
if ((background_color.Alpha() || fill_layer.Next()) &&
!fill_layer.ImageOccludesNextLayers(layout_box.GetDocument(),
box_style))
!fill_layer.ImageOccludesNextLayers(document, style))
return kBackgroundBleedClipLayer;
}
return kBackgroundBleedNone;
}
if (BorderObscuresBackgroundEdge(box_style))
if (BorderObscuresBackgroundEdge(style))
return kBackgroundBleedShrinkBackground;
return kBackgroundBleedClipLayer;
......
......@@ -11,6 +11,8 @@
namespace blink {
class LayoutBox;
class Document;
class ComputedStyle;
// Information extracted from ComputedStyle for box painting.
struct BoxDecorationData {
......@@ -26,7 +28,10 @@ struct BoxDecorationData {
bool has_appearance;
private:
BackgroundBleedAvoidance DetermineBackgroundBleedAvoidance(const LayoutBox&);
BackgroundBleedAvoidance DetermineBackgroundBleedAvoidance(
const Document&,
const ComputedStyle&,
bool background_should_always_be_clipped);
};
} // namespace blink
......
......@@ -1096,6 +1096,14 @@ FloatRoundedRect ComputedStyle::GetRoundedInnerBorderFor(
return rounded_rect;
}
bool ComputedStyle::CanRenderBorderImage() const {
if (!HasBorderDecoration())
return false;
StyleImage* border_image = BorderImage().GetImage();
return border_image && border_image->CanRender() && border_image->IsLoaded();
}
static bool AllLayersAreFixed(const FillLayer& layer) {
for (const FillLayer* curr_layer = &layer; curr_layer;
curr_layer = curr_layer->Next()) {
......
......@@ -1812,6 +1812,8 @@ class ComputedStyle : public ComputedStyleBase,
bool include_logical_left_edge,
bool include_logical_right_edge) const;
bool CanRenderBorderImage() const;
// Float utility functions.
bool IsFloating() const { return Floating() != EFloat::kNone; }
......
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