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 16 matching lines...) Expand all Loading... | |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/css/parser/CSSPropertyParser.h" | 28 #include "core/css/parser/CSSPropertyParser.h" |
| 29 | 29 |
| 30 #include "core/StylePropertyShorthand.h" | 30 #include "core/StylePropertyShorthand.h" |
| 31 #include "core/css/CSSBasicShapes.h" | 31 #include "core/css/CSSBasicShapes.h" |
| 32 #include "core/css/CSSBorderImage.h" | 32 #include "core/css/CSSBorderImage.h" |
| 33 #include "core/css/CSSCanvasValue.h" | 33 #include "core/css/CSSCanvasValue.h" |
| 34 #include "core/css/CSSContentDistributionValue.h" | 34 #include "core/css/CSSContentDistributionValue.h" |
| 35 #include "core/css/CSSCrossfadeValue.h" | 35 #include "core/css/CSSCrossfadeValue.h" |
| 36 #include "core/css/CSSCursorImageValue.h" | 36 #include "core/css/CSSCursorImageValue.h" |
| 37 #include "core/css/CSSCustomVariableValue.h" | |
| 37 #include "core/css/CSSFontFaceSrcValue.h" | 38 #include "core/css/CSSFontFaceSrcValue.h" |
| 38 #include "core/css/CSSFontFeatureValue.h" | 39 #include "core/css/CSSFontFeatureValue.h" |
| 39 #include "core/css/CSSFunctionValue.h" | 40 #include "core/css/CSSFunctionValue.h" |
| 40 #include "core/css/CSSGridLineNamesValue.h" | 41 #include "core/css/CSSGridLineNamesValue.h" |
| 41 #include "core/css/CSSImageSetValue.h" | 42 #include "core/css/CSSImageSetValue.h" |
| 42 #include "core/css/CSSImageValue.h" | 43 #include "core/css/CSSImageValue.h" |
| 43 #include "core/css/CSSLineBoxContainValue.h" | 44 #include "core/css/CSSLineBoxContainValue.h" |
| 44 #include "core/css/CSSPathValue.h" | 45 #include "core/css/CSSPathValue.h" |
| 45 #include "core/css/CSSPrimitiveValueMappings.h" | 46 #include "core/css/CSSPrimitiveValueMappings.h" |
| 46 #include "core/css/CSSProperty.h" | 47 #include "core/css/CSSProperty.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 return false; | 440 return false; |
| 440 addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitial Value(), important); | 441 addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitial Value(), important); |
| 441 return true; | 442 return true; |
| 442 } else if (id == CSSValueUnset) { | 443 } else if (id == CSSValueUnset) { |
| 443 if (m_valueList->size() != 1) | 444 if (m_valueList->size() != 1) |
| 444 return false; | 445 return false; |
| 445 addExpandedPropertyForValue(propId, cssValuePool().createUnsetValue(), i mportant); | 446 addExpandedPropertyForValue(propId, cssValuePool().createUnsetValue(), i mportant); |
| 446 return true; | 447 return true; |
| 447 } | 448 } |
| 448 | 449 |
| 450 | |
| 449 int num = inShorthand() ? 1 : m_valueList->size(); | 451 int num = inShorthand() ? 1 : m_valueList->size(); |
| 450 | 452 |
| 453 if (RuntimeEnabledFeatures::cssVariablesEnabled() && value->unit() == CSSPri mitiveValue::UnitType::VariableReference) { | |
| 454 // We don't expand the shorthand here because crazypants. | |
| 455 m_parsedProperties.append(CSSProperty(propId, CSSPrimitiveValue::create( value->variableData), important, false, 0, m_implicitShorthand)); | |
| 456 m_valueList->next(); | |
| 457 return true; | |
| 458 } | |
| 459 | |
| 451 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { | 460 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
| 452 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 461 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
| 453 return false; | 462 return false; |
| 454 if (m_valueList->next() && !inShorthand()) | 463 if (m_valueList->next() && !inShorthand()) |
| 455 return false; | 464 return false; |
| 456 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; | 465 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; |
| 457 return true; | 466 return true; |
| 458 } | 467 } |
| 459 | 468 |
| 460 bool validPrimitive = false; | 469 bool validPrimitive = false; |
| (...skipping 7114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7575 | 7584 |
| 7576 // If just one value is supplied, the second value | 7585 // If just one value is supplied, the second value |
| 7577 // is implicitly initialized with the first value. | 7586 // is implicitly initialized with the first value. |
| 7578 if (numValues == 1) | 7587 if (numValues == 1) |
| 7579 m_valueList->previous(); | 7588 m_valueList->previous(); |
| 7580 | 7589 |
| 7581 return parseViewportProperty(second, important); | 7590 return parseViewportProperty(second, important); |
| 7582 } | 7591 } |
| 7583 | 7592 |
| 7584 template <typename CharacterType> | 7593 template <typename CharacterType> |
| 7594 static bool isVariableDefinition(const CharacterType* propertyName, unsigned len gth) | |
| 7595 { | |
| 7596 return (length >= 2 && propertyName[0] == '-' && propertyName[1] == '-'); | |
| 7597 } | |
| 7598 | |
| 7599 template <typename CharacterType> | |
| 7585 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName, unsigned length) | 7600 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName, unsigned length) |
|
alancutter (OOO until 2018)
2015/08/05 08:01:43
I'm not sure that we should be returning CSSProper
| |
| 7586 { | 7601 { |
| 7587 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character | 7602 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character |
| 7588 | 7603 |
| 7589 for (unsigned i = 0; i != length; ++i) { | 7604 for (unsigned i = 0; i != length; ++i) { |
| 7590 CharacterType c = propertyName[i]; | 7605 CharacterType c = propertyName[i]; |
| 7591 if (c == 0 || c >= 0x7F) | 7606 if (c == 0 || c >= 0x7F) { |
| 7607 if (isVariableDefinition(propertyName, length)) | |
| 7608 return CSSPropertyVariable; | |
| 7592 return CSSPropertyInvalid; // illegal character | 7609 return CSSPropertyInvalid; // illegal character |
| 7610 } | |
| 7593 buffer[i] = toASCIILower(c); | 7611 buffer[i] = toASCIILower(c); |
| 7594 } | 7612 } |
| 7595 buffer[length] = '\0'; | 7613 buffer[length] = '\0'; |
| 7596 | 7614 |
| 7597 const char* name = buffer; | 7615 const char* name = buffer; |
| 7598 const Property* hashTableEntry = findProperty(name, length); | 7616 const Property* hashTableEntry = findProperty(name, length); |
| 7599 if (!hashTableEntry) | 7617 if (!hashTableEntry) { |
| 7618 if (isVariableDefinition(propertyName, length)) | |
| 7619 return CSSPropertyVariable; | |
| 7600 return CSSPropertyInvalid; | 7620 return CSSPropertyInvalid; |
| 7621 } | |
| 7601 CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id); | 7622 CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id); |
| 7602 if (!CSSPropertyMetadata::isEnabledProperty(property)) | 7623 if (!CSSPropertyMetadata::isEnabledProperty(property)) |
| 7603 return CSSPropertyInvalid; | 7624 return CSSPropertyInvalid; |
| 7604 return property; | 7625 return property; |
| 7605 } | 7626 } |
| 7606 | 7627 |
| 7607 CSSPropertyID unresolvedCSSPropertyID(const String& string) | 7628 CSSPropertyID unresolvedCSSPropertyID(const String& string) |
| 7608 { | 7629 { |
| 7609 unsigned length = string.length(); | 7630 unsigned length = string.length(); |
| 7610 | 7631 |
| 7611 if (!length) | 7632 if (!length) |
| 7612 return CSSPropertyInvalid; | 7633 return CSSPropertyInvalid; |
| 7613 if (length > maxCSSPropertyNameLength) | 7634 if (length > maxCSSPropertyNameLength) { |
| 7635 if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) | |
| 7636 return CSSPropertyVariable; | |
| 7614 return CSSPropertyInvalid; | 7637 return CSSPropertyInvalid; |
| 7638 } | |
| 7615 | 7639 |
| 7616 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); | 7640 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); |
| 7617 } | 7641 } |
| 7618 | 7642 |
| 7619 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString& string) | 7643 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString& string) |
| 7620 { | 7644 { |
| 7621 unsigned length = string.length(); | 7645 unsigned length = string.length(); |
| 7622 | 7646 |
| 7623 if (!length) | 7647 if (!length) |
| 7624 return CSSPropertyInvalid; | 7648 return CSSPropertyInvalid; |
| 7625 if (length > maxCSSPropertyNameLength) | 7649 if (length > maxCSSPropertyNameLength) { |
| 7650 if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) | |
| 7651 return CSSPropertyVariable; | |
| 7626 return CSSPropertyInvalid; | 7652 return CSSPropertyInvalid; |
| 7653 } | |
| 7627 | 7654 |
| 7628 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); | 7655 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); |
| 7629 } | 7656 } |
| 7630 | 7657 |
| 7631 template <typename CharacterType> | 7658 template <typename CharacterType> |
| 7632 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned length) | 7659 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned length) |
| 7633 { | 7660 { |
| 7634 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character | 7661 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character |
| 7635 | 7662 |
| 7636 for (unsigned i = 0; i != length; ++i) { | 7663 for (unsigned i = 0; i != length; ++i) { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8160 } | 8187 } |
| 8161 } | 8188 } |
| 8162 | 8189 |
| 8163 if (!list->length()) | 8190 if (!list->length()) |
| 8164 return nullptr; | 8191 return nullptr; |
| 8165 | 8192 |
| 8166 return list.release(); | 8193 return list.release(); |
| 8167 } | 8194 } |
| 8168 | 8195 |
| 8169 } // namespace blink | 8196 } // namespace blink |
| OLD | NEW |