Commit 05c8461d authored by fs's avatar fs Committed by Commit bot

Don't treat shorthand filters as errors on SVG content

We don't support filter shorthands yet, so we shouldn't treat them as
errors. Fix up the hasFilter() condition to also check if it's a filter
that we pretend we can handle.

Also straighten out the code-flow in applyFilterIfNecessary.

BUG=645995
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2349743003
Cr-Commit-Position: refs/heads/master@{#419267}
parent a2525d33
<!doctype html> <!doctype html>
<div style="width: 100px; height: 100px; background-color: blue; backface-visibility: hidden; filter: blur(10px)"></div> <div style="width: 100px; height: 100px; background-color: blue; backface-visibility: hidden; filter: blur(10px)"></div>
<div style="width: 100px; height: 100px; background-color: blue"></div>
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
} }
#root, #child { #root, #child {
display: block;
animation: blur-animation 1s infinite; animation: blur-animation 1s infinite;
} }
</style> </style>
<svg id="root"> <svg id="root" height="100">
<rect fill="blue" x="0" y="0" height="100" width="100" /> <rect fill="blue" x="0" y="0" height="100" width="100" />
</svg> </svg>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<!-- SVG child element: the first filter is valid, the rest are not. --> <!-- SVG child element: the first filter is valid, the rest are not. -->
<svg viewBox="0 0 50 50">
<rect fill="lime" x="0" y="0" height="50" width="50"/>
</svg>
<svg viewBox="0 0 50 50">
<rect fill="lime" x="0" y="0" height="50" width="50"/>
</svg>
<svg viewBox="0 0 50 50"> <svg viewBox="0 0 50 50">
<rect fill="lime" x="0" y="0" height="50" width="50"/> <rect fill="lime" x="0" y="0" height="50" width="50"/>
</svg> </svg>
......
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
</svg> </svg>
<svg viewBox="0 0 50 50"> <svg viewBox="0 0 50 50">
<rect fill="red" x="0" y="0" height="50" width="50" <rect fill="lime" x="0" y="0" height="50" width="50"
style="filter: url(#filter) blur(0px)"/> style="filter: url(#filter) blur(0px)"/>
</svg> </svg>
<svg viewBox="0 0 50 50"> <svg viewBox="0 0 50 50">
<rect fill="red" x="0" y="0" height="50" width="50" <rect fill="lime" x="0" y="0" height="50" width="50"
style="filter: blur(0px)"/> style="filter: blur(0px)"/>
</svg> </svg>
......
...@@ -134,12 +134,24 @@ bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) ...@@ -134,12 +134,24 @@ bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources)
return true; return true;
} }
bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) static bool hasReferenceFilterOnly(const ComputedStyle& style)
{ {
if (!resources) { if (!style.hasFilter())
if (m_object.style()->hasFilter()) return false;
const FilterOperations& operations = style.filter();
if (operations.size() != 1)
return false; return false;
} else if (LayoutSVGResourceFilter* filter = resources->filter()) { return operations.at(0)->type() == FilterOperation::REFERENCE;
}
bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources)
{
if (!resources)
return !hasReferenceFilterOnly(m_object.styleRef());
LayoutSVGResourceFilter* filter = resources->filter();
if (!filter)
return true;
m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(paintInfo().context)); m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(paintInfo().context));
m_filter = filter; m_filter = filter;
GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect(m_object, *m_filterRecordingContext); GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect(m_object, *m_filterRecordingContext);
...@@ -154,7 +166,6 @@ bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) ...@@ -154,7 +166,6 @@ bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources)
// invalidation rect changes, we need to paint the entire filter region // invalidation rect changes, we need to paint the entire filter region
// so elements outside the initial paint (due to scrolling, etc) paint. // so elements outside the initial paint (due to scrolling, etc) paint.
m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect();
}
return true; return true;
} }
......
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