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

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

Issue 1303173007: Oilpan: Unship Oilpan from CSSValues Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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
« no previous file with comments | « Source/core/css/parser/CSSParser.h ('k') | Source/core/css/parser/CSSParserFastPaths.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParser.h" 6 #include "core/css/parser/CSSParser.h"
7 7
8 #include "core/css/CSSKeyframeRule.h" 8 #include "core/css/CSSKeyframeRule.h"
9 #include "core/css/StyleColor.h" 9 #include "core/css/StyleColor.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void CSSParser::parseSheetForInspector(const CSSParserContext& context, StyleShe etContents* styleSheet, const String& text, CSSParserObserver& observer) 49 void CSSParser::parseSheetForInspector(const CSSParserContext& context, StyleShe etContents* styleSheet, const String& text, CSSParserObserver& observer)
50 { 50 {
51 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, observer); 51 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, observer);
52 } 52 }
53 53
54 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, CSSParserMode parserMod e, StyleSheetContents* styleSheet) 54 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, CSSParserMode parserMod e, StyleSheetContents* styleSheet)
55 { 55 {
56 if (string.isEmpty()) 56 if (string.isEmpty())
57 return false; 57 return false;
58 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); 58 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);
59 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(res olvedProperty, string, parserMode); 59 RefPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(resolvedPropert y, string, parserMode);
60 if (value) 60 if (value)
61 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele ase(), important)); 61 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele ase(), important));
62 CSSParserContext context(parserMode, 0); 62 CSSParserContext context(parserMode, 0);
63 if (styleSheet) { 63 if (styleSheet) {
64 context = styleSheet->parserContext(); 64 context = styleSheet->parserContext();
65 context.setMode(parserMode); 65 context.setMode(parserMode);
66 } 66 }
67 return parseValue(declaration, unresolvedProperty, string, important, contex t); 67 return parseValue(declaration, unresolvedProperty, string, important, contex t);
68 } 68 }
69 69
70 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context) 70 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context)
71 { 71 {
72 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context); 72 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context);
73 } 73 }
74 74
75 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope rtyID, const String& string, const CSSParserContext& context) 75 PassRefPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID propertyID, const String& string, const CSSParserContext& context)
76 { 76 {
77 if (string.isEmpty()) 77 if (string.isEmpty())
78 return nullptr; 78 return nullptr;
79 if (RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue (propertyID, string, context.mode())) 79 if (RefPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(propertyID, string, context.mode()))
80 return value; 80 return value;
81 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP ropertySet::create(); 81 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP ropertySet::create();
82 bool changed = parseValue(stylePropertySet.get(), propertyID, string, false, context); 82 bool changed = parseValue(stylePropertySet.get(), propertyID, string, false, context);
83 ASSERT_UNUSED(changed, changed == stylePropertySet->hasProperty(propertyID)) ; 83 ASSERT_UNUSED(changed, changed == stylePropertySet->hasProperty(propertyID)) ;
84 return stylePropertySet->getPropertyCSSValue(propertyID); 84 return stylePropertySet->getPropertyCSSValue(propertyID);
85 } 85 }
86 86
87 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDec laration(const String& styleString, Element* element) 87 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDec laration(const String& styleString, Element* element)
88 { 88 {
89 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element); 89 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element);
(...skipping 23 matching lines...) Expand all
113 return false; 113 return false;
114 114
115 // The regular color parsers don't resolve named colors, so explicitly 115 // The regular color parsers don't resolve named colors, so explicitly
116 // handle these first. 116 // handle these first.
117 Color namedColor; 117 Color namedColor;
118 if (namedColor.setNamedColor(string)) { 118 if (namedColor.setNamedColor(string)) {
119 color = namedColor.rgb(); 119 color = namedColor.rgb();
120 return true; 120 return true;
121 } 121 }
122 122
123 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode); 123 RefPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTM LStandardMode : HTMLQuirksMode);
124 // TODO(timloh): Why is this always strict mode? 124 // TODO(timloh): Why is this always strict mode?
125 if (!value) 125 if (!value)
126 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t()); 126 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t());
127 127
128 if (!value || !value->isPrimitiveValue()) 128 if (!value || !value->isPrimitiveValue())
129 return false; 129 return false;
130 130
131 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); 131 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
132 if (!primitiveValue->isRGBColor()) 132 if (!primitiveValue->isRGBColor())
133 return false; 133 return false;
134 134
135 color = primitiveValue->getRGBA32Value(); 135 color = primitiveValue->getRGBA32Value();
136 return true; 136 return true;
137 } 137 }
138 138
139 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) 139 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString)
140 { 140 {
141 CSSParserString cssColor; 141 CSSParserString cssColor;
142 cssColor.init(colorString); 142 cssColor.init(colorString);
143 CSSValueID id = cssValueKeywordID(cssColor); 143 CSSValueID id = cssValueKeywordID(cssColor);
144 if (!CSSPropertyParser::isSystemColor(id)) 144 if (!CSSPropertyParser::isSystemColor(id))
145 return false; 145 return false;
146 146
147 Color parsedColor = LayoutTheme::theme().systemColor(id); 147 Color parsedColor = LayoutTheme::theme().systemColor(id);
148 color = parsedColor.rgb(); 148 color = parsedColor.rgb();
149 return true; 149 return true;
150 } 150 }
151 151
152 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI D propertyID, const String& propertyValue, const CSSParserContext& context) 152 PassRefPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyID propertyID , const String& propertyValue, const CSSParserContext& context)
153 { 153 {
154 StringBuilder builder; 154 StringBuilder builder;
155 builder.appendLiteral("@font-face { "); 155 builder.appendLiteral("@font-face { ");
156 builder.append(getPropertyNameString(propertyID)); 156 builder.append(getPropertyNameString(propertyID));
157 builder.appendLiteral(" : "); 157 builder.appendLiteral(" : ");
158 builder.append(propertyValue); 158 builder.append(propertyValue);
159 builder.appendLiteral("; }"); 159 builder.appendLiteral("; }");
160 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString()); 160 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString());
161 if (!rule || !rule->isFontFaceRule()) 161 if (!rule || !rule->isFontFaceRule())
162 return nullptr; 162 return nullptr;
163 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 163 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
164 } 164 }
165 165
166 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParser.h ('k') | Source/core/css/parser/CSSParserFastPaths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698