Skip to content
Permalink
Browse files
[SVG] Default for x1, y1 and y2 is 0% for LinearGradient
[SVG] Default for x1, y1 and y2 is 0% for LinearGradient
https://bugs.webkit.org/show_bug.cgi?id=248212

Reviewed by Nikolas Zimmermann.

This patch is to align Webkit with Blink / Chrome and Gecko / Firefox.

Merge - https://chromium.googlesource.com/chromium/blink/+/219dff463987f53c22f5f96f35a794246a13538d

As per the spec, if the x1|y1|y2 attribute is not specified,
the effect is as if a value of "0%" were specified.

* Source/WebCore/svg/SVGLinearGradientElement.h: Update default values for x1, y1 and y2
* LayoutTests/svg/gradient/linear-gradient-default-length.html: Add Test Case
* LayoutTests/svg/gradient/linear-gradient-default-length-expected.txt: Add Test Case Expectations
* LayoutTests/svg/gradient/linear-gradient-y2-default-length.svg: Added Test Case
* LayoutTests/svg/gradient/linear-gradient-y2-default-length-expected.svg: Added Test Case Expectations
* LayoutTests/svg/gradient/linear-gradient-y1-default-length.svg: Added Test Case
* LayoutTests/svg/gradient/linear-gradient-y1-default-length-expected.svg: Added Test Case Expectations
* LayoutTests/svg/gradient/linear-gradient-x1-default-length.svg: Added Test Case
* LayoutTests/svg/gradient/linear-gradient-x1-default-length-expected.svg: Added Test Case Expectations

Canonical link: https://commits.webkit.org/257032@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Nov 26, 2022
1 parent 24d58cd commit 7a2abd482abc992a55a58f3a3b7957229775ac2c
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 3 deletions.
@@ -0,0 +1,6 @@

PASS Testing SVGLinearGradientElement coordinate defaults x1
PASS Testing SVGLinearGradientElement coordinate defaults x2
PASS Testing SVGLinearGradientElement coordinate defaults y1
PASS Testing SVGLinearGradientElement coordinate defaults y2

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>SVGLinearGradientElement coordinate defaults</title>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<svg>
<linearGradient id="lg"/>
</svg>
<script>
function testLengthValue(result, expected, testcase) {
test(function() {
assert_equals(result, expected);
}, "Testing " + document.title + " " + testcase);
}
var linearGradient = document.querySelector("#lg");
testLengthValue(linearGradient.x1.baseVal.valueAsString, "0%", "x1");
testLengthValue(linearGradient.x2.baseVal.valueAsString, "100%", "x2");
testLengthValue(linearGradient.y1.baseVal.valueAsString, "0%", "y1");
testLengthValue(linearGradient.y2.baseVal.valueAsString, "0%", "y2");
</script>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -57,10 +57,10 @@ class SVGLinearGradientElement final : public SVGGradientElement {

bool selfHasRelativeLengths() const override;

Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, SVGLengthMode::Width, "0%"_s) };
Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, SVGLengthMode::Height, "0%"_s) };
Ref<SVGAnimatedLength> m_x2 { SVGAnimatedLength::create(this, SVGLengthMode::Width, "100%"_s) };
Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, SVGLengthMode::Height, "0%"_s) };
};

} // namespace WebCore

0 comments on commit 7a2abd4

Please sign in to comment.