mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Allow currentColor in canvas context's shadowColor (#30754)
This allows unifying the parse_color function and method, aligns Servo with other browsers, and obeys the HTML spec: - https://html.spec.whatwg.org/multipage/canvas.html#shadows - https://html.spec.whatwg.org/multipage/infrastructure.html#parsed-as-a-css-color-value
This commit is contained in:
parent
334c67a3cc
commit
3543a87592
8 changed files with 186 additions and 56 deletions
|
@ -439502,7 +439502,7 @@
|
|||
[]
|
||||
],
|
||||
"shadows.yaml": [
|
||||
"366ac0b6072dfaa9de58abbda84525d9fe1806d1",
|
||||
"953ab2c555d5ad9d46d52b6c74f09d344850982c",
|
||||
[]
|
||||
],
|
||||
"text.yaml": [
|
||||
|
@ -621476,6 +621476,27 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"2d.shadow.attributes.shadowColor.current.basic.html": [
|
||||
"bfdc54d31b71e663bb2eef282c2fb4c9655af98f",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"2d.shadow.attributes.shadowColor.current.changed.html": [
|
||||
"9eee2122d5efb1c56f0ad695b90e1d2df54f2c5c",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"2d.shadow.attributes.shadowColor.current.removed.html": [
|
||||
"e1989cbdc80622ff1598adf0485377c7d28777b6",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"2d.shadow.attributes.shadowColor.initial.html": [
|
||||
"f4d0d33d6d9af347af413fdfc1436034a4a3c919",
|
||||
[
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.shadow.attributes.shadowColor.current.basic</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
|
||||
<body class="show_output">
|
||||
|
||||
<h1>2d.shadow.attributes.shadowColor.current.basic</h1>
|
||||
<p class="desc">currentColor is computed from the canvas element</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("currentColor is computed from the canvas element");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
canvas.style.color = '#0f0';
|
||||
ctx.shadowColor = 'currentColor';
|
||||
_assertSame(ctx.shadowColor, '#00ff00', "ctx.shadowColor", "'#00ff00'");
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.shadow.attributes.shadowColor.current.changed</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
|
||||
<body class="show_output">
|
||||
|
||||
<h1>2d.shadow.attributes.shadowColor.current.changed</h1>
|
||||
<p class="desc">currentColor is computed when the attribute is set, not when it is painted</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("currentColor is computed when the attribute is set, not when it is painted");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
canvas.style.color = '#0f0';
|
||||
ctx.shadowColor = 'currentColor';
|
||||
canvas.style.color = '#f00';
|
||||
_assertSame(ctx.shadowColor, '#00ff00', "ctx.shadowColor", "'#00ff00'");
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.shadow.attributes.shadowColor.current.removed</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
|
||||
<body class="show_output">
|
||||
|
||||
<h1>2d.shadow.attributes.shadowColor.current.removed</h1>
|
||||
<p class="desc">currentColor is solid black when the canvas element is not in a document</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("currentColor is solid black when the canvas element is not in a document");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
// Try not to let it undetectably incorrectly pick up opaque-black
|
||||
// from other parts of the document:
|
||||
document.documentElement.style.color = '#f00';
|
||||
document.body.style.color = '#f00';
|
||||
canvas.style.color = '#f00';
|
||||
|
||||
canvas.remove();
|
||||
ctx.shadowColor = 'currentColor';
|
||||
_assertSame(ctx.shadowColor, '#000000', "ctx.shadowColor", "'#000000'");
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -134,6 +134,37 @@
|
|||
ctx.shadowColor = 'RGBA(0,255, 0,0)';
|
||||
@assert ctx.shadowColor === 'rgba(0, 255, 0, 0)';
|
||||
|
||||
- name: 2d.shadow.attributes.shadowColor.current.basic
|
||||
desc: currentColor is computed from the canvas element
|
||||
canvasType: ['HtmlCanvas']
|
||||
code: |
|
||||
canvas.style.color = '#0f0';
|
||||
ctx.shadowColor = 'currentColor';
|
||||
@assert ctx.shadowColor === '#00ff00';
|
||||
|
||||
- name: 2d.shadow.attributes.shadowColor.current.changed
|
||||
desc: currentColor is computed when the attribute is set, not when it is painted
|
||||
canvasType: ['HtmlCanvas']
|
||||
code: |
|
||||
canvas.style.color = '#0f0';
|
||||
ctx.shadowColor = 'currentColor';
|
||||
canvas.style.color = '#f00';
|
||||
@assert ctx.shadowColor === '#00ff00';
|
||||
|
||||
- name: 2d.shadow.attributes.shadowColor.current.removed
|
||||
desc: currentColor is solid black when the canvas element is not in a document
|
||||
canvasType: ['HtmlCanvas']
|
||||
code: |
|
||||
// Try not to let it undetectably incorrectly pick up opaque-black
|
||||
// from other parts of the document:
|
||||
document.documentElement.style.color = '#f00';
|
||||
document.body.style.color = '#f00';
|
||||
canvas.style.color = '#f00';
|
||||
|
||||
canvas.remove();
|
||||
ctx.shadowColor = 'currentColor';
|
||||
@assert ctx.shadowColor === '#000000';
|
||||
|
||||
- name: 2d.shadow.attributes.shadowColor.invalid
|
||||
code: |
|
||||
ctx.shadowColor = '#00ff00';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue