haikuwebkit/LayoutTests/svg/css/computed-style-rgb-color.html

43 lines
1.6 KiB
HTML
Raw Permalink Normal View History

SVGColor custom text format is different from the CSS color custom text format https://bugs.webkit.org/show_bug.cgi?id=148879 Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-09-11 Reviewed by Daniel Bates. Source/WebCore: Implement the serialization of a CSS color value as it is described in <https://drafts.csswg.org/cssom/#serializing-css-values>. Add the new function Color::cssText() which is refactored from the existing function Color::serialized(). Use the new function for serializing the SVGColor always and also for Color but only when the alpha component is not 1. Test: svg/css/computed-style-rgb-color.html * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): Move the code for serializing the color from this function to Color::cssText(). * platform/graphics/Color.cpp: (WebCore::Color::serialized): Call Color::cssText() if the alpha component is not 1 and delete the repeated code. (WebCore::Color::cssText): * platform/graphics/Color.h: Add the new function to the header file. * svg/SVGColor.cpp: (WebCore::SVGColor::customCSSText): Call Color::cssText() always instead of calling Color::serialized() for serializing the SVGColor. LayoutTests: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/parse-color-int-or-percent-crash.html: * platform/mac/svg/webarchive/svg-script-subresouces-expected.txt: * svg/css/case-sensitive-tags-expected.txt: * svg/css/case-sensitive-tags.html: * svg/css/getComputedStyle-basic-expected.txt: * svg/css/script-tests/svg-attribute-parser-mode.js: * svg/css/svg-attribute-parser-mode-expected.txt: * svg/dom/SVGColor-expected.txt: * svg/dom/SVGPaint-expected.txt: * svg/dom/SVGStyleElement/disable-svg-style-element-expected.txt: * svg/dom/SVGStyleElement/script-tests/disable-svg-style-element.js: * svg/dom/script-tests/SVGColor.js: * svg/dom/script-tests/SVGPaint.js: * svg/webarchive/svg-script-subresouces-expected.webarchive: * transitions/svg-transitions-expected.txt: Fix expected results for existing tests * svg/css/computed-style-rgb-color-expected.txt: Added. * svg/css/computed-style-rgb-color.html: Added. Ensure that the correct format is returned when getComputedStyle() is called for an SVG color. Canonical link: https://commits.webkit.org/167179@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189646 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-12 01:51:56 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
display: inline-block;
}
.fully-opaque {
background-color: green;
}
.fully-transparent {
background-color: transparent;
}
.half-transparent {
background-color: rgba(0, 128, 0, 0.4);
}
</style>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div class="fully-opaque"></div>
<div class="fully-transparent"></div>
<div class="half-transparent"></div>
<br>
<svg width="400">
<rect id="fully-opaque" width="100" height="100" fill="green"/>
<rect id="fully-transparent" x="104" width="100" height="100" fill="none"/>
<rect id="half-transparent" x="208" width="100" height="100" fill="rgba(0, 128, 0, 0.4)"/>
</svg>
<script>
shouldBeEqualToString("getComputedStyle(document.querySelector('div.fully-opaque')).backgroundColor", "rgb(0, 128, 0)");
shouldBeEqualToString("getComputedStyle(document.querySelector('div.fully-transparent')).backgroundColor", "rgba(0, 0, 0, 0)");
shouldBeEqualToString("getComputedStyle(document.querySelector('div.half-transparent')).backgroundColor", "rgba(0, 128, 0, 0.4)");
shouldBeEqualToString("getComputedStyle(document.querySelector('svg>rect#fully-opaque')).fill", "rgb(0, 128, 0)");
shouldBeEqualToString("getComputedStyle(document.querySelector('svg>rect#fully-transparent')).fill", "none");
shouldBeEqualToString("getComputedStyle(document.querySelector('svg>rect#half-transparent')).fill", "rgba(0, 128, 0, 0.4)");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>