| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 240 |
| 234 var result; | 241 var result; |
| 235 if (attributeName === 'points') | 242 if (attributeName === 'points') |
| 236 result = element['animatedPoints']; | 243 result = element['animatedPoints']; |
| 237 else | 244 else |
| 238 result = element[attributeName].animVal; | 245 result = element[attributeName].animVal; |
| 239 | 246 |
| 240 if (!result) { | 247 if (!result) { |
| 241 if (attributeName === 'filterResX' || attributeName === 'filterResY') | 248 if (attributeName === 'filterResX' || attributeName === 'filterResY') |
| 242 return null; | 249 return null; |
| 250 if (attributeName === 'pathLength') |
| 251 return '0'; |
| 243 | 252 |
| 244 console.log('Unknown attribute, cannot get ' + element.className.baseVal +
' ' + attributeName); | 253 console.log('Unknown attribute, cannot get ' + element.className.baseVal +
' ' + attributeName); |
| 245 return null; | 254 return null; |
| 246 } | 255 } |
| 247 | 256 |
| 248 if (result instanceof SVGAngle) | 257 if (result instanceof SVGAngle) |
| 249 result = result.value; | 258 result = result.value; |
| 259 else if (result instanceof SVGNumberList) |
| 260 result = serializeSVGNumberList(result); |
| 250 else if (result instanceof SVGPointList) | 261 else if (result instanceof SVGPointList) |
| 251 result = serializeSVGPointList(result); | 262 result = serializeSVGPointList(result); |
| 252 else if (result instanceof SVGRect) | 263 else if (result instanceof SVGRect) |
| 253 result = serializeSVGRect(result); | 264 result = serializeSVGRect(result); |
| 254 | 265 |
| 255 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul
t !== 'boolean') { | 266 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul
t !== 'boolean') { |
| 256 console.log('Attribute value has unexpected type: ' + result); | 267 console.log('Attribute value has unexpected type: ' + result); |
| 257 } | 268 } |
| 258 | 269 |
| 259 return String(result); | 270 return String(result); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 277 var setElement = document.createElementNS(svgNamespace, 'set'); | 288 var setElement = document.createElementNS(svgNamespace, 'set'); |
| 278 setElement.setAttribute('attributeName', namespacedAttributeName(attribute
Name)); | 289 setElement.setAttribute('attributeName', namespacedAttributeName(attribute
Name)); |
| 279 setElement.setAttribute('attributeType', 'XML'); | 290 setElement.setAttribute('attributeType', 'XML'); |
| 280 setElement.setAttribute('to', expectation); | 291 setElement.setAttribute('to', expectation); |
| 281 element.appendChild(setElement); | 292 element.appendChild(setElement); |
| 282 } else { | 293 } else { |
| 283 element.setAttribute(attributeName, expectation); | 294 element.setAttribute(attributeName, expectation); |
| 284 } | 295 } |
| 285 } | 296 } |
| 286 | 297 |
| 287 // The following collide with CSS properties. | 298 // The following collide with CSS properties or the Web Animations API (offset
). |
| 288 var svgPrefixedAttributes = [ | 299 var svgPrefixedAttributes = [ |
| 300 'offset', |
| 289 'order', | 301 'order', |
| 290 ]; | 302 ]; |
| 291 | 303 |
| 292 function makeKeyframes(target, attributeName, params) { | 304 function makeKeyframes(target, attributeName, params) { |
| 293 if (svgPrefixedAttributes.indexOf(attributeName) !== -1) | 305 if (svgPrefixedAttributes.indexOf(attributeName) !== -1) |
| 294 attributeName = 'svg' + attributeName[0].toUpperCase() + attributeName.sli
ce(1); | 306 attributeName = 'svg' + attributeName[0].toUpperCase() + attributeName.sli
ce(1); |
| 295 | 307 |
| 296 var keyframes = [{}, {}]; | 308 var keyframes = [{}, {}]; |
| 297 if (attributeName === 'class') { | 309 if (attributeName === 'class') { |
| 298 // Preserve the existing classes as we use them to select elements. | 310 // Preserve the existing classes as we use them to select elements. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 setTimeout(function() { | 428 setTimeout(function() { |
| 417 if (finished) { | 429 if (finished) { |
| 418 return; | 430 return; |
| 419 } | 431 } |
| 420 finishTest(); | 432 finishTest(); |
| 421 }, 5000); | 433 }, 5000); |
| 422 } | 434 } |
| 423 | 435 |
| 424 window.assertAttributeInterpolation = assertAttributeInterpolation; | 436 window.assertAttributeInterpolation = assertAttributeInterpolation; |
| 425 })(); | 437 })(); |
| OLD | NEW |