summaryrefslogtreecommitdiffstats
path: root/layout/reftests/invalidation/filter-userspace-offset.svg
blob: 2f0581b4d6821df08444a844d51304917e17819b (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<svg
  width="500px" height="500px" viewBox="0 0 500 500"
  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  >
  <title>Filters and offsets, user space origins, invalidation</title>
  <defs>
    <filter id="flood-boundingBox"
            filterUnits="objectBoundingBox"
            x="0%" y="0%" width="100%" height="100%"
            color-interpolation-filters="sRGB">
      <feFlood flood-color="lime"/>
    </filter>
    <filter id="matrix-boundingBox"
            filterUnits="objectBoundingBox"
            x="0%" y="0%" width="100%" height="100%"
            color-interpolation-filters="sRGB">
      <feColorMatrix type="matrix" values="0 1 0 0 0
                                           1 0 0 0 0
                                           0 0 1 0 0
                                           0 0 0 1 0"/>
    </filter>
    <filter id="matrix-fillPaint-boundingBox"
            filterUnits="objectBoundingBox"
            x="0%" y="0%" width="100%" height="100%"
            color-interpolation-filters="sRGB">
      <feColorMatrix type="matrix" values="0 1 0 0 0
                                           1 0 0 0 0
                                           0 0 1 0 0
                                           0 0 0 1 0" in="FillPaint"/>
    </filter>
    <filter id="flood-userSpace-atZero"
            filterUnits="userSpaceOnUse"
            x="0" y="0" width="100" height="100"
            color-interpolation-filters="sRGB">
      <feFlood flood-color="lime"/>
    </filter>
    <filter id="matrix-userSpace-atZero"
            filterUnits="userSpaceOnUse"
            x="0" y="0" width="100" height="100"
            color-interpolation-filters="sRGB">
      <feColorMatrix type="matrix" values="0 1 0 0 0
                                           1 0 0 0 0
                                           0 0 1 0 0
                                           0 0 0 1 0"/>
    </filter>
    <filter id="flood-userSpace-at100"
            filterUnits="userSpaceOnUse"
            x="100" y="100" width="100" height="100"
            color-interpolation-filters="sRGB">
      <feFlood flood-color="lime"/>
    </filter>
    <filter id="matrix-userSpace-at100"
            filterUnits="userSpaceOnUse"
            x="100" y="100" width="100" height="100"
            color-interpolation-filters="sRGB">
      <feColorMatrix type="matrix" values="0 1 0 0 0
                                           1 0 0 0 0
                                           0 0 1 0 0
                                           0 0 0 1 0"/>
    </filter>
    <filter id="matrix-fillPaint-userSpace-at100"
            filterUnits="userSpaceOnUse"
            x="100" y="100" width="100" height="100"
            color-interpolation-filters="sRGB">
      <feColorMatrix type="matrix" values="0 1 0 0 0
                                           1 0 0 0 0
                                           0 0 1 0 0
                                           0 0 0 1 0" in="FillPaint"/>
    </filter>
    <mask id="boundingBox" maskContentUnits="objectBoundingBox">
      <rect x="0" y="0" width="1" height="1" fill="white"/>
    </mask>
    <mask id="userSpace-atZero" maskContentUnits="userSpaceOnUse">
      <rect x="0" y="0" width="100" height="100" fill="white"/>
    </mask>
    <mask id="userSpace-at100" maskContentUnits="userSpaceOnUse">
      <rect x="100" y="100" width="100" height="100" fill="white"/>
    </mask>
    <g id="usedRect">
      <rect class="fillColor" width="100" height="100"/>
    </g>
  </defs>
  <g transform="translate(40,40)">
    <rect stroke-width="1" stroke="black" fill="none" x="99.5" y="99.5" width="101" height="101"/>

    <rect x="0" y="100" width="100" height="100" class="fillColor offsetContainer" id="rect"/>
    <use xlink:href="#usedRect" x="0" y="100" class="offsetContainer" id="use"/>
    <svg x="0" y="100" width="100" height="100" class="offsetContainer" id="innerSVG">
      <rect class="fillColor" width="100" height="100"/>
    </svg>
    <foreignObject x="0" y="100" width="100" height="100" class="offsetContainer" id="foreignObject">
      <svg width="100" height="100">
        <rect class="fillColor" width="100" height="100"/>
      </svg>
    </foreignObject>
  </g>
  <script><![CDATA[

var options = {
  offsetContainer: "rect",
  filter: null,
  mask: null,
  updateOffsetOn: "reftestInvalidate" // | "initial" | "timeout"
};

location.search.substr(1).split("&").forEach(function (s) {
  var pv = s.split("=");
  options[pv[0]] = pv[1] || true;
});

var offsetContainer = document.getElementById(options.offsetContainer);

function updateOffsetNow() {
  offsetContainer.setAttribute("x", "100");
}

function updateOffsetOnReftestInvalidate() {
  document.documentElement.setAttribute("class", "reftest-wait");
  document.addEventListener("MozReftestInvalidate", function () {
    updateOffsetNow();
    document.documentElement.removeAttribute("class");
  }, false);
}

function updateOffsetOnTimeout() {
  setTimeout(updateOffsetNow, 500);
}

options.updateOffset = options.updateOffsetOn == "initial" ? updateOffsetNow :
                         (options.updateOffsetOn == "timeout" ? updateOffsetOnTimeout :
                          updateOffsetOnReftestInvalidate);

var offsetContainers = Array.prototype.slice.call(document.getElementsByClassName("offsetContainer"), 0);
for (var i = 0; i < offsetContainers.length; i++) {
  if (offsetContainers[i] != offsetContainer) {
    offsetContainers[i].parentNode.removeChild(offsetContainers[i]);
  }
}

var fillColor = options.filter ? "red" : "lime";
if (options.filter) {
  offsetContainer.setAttribute("filter", "url(#" + options.filter + ")");
}
if (options.mask) {
  offsetContainer.setAttribute("mask", "url(#" + options.mask + ")");
}

var fillColors = document.getElementsByClassName("fillColor");
for (var j = 0; j < fillColors.length; j++) {
  fillColors[j].setAttribute("fill", fillColor);
}

options.updateOffset();

]]></script>
</svg>