Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) |
| 1417 validPrimitive = true; | 1418 return parseKeywordBasedFont(important); |
| 1418 else | 1419 else |
| 1419 return parseFont(important); | 1420 return parseFont(important); |
| 1420 break; | 1421 break; |
| 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: |
| (...skipping 3086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4514 shape = parseBasicShapeInset(args); | 4515 shape = parseBasicShapeInset(args); |
| 4515 | 4516 |
| 4516 if (!shape) | 4517 if (!shape) |
| 4517 return nullptr; | 4518 return nullptr; |
| 4518 | 4519 |
| 4519 m_valueList->next(); | 4520 m_valueList->next(); |
| 4520 | 4521 |
| 4521 return cssValuePool().createValue(shape.release()); | 4522 return cssValuePool().createValue(shape.release()); |
| 4522 } | 4523 } |
| 4523 | 4524 |
| 4525 // [ 'caption' | 'icon' | 'menu' | 'message-box' | 'small-caption' | 'status-bar ' | '-webkit-mini-control' | '-webkit-small-control' | '-webkit-control' ] | |
| 4526 bool CSSPropertyParser::parseKeywordBasedFont(bool important) | |
| 4527 { | |
| 4528 if (m_valueList->size() != 1) | |
| 4529 return false; | |
|
darktears
2014/03/20 13:20:17
nit : You could assert here, so that we know if we
apavlov
2014/03/20 14:38:24
Done.
| |
| 4530 | |
| 4531 CSSParserValue* value = m_valueList->valueAt(0); | |
| 4532 CSSValueID id = value->id; | |
| 4533 ASSERT(id >= CSSValueCaption && id <= CSSValueStatusBar); | |
| 4534 | |
| 4535 FontDescription fontDescription; | |
| 4536 RenderTheme::theme().systemFont(id, fontDescription); | |
| 4537 RefPtr<CSSValueList> familyList = CSSValueList::createCommaSeparated(); | |
| 4538 familyList->append(cssValuePool().createFontFamilyValue(fontDescription.firs tFamily().family())); | |
| 4539 | |
| 4540 ShorthandScope scope(this, CSSPropertyFont); | |
| 4541 addProperty(CSSPropertyFontFamily, familyList, important, false); | |
| 4542 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontD escription.style() == FontStyleItalic ? CSSValueItalic : CSSValueNormal), import ant, false); | |
| 4543 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(fon tDescription.variant() == FontVariantSmallCaps ? CSSValueSmallCaps : CSSValueNor mal), important, false); | |
| 4544 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontDescriptio n.weight()), important, false); | |
| 4545 CSSParserValue fontSizeValue; | |
| 4546 fontSizeValue.setFromNumber(fontDescription.specifiedSize(), CSSPrimitiveVal ue::CSS_PX); | |
| 4547 addProperty(CSSPropertyFontSize, parseValidPrimitive(fontSizeValue.id, &font SizeValue), important, false); | |
| 4548 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV alueNormal), important, false); | |
| 4549 | |
| 4550 return true; | |
| 4551 } | |
| 4552 | |
| 4524 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family' | 4553 // [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-he ight' ]? 'font-family' |
| 4525 bool CSSPropertyParser::parseFont(bool important) | 4554 bool CSSPropertyParser::parseFont(bool important) |
| 4526 { | 4555 { |
| 4527 // Let's check if there is an inherit or initial somewhere in the shorthand. | 4556 // Let's check if there is an inherit or initial somewhere in the shorthand. |
| 4528 for (unsigned i = 0; i < m_valueList->size(); ++i) { | 4557 for (unsigned i = 0; i < m_valueList->size(); ++i) { |
| 4529 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial) | 4558 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial) |
| 4530 return false; | 4559 return false; |
| 4531 } | 4560 } |
| 4532 | 4561 |
| 4533 ShorthandScope scope(this, CSSPropertyFont); | 4562 ShorthandScope scope(this, CSSPropertyFont); |
| (...skipping 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8484 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
| 8456 if (!seenStroke) | 8485 if (!seenStroke) |
| 8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); | 8486 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); |
| 8458 if (!seenMarkers) | 8487 if (!seenMarkers) |
| 8459 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); | 8488 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); |
| 8460 | 8489 |
| 8461 return parsedValues.release(); | 8490 return parsedValues.release(); |
| 8462 } | 8491 } |
| 8463 | 8492 |
| 8464 } // namespace WebCore | 8493 } // namespace WebCore |
| OLD | NEW |