| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 static Length lengthFromUnsigned(unsigned short value) { | 91 static Length lengthFromUnsigned(unsigned short value) { |
| 92 return Length(static_cast<float>(value), Fixed); | 92 return Length(static_cast<float>(value), Fixed); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool LengthPropertyFunctions::getInitialLength(CSSPropertyID property, | 95 bool LengthPropertyFunctions::getInitialLength(CSSPropertyID property, |
| 96 Length& result) { | 96 Length& result) { |
| 97 switch (property) { | 97 switch (property) { |
| 98 // The computed value of "initial" for the following properties is 0px if th
e associated *-style property resolves to "none" or "hidden". | 98 // The computed value of "initial" for the following properties is 0px if |
| 99 // border-width: https://drafts.csswg.org/css-backgrounds-3/#the-border-widt
h | 99 // the associated *-style property resolves to "none" or "hidden". |
| 100 // outline-width: https://drafts.csswg.org/css-ui-3/#outline-width | 100 // - border-width: |
| 101 // column-rule-width: https://drafts.csswg.org/css-multicol-1/#crw | 101 // https://drafts.csswg.org/css-backgrounds-3/#the-border-width |
| 102 // We ignore this value adjustment for animations and use the wrong value fo
r hidden widths to avoid | 102 // - outline-width: https://drafts.csswg.org/css-ui-3/#outline-width |
| 103 // having to restart our animations based on the computed *-style values. | 103 // - column-rule-width: https://drafts.csswg.org/css-multicol-1/#crw |
| 104 // This is acceptable since animations running on hidden widths are unobserv
able to the user, even via getComputedStyle(). | 104 // We ignore this value adjustment for animations and use the wrong value |
| 105 // for hidden widths to avoid having to restart our animations based on the |
| 106 // computed *-style values. This is acceptable since animations running on |
| 107 // hidden widths are unobservable to the user, even via getComputedStyle(). |
| 105 case CSSPropertyBorderBottomWidth: | 108 case CSSPropertyBorderBottomWidth: |
| 106 case CSSPropertyBorderLeftWidth: | 109 case CSSPropertyBorderLeftWidth: |
| 107 case CSSPropertyBorderRightWidth: | 110 case CSSPropertyBorderRightWidth: |
| 108 case CSSPropertyBorderTopWidth: | 111 case CSSPropertyBorderTopWidth: |
| 109 result = lengthFromUnsigned(ComputedStyle::initialBorderWidth()); | 112 result = lengthFromUnsigned(ComputedStyle::initialBorderWidth()); |
| 110 return true; | 113 return true; |
| 111 case CSSPropertyOutlineWidth: | 114 case CSSPropertyOutlineWidth: |
| 112 result = lengthFromUnsigned(ComputedStyle::initialOutlineWidth()); | 115 result = lengthFromUnsigned(ComputedStyle::initialOutlineWidth()); |
| 113 return true; | 116 return true; |
| 114 case CSSPropertyColumnRuleWidth: | 117 case CSSPropertyColumnRuleWidth: |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 style.setY(value); | 413 style.setY(value); |
| 411 return true; | 414 return true; |
| 412 | 415 |
| 413 case CSSPropertyLineHeight: | 416 case CSSPropertyLineHeight: |
| 414 // Percent Lengths are used to represent numbers on line-height. | 417 // Percent Lengths are used to represent numbers on line-height. |
| 415 if (value.isPercentOrCalc()) | 418 if (value.isPercentOrCalc()) |
| 416 return false; | 419 return false; |
| 417 style.setLineHeight(value); | 420 style.setLineHeight(value); |
| 418 return true; | 421 return true; |
| 419 | 422 |
| 420 // TODO(alancutter): Support setters that take a numeric value (need to reso
lve percentages). | 423 // TODO(alancutter): Support setters that take a numeric value (need to |
| 424 // resolve percentages). |
| 421 case CSSPropertyBorderBottomWidth: | 425 case CSSPropertyBorderBottomWidth: |
| 422 case CSSPropertyBorderLeftWidth: | 426 case CSSPropertyBorderLeftWidth: |
| 423 case CSSPropertyBorderRightWidth: | 427 case CSSPropertyBorderRightWidth: |
| 424 case CSSPropertyBorderTopWidth: | 428 case CSSPropertyBorderTopWidth: |
| 425 case CSSPropertyLetterSpacing: | 429 case CSSPropertyLetterSpacing: |
| 426 case CSSPropertyOutlineOffset: | 430 case CSSPropertyOutlineOffset: |
| 427 case CSSPropertyOutlineWidth: | 431 case CSSPropertyOutlineWidth: |
| 428 case CSSPropertyPerspective: | 432 case CSSPropertyPerspective: |
| 429 case CSSPropertyStrokeWidth: | 433 case CSSPropertyStrokeWidth: |
| 430 case CSSPropertyVerticalAlign: | 434 case CSSPropertyVerticalAlign: |
| 431 case CSSPropertyWebkitBorderHorizontalSpacing: | 435 case CSSPropertyWebkitBorderHorizontalSpacing: |
| 432 case CSSPropertyWebkitBorderVerticalSpacing: | 436 case CSSPropertyWebkitBorderVerticalSpacing: |
| 433 case CSSPropertyColumnGap: | 437 case CSSPropertyColumnGap: |
| 434 case CSSPropertyColumnRuleWidth: | 438 case CSSPropertyColumnRuleWidth: |
| 435 case CSSPropertyColumnWidth: | 439 case CSSPropertyColumnWidth: |
| 436 case CSSPropertyWebkitTransformOriginZ: | 440 case CSSPropertyWebkitTransformOriginZ: |
| 437 case CSSPropertyWordSpacing: | 441 case CSSPropertyWordSpacing: |
| 438 return false; | 442 return false; |
| 439 | 443 |
| 440 default: | 444 default: |
| 441 return false; | 445 return false; |
| 442 } | 446 } |
| 443 } | 447 } |
| 444 | 448 |
| 445 } // namespace blink | 449 } // namespace blink |
| OLD | NEW |