Commit 882958ff authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Restore checking of SVGResources masker object in ScopedSVGPaintState

An <svg> element can have both a 'mask' and a '-webkit-mask' property
(both yielding a Mask paint property),  so we need to (re)check the
existence of the masker LayoutObject before creating the SVGMaskPainter.

Bug: 1063166
Change-Id: I55ce2b22185275b4dd23aefa65316230d98d960b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111316Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#752007}
parent fb8d11af
...@@ -102,12 +102,15 @@ bool ScopedSVGPaintState::ApplyEffects() { ...@@ -102,12 +102,15 @@ bool ScopedSVGPaintState::ApplyEffects() {
ApplyClipIfNecessary(); ApplyClipIfNecessary();
} }
ApplyMaskIfNecessary(); SVGResources* resources =
SVGResourcesCache::CachedResourcesForLayoutObject(object_);
ApplyMaskIfNecessary(resources);
if (is_svg_root_or_foreign_object) { if (is_svg_root_or_foreign_object) {
// PaintLayerPainter takes care of filter. // PaintLayerPainter takes care of filter.
DCHECK(object_.HasLayer() || !object_.StyleRef().HasFilter()); DCHECK(object_.HasLayer() || !object_.StyleRef().HasFilter());
} else if (!ApplyFilterIfNecessary()) { } else if (!ApplyFilterIfNecessary(resources)) {
return false; return false;
} }
return true; return true;
...@@ -147,8 +150,8 @@ void ScopedSVGPaintState::ApplyClipIfNecessary() { ...@@ -147,8 +150,8 @@ void ScopedSVGPaintState::ApplyClipIfNecessary() {
} }
} }
void ScopedSVGPaintState::ApplyMaskIfNecessary() { void ScopedSVGPaintState::ApplyMaskIfNecessary(SVGResources* resources) {
if (object_.StyleRef().SvgStyle().MaskerResource()) if (resources && resources->Masker())
mask_painter_.emplace(paint_info_.context, object_, display_item_client_); mask_painter_.emplace(paint_info_.context, object_, display_item_client_);
} }
...@@ -161,9 +164,7 @@ static bool HasReferenceFilterOnly(const ComputedStyle& style) { ...@@ -161,9 +164,7 @@ static bool HasReferenceFilterOnly(const ComputedStyle& style) {
return operations.at(0)->GetType() == FilterOperation::REFERENCE; return operations.at(0)->GetType() == FilterOperation::REFERENCE;
} }
bool ScopedSVGPaintState::ApplyFilterIfNecessary() { bool ScopedSVGPaintState::ApplyFilterIfNecessary(SVGResources* resources) {
SVGResources* resources =
SVGResourcesCache::CachedResourcesForLayoutObject(object_);
if (!resources) if (!resources)
return !HasReferenceFilterOnly(object_.StyleRef()); return !HasReferenceFilterOnly(object_.StyleRef());
LayoutSVGResourceFilter* filter = resources->Filter(); LayoutSVGResourceFilter* filter = resources->Filter();
......
...@@ -38,6 +38,7 @@ namespace blink { ...@@ -38,6 +38,7 @@ namespace blink {
class FilterData; class FilterData;
class LayoutObject; class LayoutObject;
class SVGResources;
// Hooks up the correct paint property transform node. // Hooks up the correct paint property transform node.
class ScopedSVGTransformState { class ScopedSVGTransformState {
...@@ -104,11 +105,11 @@ class ScopedSVGPaintState { ...@@ -104,11 +105,11 @@ class ScopedSVGPaintState {
private: private:
void ApplyPaintPropertyState(); void ApplyPaintPropertyState();
void ApplyClipIfNecessary(); void ApplyClipIfNecessary();
void ApplyMaskIfNecessary(); void ApplyMaskIfNecessary(SVGResources*);
// Return true if no filtering is necessary or if the filter is successfully // Return true if no filtering is necessary or if the filter is successfully
// applied. // applied.
bool ApplyFilterIfNecessary(); bool ApplyFilterIfNecessary(SVGResources*);
const LayoutObject& object_; const LayoutObject& object_;
PaintInfo paint_info_; PaintInfo paint_info_;
......
<!doctype html>
<div style="width: 100px; height: 100px; background-color: green"></div>
<!doctype html>
<title>CSS Masking: An invalid mask reference generates a transparent black mask</title>
<div style="width: 100px; height: 100px; background-color: green">
<svg mask="url(#nonexistent)" style="-webkit-mask: url(#nonexistent)">
<rect width="100" height="100" fill="red"/>
</svg>
</div>
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