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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.cpp

Issue 1526103002: Shrink SVGPreserveAspectRatio::valueAsString (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android warning. Created 5 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 else if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESE RVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMID) 324 else if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESE RVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMID)
325 transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogi calHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidt h) / 2); 325 transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogi calHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidt h) / 2);
326 else 326 else
327 transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogi calHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidt h)); 327 transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogi calHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidt h));
328 328
329 return transform; 329 return transform;
330 } 330 }
331 331
332 String SVGPreserveAspectRatio::valueAsString() const 332 String SVGPreserveAspectRatio::valueAsString() const
333 { 333 {
334 String alignType; 334 StringBuilder builder;
335 335
336 const char* alignString = "";
336 switch (m_align) { 337 switch (m_align) {
337 case SVG_PRESERVEASPECTRATIO_NONE: 338 case SVG_PRESERVEASPECTRATIO_NONE:
338 alignType = "none"; 339 alignString = "none";
339 break; 340 break;
340 case SVG_PRESERVEASPECTRATIO_XMINYMIN: 341 case SVG_PRESERVEASPECTRATIO_XMINYMIN:
341 alignType = "xMinYMin"; 342 alignString = "xMinYMin";
342 break; 343 break;
343 case SVG_PRESERVEASPECTRATIO_XMIDYMIN: 344 case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
344 alignType = "xMidYMin"; 345 alignString = "xMidYMin";
345 break; 346 break;
346 case SVG_PRESERVEASPECTRATIO_XMAXYMIN: 347 case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
347 alignType = "xMaxYMin"; 348 alignString = "xMaxYMin";
348 break; 349 break;
349 case SVG_PRESERVEASPECTRATIO_XMINYMID: 350 case SVG_PRESERVEASPECTRATIO_XMINYMID:
350 alignType = "xMinYMid"; 351 alignString = "xMinYMid";
351 break; 352 break;
352 case SVG_PRESERVEASPECTRATIO_XMIDYMID: 353 case SVG_PRESERVEASPECTRATIO_XMIDYMID:
353 alignType = "xMidYMid"; 354 alignString = "xMidYMid";
354 break; 355 break;
355 case SVG_PRESERVEASPECTRATIO_XMAXYMID: 356 case SVG_PRESERVEASPECTRATIO_XMAXYMID:
356 alignType = "xMaxYMid"; 357 alignString = "xMaxYMid";
357 break; 358 break;
358 case SVG_PRESERVEASPECTRATIO_XMINYMAX: 359 case SVG_PRESERVEASPECTRATIO_XMINYMAX:
359 alignType = "xMinYMax"; 360 alignString = "xMinYMax";
360 break; 361 break;
361 case SVG_PRESERVEASPECTRATIO_XMIDYMAX: 362 case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
362 alignType = "xMidYMax"; 363 alignString = "xMidYMax";
363 break; 364 break;
364 case SVG_PRESERVEASPECTRATIO_XMAXYMAX: 365 case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
365 alignType = "xMaxYMax"; 366 alignString = "xMaxYMax";
366 break; 367 break;
367 case SVG_PRESERVEASPECTRATIO_UNKNOWN: 368 case SVG_PRESERVEASPECTRATIO_UNKNOWN:
368 alignType = "unknown"; 369 alignString = "unknown";
369 break; 370 break;
370 }; 371 }
372 builder.append(alignString);
371 373
374 const char* meetOrSliceString = "";
372 switch (m_meetOrSlice) { 375 switch (m_meetOrSlice) {
373 default: 376 default:
374 case SVG_MEETORSLICE_UNKNOWN: 377 case SVG_MEETORSLICE_UNKNOWN:
375 return alignType; 378 break;
376 case SVG_MEETORSLICE_MEET: 379 case SVG_MEETORSLICE_MEET:
377 return alignType + " meet"; 380 meetOrSliceString = " meet";
381 break;
378 case SVG_MEETORSLICE_SLICE: 382 case SVG_MEETORSLICE_SLICE:
379 return alignType + " slice"; 383 meetOrSliceString = " slice";
384 break;
380 } 385 }
386 builder.append(meetOrSliceString);
387 return builder.toString();
381 } 388 }
382 389
383 void SVGPreserveAspectRatio::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) 390 void SVGPreserveAspectRatio::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
384 { 391 {
385 ASSERT_NOT_REACHED(); 392 ASSERT_NOT_REACHED();
386 } 393 }
387 394
388 void SVGPreserveAspectRatio::calculateAnimatedValue(SVGAnimationElement* animati onElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPro pertyBase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPt rWillBeRawPtr<SVGPropertyBase>, SVGElement*) 395 void SVGPreserveAspectRatio::calculateAnimatedValue(SVGAnimationElement* animati onElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPro pertyBase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPt rWillBeRawPtr<SVGPropertyBase>, SVGElement*)
389 { 396 {
390 ASSERT(animationElement); 397 ASSERT(animationElement);
391 398
392 bool useToValue; 399 bool useToValue;
393 animationElement->animateDiscreteType(percentage, false, true, useToValue); 400 animationElement->animateDiscreteType(percentage, false, true, useToValue);
394 401
395 RefPtrWillBeRawPtr<SVGPreserveAspectRatio> preserveAspectRatioToUse = useToV alue ? toSVGPreserveAspectRatio(toValue) : toSVGPreserveAspectRatio(fromValue); 402 RefPtrWillBeRawPtr<SVGPreserveAspectRatio> preserveAspectRatioToUse = useToV alue ? toSVGPreserveAspectRatio(toValue) : toSVGPreserveAspectRatio(fromValue);
396 403
397 m_align = preserveAspectRatioToUse->m_align; 404 m_align = preserveAspectRatioToUse->m_align;
398 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; 405 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice;
399 } 406 }
400 407
401 float SVGPreserveAspectRatio::calculateDistance(PassRefPtrWillBeRawPtr<SVGProper tyBase> toValue, SVGElement* contextElement) 408 float SVGPreserveAspectRatio::calculateDistance(PassRefPtrWillBeRawPtr<SVGProper tyBase> toValue, SVGElement* contextElement)
402 { 409 {
403 // No paced animations for SVGPreserveAspectRatio. 410 // No paced animations for SVGPreserveAspectRatio.
404 return -1; 411 return -1;
405 } 412 }
406 413
407 } 414 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698