Commit 2f1645ac authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Move SVGPaintServer::ExistsForLayoutObject to LayoutSVGShape

This only needs to answer the query "do we have a paint", so it can be
simplified to reflect that.

Bug: 109212
Change-Id: If1aa31e81f32c5c3aace708fe5a81edb653cb1e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440657Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#812589}
parent 034bb9ca
...@@ -173,13 +173,6 @@ SVGPaintServer SVGPaintServer::RequestForLayoutObject( ...@@ -173,13 +173,6 @@ SVGPaintServer SVGPaintServer::RequestForLayoutObject(
return Invalid(); return Invalid();
} }
bool SVGPaintServer::ExistsForLayoutObject(
const LayoutObject& layout_object,
const ComputedStyle& style,
LayoutSVGResourceMode resource_mode) {
return RequestPaint(layout_object, style, resource_mode).is_valid;
}
LayoutSVGResourcePaintServer::LayoutSVGResourcePaintServer(SVGElement* element) LayoutSVGResourcePaintServer::LayoutSVGResourcePaintServer(SVGElement* element)
: LayoutSVGResourceContainer(element) {} : LayoutSVGResourceContainer(element) {}
......
...@@ -48,9 +48,6 @@ class SVGPaintServer { ...@@ -48,9 +48,6 @@ class SVGPaintServer {
static SVGPaintServer RequestForLayoutObject(const LayoutObject&, static SVGPaintServer RequestForLayoutObject(const LayoutObject&,
const ComputedStyle&, const ComputedStyle&,
LayoutSVGResourceMode); LayoutSVGResourceMode);
static bool ExistsForLayoutObject(const LayoutObject&,
const ComputedStyle&,
LayoutSVGResourceMode);
void ApplyToPaintFlags(PaintFlags&, float alpha); void ApplyToPaintFlags(PaintFlags&, float alpha);
......
...@@ -225,6 +225,26 @@ bool LayoutSVGShape::ShapeDependentFillContains( ...@@ -225,6 +225,26 @@ bool LayoutSVGShape::ShapeDependentFillContains(
return GetPath().Contains(location.TransformedPoint(), fill_rule); return GetPath().Contains(location.TransformedPoint(), fill_rule);
} }
static bool HasPaintServer(const LayoutObject& layout_object,
const ComputedStyle& style,
LayoutSVGResourceMode resource_mode) {
const bool apply_to_fill = resource_mode == kApplyToFillMode;
const SVGComputedStyle& svg_style = style.SvgStyle();
const SVGPaint& paint =
apply_to_fill ? svg_style.FillPaint() : svg_style.StrokePaint();
if (paint.HasColor())
return true;
if (paint.HasUrl()) {
SVGResources* resources =
SVGResourcesCache::CachedResourcesForLayoutObject(layout_object);
if (resources) {
if (apply_to_fill ? resources->Fill() : resources->Stroke())
return true;
}
}
return false;
}
bool LayoutSVGShape::FillContains(const HitTestLocation& location, bool LayoutSVGShape::FillContains(const HitTestLocation& location,
bool requires_fill, bool requires_fill,
const WindRule fill_rule) { const WindRule fill_rule) {
...@@ -232,8 +252,7 @@ bool LayoutSVGShape::FillContains(const HitTestLocation& location, ...@@ -232,8 +252,7 @@ bool LayoutSVGShape::FillContains(const HitTestLocation& location,
if (!fill_bounding_box_.Contains(location.TransformedPoint())) if (!fill_bounding_box_.Contains(location.TransformedPoint()))
return false; return false;
if (requires_fill && !SVGPaintServer::ExistsForLayoutObject(*this, StyleRef(), if (requires_fill && !HasPaintServer(*this, StyleRef(), kApplyToFillMode))
kApplyToFillMode))
return false; return false;
return ShapeDependentFillContains(location, fill_rule); return ShapeDependentFillContains(location, fill_rule);
...@@ -250,8 +269,7 @@ bool LayoutSVGShape::StrokeContains(const HitTestLocation& location, ...@@ -250,8 +269,7 @@ bool LayoutSVGShape::StrokeContains(const HitTestLocation& location,
if (!StrokeBoundingBox().Contains(location.TransformedPoint())) if (!StrokeBoundingBox().Contains(location.TransformedPoint()))
return false; return false;
if (!SVGPaintServer::ExistsForLayoutObject(*this, StyleRef(), if (!HasPaintServer(*this, StyleRef(), kApplyToStrokeMode))
kApplyToStrokeMode))
return false; return false;
} else { } else {
if (!HitTestStrokeBoundingBox().Contains(location.TransformedPoint())) if (!HitTestStrokeBoundingBox().Contains(location.TransformedPoint()))
......
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