| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 (function() { | 6 (function() { |
| 7 var testCount = 0; | 7 var testCount = 0; |
| 8 var animationEventCount = 0; | 8 var animationEventCount = 0; |
| 9 | 9 |
| 10 var durationSeconds = 0.001; | 10 var durationSeconds = 0.001; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 var url = /url\(([^\)]*)\)/g.exec(matches[i])[1]; | 181 var url = /url\(([^\)]*)\)/g.exec(matches[i])[1]; |
| 182 var anchor = document.createElement('a'); | 182 var anchor = document.createElement('a'); |
| 183 anchor.href = url; | 183 anchor.href = url; |
| 184 anchor.pathname = '...' + anchor.pathname.substring(anchor.pathname.last
IndexOf('/')); | 184 anchor.pathname = '...' + anchor.pathname.substring(anchor.pathname.last
IndexOf('/')); |
| 185 value = value.replace(matches[i], 'url(' + anchor.href + ')'); | 185 value = value.replace(matches[i], 'url(' + anchor.href + ')'); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 return value; | 188 return value; |
| 189 } | 189 } |
| 190 | 190 |
| 191 function serializeSVGNumberList(numberList) { |
| 192 var elements = []; |
| 193 for (var index = 0; index < numberList.numberOfItems; ++index) |
| 194 elements.push(numberList.getItem(index).value); |
| 195 return String(elements); |
| 196 } |
| 197 |
| 191 function serializeSVGPointList(pointList) { | 198 function serializeSVGPointList(pointList) { |
| 192 var elements = []; | 199 var elements = []; |
| 193 for (var index = 0; index < pointList.numberOfItems; ++index) { | 200 for (var index = 0; index < pointList.numberOfItems; ++index) { |
| 194 var point = pointList.getItem(index); | 201 var point = pointList.getItem(index); |
| 195 elements.push(point.x); | 202 elements.push(point.x); |
| 196 elements.push(point.y); | 203 elements.push(point.y); |
| 197 } | 204 } |
| 198 return String(elements); | 205 return String(elements); |
| 199 } | 206 } |
| 200 | 207 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 229 | 236 |
| 230 var result; | 237 var result; |
| 231 if (attributeName === 'points') | 238 if (attributeName === 'points') |
| 232 result = element['animatedPoints']; | 239 result = element['animatedPoints']; |
| 233 else | 240 else |
| 234 result = element[attributeName].animVal; | 241 result = element[attributeName].animVal; |
| 235 | 242 |
| 236 if (!result) { | 243 if (!result) { |
| 237 if (attributeName === 'filterResX' || attributeName === 'filterResY') | 244 if (attributeName === 'filterResX' || attributeName === 'filterResY') |
| 238 return null; | 245 return null; |
| 246 if (attributeName === 'pathLength') |
| 247 return '0'; |
| 239 | 248 |
| 240 console.log('Unknown attribute, cannot get ' + element.className.baseVal +
' ' + attributeName); | 249 console.log('Unknown attribute, cannot get ' + element.className.baseVal +
' ' + attributeName); |
| 241 return null; | 250 return null; |
| 242 } | 251 } |
| 243 | 252 |
| 244 if (result instanceof SVGAngle) | 253 if (result instanceof SVGAngle) |
| 245 result = result.value; | 254 result = result.value; |
| 255 else if (result instanceof SVGNumberList) |
| 256 result = serializeSVGNumberList(result); |
| 246 else if (result instanceof SVGPointList) | 257 else if (result instanceof SVGPointList) |
| 247 result = serializeSVGPointList(result); | 258 result = serializeSVGPointList(result); |
| 248 | 259 |
| 249 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul
t !== 'boolean') { | 260 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul
t !== 'boolean') { |
| 250 console.log('Attribute value has unexpected type: ' + result); | 261 console.log('Attribute value has unexpected type: ' + result); |
| 251 } | 262 } |
| 252 | 263 |
| 253 return String(result); | 264 return String(result); |
| 254 } | 265 } |
| 255 | 266 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 271 var setElement = document.createElementNS(svgNamespace, 'set'); | 282 var setElement = document.createElementNS(svgNamespace, 'set'); |
| 272 setElement.setAttribute('attributeName', namespacedAttributeName(attribute
Name)); | 283 setElement.setAttribute('attributeName', namespacedAttributeName(attribute
Name)); |
| 273 setElement.setAttribute('attributeType', 'XML'); | 284 setElement.setAttribute('attributeType', 'XML'); |
| 274 setElement.setAttribute('to', expectation); | 285 setElement.setAttribute('to', expectation); |
| 275 element.appendChild(setElement); | 286 element.appendChild(setElement); |
| 276 } else { | 287 } else { |
| 277 element.setAttribute(attributeName, expectation); | 288 element.setAttribute(attributeName, expectation); |
| 278 } | 289 } |
| 279 } | 290 } |
| 280 | 291 |
| 281 // The following collide with CSS properties. | 292 // The following collide with CSS properties or the Web Animations API (offset
). |
| 282 var svgPrefixedAttributes = [ | 293 var svgPrefixedAttributes = [ |
| 294 'offset', |
| 283 'order', | 295 'order', |
| 284 ]; | 296 ]; |
| 285 | 297 |
| 286 function makeKeyframes(target, attributeName, params) { | 298 function makeKeyframes(target, attributeName, params) { |
| 287 if (svgPrefixedAttributes.indexOf(attributeName) !== -1) | 299 if (svgPrefixedAttributes.indexOf(attributeName) !== -1) |
| 288 attributeName = 'svg' + attributeName[0].toUpperCase() + attributeName.sli
ce(1); | 300 attributeName = 'svg' + attributeName[0].toUpperCase() + attributeName.sli
ce(1); |
| 289 | 301 |
| 290 var keyframes = [{}, {}]; | 302 var keyframes = [{}, {}]; |
| 291 if (attributeName === 'class') { | 303 if (attributeName === 'class') { |
| 292 // Preserve the existing classes as we use them to select elements. | 304 // Preserve the existing classes as we use them to select elements. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 setTimeout(function() { | 422 setTimeout(function() { |
| 411 if (finished) { | 423 if (finished) { |
| 412 return; | 424 return; |
| 413 } | 425 } |
| 414 finishTest(); | 426 finishTest(); |
| 415 }, 5000); | 427 }, 5000); |
| 416 } | 428 } |
| 417 | 429 |
| 418 window.assertAttributeInterpolation = assertAttributeInterpolation; | 430 window.assertAttributeInterpolation = assertAttributeInterpolation; |
| 419 })(); | 431 })(); |
| OLD | NEW |