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

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

Issue 1103273010: Add parseFontFaceDescriptor for @font-face handling (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V5 Created 5 years, 7 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
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (!value) 419 if (!value)
420 return false; 420 return false;
421 421
422 if (inViewport()) { 422 if (inViewport()) {
423 // Allow @viewport rules from UA stylesheets even if the feature is disa bled. 423 // Allow @viewport rules from UA stylesheets even if the feature is disa bled.
424 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior( m_context.mode())) 424 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior( m_context.mode()))
425 return false; 425 return false;
426 426
427 return parseViewportProperty(propId, important); 427 return parseViewportProperty(propId, important);
428 } 428 }
429 if (m_ruleType == StyleRule::FontFace) {
430 if (important)
431 return false;
432 return parseFontFaceDescriptor(propId);
433 }
429 434
430 // Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function. 435 // Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function.
431 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller s. 436 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller s.
432 ASSERT(!m_parsedCalculation); 437 ASSERT(!m_parsedCalculation);
433 438
434 CSSValueID id = value->id; 439 CSSValueID id = value->id;
435 440
436 if (id == CSSValueInherit) { 441 if (id == CSSValueInherit) {
437 if (m_valueList->size() != 1) 442 if (m_valueList->size() != 1)
438 return false; 443 return false;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 validPrimitive = true; 924 validPrimitive = true;
920 else 925 else
921 validPrimitive = validUnit(value, FNumber | FPercent | FNonNeg); 926 validPrimitive = validUnit(value, FNumber | FPercent | FNonNeg);
922 if (validPrimitive && m_context.useCounter() 927 if (validPrimitive && m_context.useCounter()
923 && !(id == CSSValueNormal 928 && !(id == CSSValueNormal
924 || (value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValu e == 1) 929 || (value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValu e == 1)
925 || (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE && value->f Value == 100))) 930 || (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE && value->f Value == 100)))
926 m_context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); 931 m_context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne);
927 break; 932 break;
928 933
929 case CSSPropertySrc: // Only used within @font-face so cannot use inherit | initial or be !important. This is a list of urls or local references. 934 case CSSPropertySrc:
930 parsedValue = parseFontFaceSrc();
931 break;
932
933 case CSSPropertyUnicodeRange: 935 case CSSPropertyUnicodeRange:
934 parsedValue = parseFontFaceUnicodeRange(); 936 /* @font-face only descriptors */
935 break; 937 break;
936 938
937 /* CSS3 properties */ 939 /* CSS3 properties */
938 940
939 case CSSPropertyBorderImage: 941 case CSSPropertyBorderImage:
940 case CSSPropertyWebkitMaskBoxImage: 942 case CSSPropertyWebkitMaskBoxImage:
941 return parseBorderImageShorthand(propId, important); 943 return parseBorderImageShorthand(propId, important);
942 case CSSPropertyWebkitBorderImage: { 944 case CSSPropertyWebkitBorderImage: {
943 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { 945 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) {
944 addProperty(propId, result, important); 946 addProperty(propId, result, important);
(...skipping 6688 matching lines...) Expand 10 before | Expand all | Expand 10 after
7633 7635
7634 ASSERT(!m_parsedCalculation); 7636 ASSERT(!m_parsedCalculation);
7635 m_parsedCalculation = CSSCalcValue::create(args, range); 7637 m_parsedCalculation = CSSCalcValue::create(args, range);
7636 7638
7637 if (!m_parsedCalculation) 7639 if (!m_parsedCalculation)
7638 return false; 7640 return false;
7639 7641
7640 return true; 7642 return true;
7641 } 7643 }
7642 7644
7645 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
7646 {
7647 CSSParserValue* value = m_valueList->current();
7648 ASSERT(value);
7649 CSSValueID id = value->id;
7650 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
7651
7652 switch (propId) {
7653 case CSSPropertyFontFamily:
7654 // <family-name>
7655 // TODO(rwlbuis): check there is only one family-name
7656 parsedValue = parseFontFamily();
7657 break;
7658 case CSSPropertySrc: // This is a list of urls or local references.
7659 parsedValue = parseFontFaceSrc();
7660 break;
7661 case CSSPropertyUnicodeRange:
7662 parsedValue = parseFontFaceUnicodeRange();
7663 break;
7664 case CSSPropertyFontWeight: // normal | bold | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
7665 if (m_valueList->size() != 1)
7666 return false;
7667 return parseFontWeight(false);
7668 case CSSPropertyFontStretch:
7669 case CSSPropertyFontStyle:
7670 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id))
7671 return false;
7672 addProperty(propId, cssValuePool().createIdentifierValue(id), false);
7673 return true;
7674 case CSSPropertyFontVariant: // normal | small-caps | inherit
7675 return parseFontVariant(false);
7676 case CSSPropertyWebkitFontFeatureSettings:
7677 if (id == CSSValueNormal) {
7678 parsedValue = cssValuePool().createIdentifierValue(CSSValueNormal);
7679 m_valueList->next();
7680 } else {
7681 parsedValue = parseFontFeatureSettings();
7682 }
7683 break;
7684 default:
7685 break;
7686 }
7687
7688 if (!parsedValue || m_valueList->current())
7689 return false;
7690
7691 addProperty(propId, parsedValue.release(), false);
7692 return true;
7693 }
7694
7643 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) 7695 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt)
7644 { 7696 {
7645 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7697 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
7646 7698
7647 CSSParserValue* value = m_valueList->current(); 7699 CSSParserValue* value = m_valueList->current();
7648 if (!value) 7700 if (!value)
7649 return false; 7701 return false;
7650 7702
7651 CSSValueID id = value->id; 7703 CSSValueID id = value->id;
7652 bool validPrimitive = false; 7704 bool validPrimitive = false;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
8405 } 8457 }
8406 } 8458 }
8407 8459
8408 if (!list->length()) 8460 if (!list->length())
8409 return nullptr; 8461 return nullptr;
8410 8462
8411 return list.release(); 8463 return list.release();
8412 } 8464 }
8413 8465
8414 } // namespace blink 8466 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698