Update handling of negative std.dev for feGaussianblur/feDropShadow

Spec[1] states:

 "A negative value or a value of zero disables the effect of the given
  filter primitive (i.e., the result is the filter input image)."

Update SVGFEGaussianBlurElement and SVGFEDropShadowElement to reflect
this, and update the references for the corresponding tests.

Drop accessors on FEDropShadow because they are unused.

[1] https://drafts.fxtf.org/filters/#element-attrdef-fegaussianblur-stddeviation

BUG=533457

Review URL: https://codereview.chromium.org/1350903009

git-svn-id: svn://svn.chromium.org/blink/trunk@202643 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation-expected.svg b/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation-expected.svg
index 5304af0..1630e43 100644
--- a/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation-expected.svg
+++ b/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation-expected.svg
@@ -1,6 +1,21 @@
 <?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
-"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+  <defs>
+    <filter id="f1">
+      <feDropShadow stdDeviation="0"/>
+    </filter>
+    <filter id="f2">
+      <feDropShadow stdDeviation="0 0"/>
+    </filter>
+    <filter id="f3">
+      <feDropShadow stdDeviation="1 0"/>
+    </filter>
+    <filter id="f4">
+      <feDropShadow stdDeviation="0 1"/>
+    </filter>
+  </defs>
+  <rect x="50" y="20" width="10" height="10" fill="green" filter="url(#f1)"/>
+  <rect x="50" y="40" width="10" height="10" fill="green" filter="url(#f2)"/>
+  <rect x="50" y="60" width="10" height="10" fill="green" filter="url(#f3)"/>
+  <rect x="50" y="80" width="10" height="10" fill="green" filter="url(#f4)"/>
 </svg>
diff --git a/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation.svg b/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation.svg
index 09c99a6..c9a5ff8 100644
--- a/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation.svg
+++ b/third_party/WebKit/LayoutTests/svg/filters/feDropShadow-negative-deviation.svg
@@ -1,7 +1,4 @@
 <?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
-"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
   <defs>
     <filter id="f1">
diff --git a/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation-expected.svg b/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation-expected.svg
index 5304af0..7cd5d79 100644
--- a/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation-expected.svg
+++ b/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation-expected.svg
@@ -1,6 +1,21 @@
 <?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
-"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+  <defs>
+    <filter id="f1">
+      <feGaussianBlur stdDeviation="0"/>
+    </filter>
+    <filter id="f2">
+      <feGaussianBlur stdDeviation="0 0"/>
+    </filter>
+    <filter id="f3">
+      <feGaussianBlur stdDeviation="1 0"/>
+    </filter>
+    <filter id="f4">
+      <feGaussianBlur stdDeviation="0 1"/>
+    </filter>
+  </defs>
+  <rect x="50" y="20" width="10" height="10" fill="green" filter="url(#f1)"/>
+  <rect x="50" y="40" width="10" height="10" fill="green" filter="url(#f2)"/>
+  <rect x="50" y="60" width="10" height="10" fill="green" filter="url(#f3)"/>
+  <rect x="50" y="80" width="10" height="10" fill="green" filter="url(#f4)"/>
 </svg>
diff --git a/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation.svg b/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation.svg
index 04d62311..368262a 100644
--- a/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation.svg
+++ b/third_party/WebKit/LayoutTests/svg/filters/feGaussianBlur-negative-deviation.svg
@@ -1,7 +1,4 @@
 <?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
-"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
   <defs>
     <filter id="f1">
diff --git a/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp b/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp
index 932e30e..24775e1 100644
--- a/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGFEDropShadowElement.cpp
@@ -80,9 +80,6 @@
     if (!layoutObject)
         return nullptr;
 
-    if (stdDeviationX()->currentValue()->value() < 0 || stdDeviationY()->currentValue()->value() < 0)
-        return nullptr;
-
     ASSERT(layoutObject->style());
     const SVGComputedStyle& svgStyle = layoutObject->style()->svgStyle();
 
@@ -93,7 +90,10 @@
     if (!input1)
         return nullptr;
 
-    RefPtrWillBeRawPtr<FilterEffect> effect = FEDropShadow::create(filter, stdDeviationX()->currentValue()->value(), stdDeviationY()->currentValue()->value(), m_dx->currentValue()->value(), m_dy->currentValue()->value(), color, opacity);
+    // Clamp std.dev. to non-negative. (See SVGFEGaussianBlurElement::build)
+    float stdDevX = std::max(0.0f, stdDeviationX()->currentValue()->value());
+    float stdDevY = std::max(0.0f, stdDeviationY()->currentValue()->value());
+    RefPtrWillBeRawPtr<FilterEffect> effect = FEDropShadow::create(filter, stdDevX, stdDevY, m_dx->currentValue()->value(), m_dy->currentValue()->value(), color, opacity);
     effect->inputEffects().append(input1);
     return effect.release();
 }
diff --git a/third_party/WebKit/Source/core/svg/SVGFEGaussianBlurElement.cpp b/third_party/WebKit/Source/core/svg/SVGFEGaussianBlurElement.cpp
index c322d8d..cfb1503e 100644
--- a/third_party/WebKit/Source/core/svg/SVGFEGaussianBlurElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGFEGaussianBlurElement.cpp
@@ -72,10 +72,14 @@
     if (!input1)
         return nullptr;
 
-    if (stdDeviationX()->currentValue()->value() < 0 || stdDeviationY()->currentValue()->value() < 0)
-        return nullptr;
-
-    RefPtrWillBeRawPtr<FilterEffect> effect = FEGaussianBlur::create(filter, stdDeviationX()->currentValue()->value(), stdDeviationY()->currentValue()->value());
+    // "A negative value or a value of zero disables the effect of the given
+    // filter primitive (i.e., the result is the filter input image)."
+    // (https://drafts.fxtf.org/filters/#element-attrdef-fegaussianblur-stddeviation)
+    //
+    // => Clamp to non-negative.
+    float stdDevX = std::max(0.0f, stdDeviationX()->currentValue()->value());
+    float stdDevY = std::max(0.0f, stdDeviationY()->currentValue()->value());
+    RefPtrWillBeRawPtr<FilterEffect> effect = FEGaussianBlur::create(filter, stdDevX, stdDevY);
     effect->inputEffects().append(input1);
     return effect.release();
 }
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h b/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
index ce7504f9..a1a02aa 100644
--- a/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
+++ b/third_party/WebKit/Source/platform/graphics/filters/FEDropShadow.h
@@ -30,24 +30,6 @@
 public:
     static PassRefPtrWillBeRawPtr<FEDropShadow> create(Filter*, float, float, float, float, const Color&, float);
 
-    float stdDeviationX() const { return m_stdX; }
-    void setStdDeviationX(float stdX) { m_stdX = stdX; }
-
-    float stdDeviationY() const { return m_stdY; }
-    void setStdDeviationY(float stdY) { m_stdY = stdY; }
-
-    float dx() const { return m_dx; }
-    void setDx(float dx) { m_dx = dx; }
-
-    float dy() const { return m_dy; }
-    void setDy(float dy) { m_dy = dy; }
-
-    Color shadowColor() const { return m_shadowColor; }
-    void setShadowColor(const Color& shadowColor) { m_shadowColor = shadowColor; }
-
-    float shadowOpacity() const { return m_shadowOpacity; }
-    void setShadowOpacity(float shadowOpacity) { m_shadowOpacity = shadowOpacity; }
-
     FloatRect mapRect(const FloatRect&, bool forward = true) final;
 
     TextStream& externalRepresentation(TextStream&, int indention) const override;