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

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 205743004: Expand system font values during font property parsing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and fix up unittest use of systemFont() Created 6 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/css/CSSGridTemplateAreasValue.h" 48 #include "core/css/CSSGridTemplateAreasValue.h"
49 #include "core/css/CSSImageSetValue.h" 49 #include "core/css/CSSImageSetValue.h"
50 #include "core/css/CSSImageValue.h" 50 #include "core/css/CSSImageValue.h"
51 #include "core/css/CSSInheritedValue.h" 51 #include "core/css/CSSInheritedValue.h"
52 #include "core/css/CSSInitialValue.h" 52 #include "core/css/CSSInitialValue.h"
53 #include "core/css/CSSKeyframeRule.h" 53 #include "core/css/CSSKeyframeRule.h"
54 #include "core/css/CSSKeyframesRule.h" 54 #include "core/css/CSSKeyframesRule.h"
55 #include "core/css/CSSLineBoxContainValue.h" 55 #include "core/css/CSSLineBoxContainValue.h"
56 #include "core/css/CSSParserValues.h" 56 #include "core/css/CSSParserValues.h"
57 #include "core/css/CSSPrimitiveValue.h" 57 #include "core/css/CSSPrimitiveValue.h"
58 #include "core/css/CSSPrimitiveValueMappings.h"
58 #include "core/css/CSSPropertySourceData.h" 59 #include "core/css/CSSPropertySourceData.h"
59 #include "core/css/CSSReflectValue.h" 60 #include "core/css/CSSReflectValue.h"
60 #include "core/css/CSSSVGDocumentValue.h" 61 #include "core/css/CSSSVGDocumentValue.h"
61 #include "core/css/CSSSelector.h" 62 #include "core/css/CSSSelector.h"
62 #include "core/css/CSSShadowValue.h" 63 #include "core/css/CSSShadowValue.h"
63 #include "core/css/CSSTimingFunctionValue.h" 64 #include "core/css/CSSTimingFunctionValue.h"
64 #include "core/css/CSSTransformValue.h" 65 #include "core/css/CSSTransformValue.h"
65 #include "core/css/CSSUnicodeRangeValue.h" 66 #include "core/css/CSSUnicodeRangeValue.h"
66 #include "core/css/CSSValueList.h" 67 #include "core/css/CSSValueList.h"
67 #include "core/css/CSSValuePool.h" 68 #include "core/css/CSSValuePool.h"
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 // <margin-width>{1,4} | inherit 1407 // <margin-width>{1,4} | inherit
1407 return parse4Values(propId, marginShorthand().properties(), important); 1408 return parse4Values(propId, marginShorthand().properties(), important);
1408 case CSSPropertyPadding: 1409 case CSSPropertyPadding:
1409 // <padding-width>{1,4} | inherit 1410 // <padding-width>{1,4} | inherit
1410 return parse4Values(propId, paddingShorthand().properties(), important); 1411 return parse4Values(propId, paddingShorthand().properties(), important);
1411 case CSSPropertyFlexFlow: 1412 case CSSPropertyFlexFlow:
1412 return parseShorthand(propId, flexFlowShorthand(), important); 1413 return parseShorthand(propId, flexFlowShorthand(), important);
1413 case CSSPropertyFont: 1414 case CSSPropertyFont:
1414 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 1415 // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
1415 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit 1416 // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
1416 if (id >= CSSValueCaption && id <= CSSValueStatusBar) 1417 if (num == 1 && id >= CSSValueCaption && id <= CSSValueStatusBar) {
1417 validPrimitive = true; 1418 parseSystemFont(important);
1418 else 1419 return true;
1419 return parseFont(important); 1420 }
1420 break; 1421 return parseFont(important);
1421 case CSSPropertyListStyle: 1422 case CSSPropertyListStyle:
1422 return parseShorthand(propId, listStyleShorthand(), important); 1423 return parseShorthand(propId, listStyleShorthand(), important);
1423 case CSSPropertyWebkitColumns: 1424 case CSSPropertyWebkitColumns:
1424 return parseColumnsShorthand(important); 1425 return parseColumnsShorthand(important);
1425 case CSSPropertyWebkitColumnRule: 1426 case CSSPropertyWebkitColumnRule:
1426 return parseShorthand(propId, webkitColumnRuleShorthand(), important); 1427 return parseShorthand(propId, webkitColumnRuleShorthand(), important);
1427 case CSSPropertyWebkitTextStroke: 1428 case CSSPropertyWebkitTextStroke:
1428 return parseShorthand(propId, webkitTextStrokeShorthand(), important); 1429 return parseShorthand(propId, webkitTextStrokeShorthand(), important);
1429 case CSSPropertyAnimation: 1430 case CSSPropertyAnimation:
1430 if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled()) 1431 if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
4275 shape = parseBasicShapeInset(args); 4276 shape = parseBasicShapeInset(args);
4276 4277
4277 if (!shape) 4278 if (!shape)
4278 return nullptr; 4279 return nullptr;
4279 4280
4280 m_valueList->next(); 4281 m_valueList->next();
4281 4282
4282 return cssValuePool().createValue(shape.release()); 4283 return cssValuePool().createValue(shape.release());
4283 } 4284 }
4284 4285
4286 void CSSPropertyParser::parseSystemFont(bool important)
4287 {
4288 ASSERT(m_valueList->size() == 1);
4289 CSSValueID systemFontID = m_valueList->valueAt(0)->id;
4290 ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar) ;
4291 m_valueList->next();
4292
4293 FontStyle fontStyle = FontStyleNormal;
4294 FontWeight fontWeight = FontWeightNormal;
4295 float fontSize = 0;
4296 AtomicString fontFamily;
4297 RenderTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz e, fontFamily);
4298
4299 ShorthandScope scope(this, CSSPropertyFont);
4300 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important);
4301 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i mportant);
4302 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri mitiveValue::CSS_PX), important);
4303 RefPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
4304 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily));
4305 addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important);
4306 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS ValueNormal), important);
4307 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV alueNormal), important);
4308 }
4309
4285 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family' 4310 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family'
4286 bool CSSPropertyParser::parseFont(bool important) 4311 bool CSSPropertyParser::parseFont(bool important)
4287 { 4312 {
4288 // Let's check if there is an inherit or initial somewhere in the shorthand. 4313 // Let's check if there is an inherit or initial somewhere in the shorthand.
4289 for (unsigned i = 0; i < m_valueList->size(); ++i) { 4314 for (unsigned i = 0; i < m_valueList->size(); ++i) {
4290 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial) 4315 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial)
4291 return false; 4316 return false;
4292 } 4317 }
4293 4318
4294 ShorthandScope scope(this, CSSPropertyFont); 4319 ShorthandScope scope(this, CSSPropertyFont);
(...skipping 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after
8217 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8242 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8218 if (!seenStroke) 8243 if (!seenStroke)
8219 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8244 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8220 if (!seenMarkers) 8245 if (!seenMarkers)
8221 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8246 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8222 8247
8223 return parsedValues.release(); 8248 return parsedValues.release();
8224 } 8249 }
8225 8250
8226 } // namespace WebCore 8251 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698