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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); | 412 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); |
413 | 413 |
414 if (!m_valueList) | 414 if (!m_valueList) |
415 return false; | 415 return false; |
416 | 416 |
417 CSSParserValue* value = m_valueList->current(); | 417 CSSParserValue* value = m_valueList->current(); |
418 | 418 |
419 if (!value) | 419 if (!value) |
420 return false; | 420 return false; |
421 | 421 |
422 if (inViewport()) { | 422 if (m_ruleType >= StyleRule::FontFace) { |
423 // Allow @viewport rules from UA stylesheets even if the feature is disa bled. | 423 if (m_ruleType == StyleRule::Viewport) { |
Timothy Loh
2015/05/01 04:32:16
This reads weird, and also probably breaks @viewpo
| |
424 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior( m_context.mode())) | 424 // Allow @viewport rules from UA stylesheets even if the feature is disabled. |
425 return false; | 425 if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehav ior(m_context.mode())) |
426 return false; | |
426 | 427 |
427 return parseViewportProperty(propId, important); | 428 return parseViewportProperty(propId, important); |
429 } | |
430 return parseFontFaceProperty(propId, important); | |
428 } | 431 } |
429 | 432 |
430 // Note: m_parsedCalculation is used to pass the calc value to validUnit and then cleared at the end of this function. | 433 // 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. | 434 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller s. |
432 ASSERT(!m_parsedCalculation); | 435 ASSERT(!m_parsedCalculation); |
433 | 436 |
434 CSSValueID id = value->id; | 437 CSSValueID id = value->id; |
435 | 438 |
436 if (id == CSSValueInherit) { | 439 if (id == CSSValueInherit) { |
437 if (m_valueList->size() != 1) | 440 if (m_valueList->size() != 1) |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 validPrimitive = true; | 927 validPrimitive = true; |
925 else | 928 else |
926 validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonN eg)); | 929 validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonN eg)); |
927 if (validPrimitive && m_context.useCounter() | 930 if (validPrimitive && m_context.useCounter() |
928 && !(id == CSSValueNormal | 931 && !(id == CSSValueNormal |
929 || (value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValu e == 1) | 932 || (value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValu e == 1) |
930 || (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE && value->f Value == 100))) | 933 || (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE && value->f Value == 100))) |
931 m_context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); | 934 m_context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); |
932 break; | 935 break; |
933 | 936 |
934 case CSSPropertySrc: // Only used within @font-face so cannot use inherit | initial or be !important. This is a list of urls or local references. | 937 case CSSPropertySrc: |
935 parsedValue = parseFontFaceSrc(); | |
936 break; | |
937 | |
938 case CSSPropertyUnicodeRange: | 938 case CSSPropertyUnicodeRange: |
939 parsedValue = parseFontFaceUnicodeRange(); | 939 /* @font-face only descriptors */ |
940 break; | 940 break; |
941 | 941 |
942 /* CSS3 properties */ | 942 /* CSS3 properties */ |
943 | 943 |
944 case CSSPropertyBorderImage: | 944 case CSSPropertyBorderImage: |
945 case CSSPropertyWebkitMaskBoxImage: | 945 case CSSPropertyWebkitMaskBoxImage: |
946 return parseBorderImageShorthand(propId, important); | 946 return parseBorderImageShorthand(propId, important); |
947 case CSSPropertyWebkitBorderImage: { | 947 case CSSPropertyWebkitBorderImage: { |
948 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { | 948 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { |
949 addProperty(propId, result, important); | 949 addProperty(propId, result, important); |
(...skipping 6700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7650 | 7650 |
7651 ASSERT(!m_parsedCalculation); | 7651 ASSERT(!m_parsedCalculation); |
7652 m_parsedCalculation = CSSCalcValue::create(args, range); | 7652 m_parsedCalculation = CSSCalcValue::create(args, range); |
7653 | 7653 |
7654 if (!m_parsedCalculation) | 7654 if (!m_parsedCalculation) |
7655 return false; | 7655 return false; |
7656 | 7656 |
7657 return true; | 7657 return true; |
7658 } | 7658 } |
7659 | 7659 |
7660 bool CSSPropertyParser::parseFontFaceProperty(CSSPropertyID propId, bool importa nt) | |
Timothy Loh
2015/05/01 04:32:16
I think this would be cleaner as
PassRefPtrWillBe
| |
7661 { | |
7662 CSSParserValue* value = m_valueList->current(); | |
7663 ASSERT(value); | |
7664 CSSValueID id = value->id; | |
7665 bool validPrimitive = false; | |
7666 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
7667 | |
7668 switch (propId) { | |
7669 case CSSPropertyFontFamily: | |
7670 // <family-name> | |
7671 // TODO: check there is only one family-name | |
Timothy Loh
2015/05/01 04:32:16
TODO(rwlbuis)?
| |
7672 parsedValue = parseFontFamily(); | |
7673 break; | |
7674 case CSSPropertySrc: // This is a list of urls or local references. | |
7675 parsedValue = parseFontFaceSrc(); | |
7676 break; | |
7677 case CSSPropertyUnicodeRange: | |
7678 parsedValue = parseFontFaceUnicodeRange(); | |
7679 break; | |
7680 case CSSPropertyFontWeight: // normal | bold | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | |
7681 if (m_valueList->size() != 1) | |
7682 return false; | |
7683 return parseFontWeight(important); | |
7684 case CSSPropertyFontStyle: | |
7685 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontS tyle, id)) | |
7686 return false; | |
7687 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; | |
7688 return true; | |
7689 case CSSPropertyFontVariant: // normal | small-caps | inherit | |
7690 return parseFontVariant(important); | |
7691 case CSSPropertyWebkitFontFeatureSettings: | |
7692 if (id == CSSValueNormal) | |
7693 validPrimitive = true; | |
7694 else | |
7695 parsedValue = parseFontFeatureSettings(); | |
7696 break; | |
7697 default: | |
Timothy Loh
2015/05/01 04:32:16
FontStretch?
| |
7698 break; | |
7699 } | |
7700 | |
7701 if (validPrimitive) { | |
7702 parsedValue = parseValidPrimitive(id, value); | |
7703 m_valueList->next(); | |
7704 } | |
7705 | |
7706 if (parsedValue) { | |
7707 if (!m_valueList->current() || inShorthand()) { | |
Timothy Loh
2015/05/01 04:32:16
No shorthands in here, right?
| |
7708 addProperty(propId, parsedValue.release(), important); | |
7709 return true; | |
7710 } | |
7711 } | |
7712 | |
7713 return false; | |
7714 } | |
7715 | |
7660 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) | 7716 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) |
7661 { | 7717 { |
7662 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); | 7718 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); |
7663 | 7719 |
7664 CSSParserValue* value = m_valueList->current(); | 7720 CSSParserValue* value = m_valueList->current(); |
7665 if (!value) | 7721 if (!value) |
7666 return false; | 7722 return false; |
7667 | 7723 |
7668 CSSValueID id = value->id; | 7724 CSSValueID id = value->id; |
7669 bool validPrimitive = false; | 7725 bool validPrimitive = false; |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8424 } | 8480 } |
8425 } | 8481 } |
8426 | 8482 |
8427 if (!list->length()) | 8483 if (!list->length()) |
8428 return nullptr; | 8484 return nullptr; |
8429 | 8485 |
8430 return list.release(); | 8486 return list.release(); |
8431 } | 8487 } |
8432 | 8488 |
8433 } // namespace blink | 8489 } // namespace blink |
OLD | NEW |