Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/resources/interpolation-test.js

Issue 1417103003: Use getAttribute to sample 'd' attribute in interpolation-test.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/svg-d-interpolation.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return String(elements); 195 return String(elements);
196 } 196 }
197 197
198 function serializeSVGNumberList(numberList) { 198 function serializeSVGNumberList(numberList) {
199 var elements = []; 199 var elements = [];
200 for (var index = 0; index < numberList.numberOfItems; ++index) 200 for (var index = 0; index < numberList.numberOfItems; ++index)
201 elements.push(numberList.getItem(index).value); 201 elements.push(numberList.getItem(index).value);
202 return String(elements); 202 return String(elements);
203 } 203 }
204 204
205 function serializeSVGPathSegList(pathSegList) {
206 var elements = [];
207 for (var index = 0; index < pathSegList.numberOfItems; ++index) {
208 var pathSeg = pathSegList.getItem(index);
209 switch (pathSeg.pathSegType) {
210 case SVGPathSeg.PATHSEG_CLOSEPATH:
211 elements.push('z');
212 break;
213 case SVGPathSeg.PATHSEG_MOVETO_ABS:
214 elements.push('M');
215 elements.push(pathSeg.x);
216 elements.push(pathSeg.y);
217 break;
218 case SVGPathSeg.PATHSEG_MOVETO_REL:
219 elements.push('m');
220 elements.push(pathSeg.x);
221 elements.push(pathSeg.y);
222 break;
223 case SVGPathSeg.PATHSEG_LINETO_ABS:
224 elements.push('L');
225 elements.push(pathSeg.x);
226 elements.push(pathSeg.y);
227 break;
228 case SVGPathSeg.PATHSEG_LINETO_REL:
229 elements.push('l');
230 elements.push(pathSeg.x);
231 elements.push(pathSeg.y);
232 break;
233 case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
234 elements.push('C');
235 elements.push(pathSeg.x1);
236 elements.push(pathSeg.y1);
237 elements.push(pathSeg.x2);
238 elements.push(pathSeg.y2);
239 elements.push(pathSeg.x);
240 elements.push(pathSeg.y);
241 break;
242 case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
243 elements.push('c');
244 elements.push(pathSeg.x1);
245 elements.push(pathSeg.y1);
246 elements.push(pathSeg.x2);
247 elements.push(pathSeg.y2);
248 elements.push(pathSeg.x);
249 elements.push(pathSeg.y);
250 break;
251 case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
252 elements.push('Q');
253 elements.push(pathSeg.x1);
254 elements.push(pathSeg.y1);
255 elements.push(pathSeg.x);
256 elements.push(pathSeg.y);
257 break;
258 case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
259 elements.push('q');
260 elements.push(pathSeg.x1);
261 elements.push(pathSeg.y1);
262 elements.push(pathSeg.x);
263 elements.push(pathSeg.y);
264 break;
265 case SVGPathSeg.PATHSEG_ARC_ABS:
266 elements.push('A');
267 elements.push(pathSeg.r1);
268 elements.push(pathSeg.r2);
269 elements.push(pathSeg.angle);
270 elements.push(pathSeg.largeArcFlag);
271 elements.push(pathSeg.sweepFlag);
272 elements.push(pathSeg.x);
273 elements.push(pathSeg.y);
274 break;
275 case SVGPathSeg.PATHSEG_ARC_REL:
276 elements.push('a');
277 elements.push(pathSeg.r1);
278 elements.push(pathSeg.r2);
279 elements.push(pathSeg.angle);
280 elements.push(pathSeg.largeArcFlag);
281 elements.push(pathSeg.sweepFlag);
282 elements.push(pathSeg.x);
283 elements.push(pathSeg.y);
284 break;
285 case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
286 elements.push('H');
287 elements.push(pathSeg.x);
288 break;
289 case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
290 elements.push('h');
291 elements.push(pathSeg.x);
292 break;
293 case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
294 elements.push('V');
295 elements.push(pathSeg.y);
296 break;
297 case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
298 elements.push('v');
299 elements.push(pathSeg.y);
300 break;
301 case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
302 elements.push('S');
303 elements.push(pathSeg.x2);
304 elements.push(pathSeg.y2);
305 elements.push(pathSeg.x);
306 elements.push(pathSeg.y);
307 break;
308 case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
309 elements.push('s');
310 elements.push(pathSeg.x2);
311 elements.push(pathSeg.y2);
312 elements.push(pathSeg.x);
313 elements.push(pathSeg.y);
314 break;
315 case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
316 elements.push('T');
317 elements.push(pathSeg.x);
318 elements.push(pathSeg.y);
319 break;
320 case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
321 elements.push('t');
322 elements.push(pathSeg.x);
323 elements.push(pathSeg.y);
324 break;
325 default:
326 console.log('Invalid path segment type ' + pathSeg.pathSegType);
327 return null;
328 }
329 }
330 return elements.join(' ').replace('false', '0').replace('true', '1');
331 }
332
333 function serializeSVGPointList(pointList) { 205 function serializeSVGPointList(pointList) {
334 var elements = []; 206 var elements = [];
335 for (var index = 0; index < pointList.numberOfItems; ++index) { 207 for (var index = 0; index < pointList.numberOfItems; ++index) {
336 var point = pointList.getItem(index); 208 var point = pointList.getItem(index);
337 elements.push(point.x); 209 elements.push(point.x);
338 elements.push(point.y); 210 elements.push(point.y);
339 } 211 }
340 return String(elements); 212 return String(elements);
341 } 213 }
342 214
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 267
396 // The attribute 'orient' is exposed in IDL as 'orientType' and 'orientAngle ' 268 // The attribute 'orient' is exposed in IDL as 'orientType' and 'orientAngle '
397 if (attributeName === 'orient') { 269 if (attributeName === 'orient') {
398 if (element['orientType'] && element['orientType'].animVal === SVGMarkerEl ement.SVG_MARKER_ORIENT_AUTO) 270 if (element['orientType'] && element['orientType'].animVal === SVGMarkerEl ement.SVG_MARKER_ORIENT_AUTO)
399 return 'auto'; 271 return 'auto';
400 attributeName = 'orientAngle'; 272 attributeName = 'orientAngle';
401 } 273 }
402 274
403 var result; 275 var result;
404 if (attributeName === 'd') 276 if (attributeName === 'd')
405 result = element['animatedPathSegList']; 277 result = element.getAttribute('d');
406 else if (attributeName === 'points') 278 else if (attributeName === 'points')
407 result = element['animatedPoints']; 279 result = element['animatedPoints'];
408 else 280 else
409 result = element[attributeName].animVal; 281 result = element[attributeName].animVal;
410 282
411 if (!result) { 283 if (!result) {
412 if (attributeName === 'pathLength') 284 if (attributeName === 'pathLength')
413 return '0'; 285 return '0';
414 if (attributeName === 'preserveAlpha') 286 if (attributeName === 'preserveAlpha')
415 return 'false'; 287 return 'false';
416 288
417 console.log('Unknown attribute, cannot get ' + element.className.baseVal + ' ' + attributeName); 289 console.log('Unknown attribute, cannot get ' + element.className.baseVal + ' ' + attributeName);
418 return null; 290 return null;
419 } 291 }
420 292
421 if (result instanceof SVGAngle || result instanceof SVGLength) 293 if (result instanceof SVGAngle || result instanceof SVGLength)
422 result = result.value; 294 result = result.value;
423 else if (result instanceof SVGLengthList) 295 else if (result instanceof SVGLengthList)
424 result = serializeSVGLengthList(result); 296 result = serializeSVGLengthList(result);
425 else if (result instanceof SVGNumberList) 297 else if (result instanceof SVGNumberList)
426 result = serializeSVGNumberList(result); 298 result = serializeSVGNumberList(result);
427 else if (result instanceof SVGPathSegList)
428 result = serializeSVGPathSegList(result);
429 else if (result instanceof SVGPointList) 299 else if (result instanceof SVGPointList)
430 result = serializeSVGPointList(result); 300 result = serializeSVGPointList(result);
431 else if (result instanceof SVGPreserveAspectRatio) 301 else if (result instanceof SVGPreserveAspectRatio)
432 result = serializeSVGPreserveAspectRatio(result); 302 result = serializeSVGPreserveAspectRatio(result);
433 else if (result instanceof SVGRect) 303 else if (result instanceof SVGRect)
434 result = serializeSVGRect(result); 304 result = serializeSVGRect(result);
435 else if (result instanceof SVGTransformList) 305 else if (result instanceof SVGTransformList)
436 result = serializeSVGTransformList(result); 306 result = serializeSVGTransformList(result);
437 307
438 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul t !== 'boolean') { 308 if (typeof result !== 'string' && typeof result !== 'number' && typeof resul t !== 'boolean') {
439 console.log('Attribute value has unexpected type: ' + result); 309 console.log('Attribute value has unexpected type: ' + result);
440 } 310 }
441 311
442 return String(result); 312 return String(result);
443 } 313 }
444 314
445 function setAttributeValue(element, attributeName, expectation) { 315 function setAttributeValue(element, attributeName, expectation) {
446 if (!element[attributeName] 316 if (!element[attributeName]
447 && attributeName !== 'class' 317 && attributeName !== 'class'
448 && (attributeName !== 'd' || !element['pathSegList']) 318 && attributeName !== 'd'
449 && (attributeName !== 'in' || !element['in1']) 319 && (attributeName !== 'in' || !element['in1'])
450 && (attributeName !== 'orient' || !element['orientType']) 320 && (attributeName !== 'orient' || !element['orientType'])
451 && (animatedNumberOptionalNumberAttributes.indexOf(attributeName) === -1 || !element[attributeName + 'X'])) { 321 && (animatedNumberOptionalNumberAttributes.indexOf(attributeName) === -1 || !element[attributeName + 'X'])) {
452 console.log('Unknown attribute, cannot set ' + element.className.baseVal + ' ' + attributeName); 322 console.log('Unknown attribute, cannot set ' + element.className.baseVal + ' ' + attributeName);
453 return; 323 return;
454 } 324 }
455 325
456 if (attributeName === 'class') { 326 if (attributeName === 'class') {
457 // Preserve the existing classes as we use them to select elements. 327 // Preserve the existing classes as we use them to select elements.
458 expectation = element['className'].baseVal + ' ' + expectation; 328 expectation = element['className'].baseVal + ' ' + expectation;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 setTimeout(function() { 525 setTimeout(function() {
656 if (finished) { 526 if (finished) {
657 return; 527 return;
658 } 528 }
659 finishTest(); 529 finishTest();
660 }, 5000); 530 }, 5000);
661 } 531 }
662 532
663 window.assertAttributeInterpolation = assertAttributeInterpolation; 533 window.assertAttributeInterpolation = assertAttributeInterpolation;
664 })(); 534 })();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/animations/svg-attribute-interpolation/svg-d-interpolation.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698