Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * * Redistributions of source code must retain the above copyright | 4 * * Redistributions of source code must retain the above copyright |
| 5 * notice, this list of conditions and the following disclaimer. | 5 * notice, this list of conditions and the following disclaimer. |
| 6 * * Redistributions in binary form must reproduce the above | 6 * * Redistributions in binary form must reproduce the above |
| 7 * copyright notice, this list of conditions and the following disclaimer | 7 * copyright notice, this list of conditions and the following disclaimer |
| 8 * in the documentation and/or other materials provided with the | 8 * in the documentation and/or other materials provided with the |
| 9 * distribution. | 9 * distribution. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 CSSValueList* list = toCSSValueList(value); | 182 CSSValueList* list = toCSSValueList(value); |
| 183 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); | 183 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); |
| 184 int len = list->length(); | 184 int len = list->length(); |
| 185 for (int i = 0; i < len; ++i) { | 185 for (int i = 0; i < len; ++i) { |
| 186 CSSFontFeatureValue* feature = toCSSFontFeatureValue(list->item(i)); | 186 CSSFontFeatureValue* feature = toCSSFontFeatureValue(list->item(i)); |
| 187 settings->append(FontFeature(feature->tag(), feature->value())); | 187 settings->append(FontFeature(feature->tag(), feature->value())); |
| 188 } | 188 } |
| 189 return settings; | 189 return settings; |
| 190 } | 190 } |
| 191 | 191 |
| 192 class RedirectSetHasViewportUnits { | |
| 193 public: | |
| 194 RedirectSetHasViewportUnits(RenderStyle* from, RenderStyle* to) | |
| 195 : m_from(from), m_to(to), m_hadViewportUnits(from->hasViewportUnits()) | |
| 196 { | |
| 197 from->setHasViewportUnits(false); | |
| 198 } | |
| 199 ~RedirectSetHasViewportUnits() | |
| 200 { | |
| 201 m_to->setHasViewportUnits(m_from->hasViewportUnits()); | |
| 202 m_from->setHasViewportUnits(m_hadViewportUnits); | |
| 203 } | |
| 204 private: | |
| 205 RenderStyle* m_from; | |
| 206 RenderStyle* m_to; | |
| 207 bool m_hadViewportUnits; | |
| 208 }; | |
| 209 | |
| 210 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue* primi tiveValue, const FontDescription::Size& parentSize) | 192 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue* primi tiveValue, const FontDescription::Size& parentSize) |
| 211 { | 193 { |
| 212 RedirectSetHasViewportUnits redirect(state.parentStyle(), state.style()); | 194 float em = state.parentStyle()->specifiedFontSize(); |
| 195 float rem = state.rootElementStyle() ? state.rootElementStyle()->specifiedFo ntSize() : 1.0f; | |
|
Timothy Loh
2014/11/06 16:24:00
As mentioned elsewhere, I think we always have a r
andersr
2014/11/07 10:43:11
Done.
| |
| 196 CSSToLengthFontSizes fontSizes(em, rem, &state.parentStyle()->font()); | |
| 197 CSSToLengthViewportSize viewportSize(state.document().renderView()); | |
| 213 | 198 |
| 214 CSSToLengthConversionData conversionData(state.parentStyle(), state.rootElem entStyle(), state.document().renderView(), 1.0f, true); | 199 CSSToLengthConversionData conversionData(state.style(), fontSizes, viewportS ize, 1.0f); |
| 215 if (primitiveValue->isLength()) | 200 if (primitiveValue->isLength()) |
| 216 return primitiveValue->computeLength<float>(conversionData); | 201 return primitiveValue->computeLength<float>(conversionData); |
| 217 if (primitiveValue->isCalculatedPercentageWithLength()) | 202 if (primitiveValue->isCalculatedPercentageWithLength()) |
| 218 return primitiveValue->cssCalcValue()->toCalcValue(conversionData)->eval uate(parentSize.value); | 203 return primitiveValue->cssCalcValue()->toCalcValue(conversionData)->eval uate(parentSize.value); |
| 219 | 204 |
| 220 ASSERT_NOT_REACHED(); | 205 ASSERT_NOT_REACHED(); |
| 221 return 0; | 206 return 0; |
| 222 } | 207 } |
| 223 | 208 |
| 224 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState& state, CSSValue* value) | 209 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState& state, CSSValue* value) |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2)); | 804 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2)); |
| 820 | 805 |
| 821 return TransformOrigin( | 806 return TransformOrigin( |
| 822 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , | 807 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , |
| 823 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , | 808 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , |
| 824 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) | 809 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) |
| 825 ); | 810 ); |
| 826 } | 811 } |
| 827 | 812 |
| 828 } // namespace blink | 813 } // namespace blink |
| OLD | NEW |