summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/painting/reftests/display-none-mask.html
blob: a6aa6007574ff6c3b2930fd15b6e51d65a633c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Mask behaviour when mask image is missing or display:none</title>
  <link rel="match"  href="display-none-mask-ref.html">
  <link name="author" title="Timothy Nikkel" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1624532">
  <link name="author" title="Mike Bremford" href="http://bfo.com"> <!-- edited 202010 -->
  <link rel="help" href="https://drafts.fxtf.org/css-masking-1/#the-mask-image">
  <link rel="help" href="https://drafts.fxtf.org/css-masking-1/#MaskElement">
  <link rel="help" href="https://github.com/w3c/fxtf-drafts/issues/245">
  <meta name="assert" content="A missing or invalid mask image is equivalent to transparent black (i.e. nothing is displayed). A mask with display:none is disabled (which is a change to the specified behaviour as of issue 245)">
</head>

<body>
  <svg width="200" height="200">
    <!-- missing/invalid mask is equivalent to transparent black - nothing displayed -->
    <foreignObject x="0" y="0" width="200" height="200" style="mask: url('#notfound');">
      <div style="width: 200px; height: 200px; background: red"></div>
    </foreignObject>
  </svg>
  <svg width="200" height="200">
    <!-- display:none on mask means mask is not applied (new in https://github.com/w3c/fxtf-drafts/issues/245) -->
    <foreignObject x="0" y="0" width="200" height="200" style="mask: url('#noneMask');">
      <div style="width: 200px; height: 200px; background: green"></div>
    </foreignObject>
  </svg>
  <svg width="200" height="200">
    <foreignObject x="0" y="0" width="200" height="200">
      <!-- missing/invalid mask is equivalent to transparent black - nothing displayed -->
      <div style="width: 200px; height: 200px; background: red; mask: url('#notfound');"></div>
    </foreignObject>
  </svg>
  <svg width="200" height="200">
    <foreignObject x="0" y="0" width="200" height="200">
      <!-- display:none on mask means mask is not applied (new in https://github.com/w3c/fxtf-drafts/issues/245) -->
      <div style="width: 200px; height: 200px; background: green; mask: url('#noneMask');"></div>
    </foreignObject>
  </svg>

  <svg width="200" height="200" style="display:none">
    <defs>
      <mask id="noneMask">
        <rect x="0" y="0" width="200" height="200" fill="#4d4d4d"></rect>
      </mask>
    </defs>
  </svg>

  <!-- make sure masking actually works -->
  <svg width="200" height="200">
    <defs>
      <mask id="aMask">
        <rect x="0" y="0" width="100" height="50" fill="#ffffff"></rect>
        <rect x="0" y="100" width="100" height="50" fill="#ffffff"></rect>
      </mask>
    </defs>
    <foreignObject x="0" y="0" width="200" height="200" style="mask: url('#aMask');">
      <div style="width: 200px; height: 200px; background: green;"></div>
    </foreignObject>
  </svg>
  <svg width="200" height="200">
    <foreignObject x="0" y="0" width="200" height="200">
      <div style="width: 200px; height: 200px; background: green; mask: url('#aMask');"></div>
    </foreignObject>
  </svg>

  <!-- make sure masking works on active content -->
  <svg width="200" height="200">
    <foreignObject x="0" y="0" width="200" height="200" style="mask: url('#aMask');">
      <div style="width: 200px; height: 200px; background: green; will-change: transform"></div>
    </foreignObject>
  </svg>
  <svg width="200" height="200">
    <foreignObject x="0" y="0" width="200" height="200">
      <div style="width: 200px; height: 200px; background: green; will-change: transform; mask: url('#aMask');"></div>
    </foreignObject>
  </svg>
</body>
</html>