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

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: Fix compile failures 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
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 (id >= CSSValueCaption && id <= CSSValueStatusBar) {
apavlov 2014/03/20 15:27:49 This condition is missing "num == 1" - otherwise w
1417 validPrimitive = true; 1418 parseSystemFont(id, 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 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after
4512 shape = parseBasicShapeInset(args); 4513 shape = parseBasicShapeInset(args);
4513 4514
4514 if (!shape) 4515 if (!shape)
4515 return nullptr; 4516 return nullptr;
4516 4517
4517 m_valueList->next(); 4518 m_valueList->next();
4518 4519
4519 return cssValuePool().createValue(shape.release()); 4520 return cssValuePool().createValue(shape.release());
4520 } 4521 }
4521 4522
4523 void CSSPropertyParser::parseSystemFont(CSSValueID systemFontID, bool important)
4524 {
4525 FontStyle fontStyle = FontStyleNormal;
4526 FontWeight fontWeight = FontWeightNormal;
4527 float fontSize = 0;
4528 AtomicString fontFamily;
4529 RenderTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz e, fontFamily);
4530 addProperty(CSSPropertyFontStyle, cssValuePool().createValue(fontStyle), imp ortant);
4531 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i mportant);
4532 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri mitiveValue::CSS_PX), important);
4533 RefPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
4534 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily));
4535 addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important);
4536 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS ValueNormal), important);
4537 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV alueNormal), important);
4538 }
4539
4522 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family' 4540 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family'
4523 bool CSSPropertyParser::parseFont(bool important) 4541 bool CSSPropertyParser::parseFont(bool important)
4524 { 4542 {
4525 // Let's check if there is an inherit or initial somewhere in the shorthand. 4543 // Let's check if there is an inherit or initial somewhere in the shorthand.
4526 for (unsigned i = 0; i < m_valueList->size(); ++i) { 4544 for (unsigned i = 0; i < m_valueList->size(); ++i) {
4527 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial) 4545 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial)
4528 return false; 4546 return false;
4529 } 4547 }
4530 4548
4531 ShorthandScope scope(this, CSSPropertyFont); 4549 ShorthandScope scope(this, CSSPropertyFont);
(...skipping 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after
8453 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8471 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8454 if (!seenStroke) 8472 if (!seenStroke)
8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8473 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8456 if (!seenMarkers) 8474 if (!seenMarkers)
8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8475 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8458 8476
8459 return parsedValues.release(); 8477 return parsedValues.release();
8460 } 8478 }
8461 8479
8462 } // namespace WebCore 8480 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698