| 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 #include "core/animation/LengthPropertyFunctions.h" | 5 #include "core/animation/LengthPropertyFunctions.h" |
| 6 | 6 |
| 7 #include "core/style/ComputedStyle.h" | 7 #include "core/style/ComputedStyle.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 case CSSPropertyPaddingRight: | 30 case CSSPropertyPaddingRight: |
| 31 case CSSPropertyPaddingTop: | 31 case CSSPropertyPaddingTop: |
| 32 case CSSPropertyPerspective: | 32 case CSSPropertyPerspective: |
| 33 case CSSPropertyR: | 33 case CSSPropertyR: |
| 34 case CSSPropertyRx: | 34 case CSSPropertyRx: |
| 35 case CSSPropertyRy: | 35 case CSSPropertyRy: |
| 36 case CSSPropertyShapeMargin: | 36 case CSSPropertyShapeMargin: |
| 37 case CSSPropertyStrokeWidth: | 37 case CSSPropertyStrokeWidth: |
| 38 case CSSPropertyWebkitBorderHorizontalSpacing: | 38 case CSSPropertyWebkitBorderHorizontalSpacing: |
| 39 case CSSPropertyWebkitBorderVerticalSpacing: | 39 case CSSPropertyWebkitBorderVerticalSpacing: |
| 40 case CSSPropertyWebkitColumnGap: | 40 case CSSPropertyColumnGap: |
| 41 case CSSPropertyWebkitColumnWidth: | 41 case CSSPropertyColumnWidth: |
| 42 case CSSPropertyWidth: | 42 case CSSPropertyWidth: |
| 43 return ValueRangeNonNegative; | 43 return ValueRangeNonNegative; |
| 44 default: | 44 default: |
| 45 return ValueRangeAll; | 45 return ValueRangeAll; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool LengthPropertyFunctions::isZoomedLength(CSSPropertyID property) | 49 bool LengthPropertyFunctions::isZoomedLength(CSSPropertyID property) |
| 50 { | 50 { |
| 51 return property != CSSPropertyStrokeWidth; | 51 return property != CSSPropertyStrokeWidth; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool LengthPropertyFunctions::getPixelsForKeyword(CSSPropertyID property, CSSVal
ueID valueID, double& result) | 54 bool LengthPropertyFunctions::getPixelsForKeyword(CSSPropertyID property, CSSVal
ueID valueID, double& result) |
| 55 { | 55 { |
| 56 switch (property) { | 56 switch (property) { |
| 57 case CSSPropertyBaselineShift: | 57 case CSSPropertyBaselineShift: |
| 58 if (valueID == CSSValueBaseline) { | 58 if (valueID == CSSValueBaseline) { |
| 59 result = 0; | 59 result = 0; |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 return false; | 62 return false; |
| 63 case CSSPropertyBorderBottomWidth: | 63 case CSSPropertyBorderBottomWidth: |
| 64 case CSSPropertyBorderLeftWidth: | 64 case CSSPropertyBorderLeftWidth: |
| 65 case CSSPropertyBorderRightWidth: | 65 case CSSPropertyBorderRightWidth: |
| 66 case CSSPropertyBorderTopWidth: | 66 case CSSPropertyBorderTopWidth: |
| 67 case CSSPropertyWebkitColumnRuleWidth: | 67 case CSSPropertyColumnRuleWidth: |
| 68 case CSSPropertyOutlineWidth: | 68 case CSSPropertyOutlineWidth: |
| 69 if (valueID == CSSValueThin) { | 69 if (valueID == CSSValueThin) { |
| 70 result = 1; | 70 result = 1; |
| 71 return true; | 71 return true; |
| 72 } | 72 } |
| 73 if (valueID == CSSValueMedium) { | 73 if (valueID == CSSValueMedium) { |
| 74 result = 3; | 74 result = 3; |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 if (valueID == CSSValueThick) { | 77 if (valueID == CSSValueThick) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 95 { | 95 { |
| 96 return Length(static_cast<float>(value), Fixed); | 96 return Length(static_cast<float>(value), Fixed); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool LengthPropertyFunctions::getInitialLength(CSSPropertyID property, Length& r
esult) | 99 bool LengthPropertyFunctions::getInitialLength(CSSPropertyID property, Length& r
esult) |
| 100 { | 100 { |
| 101 switch (property) { | 101 switch (property) { |
| 102 // The computed value of "initial" for the following properties is 0px if th
e associated *-style property resolves to "none" or "hidden". | 102 // The computed value of "initial" for the following properties is 0px if th
e associated *-style property resolves to "none" or "hidden". |
| 103 // border-width: https://drafts.csswg.org/css-backgrounds-3/#the-border-widt
h | 103 // border-width: https://drafts.csswg.org/css-backgrounds-3/#the-border-widt
h |
| 104 // outline-width: https://drafts.csswg.org/css-ui-3/#outline-width | 104 // outline-width: https://drafts.csswg.org/css-ui-3/#outline-width |
| 105 // -webkit-column-rule-width: https://drafts.csswg.org/css-multicol-1/#crw | 105 // column-rule-width: https://drafts.csswg.org/css-multicol-1/#crw |
| 106 // We ignore this value adjustment for animations and use the wrong value fo
r hidden widths to avoid | 106 // We ignore this value adjustment for animations and use the wrong value fo
r hidden widths to avoid |
| 107 // having to restart our animations based on the computed *-style values. | 107 // having to restart our animations based on the computed *-style values. |
| 108 // This is acceptable since animations running on hidden widths are unobserv
able to the user, even via getComputedStyle(). | 108 // This is acceptable since animations running on hidden widths are unobserv
able to the user, even via getComputedStyle(). |
| 109 case CSSPropertyBorderBottomWidth: | 109 case CSSPropertyBorderBottomWidth: |
| 110 case CSSPropertyBorderLeftWidth: | 110 case CSSPropertyBorderLeftWidth: |
| 111 case CSSPropertyBorderRightWidth: | 111 case CSSPropertyBorderRightWidth: |
| 112 case CSSPropertyBorderTopWidth: | 112 case CSSPropertyBorderTopWidth: |
| 113 result = lengthFromUnsigned(ComputedStyle::initialBorderWidth()); | 113 result = lengthFromUnsigned(ComputedStyle::initialBorderWidth()); |
| 114 return true; | 114 return true; |
| 115 case CSSPropertyOutlineWidth: | 115 case CSSPropertyOutlineWidth: |
| 116 result = lengthFromUnsigned(ComputedStyle::initialOutlineWidth()); | 116 result = lengthFromUnsigned(ComputedStyle::initialOutlineWidth()); |
| 117 return true; | 117 return true; |
| 118 case CSSPropertyWebkitColumnRuleWidth: | 118 case CSSPropertyColumnRuleWidth: |
| 119 result = lengthFromUnsigned(ComputedStyle::initialColumnRuleWidth()); | 119 result = lengthFromUnsigned(ComputedStyle::initialColumnRuleWidth()); |
| 120 return true; | 120 return true; |
| 121 | 121 |
| 122 default: | 122 default: |
| 123 return getLength(property, *ComputedStyle::initialStyle(), result); | 123 return getLength(property, *ComputedStyle::initialStyle(), result); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool LengthPropertyFunctions::getLength(CSSPropertyID property, const ComputedSt
yle& style, Length& result) | 127 bool LengthPropertyFunctions::getLength(CSSPropertyID property, const ComputedSt
yle& style, Length& result) |
| 128 { | 128 { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return true; | 250 return true; |
| 251 case CSSPropertyOutlineWidth: | 251 case CSSPropertyOutlineWidth: |
| 252 result = Length(style.outlineWidth(), Fixed); | 252 result = Length(style.outlineWidth(), Fixed); |
| 253 return true; | 253 return true; |
| 254 case CSSPropertyWebkitBorderHorizontalSpacing: | 254 case CSSPropertyWebkitBorderHorizontalSpacing: |
| 255 result = Length(style.horizontalBorderSpacing(), Fixed); | 255 result = Length(style.horizontalBorderSpacing(), Fixed); |
| 256 return true; | 256 return true; |
| 257 case CSSPropertyWebkitBorderVerticalSpacing: | 257 case CSSPropertyWebkitBorderVerticalSpacing: |
| 258 result = Length(style.verticalBorderSpacing(), Fixed); | 258 result = Length(style.verticalBorderSpacing(), Fixed); |
| 259 return true; | 259 return true; |
| 260 case CSSPropertyWebkitColumnGap: | 260 case CSSPropertyColumnGap: |
| 261 result = Length(style.columnGap(), Fixed); | 261 result = Length(style.columnGap(), Fixed); |
| 262 return true; | 262 return true; |
| 263 case CSSPropertyWebkitColumnRuleWidth: | 263 case CSSPropertyColumnRuleWidth: |
| 264 result = Length(style.columnRuleWidth(), Fixed); | 264 result = Length(style.columnRuleWidth(), Fixed); |
| 265 return true; | 265 return true; |
| 266 case CSSPropertyWebkitTransformOriginZ: | 266 case CSSPropertyWebkitTransformOriginZ: |
| 267 result = Length(style.transformOriginZ(), Fixed); | 267 result = Length(style.transformOriginZ(), Fixed); |
| 268 return true; | 268 return true; |
| 269 case CSSPropertyWordSpacing: | 269 case CSSPropertyWordSpacing: |
| 270 result = Length(style.wordSpacing(), Fixed); | 270 result = Length(style.wordSpacing(), Fixed); |
| 271 return true; | 271 return true; |
| 272 | 272 |
| 273 case CSSPropertyBaselineShift: | 273 case CSSPropertyBaselineShift: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 288 return true; | 288 return true; |
| 289 case CSSPropertyStrokeWidth: | 289 case CSSPropertyStrokeWidth: |
| 290 ASSERT(!isZoomedLength(CSSPropertyStrokeWidth)); | 290 ASSERT(!isZoomedLength(CSSPropertyStrokeWidth)); |
| 291 result = style.strokeWidth().length(); | 291 result = style.strokeWidth().length(); |
| 292 return true; | 292 return true; |
| 293 case CSSPropertyVerticalAlign: | 293 case CSSPropertyVerticalAlign: |
| 294 if (style.verticalAlign() != LENGTH) | 294 if (style.verticalAlign() != LENGTH) |
| 295 return false; | 295 return false; |
| 296 result = style.verticalAlignLength(); | 296 result = style.verticalAlignLength(); |
| 297 return true; | 297 return true; |
| 298 case CSSPropertyWebkitColumnWidth: | 298 case CSSPropertyColumnWidth: |
| 299 if (style.hasAutoColumnWidth()) | 299 if (style.hasAutoColumnWidth()) |
| 300 return false; | 300 return false; |
| 301 result = Length(style.columnWidth(), Fixed); | 301 result = Length(style.columnWidth(), Fixed); |
| 302 return true; | 302 return true; |
| 303 default: | 303 default: |
| 304 return false; | 304 return false; |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool LengthPropertyFunctions::setLength(CSSPropertyID property, ComputedStyle& s
tyle, const Length& value) | 308 bool LengthPropertyFunctions::setLength(CSSPropertyID property, ComputedStyle& s
tyle, const Length& value) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 case CSSPropertyBorderRightWidth: | 425 case CSSPropertyBorderRightWidth: |
| 426 case CSSPropertyBorderTopWidth: | 426 case CSSPropertyBorderTopWidth: |
| 427 case CSSPropertyLetterSpacing: | 427 case CSSPropertyLetterSpacing: |
| 428 case CSSPropertyOutlineOffset: | 428 case CSSPropertyOutlineOffset: |
| 429 case CSSPropertyOutlineWidth: | 429 case CSSPropertyOutlineWidth: |
| 430 case CSSPropertyPerspective: | 430 case CSSPropertyPerspective: |
| 431 case CSSPropertyStrokeWidth: | 431 case CSSPropertyStrokeWidth: |
| 432 case CSSPropertyVerticalAlign: | 432 case CSSPropertyVerticalAlign: |
| 433 case CSSPropertyWebkitBorderHorizontalSpacing: | 433 case CSSPropertyWebkitBorderHorizontalSpacing: |
| 434 case CSSPropertyWebkitBorderVerticalSpacing: | 434 case CSSPropertyWebkitBorderVerticalSpacing: |
| 435 case CSSPropertyWebkitColumnGap: | 435 case CSSPropertyColumnGap: |
| 436 case CSSPropertyWebkitColumnRuleWidth: | 436 case CSSPropertyColumnRuleWidth: |
| 437 case CSSPropertyWebkitColumnWidth: | 437 case CSSPropertyColumnWidth: |
| 438 case CSSPropertyWebkitTransformOriginZ: | 438 case CSSPropertyWebkitTransformOriginZ: |
| 439 case CSSPropertyWordSpacing: | 439 case CSSPropertyWordSpacing: |
| 440 return false; | 440 return false; |
| 441 | 441 |
| 442 default: | 442 default: |
| 443 return false; | 443 return false; |
| 444 } | 444 } |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace blink | 447 } // namespace blink |
| OLD | NEW |