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

Side by Side Diff: sky/engine/core/css/parser/BisonCSSParser-in.cpp

Issue 860423004: Remove css !important (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/core/css/parser/BisonCSSParser.h ('k') | sky/engine/core/css/parser/CSSGrammar.y » ('j') | 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int cssyyparse(blink::BisonCSSParser*); 91 int cssyyparse(blink::BisonCSSParser*);
92 92
93 using namespace WTF; 93 using namespace WTF;
94 94
95 namespace blink { 95 namespace blink {
96 96
97 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX; 97 static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
98 98
99 BisonCSSParser::BisonCSSParser(const CSSParserContext& context) 99 BisonCSSParser::BisonCSSParser(const CSSParserContext& context)
100 : m_context(context) 100 : m_context(context)
101 , m_important(false)
102 , m_id(CSSPropertyInvalid) 101 , m_id(CSSPropertyInvalid)
103 , m_styleSheet(nullptr) 102 , m_styleSheet(nullptr)
104 , m_supportsCondition(false) 103 , m_supportsCondition(false)
105 , m_selectorListForParseSelector(0) 104 , m_selectorListForParseSelector(0)
106 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES) 105 , m_numParsedPropertiesBeforeMarginBox(INVALID_NUM_PARSED_PROPERTIES)
107 , m_hadSyntacticallyValidCSSRule(false) 106 , m_hadSyntacticallyValidCSSRule(false)
108 , m_ignoreErrors(false) 107 , m_ignoreErrors(false)
109 , m_defaultNamespace(starAtom) 108 , m_defaultNamespace(starAtom)
110 , m_observer(0) 109 , m_observer(0)
111 , m_source(0) 110 , m_source(0)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case CSSPropertyWebkitTextEmphasisColor: 203 case CSSPropertyWebkitTextEmphasisColor:
205 case CSSPropertyWebkitTextFillColor: 204 case CSSPropertyWebkitTextFillColor:
206 case CSSPropertyWebkitTextStrokeColor: 205 case CSSPropertyWebkitTextStrokeColor:
207 case CSSPropertyTextDecorationColor: 206 case CSSPropertyTextDecorationColor:
208 return true; 207 return true;
209 default: 208 default:
210 return false; 209 return false;
211 } 210 }
212 } 211 }
213 212
214 static bool parseColorValue(MutableStylePropertySet* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode) 213 static bool parseColorValue(MutableStylePropertySet* declaration, CSSPropertyID propertyId, const String& string, CSSParserMode cssParserMode)
215 { 214 {
216 ASSERT(!string.isEmpty()); 215 ASSERT(!string.isEmpty());
217 bool quirksMode = isQuirksModeBehavior(cssParserMode); 216 bool quirksMode = isQuirksModeBehavior(cssParserMode);
218 if (!isColorPropertyID(propertyId)) 217 if (!isColorPropertyID(propertyId))
219 return false; 218 return false;
220 CSSParserString cssString; 219 CSSParserString cssString;
221 cssString.init(string); 220 cssString.init(string);
222 CSSValueID valueID = cssValueKeywordID(cssString); 221 CSSValueID valueID = cssValueKeywordID(cssString);
223 bool validPrimitive = false; 222 bool validPrimitive = false;
224 if (valueID == CSSValueCurrentcolor) 223 if (valueID == CSSValueCurrentcolor)
225 validPrimitive = true; 224 validPrimitive = true;
226 225
227 if (validPrimitive) { 226 if (validPrimitive) {
228 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID); 227 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID);
229 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)); 228 declaration->addParsedProperty(CSSProperty(propertyId, value.release())) ;
230 return true; 229 return true;
231 } 230 }
232 RGBA32 color; 231 RGBA32 color;
233 if (!CSSPropertyParser::fastParseColor(color, string, !quirksMode && string[ 0] != '#')) 232 if (!CSSPropertyParser::fastParseColor(color, string, !quirksMode && string[ 0] != '#'))
234 return false; 233 return false;
235 RefPtr<CSSValue> value = cssValuePool().createColorValue(color); 234 RefPtr<CSSValue> value = cssValuePool().createColorValue(color);
236 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), impo rtant)); 235 declaration->addParsedProperty(CSSProperty(propertyId, value.release()));
237 return true; 236 return true;
238 } 237 }
239 238
240 static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce ptsNegativeNumbers) 239 static inline bool isSimpleLengthPropertyID(CSSPropertyID propertyId, bool& acce ptsNegativeNumbers)
241 { 240 {
242 switch (propertyId) { 241 switch (propertyId) {
243 case CSSPropertyFontSize: 242 case CSSPropertyFontSize:
244 case CSSPropertyHeight: 243 case CSSPropertyHeight:
245 case CSSPropertyWidth: 244 case CSSPropertyWidth:
246 case CSSPropertyMinHeight: 245 case CSSPropertyMinHeight:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 289 }
291 290
292 // We rely on charactersToDouble for validation as well. The function 291 // We rely on charactersToDouble for validation as well. The function
293 // will set "ok" to "false" if the entire passed-in character range does 292 // will set "ok" to "false" if the entire passed-in character range does
294 // not represent a double. 293 // not represent a double.
295 bool ok; 294 bool ok;
296 number = charactersToDouble(characters, length, &ok); 295 number = charactersToDouble(characters, length, &ok);
297 return ok; 296 return ok;
298 } 297 }
299 298
300 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, bool important, CSSParserMode cssParser Mode) 299 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, CSSParserMode cssParserMode)
301 { 300 {
302 ASSERT(!string.isEmpty()); 301 ASSERT(!string.isEmpty());
303 bool acceptsNegativeNumbers = false; 302 bool acceptsNegativeNumbers = false;
304 303
305 // In @viewport, width and height are shorthands, not simple length values. 304 // In @viewport, width and height are shorthands, not simple length values.
306 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers)) 305 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers))
307 return false; 306 return false;
308 307
309 unsigned length = string.length(); 308 unsigned length = string.length();
310 double number; 309 double number;
(...skipping 10 matching lines...) Expand all
321 if (unit == CSSPrimitiveValue::CSS_NUMBER) { 320 if (unit == CSSPrimitiveValue::CSS_NUMBER) {
322 bool quirksMode = isQuirksModeBehavior(cssParserMode); 321 bool quirksMode = isQuirksModeBehavior(cssParserMode);
323 if (number && !quirksMode) 322 if (number && !quirksMode)
324 return false; 323 return false;
325 unit = CSSPrimitiveValue::CSS_PX; 324 unit = CSSPrimitiveValue::CSS_PX;
326 } 325 }
327 if (number < 0 && !acceptsNegativeNumbers) 326 if (number < 0 && !acceptsNegativeNumbers)
328 return false; 327 return false;
329 328
330 RefPtr<CSSValue> value = cssValuePool().createValue(number, unit); 329 RefPtr<CSSValue> value = cssValuePool().createValue(number, unit);
331 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), impo rtant)); 330 declaration->addParsedProperty(CSSProperty(propertyId, value.release()));
332 return true; 331 return true;
333 } 332 }
334 333
335 bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, CSSValueID valueID , const CSSParserContext& parserContext) 334 bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, CSSValueID valueID , const CSSParserContext& parserContext)
336 { 335 {
337 if (valueID == CSSValueInvalid) 336 if (valueID == CSSValueInvalid)
338 return false; 337 return false;
339 338
340 switch (propertyId) { 339 switch (propertyId) {
341 case CSSPropertyAll: 340 case CSSPropertyAll:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 case CSSPropertyWebkitUserSelect: 544 case CSSPropertyWebkitUserSelect:
546 case CSSPropertyWhiteSpace: 545 case CSSPropertyWhiteSpace:
547 case CSSPropertyWordBreak: 546 case CSSPropertyWordBreak:
548 case CSSPropertyWordWrap: 547 case CSSPropertyWordWrap:
549 return true; 548 return true;
550 default: 549 default:
551 return false; 550 return false;
552 } 551 }
553 } 552 }
554 553
555 static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyI D propertyId, const String& string, bool important, const CSSParserContext& pars erContext) 554 static bool parseKeywordValue(MutableStylePropertySet* declaration, CSSPropertyI D propertyId, const String& string, const CSSParserContext& parserContext)
556 { 555 {
557 ASSERT(!string.isEmpty()); 556 ASSERT(!string.isEmpty());
558 557
559 if (!isKeywordPropertyID(propertyId)) { 558 if (!isKeywordPropertyID(propertyId)) {
560 // All properties accept the values of "initial" and "inherit". 559 // All properties accept the values of "initial" and "inherit".
561 String lowerCaseString = string.lower(); 560 String lowerCaseString = string.lower();
562 if (lowerCaseString != "initial" && lowerCaseString != "inherit") 561 if (lowerCaseString != "initial" && lowerCaseString != "inherit")
563 return false; 562 return false;
564 563
565 // Parse initial/inherit shorthands using the BisonCSSParser. 564 // Parse initial/inherit shorthands using the BisonCSSParser.
(...skipping 11 matching lines...) Expand all
577 RefPtr<CSSValue> value = nullptr; 576 RefPtr<CSSValue> value = nullptr;
578 if (valueID == CSSValueInherit) 577 if (valueID == CSSValueInherit)
579 value = cssValuePool().createInheritedValue(); 578 value = cssValuePool().createInheritedValue();
580 else if (valueID == CSSValueInitial) 579 else if (valueID == CSSValueInitial)
581 value = cssValuePool().createExplicitInitialValue(); 580 value = cssValuePool().createExplicitInitialValue();
582 else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext)) 581 else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext))
583 value = cssValuePool().createIdentifierValue(valueID); 582 value = cssValuePool().createIdentifierValue(valueID);
584 else 583 else
585 return false; 584 return false;
586 585
587 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), impo rtant)); 586 declaration->addParsedProperty(CSSProperty(propertyId, value.release()));
588 return true; 587 return true;
589 } 588 }
590 589
591 template <typename CharType> 590 template <typename CharType>
592 static bool parseTransformTranslateArguments(CharType*& pos, CharType* end, unsi gned expectedCount, CSSTransformValue* transformValue) 591 static bool parseTransformTranslateArguments(CharType*& pos, CharType* end, unsi gned expectedCount, CSSTransformValue* transformValue)
593 { 592 {
594 while (expectedCount) { 593 while (expectedCount) {
595 size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' : ','); 594 size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' : ',');
596 if (delimiter == kNotFound) 595 if (delimiter == kNotFound)
597 return false; 596 return false;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 transformList = CSSValueList::createSpaceSeparated(); 726 transformList = CSSValueList::createSpaceSeparated();
728 transformList->append(transformValue.release()); 727 transformList->append(transformValue.release());
729 if (pos < end) { 728 if (pos < end) {
730 if (isCSSSpace(*pos)) 729 if (isCSSSpace(*pos))
731 return nullptr; 730 return nullptr;
732 } 731 }
733 } 732 }
734 return transformList.release(); 733 return transformList.release();
735 } 734 }
736 735
737 static bool parseSimpleTransform(MutableStylePropertySet* properties, CSSPropert yID propertyID, const String& string, bool important) 736 static bool parseSimpleTransform(MutableStylePropertySet* properties, CSSPropert yID propertyID, const String& string)
738 { 737 {
739 if (propertyID != CSSPropertyTransform && propertyID != CSSPropertyWebkitTra nsform) 738 if (propertyID != CSSPropertyTransform && propertyID != CSSPropertyWebkitTra nsform)
740 return false; 739 return false;
741 if (string.isEmpty()) 740 if (string.isEmpty())
742 return false; 741 return false;
743 RefPtr<CSSValueList> transformList = nullptr; 742 RefPtr<CSSValueList> transformList = nullptr;
744 if (string.is8Bit()) { 743 if (string.is8Bit()) {
745 const LChar* pos = string.characters8(); 744 const LChar* pos = string.characters8();
746 const LChar* end = pos + string.length(); 745 const LChar* end = pos + string.length();
747 transformList = parseSimpleTransformList(pos, end); 746 transformList = parseSimpleTransformList(pos, end);
748 if (!transformList) 747 if (!transformList)
749 return false; 748 return false;
750 } else { 749 } else {
751 const UChar* pos = string.characters16(); 750 const UChar* pos = string.characters16();
752 const UChar* end = pos + string.length(); 751 const UChar* end = pos + string.length();
753 transformList = parseSimpleTransformList(pos, end); 752 transformList = parseSimpleTransformList(pos, end);
754 if (!transformList) 753 if (!transformList)
755 return false; 754 return false;
756 } 755 }
757 properties->addParsedProperty(CSSProperty(propertyID, transformList.release( ), important)); 756 properties->addParsedProperty(CSSProperty(propertyID, transformList.release( )));
758 return true; 757 return true;
759 } 758 }
760 759
761 PassRefPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const AtomicString& string) 760 PassRefPtr<CSSValueList> BisonCSSParser::parseFontFaceValue(const AtomicString& string)
762 { 761 {
763 if (string.isEmpty()) 762 if (string.isEmpty())
764 return nullptr; 763 return nullptr;
765 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create (); 764 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create ();
766 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, false, HTML StandardMode, 0)) 765 if (!parseValue(dummyStyle.get(), CSSPropertyFontFamily, string, HTMLStandar dMode, 0))
767 return nullptr; 766 return nullptr;
768 767
769 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon tFamily); 768 RefPtr<CSSValue> fontFamily = dummyStyle->getPropertyCSSValue(CSSPropertyFon tFamily);
770 if (!fontFamily->isValueList()) 769 if (!fontFamily->isValueList())
771 return nullptr; 770 return nullptr;
772 771
773 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily) .get()); 772 return toCSSValueList(dummyStyle->getPropertyCSSValue(CSSPropertyFontFamily) .get());
774 } 773 }
775 774
776 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionValue(const Str ing& string) 775 PassRefPtr<CSSValue> BisonCSSParser::parseAnimationTimingFunctionValue(const Str ing& string)
777 { 776 {
778 if (string.isEmpty()) 777 if (string.isEmpty())
779 return nullptr; 778 return nullptr;
780 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); 779 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create();
781 if (!parseValue(style.get(), CSSPropertyTransitionTimingFunction, string, fa lse, HTMLStandardMode, 0)) 780 if (!parseValue(style.get(), CSSPropertyTransitionTimingFunction, string, HT MLStandardMode, 0))
782 return nullptr; 781 return nullptr;
783 782
784 RefPtr<CSSValue> value = style->getPropertyCSSValue(CSSPropertyTransitionTim ingFunction); 783 RefPtr<CSSValue> value = style->getPropertyCSSValue(CSSPropertyTransitionTim ingFunction);
785 if (!value || value->isInitialValue() || value->isInheritedValue()) 784 if (!value || value->isInitialValue() || value->isInheritedValue())
786 return nullptr; 785 return nullptr;
787 CSSValueList* valueList = toCSSValueList(value.get()); 786 CSSValueList* valueList = toCSSValueList(value.get());
788 if (valueList->length() > 1) 787 if (valueList->length() > 1)
789 return nullptr; 788 return nullptr;
790 return valueList->item(0); 789 return valueList->item(0);
791 } 790 }
792 791
793 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, const Document& document) 792 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, const Document& document)
794 { 793 {
795 ASSERT(!string.isEmpty()); 794 ASSERT(!string.isEmpty());
796 795
797 CSSParserContext context(document, UseCounter::getFrom(&document)); 796 CSSParserContext context(document, UseCounter::getFrom(&document));
798 797
799 if (parseSimpleLengthValue(declaration, propertyID, string, important, conte xt.mode())) 798 if (parseSimpleLengthValue(declaration, propertyID, string, context.mode()))
800 return true; 799 return true;
801 if (parseColorValue(declaration, propertyID, string, important, context.mode ())) 800 if (parseColorValue(declaration, propertyID, string, context.mode()))
802 return true; 801 return true;
803 if (parseKeywordValue(declaration, propertyID, string, important, context)) 802 if (parseKeywordValue(declaration, propertyID, string, context))
804 return true; 803 return true;
805 804
806 BisonCSSParser parser(context); 805 BisonCSSParser parser(context);
807 return parser.parseValue(declaration, propertyID, string, important, static_ cast<StyleSheetContents*>(0)); 806 return parser.parseValue(declaration, propertyID, string, static_cast<StyleS heetContents*>(0));
808 } 807 }
809 808
810 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, CSSParserMode cssParserMod e, StyleSheetContents* contextStyleSheet) 809 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, CSSParserMode cssParserMode, StyleSheetCon tents* contextStyleSheet)
811 { 810 {
812 ASSERT(!string.isEmpty()); 811 ASSERT(!string.isEmpty());
813 if (parseSimpleLengthValue(declaration, propertyID, string, important, cssPa rserMode)) 812 if (parseSimpleLengthValue(declaration, propertyID, string, cssParserMode))
814 return true; 813 return true;
815 if (parseColorValue(declaration, propertyID, string, important, cssParserMod e)) 814 if (parseColorValue(declaration, propertyID, string, cssParserMode))
816 return true; 815 return true;
817 816
818 CSSParserContext context(0); // FIXME: Why does this not have a UseCounter? 817 CSSParserContext context(0); // FIXME: Why does this not have a UseCounter?
819 if (contextStyleSheet) { 818 if (contextStyleSheet) {
820 context = contextStyleSheet->parserContext(); 819 context = contextStyleSheet->parserContext();
821 } 820 }
822 821
823 if (parseKeywordValue(declaration, propertyID, string, important, context)) 822 if (parseKeywordValue(declaration, propertyID, string, context))
824 return true; 823 return true;
825 if (parseSimpleTransform(declaration, propertyID, string, important)) 824 if (parseSimpleTransform(declaration, propertyID, string))
826 return true; 825 return true;
827 826
828 BisonCSSParser parser(context); 827 BisonCSSParser parser(context);
829 return parser.parseValue(declaration, propertyID, string, important, context StyleSheet); 828 return parser.parseValue(declaration, propertyID, string, contextStyleSheet) ;
830 } 829 }
831 830
832 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, bool important, StyleSheetContents* contex tStyleSheet) 831 bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert yID propertyID, const String& string, StyleSheetContents* contextStyleSheet)
833 { 832 {
834 if (m_context.useCounter()) 833 if (m_context.useCounter())
835 m_context.useCounter()->count(m_context, propertyID); 834 m_context.useCounter()->count(m_context, propertyID);
836 835
837 setStyleSheet(contextStyleSheet); 836 setStyleSheet(contextStyleSheet);
838 837
839 setupParser("@-internal-value ", string, ""); 838 setupParser("@-internal-value ", string, "");
840 839
841 m_id = propertyID; 840 m_id = propertyID;
842 m_important = important;
843 841
844 cssyyparse(this); 842 cssyyparse(this);
845 843
846 m_rule = nullptr; 844 m_rule = nullptr;
847 m_id = CSSPropertyInvalid; 845 m_id = CSSPropertyInvalid;
848 846
849 bool ok = false; 847 bool ok = false;
850 if (!m_parsedProperties.isEmpty()) { 848 if (!m_parsedProperties.isEmpty()) {
851 ok = true; 849 ok = true;
852 declaration->addParsedProperties(m_parsedProperties); 850 declaration->addParsedProperties(m_parsedProperties);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 { 978 {
981 if (!RuntimeEnabledFeatures::cssAttributeCaseSensitivityEnabled() && !isUASh eetBehavior(m_context.mode())) 979 if (!RuntimeEnabledFeatures::cssAttributeCaseSensitivityEnabled() && !isUASh eetBehavior(m_context.mode()))
982 return false; 980 return false;
983 if (string == "i") { 981 if (string == "i") {
984 matchType = CSSSelector::CaseInsensitive; 982 matchType = CSSSelector::CaseInsensitive;
985 return true; 983 return true;
986 } 984 }
987 return false; 985 return false;
988 } 986 }
989 987
990 static inline void filterProperties(bool important, const Vector<CSSProperty, 25 6>& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<num CSSProperties>& seenProperties) 988 static inline void filterProperties(const Vector<CSSProperty, 256>& input, Vecto r<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties)
991 { 989 {
992 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found. 990 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
993 for (int i = input.size() - 1; i >= 0; --i) { 991 for (int i = input.size() - 1; i >= 0; --i) {
994 const CSSProperty& property = input[i]; 992 const CSSProperty& property = input[i];
995 if (property.isImportant() != important)
996 continue;
997 const unsigned propertyIDIndex = property.id() - firstCSSProperty; 993 const unsigned propertyIDIndex = property.id() - firstCSSProperty;
998 if (seenProperties.get(propertyIDIndex)) 994 if (seenProperties.get(propertyIDIndex))
999 continue; 995 continue;
1000 seenProperties.set(propertyIDIndex); 996 seenProperties.set(propertyIDIndex);
1001 output[--unusedEntries] = property; 997 output[--unusedEntries] = property;
1002 } 998 }
1003 } 999 }
1004 1000
1005 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet() 1001 PassRefPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet()
1006 { 1002 {
1007 BitArray<numCSSProperties> seenProperties; 1003 BitArray<numCSSProperties> seenProperties;
1008 size_t unusedEntries = m_parsedProperties.size(); 1004 size_t unusedEntries = m_parsedProperties.size();
1009 Vector<CSSProperty, 256> results(unusedEntries); 1005 Vector<CSSProperty, 256> results(unusedEntries);
1010 1006
1011 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. 1007 filterProperties(m_parsedProperties, results, unusedEntries, seenProperties) ;
1012 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties);
1013 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties);
1014 if (unusedEntries) 1008 if (unusedEntries)
1015 results.remove(0, unusedEntries); 1009 results.remove(0, unusedEntries);
1016 1010
1017 return ImmutableStylePropertySet::create(results.data(), results.size(), HTM LStandardMode); 1011 return ImmutableStylePropertySet::create(results.data(), results.size(), HTM LStandardMode);
1018 } 1012 }
1019 1013
1020 void BisonCSSParser::rollbackLastProperties(int num) 1014 void BisonCSSParser::rollbackLastProperties(int num)
1021 { 1015 {
1022 ASSERT(num >= 0); 1016 ASSERT(num >= 0);
1023 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); 1017 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num));
1024 m_parsedProperties.shrink(m_parsedProperties.size() - num); 1018 m_parsedProperties.shrink(m_parsedProperties.size() - num);
1025 } 1019 }
1026 1020
1027 void BisonCSSParser::clearProperties() 1021 void BisonCSSParser::clearProperties()
1028 { 1022 {
1029 m_parsedProperties.clear(); 1023 m_parsedProperties.clear();
1030 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES; 1024 m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES;
1031 } 1025 }
1032 1026
1033 void BisonCSSParser::setCurrentProperty(CSSPropertyID propId) 1027 void BisonCSSParser::setCurrentProperty(CSSPropertyID propId)
1034 { 1028 {
1035 m_id = propId; 1029 m_id = propId;
1036 } 1030 }
1037 1031
1038 bool BisonCSSParser::parseValue(CSSPropertyID propId, bool important) 1032 bool BisonCSSParser::parseValue(CSSPropertyID propId)
1039 { 1033 {
1040 return CSSPropertyParser::parseValue(propId, important, m_valueList.get(), m _context, m_inViewport, m_parsedProperties, m_ruleHeaderType); 1034 return CSSPropertyParser::parseValue(propId, m_valueList.get(), m_context, m _inViewport, m_parsedProperties, m_ruleHeaderType);
1041 } 1035 }
1042 1036
1043 1037
1044 class TransformOperationInfo { 1038 class TransformOperationInfo {
1045 public: 1039 public:
1046 TransformOperationInfo(const CSSParserString& name) 1040 TransformOperationInfo(const CSSParserString& name)
1047 : m_type(CSSTransformValue::UnknownTransformOperation) 1041 : m_type(CSSTransformValue::UnknownTransformOperation)
1048 , m_argCount(1) 1042 , m_argCount(1)
1049 , m_allowSingleArgument(false) 1043 , m_allowSingleArgument(false)
1050 , m_unit(CSSPropertyParser::FUnknown) 1044 , m_unit(CSSPropertyParser::FUnknown)
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (m_observer) 1677 if (m_observer)
1684 m_observer->startRuleBody(m_tokenizer.safeUserStringTokenOffset()); 1678 m_observer->startRuleBody(m_tokenizer.safeUserStringTokenOffset());
1685 } 1679 }
1686 1680
1687 void BisonCSSParser::startProperty() 1681 void BisonCSSParser::startProperty()
1688 { 1682 {
1689 if (m_observer) 1683 if (m_observer)
1690 m_observer->startProperty(m_tokenizer.safeUserStringTokenOffset()); 1684 m_observer->startProperty(m_tokenizer.safeUserStringTokenOffset());
1691 } 1685 }
1692 1686
1693 void BisonCSSParser::endProperty(bool isImportantFound, bool isPropertyParsed, C SSParserError errorType) 1687 void BisonCSSParser::endProperty(bool isPropertyParsed, CSSParserError errorType )
1694 { 1688 {
1695 m_id = CSSPropertyInvalid; 1689 m_id = CSSPropertyInvalid;
1696 if (m_observer) 1690 if (m_observer)
1697 m_observer->endProperty(isImportantFound, isPropertyParsed, m_tokenizer. safeUserStringTokenOffset(), errorType); 1691 m_observer->endProperty(isPropertyParsed, m_tokenizer.safeUserStringToke nOffset(), errorType);
1698 } 1692 }
1699 1693
1700 void BisonCSSParser::startEndUnknownRule() 1694 void BisonCSSParser::startEndUnknownRule()
1701 { 1695 {
1702 if (m_observer) 1696 if (m_observer)
1703 m_observer->startEndUnknownRule(); 1697 m_observer->startEndUnknownRule();
1704 } 1698 }
1705 1699
1706 } 1700 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/BisonCSSParser.h ('k') | sky/engine/core/css/parser/CSSGrammar.y » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698