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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 2558053002: Add CSS support for font-variation-settings (Closed)
Patch Set: DCHECK corrected, newline removed. Created 4 years 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
OLDNEW
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 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "core/css/resolver/StyleBuilderConverter.h" 27 #include "core/css/resolver/StyleBuilderConverter.h"
28 28
29 #include "core/css/BasicShapeFunctions.h" 29 #include "core/css/BasicShapeFunctions.h"
30 #include "core/css/CSSBasicShapeValues.h" 30 #include "core/css/CSSBasicShapeValues.h"
31 #include "core/css/CSSContentDistributionValue.h" 31 #include "core/css/CSSContentDistributionValue.h"
32 #include "core/css/CSSCustomIdentValue.h" 32 #include "core/css/CSSCustomIdentValue.h"
33 #include "core/css/CSSFontFamilyValue.h" 33 #include "core/css/CSSFontFamilyValue.h"
34 #include "core/css/CSSFontFeatureValue.h" 34 #include "core/css/CSSFontFeatureValue.h"
35 #include "core/css/CSSFontVariationValue.h"
35 #include "core/css/CSSFunctionValue.h" 36 #include "core/css/CSSFunctionValue.h"
36 #include "core/css/CSSGridAutoRepeatValue.h" 37 #include "core/css/CSSGridAutoRepeatValue.h"
37 #include "core/css/CSSGridLineNamesValue.h" 38 #include "core/css/CSSGridLineNamesValue.h"
38 #include "core/css/CSSIdentifierValue.h" 39 #include "core/css/CSSIdentifierValue.h"
39 #include "core/css/CSSPathValue.h" 40 #include "core/css/CSSPathValue.h"
40 #include "core/css/CSSPrimitiveValueMappings.h" 41 #include "core/css/CSSPrimitiveValueMappings.h"
41 #include "core/css/CSSQuadValue.h" 42 #include "core/css/CSSQuadValue.h"
42 #include "core/css/CSSReflectValue.h" 43 #include "core/css/CSSReflectValue.h"
43 #include "core/css/CSSShadowValue.h" 44 #include "core/css/CSSShadowValue.h"
44 #include "core/css/CSSStringValue.h" 45 #include "core/css/CSSStringValue.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const CSSValueList& list = toCSSValueList(value); 244 const CSSValueList& list = toCSSValueList(value);
244 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); 245 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
245 int len = list.length(); 246 int len = list.length();
246 for (int i = 0; i < len; ++i) { 247 for (int i = 0; i < len; ++i) {
247 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i)); 248 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i));
248 settings->append(FontFeature(feature.tag(), feature.value())); 249 settings->append(FontFeature(feature.tag(), feature.value()));
249 } 250 }
250 return settings; 251 return settings;
251 } 252 }
252 253
254 PassRefPtr<FontVariationSettings>
255 StyleBuilderConverter::convertFontVariationSettings(StyleResolverState& state,
256 const CSSValue& value) {
257 if (value.isIdentifierValue() &&
258 toCSSIdentifierValue(value).getValueID() == CSSValueNormal)
259 return FontBuilder::initialVariationSettings();
260
261 const CSSValueList& list = toCSSValueList(value);
262 RefPtr<FontVariationSettings> settings = FontVariationSettings::create();
263 int len = list.length();
264 for (int i = 0; i < len; ++i) {
265 const CSSFontVariationValue& feature =
266 toCSSFontVariationValue(list.item(i));
267 settings->append(FontVariationAxis(feature.tag(), feature.value()));
268 }
269 return settings;
270 }
271
253 static float computeFontSize(StyleResolverState& state, 272 static float computeFontSize(StyleResolverState& state,
254 const CSSPrimitiveValue& primitiveValue, 273 const CSSPrimitiveValue& primitiveValue,
255 const FontDescription::Size& parentSize) { 274 const FontDescription::Size& parentSize) {
256 if (primitiveValue.isLength()) 275 if (primitiveValue.isLength())
257 return primitiveValue.computeLength<float>(state.fontSizeConversionData()); 276 return primitiveValue.computeLength<float>(state.fontSizeConversionData());
258 if (primitiveValue.isCalculatedPercentageWithLength()) 277 if (primitiveValue.isCalculatedPercentageWithLength())
259 return primitiveValue.cssCalcValue() 278 return primitiveValue.cssCalcValue()
260 ->toCalcValue(state.fontSizeConversionData()) 279 ->toCalcValue(state.fontSizeConversionData())
261 ->evaluate(parentSize.value); 280 ->evaluate(parentSize.value);
262 281
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // Instead of the actual zoom, use 1 to avoid potential rounding errors 1295 // Instead of the actual zoom, use 1 to avoid potential rounding errors
1277 Length length = primitiveValue.convertToLength( 1296 Length length = primitiveValue.convertToLength(
1278 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); 1297 state.cssToLengthConversionData().copyWithAdjustedZoom(1));
1279 return *CSSPrimitiveValue::create(length, 1); 1298 return *CSSPrimitiveValue::create(length, 1);
1280 } 1299 }
1281 } 1300 }
1282 return value; 1301 return value;
1283 } 1302 }
1284 1303
1285 } // namespace blink 1304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698