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

Side by Side Diff: Source/core/animation/css/CSSAnimatableValueFactory.cpp

Issue 983103003: Use Length for the stroke-width property in SVGLayoutStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Adjust transitions/svg-transitions.html Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include "core/animation/animatable/AnimatableDoubleAndBool.h" 38 #include "core/animation/animatable/AnimatableDoubleAndBool.h"
39 #include "core/animation/animatable/AnimatableFilterOperations.h" 39 #include "core/animation/animatable/AnimatableFilterOperations.h"
40 #include "core/animation/animatable/AnimatableImage.h" 40 #include "core/animation/animatable/AnimatableImage.h"
41 #include "core/animation/animatable/AnimatableLength.h" 41 #include "core/animation/animatable/AnimatableLength.h"
42 #include "core/animation/animatable/AnimatableLengthBox.h" 42 #include "core/animation/animatable/AnimatableLengthBox.h"
43 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h" 43 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h"
44 #include "core/animation/animatable/AnimatableLengthPoint.h" 44 #include "core/animation/animatable/AnimatableLengthPoint.h"
45 #include "core/animation/animatable/AnimatableLengthPoint3D.h" 45 #include "core/animation/animatable/AnimatableLengthPoint3D.h"
46 #include "core/animation/animatable/AnimatableLengthSize.h" 46 #include "core/animation/animatable/AnimatableLengthSize.h"
47 #include "core/animation/animatable/AnimatableRepeatable.h" 47 #include "core/animation/animatable/AnimatableRepeatable.h"
48 #include "core/animation/animatable/AnimatableSVGLength.h"
49 #include "core/animation/animatable/AnimatableSVGPaint.h" 48 #include "core/animation/animatable/AnimatableSVGPaint.h"
50 #include "core/animation/animatable/AnimatableShadow.h" 49 #include "core/animation/animatable/AnimatableShadow.h"
51 #include "core/animation/animatable/AnimatableShapeValue.h" 50 #include "core/animation/animatable/AnimatableShapeValue.h"
52 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h" 51 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h"
53 #include "core/animation/animatable/AnimatableTransform.h" 52 #include "core/animation/animatable/AnimatableTransform.h"
54 #include "core/animation/animatable/AnimatableUnknown.h" 53 #include "core/animation/animatable/AnimatableUnknown.h"
55 #include "core/animation/animatable/AnimatableVisibility.h" 54 #include "core/animation/animatable/AnimatableVisibility.h"
56 #include "core/css/CSSCalculationValue.h" 55 #include "core/css/CSSCalculationValue.h"
57 #include "core/css/CSSPrimitiveValue.h" 56 #include "core/css/CSSPrimitiveValue.h"
58 #include "core/css/CSSPrimitiveValueMappings.h" 57 #include "core/css/CSSPrimitiveValueMappings.h"
59 #include "core/css/CSSPropertyMetadata.h" 58 #include "core/css/CSSPropertyMetadata.h"
60 #include "core/layout/style/LayoutStyle.h" 59 #include "core/layout/style/LayoutStyle.h"
61 #include "platform/Length.h" 60 #include "platform/Length.h"
62 #include "platform/LengthBox.h" 61 #include "platform/LengthBox.h"
63 62
64 namespace blink { 63 namespace blink {
65 64
66 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLength(const Length& le ngth, const LayoutStyle& style) 65 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthWithZoom(const Le ngth& length, float zoom)
67 { 66 {
68 switch (length.type()) { 67 switch (length.type()) {
69 case Fixed: 68 case Fixed:
70 case Percent: 69 case Percent:
71 case Calculated: 70 case Calculated:
72 return AnimatableLength::create(length, style.effectiveZoom()); 71 return AnimatableLength::create(length, zoom);
73 case Auto: 72 case Auto:
74 case Intrinsic: 73 case Intrinsic:
75 case MinIntrinsic: 74 case MinIntrinsic:
76 case MinContent: 75 case MinContent:
77 case MaxContent: 76 case MaxContent:
78 case FillAvailable: 77 case FillAvailable:
79 case FitContent: 78 case FitContent:
80 return AnimatableUnknown::create(CSSPrimitiveValue::create(length, 1)); 79 return AnimatableUnknown::create(CSSPrimitiveValue::create(length, 1));
81 case MaxSizeNone: 80 case MaxSizeNone:
82 return AnimatableUnknown::create(CSSValueNone); 81 return AnimatableUnknown::create(CSSValueNone);
83 case ExtendToZoom: // Does not apply to elements. 82 case ExtendToZoom: // Does not apply to elements.
84 case DeviceWidth: 83 case DeviceWidth:
85 case DeviceHeight: 84 case DeviceHeight:
86 ASSERT_NOT_REACHED(); 85 ASSERT_NOT_REACHED();
87 return nullptr; 86 return nullptr;
88 } 87 }
89 ASSERT_NOT_REACHED(); 88 ASSERT_NOT_REACHED();
90 return nullptr; 89 return nullptr;
91 } 90 }
92 91
92 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLength(const Length& le ngth, const LayoutStyle& style)
93 {
94 return createFromLengthWithZoom(length, style.effectiveZoom());
95 }
96
97 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromUnzoomedLength(const Un zoomedLength& unzoomedLength)
98 {
99 return createFromLengthWithZoom(unzoomedLength.length(), 1);
100 }
101
93 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLineHeight(const Length & length, const LayoutStyle& style) 102 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLineHeight(const Length & length, const LayoutStyle& style)
94 { 103 {
95 if (length.type() == Percent) { 104 if (length.type() == Percent) {
96 double value = length.value(); 105 double value = length.value();
97 // -100% is used to represent "normal" line height. 106 // -100% is used to represent "normal" line height.
98 if (value == -100) 107 if (value == -100)
99 return AnimatableUnknown::create(CSSValueNormal); 108 return AnimatableUnknown::create(CSSValueNormal);
100 return AnimatableDouble::create(value); 109 return AnimatableDouble::create(value);
101 } 110 }
102 return createFromLength(length, style); 111 return createFromLength(length, style);
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return createFromLength(style.paddingBottom(), style); 436 return createFromLength(style.paddingBottom(), style);
428 case CSSPropertyPaddingLeft: 437 case CSSPropertyPaddingLeft:
429 return createFromLength(style.paddingLeft(), style); 438 return createFromLength(style.paddingLeft(), style);
430 case CSSPropertyPaddingRight: 439 case CSSPropertyPaddingRight:
431 return createFromLength(style.paddingRight(), style); 440 return createFromLength(style.paddingRight(), style);
432 case CSSPropertyPaddingTop: 441 case CSSPropertyPaddingTop:
433 return createFromLength(style.paddingTop(), style); 442 return createFromLength(style.paddingTop(), style);
434 case CSSPropertyRight: 443 case CSSPropertyRight:
435 return createFromLength(style.right(), style); 444 return createFromLength(style.right(), style);
436 case CSSPropertyStrokeWidth: 445 case CSSPropertyStrokeWidth:
437 return AnimatableSVGLength::create(style.strokeWidth()); 446 return createFromUnzoomedLength(style.strokeWidth());
438 case CSSPropertyStopColor: 447 case CSSPropertyStopColor:
439 return createFromColor(property, style); 448 return createFromColor(property, style);
440 case CSSPropertyStopOpacity: 449 case CSSPropertyStopOpacity:
441 return createFromDouble(style.stopOpacity()); 450 return createFromDouble(style.stopOpacity());
442 case CSSPropertyStrokeDasharray: 451 case CSSPropertyStrokeDasharray:
443 return AnimatableStrokeDasharrayList::create(style.strokeDashArray(), st yle.effectiveZoom()); 452 return AnimatableStrokeDasharrayList::create(style.strokeDashArray(), st yle.effectiveZoom());
444 case CSSPropertyStrokeDashoffset: 453 case CSSPropertyStrokeDashoffset:
445 return createFromLength(style.strokeDashOffset(), style); 454 return createFromLength(style.strokeDashOffset(), style);
446 case CSSPropertyStrokeMiterlimit: 455 case CSSPropertyStrokeMiterlimit:
447 return createFromDouble(style.strokeMiterLimit()); 456 return createFromDouble(style.strokeMiterLimit());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 case CSSPropertyZIndex: 548 case CSSPropertyZIndex:
540 return createFromDouble(style.zIndex()); 549 return createFromDouble(style.zIndex());
541 default: 550 default:
542 ASSERT_NOT_REACHED(); 551 ASSERT_NOT_REACHED();
543 // This return value is to avoid a release crash if possible. 552 // This return value is to avoid a release crash if possible.
544 return AnimatableUnknown::create(nullptr); 553 return AnimatableUnknown::create(nullptr);
545 } 554 }
546 } 555 }
547 556
548 } // namespace blink 557 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698