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

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

Issue 199423003: Add plumbing for font-stretch (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd 554 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd
555 || value->unit == CSSPrimitiveValue::CSS_STRING) 555 || value->unit == CSSPrimitiveValue::CSS_STRING)
556 validPrimitive = true; 556 validPrimitive = true;
557 break; 557 break;
558 558
559 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit 559 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
560 if (m_valueList->size() != 1) 560 if (m_valueList->size() != 1)
561 return false; 561 return false;
562 return parseFontWeight(important); 562 return parseFontWeight(important);
563 } 563 }
564
565 case CSSPropertyFontStretch: { // normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultr a-expanded
ojan 2014/03/13 21:53:24 I know code around this does this comment thing, b
566 if (m_valueList->size() != 1)
567 return false;
568 return parseFontStretch(important);
569 }
570
564 case CSSPropertyBorderSpacing: { 571 case CSSPropertyBorderSpacing: {
565 if (num == 1) { 572 if (num == 1) {
566 ShorthandScope scope(this, CSSPropertyBorderSpacing); 573 ShorthandScope scope(this, CSSPropertyBorderSpacing);
567 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) ) 574 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) )
568 return false; 575 return false;
569 CSSValue* value = m_parsedProperties.last().value(); 576 CSSValue* value = m_parsedProperties.last().value();
570 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important ); 577 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important );
571 return true; 578 return true;
572 } 579 }
573 else if (num == 2) { 580 else if (num == 2) {
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 break; 1438 break;
1432 case CSSPropertyWebkitAnimation: 1439 case CSSPropertyWebkitAnimation:
1433 return parseAnimationShorthand(propId, important); 1440 return parseAnimationShorthand(propId, important);
1434 case CSSPropertyTransition: 1441 case CSSPropertyTransition:
1435 case CSSPropertyWebkitTransition: 1442 case CSSPropertyWebkitTransition:
1436 return parseTransitionShorthand(propId, important); 1443 return parseTransitionShorthand(propId, important);
1437 case CSSPropertyInvalid: 1444 case CSSPropertyInvalid:
1438 return false; 1445 return false;
1439 case CSSPropertyPage: 1446 case CSSPropertyPage:
1440 return parsePage(propId, important); 1447 return parsePage(propId, important);
1441 case CSSPropertyFontStretch:
1442 return false;
1443 // CSS Text Layout Module Level 3: Vertical writing support 1448 // CSS Text Layout Module Level 3: Vertical writing support
1444 case CSSPropertyWebkitTextEmphasis: 1449 case CSSPropertyWebkitTextEmphasis:
1445 return parseShorthand(propId, webkitTextEmphasisShorthand(), important); 1450 return parseShorthand(propId, webkitTextEmphasisShorthand(), important);
1446 1451
1447 case CSSPropertyWebkitTextEmphasisStyle: 1452 case CSSPropertyWebkitTextEmphasisStyle:
1448 return parseTextEmphasisStyle(important); 1453 return parseTextEmphasisStyle(important);
1449 1454
1450 case CSSPropertyWebkitTextOrientation: 1455 case CSSPropertyWebkitTextOrientation:
1451 // FIXME: For now just support sideways, sideways-right, upright and ver tical-right. 1456 // FIXME: For now just support sideways, sideways-right, upright and ver tical-right.
1452 if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSVa lueVerticalRight || id == CSSValueUpright) 1457 if (id == CSSValueSideways || id == CSSValueSidewaysRight || id == CSSVa lueVerticalRight || id == CSSValueUpright)
(...skipping 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 for (unsigned i = 0; i < m_valueList->size(); ++i) { 4533 for (unsigned i = 0; i < m_valueList->size(); ++i) {
4529 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial) 4534 if (m_valueList->valueAt(i)->id == CSSValueInherit || m_valueList->value At(i)->id == CSSValueInitial)
4530 return false; 4535 return false;
4531 } 4536 }
4532 4537
4533 ShorthandScope scope(this, CSSPropertyFont); 4538 ShorthandScope scope(this, CSSPropertyFont);
4534 // Optional font-style, font-variant and font-weight. 4539 // Optional font-style, font-variant and font-weight.
4535 bool fontStyleParsed = false; 4540 bool fontStyleParsed = false;
4536 bool fontVariantParsed = false; 4541 bool fontVariantParsed = false;
4537 bool fontWeightParsed = false; 4542 bool fontWeightParsed = false;
4543 bool fontStretchParsed = false;
4538 CSSParserValue* value; 4544 CSSParserValue* value;
4539 while ((value = m_valueList->current())) { 4545 while ((value = m_valueList->current())) {
4540 if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontSt yle, value->id, m_context)) { 4546 if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontSt yle, value->id, m_context)) {
4541 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierVal ue(value->id), important); 4547 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierVal ue(value->id), important);
4542 fontStyleParsed = true; 4548 fontStyleParsed = true;
4543 } else if (!fontVariantParsed && (value->id == CSSValueNormal || value-> id == CSSValueSmallCaps)) { 4549 } else if (!fontVariantParsed && (value->id == CSSValueNormal || value-> id == CSSValueSmallCaps)) {
4544 // Font variant in the shorthand is particular, it only accepts norm al or small-caps. 4550 // Font variant in the shorthand is particular, it only accepts norm al or small-caps.
4545 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierV alue(value->id), important); 4551 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierV alue(value->id), important);
4546 fontVariantParsed = true; 4552 fontVariantParsed = true;
4547 } else if (!fontWeightParsed && parseFontWeight(important)) 4553 } else if (!fontWeightParsed && parseFontWeight(important)) {
4548 fontWeightParsed = true; 4554 fontWeightParsed = true;
4549 else 4555 } else if (!fontStretchParsed && parseFontStretch(important)) {
4556 fontStretchParsed = true;
4557 } else {
4550 break; 4558 break;
4559 }
4551 m_valueList->next(); 4560 m_valueList->next();
4552 } 4561 }
4553 4562
4554 if (!value) 4563 if (!value)
4555 return false; 4564 return false;
4556 4565
4557 if (!fontStyleParsed) 4566 if (!fontStyleParsed)
4558 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(C SSValueNormal), important, true); 4567 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(C SSValueNormal), important, true);
4559 if (!fontVariantParsed) 4568 if (!fontVariantParsed)
4560 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue (CSSValueNormal), important, true); 4569 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue (CSSValueNormal), important, true);
4561 if (!fontWeightParsed) 4570 if (!fontWeightParsed)
4562 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true); 4571 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true);
4572 if (!fontStretchParsed)
4573 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue (CSSValueNormal), important, true);
4563 4574
4564 // Now a font size _must_ come. 4575 // Now a font size _must_ come.
4565 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit 4576 // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
4566 if (!parseFontSize(important)) 4577 if (!parseFontSize(important))
4567 return false; 4578 return false;
4568 4579
4569 value = m_valueList->current(); 4580 value = m_valueList->current();
4570 if (!value) 4581 if (!value)
4571 return false; 4582 return false;
4572 4583
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 if (validUnit(value, FInteger | FNonNeg, HTMLQuirksMode)) { 4802 if (validUnit(value, FInteger | FNonNeg, HTMLQuirksMode)) {
4792 int weight = static_cast<int>(value->fValue); 4803 int weight = static_cast<int>(value->fValue);
4793 if (!(weight % 100) && weight >= 100 && weight <= 900) { 4804 if (!(weight % 100) && weight >= 100 && weight <= 900) {
4794 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); 4805 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important);
4795 return true; 4806 return true;
4796 } 4807 }
4797 } 4808 }
4798 return false; 4809 return false;
4799 } 4810 }
4800 4811
4812 bool CSSPropertyParser::parseFontStretch(bool important)
4813 {
4814 CSSParserValue* value = m_valueList->current();
4815 if (value->id == CSSValueNormal || (value->id >= CSSValueUltraCondensed && v alue->id <= CSSValueUltraExpanded)) {
4816 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue (value->id), important);
4817 return true;
4818 }
4819 return false;
4820 }
4821
4801 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) 4822 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
4802 { 4823 {
4803 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create (completeURL(m_valueList->current()->string))); 4824 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create (completeURL(m_valueList->current()->string)));
4804 4825
4805 CSSParserValue* value = m_valueList->next(); 4826 CSSParserValue* value = m_valueList->next();
4806 if (!value) { 4827 if (!value) {
4807 valueList->append(uriValue.release()); 4828 valueList->append(uriValue.release());
4808 return true; 4829 return true;
4809 } 4830 }
4810 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { 4831 if (value->unit == CSSParserValue::Operator && value->iValue == ',') {
(...skipping 3644 matching lines...) Expand 10 before | Expand all | Expand 10 after
8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8476 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8456 if (!seenStroke) 8477 if (!seenStroke)
8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8478 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8458 if (!seenMarkers) 8479 if (!seenMarkers)
8459 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8480 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8460 8481
8461 return parsedValues.release(); 8482 return parsedValues.release();
8462 } 8483 }
8463 8484
8464 } // namespace WebCore 8485 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698