haikuwebkit/LayoutTests/css3/color/gradients.html

47 lines
2.7 KiB
HTML
Raw Permalink Normal View History

[Color] Make gradients work with ExtendedColors https://bugs.webkit.org/show_bug.cgi?id=171315 <rdar://problems/31830177> Reviewed by Antoine Quint. Source/WebCore: Allow gradients to hold Color objects, and thus handle ExtendedColor. Implement the backend for CoreGraphics. Test: css3/color/gradients.html * platform/graphics/Gradient.cpp: (WebCore::Gradient::addColorStop): Just copy the Color now. (WebCore::compareStops): Handle rename of stop to offset. (WebCore::Gradient::hasAlpha): Use Color's helper. * platform/graphics/Gradient.h: (WebCore::Gradient::ColorStop::ColorStop): Rename stop to offset, and store a Color rather than four floating point values. * platform/graphics/cairo/GradientCairo.cpp: (WebCore::Gradient::platformGradient): * platform/graphics/cg/GradientCG.cpp: (WebCore::Gradient::platformGradient): Use the CG method that can handle CGColorRefs with ColorSpace values, and pass the Extended sRGB space which should be no change for all existing gradients but also handle ColorSpaces like Display P3. * platform/graphics/win/GradientDirect2D.cpp: (WebCore::Gradient::generateGradient): * svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::buildStops): LayoutTests: Test for gradients using the color() syntax. Unfortunately, due to rounding errors, we can't use a ref test for some transparent colors, so comment them out for the moment. These can be re-enabled when we can specify a tolerance value for image comparison in the testing framework. * css3/color/gradients-expected.html: Added. * css3/color/gradients.html: Added. Canonical link: https://commits.webkit.org/188211@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-26 17:34:50 +00:00
<style>
body {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><g fill="#ccc"><rect width="5" height="5"/><rect x="5" y="5" width="5" height="5"/></g></svg>');
background-size: 100px 100px;
}
.box {
display: inline-block;
width: 80px;
height: 80px;
}
</style>
<p>These two rows should be identical</p>
<div class="box" style="background: linear-gradient(red, blue);"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: linear-gradient(red, rgba(0, 0, 255, 0.5));"></div> -->
<div class="box" style="background: linear-gradient(red, blue, green, cyan);"></div>
<div class="box" style="background: linear-gradient(to bottom right, red, blue);"></div>
<div class="box" style="background: linear-gradient(to bottom left, rgba(255, 0, 0, 0.6), rgba(0, 0, 255, 0.6));"></div>
<br>
<div class="box" style="background: linear-gradient(color(srgb 1 0 0), blue);"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: linear-gradient(red, color(srgb 0 0 1 / 0.5));"></div> -->
<div class="box" style="background: linear-gradient(red, color(srgb 0 0 1), green, color(srgb 0 1 1));"></div>
<div class="box" style="background: linear-gradient(to bottom right, color(srgb 1 0 0), color(srgb 0 0 1));"></div>
<div class="box" style="background: linear-gradient(to bottom left, color(srgb 1 0 0 / 0.6), color(srgb 0 0 1 / 0.6));"></div>
<br>
<p>These two rows should be identical</p>
<div class="box" style="background: radial-gradient(green, yellow);"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: radial-gradient(orange, rgba(0, 0, 255, 0.5));"></div> -->
<div class="box" style="background: radial-gradient(red, blue, green, cyan);"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: radial-gradient(circle at top right, orange, purple);"></div> -->
<br>
<div class="box" style="background: radial-gradient(color(srgb 0 0.5 0), color(srgb 1 1 0));"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: radial-gradient(orange, color(srgb 0 0 1 / 0.5));"></div> -->
<div class="box" style="background: radial-gradient(red, color(srgb 0 0 1), green, color(srgb 0 1 1));"></div>
<!-- Floating point rounding means we can't use this in a ref test without some tolerance -->
<!-- <div class="box" style="background: radial-gradient(circle at top right, orange, color(srgb 0.5 0 0.5));"></div> -->