summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-08-17 20:27:14 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-03-12 08:39:15 +0100
commitb736f53a13af48de08026b7c7e64275122af66e2 (patch)
tree54c20be9b96d7085973469c12332f43839d82f88
parent4577efd50f8361ffa787d7fcba5f5894438f826c (diff)
downloadUXP-b736f53a13af48de08026b7c7e64275122af66e2.tar
UXP-b736f53a13af48de08026b7c7e64275122af66e2.tar.gz
UXP-b736f53a13af48de08026b7c7e64275122af66e2.tar.lz
UXP-b736f53a13af48de08026b7c7e64275122af66e2.tar.xz
UXP-b736f53a13af48de08026b7c7e64275122af66e2.zip
SVG - support radialGradient fr attribute
-rw-r--r--dom/base/nsGkAtomList.h1
-rw-r--r--dom/svg/SVGGradientElement.cpp9
-rw-r--r--dom/svg/SVGGradientElement.h7
-rw-r--r--dom/webidl/SVGRadialGradientElement.webidl4
-rw-r--r--layout/reftests/svg/radialGradient-fr-01.svg27
-rw-r--r--layout/reftests/svg/radialGradient-fr-02-ref.svg28
-rw-r--r--layout/reftests/svg/radialGradient-fr-02.svg27
-rw-r--r--layout/reftests/svg/reftest.list2
-rw-r--r--layout/svg/nsSVGGradientFrame.cpp5
-rw-r--r--testing/web-platform/meta/svg/interfaces.html.ini6
10 files changed, 103 insertions, 13 deletions
diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h
index 86a6fa99c..91427fabb 100644
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -1450,6 +1450,7 @@ GK_ATOM(font_style, "font-style")
GK_ATOM(font_variant, "font-variant")
GK_ATOM(foreignObject, "foreignObject")
GK_ATOM(fractalNoise, "fractalNoise")
+GK_ATOM(fr, "fr")
GK_ATOM(fx, "fx")
GK_ATOM(fy, "fy")
GK_ATOM(G, "G")
diff --git a/dom/svg/SVGGradientElement.cpp b/dom/svg/SVGGradientElement.cpp
index 1bcac67e6..93767c934 100644
--- a/dom/svg/SVGGradientElement.cpp
+++ b/dom/svg/SVGGradientElement.cpp
@@ -198,13 +198,14 @@ SVGRadialGradientElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenP
return SVGRadialGradientElementBinding::Wrap(aCx, this, aGivenProto);
}
-nsSVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[5] =
+nsSVGElement::LengthInfo SVGRadialGradientElement::sLengthInfo[6] =
{
{ &nsGkAtoms::cx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
{ &nsGkAtoms::cy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
{ &nsGkAtoms::r, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY },
{ &nsGkAtoms::fx, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
{ &nsGkAtoms::fy, 50, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
+ { &nsGkAtoms::fr, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY },
};
//----------------------------------------------------------------------
@@ -252,6 +253,12 @@ SVGRadialGradientElement::Fy()
return mLengthAttributes[ATTR_FY].ToDOMAnimatedLength(this);
}
+already_AddRefed<SVGAnimatedLength>
+SVGRadialGradientElement::Fr()
+{
+ return mLengthAttributes[ATTR_FR].ToDOMAnimatedLength(this);
+}
+
//----------------------------------------------------------------------
// nsSVGElement methods
diff --git a/dom/svg/SVGGradientElement.h b/dom/svg/SVGGradientElement.h
index 7b2c6b220..ce9f3b4b1 100644
--- a/dom/svg/SVGGradientElement.h
+++ b/dom/svg/SVGGradientElement.h
@@ -139,13 +139,14 @@ public:
already_AddRefed<SVGAnimatedLength> R();
already_AddRefed<SVGAnimatedLength> Fx();
already_AddRefed<SVGAnimatedLength> Fy();
+ already_AddRefed<SVGAnimatedLength> Fr();
protected:
virtual LengthAttributesInfo GetLengthInfo() override;
- enum { ATTR_CX, ATTR_CY, ATTR_R, ATTR_FX, ATTR_FY };
- nsSVGLength2 mLengthAttributes[5];
- static LengthInfo sLengthInfo[5];
+ enum { ATTR_CX, ATTR_CY, ATTR_R, ATTR_FX, ATTR_FY, ATTR_FR };
+ nsSVGLength2 mLengthAttributes[6];
+ static LengthInfo sLengthInfo[6];
};
} // namespace dom
diff --git a/dom/webidl/SVGRadialGradientElement.webidl b/dom/webidl/SVGRadialGradientElement.webidl
index d4a3724f6..8d7ce9016 100644
--- a/dom/webidl/SVGRadialGradientElement.webidl
+++ b/dom/webidl/SVGRadialGradientElement.webidl
@@ -21,5 +21,7 @@ interface SVGRadialGradientElement : SVGGradientElement {
readonly attribute SVGAnimatedLength fx;
[Constant]
readonly attribute SVGAnimatedLength fy;
- // readonly attribute SVGAnimatedLength fr;
+ // XXX: Bug 1242048
+ // [SameObject]
+ readonly attribute SVGAnimatedLength fr;
};
diff --git a/layout/reftests/svg/radialGradient-fr-01.svg b/layout/reftests/svg/radialGradient-fr-01.svg
new file mode 100644
index 000000000..2f28d3aba
--- /dev/null
+++ b/layout/reftests/svg/radialGradient-fr-01.svg
@@ -0,0 +1,27 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>Test gradient fr attribute</title>
+ <defs>
+ <radialGradient id="grad1" fr="100%">
+ <stop offset="0%" stop-color="red" />
+ <stop offset="100%" stop-color="lime" />
+ </radialGradient>
+ <radialGradient id="grad2" xlink:href="#grad1"/>
+ <style>
+ circle {
+ stroke-width: 3px;
+ stroke: lime;
+ }
+ </style>
+ </defs>
+ <rect width="100%" height="100%" fill="lime"/>
+
+ <circle cx="100" cy="100" r="50" fill="url(#grad1)" />
+
+ <circle cx="300" cy="100" r="50" fill="url(#grad2)" />
+</svg>
+
diff --git a/layout/reftests/svg/radialGradient-fr-02-ref.svg b/layout/reftests/svg/radialGradient-fr-02-ref.svg
new file mode 100644
index 000000000..c256f72a2
--- /dev/null
+++ b/layout/reftests/svg/radialGradient-fr-02-ref.svg
@@ -0,0 +1,28 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>Test gradient fr attribute</title>
+ <defs>
+ <radialGradient id="grad1">
+ <stop offset="0%" stop-color="red" />
+ <stop offset="20%" stop-color="red" />
+ <stop offset="100%" stop-color="lime" />
+ </radialGradient>
+ <style>
+ .cover {
+ stroke-width: 3px;
+ stroke: lime;
+ fill: none;
+ image-rendering: optimizeSpeed;
+ }
+ </style>
+ </defs>
+ <rect width="100%" height="100%" fill="lime"/>
+
+ <circle cx="100" cy="100" r="50" fill="url(#grad1)" />
+ <circle class="cover" cx="100" cy="100" r="50" fill="none"/>
+</svg>
+
diff --git a/layout/reftests/svg/radialGradient-fr-02.svg b/layout/reftests/svg/radialGradient-fr-02.svg
new file mode 100644
index 000000000..1933203be
--- /dev/null
+++ b/layout/reftests/svg/radialGradient-fr-02.svg
@@ -0,0 +1,27 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>Test gradient fr attribute</title>
+ <defs>
+ <radialGradient id="grad1" fr="10%">
+ <stop offset="0%" stop-color="red" />
+ <stop offset="100%" stop-color="lime" />
+ </radialGradient>
+ <style>
+ .cover {
+ stroke-width: 3px;
+ stroke: lime;
+ fill: none;
+ image-rendering: optimizeSpeed;
+ }
+ </style>
+ </defs>
+ <rect width="100%" height="100%" fill="lime"/>
+
+ <circle cx="100" cy="100" r="50" fill="url(#grad1)" />
+ <circle class="cover" cx="100" cy="100" r="50" />
+</svg>
+
diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list
index e596feae8..520adc9e6 100644
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -290,6 +290,8 @@ fuzzy-if(skiaContent,3,5) == pattern-scale-01c.svg pattern-scale-01-ref.svg
== radialGradient-basic-02.svg pass.svg
fuzzy-if(cocoaWidget,4,15982) fuzzy-if(winWidget,4,92) fuzzy-if(skiaContent,4,60) == radialGradient-basic-03.svg radialGradient-basic-03-ref.svg
== radialGradient-basic-04.svg pass.svg
+== radialGradient-fr-01.svg pass.svg
+fuzzy(1,3235) fuzzy-if(winWidget,1,6704) == radialGradient-fr-02.svg radialGradient-fr-02-ref.svg
fuzzy-if(skiaContent,1,3600) == rect-01.svg pass.svg
== rect-02.svg pass.svg
== rect-03.svg pass.svg
diff --git a/layout/svg/nsSVGGradientFrame.cpp b/layout/svg/nsSVGGradientFrame.cpp
index 217ab8c4a..2d7684f5a 100644
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -623,7 +623,7 @@ nsSVGRadialGradientFrame::GradientVectorLengthIsZero()
already_AddRefed<gfxPattern>
nsSVGRadialGradientFrame::CreateGradient()
{
- float cx, cy, r, fx, fy;
+ float cx, cy, r, fx, fy, fr;
cx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CX);
cy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CY);
@@ -631,6 +631,7 @@ nsSVGRadialGradientFrame::CreateGradient()
// If fx or fy are not set, use cx/cy instead
fx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FX, cx);
fy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FY, cy);
+ fr = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FR);
if (fx != cx || fy != cy) {
// The focal point (fFx and fFy) must be clamped to be *inside* - not on -
@@ -651,7 +652,7 @@ nsSVGRadialGradientFrame::CreateGradient()
}
}
- RefPtr<gfxPattern> pattern = new gfxPattern(fx, fy, 0, cx, cy, r);
+ RefPtr<gfxPattern> pattern = new gfxPattern(fx, fy, fr, cx, cy, r);
return pattern.forget();
}
diff --git a/testing/web-platform/meta/svg/interfaces.html.ini b/testing/web-platform/meta/svg/interfaces.html.ini
index f3f7f6b5c..1162695c8 100644
--- a/testing/web-platform/meta/svg/interfaces.html.ini
+++ b/testing/web-platform/meta/svg/interfaces.html.ini
@@ -820,12 +820,6 @@
[SVGElement interface: linearGradient must inherit property "onsort" with the proper type (62)]
expected: FAIL
- [SVGRadialGradientElement interface: attribute fr]
- expected: FAIL
-
- [SVGRadialGradientElement interface: radialGradient must inherit property "fr" with the proper type (5)]
- expected: FAIL
-
[SVGElement interface: radialGradient must inherit property "onautocomplete" with the proper type (8)]
expected: FAIL