Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/css/cssom/ComputedStylePropertyMap.h" | 5 #include "core/css/cssom/ComputedStylePropertyMap.h" |
| 6 | 6 |
| 7 #include "core/css/CSSComputedStyleDeclaration.h" | 7 #include "core/css/CSSComputedStyleDeclaration.h" |
| 8 #include "core/css/ComputedStyleCSSValueMapping.h" | 8 #include "core/css/ComputedStyleCSSValueMapping.h" |
| 9 #include "core/css/cssom/CSSCalcLength.h" | 9 #include "core/css/cssom/CSSCalcLength.h" |
| 10 #include "core/css/cssom/CSSKeywordValue.h" | 10 #include "core/css/cssom/CSSKeywordValue.h" |
| 11 #include "core/css/cssom/CSSNumberValue.h" | |
| 11 #include "core/css/cssom/CSSSimpleLength.h" | 12 #include "core/css/cssom/CSSSimpleLength.h" |
| 12 #include "core/css/cssom/CSSUnsupportedStyleValue.h" | 13 #include "core/css/cssom/CSSUnsupportedStyleValue.h" |
| 13 #include "core/css/cssom/StyleValueFactory.h" | 14 #include "core/css/cssom/StyleValueFactory.h" |
| 14 #include "core/css/resolver/StyleResolver.h" | 15 #include "core/css/resolver/StyleResolver.h" |
| 15 #include "core/dom/PseudoElement.h" | 16 #include "core/dom/PseudoElement.h" |
| 16 #include "core/dom/StyleEngine.h" | 17 #include "core/dom/StyleEngine.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 break; | 99 break; |
| 99 case CSSPropertyBottom: | 100 case CSSPropertyBottom: |
| 100 styleValue = styleValueForLength(style->bottom()); | 101 styleValue = styleValueForLength(style->bottom()); |
| 101 break; | 102 break; |
| 102 case CSSPropertyHeight: | 103 case CSSPropertyHeight: |
| 103 styleValue = styleValueForLength(style->height()); | 104 styleValue = styleValueForLength(style->height()); |
| 104 break; | 105 break; |
| 105 case CSSPropertyWidth: | 106 case CSSPropertyWidth: |
| 106 styleValue = styleValueForLength(style->width()); | 107 styleValue = styleValueForLength(style->width()); |
| 107 break; | 108 break; |
| 109 case CSSPropertyLineHeight: { | |
| 110 // LineHeight is represented as a Length in ComputedStyle, even though it | |
| 111 // can be a number or the "normal" keyword. "normal" is encoded as a | |
| 112 // negative percent, and numbers (which must be positive) are encoded as | |
| 113 // percents. | |
|
meade_UTC10
2017/02/09 06:50:48
WTF... (no action required)
| |
| 114 Length lineHeight = style->lineHeight(); | |
| 115 if (lineHeight.isNegative()) { | |
| 116 styleValue = CSSKeywordValue::create("normal"); | |
| 117 break; | |
| 118 } | |
| 119 if (lineHeight.isPercent()) { | |
| 120 styleValue = CSSNumberValue::create(lineHeight.percent()); | |
| 121 break; | |
| 122 } | |
| 123 if (lineHeight.isFixed()) { | |
| 124 styleValue = CSSSimpleLength::create( | |
| 125 lineHeight.pixels(), CSSPrimitiveValue::UnitType::Pixels); | |
| 126 break; | |
| 127 } | |
| 128 NOTREACHED(); | |
| 129 break; | |
| 130 } | |
| 108 default: | 131 default: |
| 109 // TODO(rjwright): Add a flag argument to | 132 // TODO(rjwright): Add a flag argument to |
| 110 // ComputedStyleCSSValyeMapping::get that makes it return | 133 // ComputedStyleCSSValyeMapping::get that makes it return |
| 111 // just the raw value off the ComputedStyle, and not zoom adjusted or | 134 // just the raw value off the ComputedStyle, and not zoom adjusted or |
| 112 // anything like that. | 135 // anything like that. |
| 113 const CSSValue* value = ComputedStyleCSSValueMapping::get( | 136 const CSSValue* value = ComputedStyleCSSValueMapping::get( |
| 114 propertyID, *style, nullptr, node, false); | 137 propertyID, *style, nullptr, node, false); |
| 115 if (value) { | 138 if (value) { |
| 116 return StyleValueFactory::cssValueToStyleValueVector(propertyID, | 139 return StyleValueFactory::cssValueToStyleValueVector(propertyID, |
| 117 *value); | 140 *value); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 137 | 160 |
| 138 Vector<String> ComputedStylePropertyMap::getProperties() { | 161 Vector<String> ComputedStylePropertyMap::getProperties() { |
| 139 Vector<String> result; | 162 Vector<String> result; |
| 140 for (unsigned i = 0; i < m_computedStyleDeclaration->length(); i++) { | 163 for (unsigned i = 0; i < m_computedStyleDeclaration->length(); i++) { |
| 141 result.push_back(m_computedStyleDeclaration->item(i)); | 164 result.push_back(m_computedStyleDeclaration->item(i)); |
| 142 } | 165 } |
| 143 return result; | 166 return result; |
| 144 } | 167 } |
| 145 | 168 |
| 146 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |