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

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

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 "core/css/parser/CSSParser.h" 5 #include "core/css/parser/CSSParser.h"
6 6
7 #include "core/css/CSSColorValue.h" 7 #include "core/css/CSSColorValue.h"
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 25 matching lines...) Expand all
36 CSSTokenizer::Scope scope(selector); 36 CSSTokenizer::Scope scope(selector);
37 return CSSSelectorParser::parseSelector(scope.tokenRange(), context, styleSh eetContents); 37 return CSSSelectorParser::parseSelector(scope.tokenRange(), context, styleSh eetContents);
38 } 38 }
39 39
40 CSSSelectorList CSSParser::parsePageSelector(const CSSParserContext& context, St yleSheetContents* styleSheetContents, const String& selector) 40 CSSSelectorList CSSParser::parsePageSelector(const CSSParserContext& context, St yleSheetContents* styleSheetContents, const String& selector)
41 { 41 {
42 CSSTokenizer::Scope scope(selector); 42 CSSTokenizer::Scope scope(selector);
43 return CSSParserImpl::parsePageSelector(scope.tokenRange(), styleSheetConten ts); 43 return CSSParserImpl::parsePageSelector(scope.tokenRange(), styleSheetConten ts);
44 } 44 }
45 45
46 RawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContext& context, Styl eSheetContents* styleSheet, const String& rule) 46 StyleRuleBase* CSSParser::parseRule(const CSSParserContext& context, StyleSheetC ontents* styleSheet, const String& rule)
47 { 47 {
48 return CSSParserImpl::parseRule(rule, context, styleSheet, CSSParserImpl::Al lowImportRules); 48 return CSSParserImpl::parseRule(rule, context, styleSheet, CSSParserImpl::Al lowImportRules);
49 } 49 }
50 50
51 void CSSParser::parseSheet(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& text) 51 void CSSParser::parseSheet(const CSSParserContext& context, StyleSheetContents* styleSheet, const String& text)
52 { 52 {
53 return CSSParserImpl::parseStyleSheet(text, context, styleSheet); 53 return CSSParserImpl::parseStyleSheet(text, context, styleSheet);
54 } 54 }
55 55
56 void CSSParser::parseSheetForInspector(const CSSParserContext& context, StyleShe etContents* styleSheet, const String& text, CSSParserObserver& observer) 56 void CSSParser::parseSheetForInspector(const CSSParserContext& context, StyleShe etContents* styleSheet, const String& text, CSSParserObserver& observer)
57 { 57 {
58 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, observer); 58 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, observer);
59 } 59 }
60 60
61 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, StyleSheetContents* sty leSheet) 61 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, StyleSheetContents* sty leSheet)
62 { 62 {
63 if (string.isEmpty()) 63 if (string.isEmpty())
64 return false; 64 return false;
65 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); 65 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);
66 CSSParserMode parserMode = declaration->cssParserMode(); 66 CSSParserMode parserMode = declaration->cssParserMode();
67 RawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(resolvedPropert y, string, parserMode); 67 CSSValue* value = CSSParserFastPaths::maybeParseValue(resolvedProperty, stri ng, parserMode);
68 if (value) 68 if (value)
69 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele ase(), important)); 69 return declaration->setProperty(CSSProperty(resolvedProperty, value, imp ortant));
70 CSSParserContext context(parserMode, 0); 70 CSSParserContext context(parserMode, 0);
71 if (styleSheet) { 71 if (styleSheet) {
72 context = styleSheet->parserContext(); 72 context = styleSheet->parserContext();
73 context.setMode(parserMode); 73 context.setMode(parserMode);
74 } 74 }
75 return parseValue(declaration, unresolvedProperty, string, important, contex t); 75 return parseValue(declaration, unresolvedProperty, string, important, contex t);
76 } 76 }
77 77
78 bool CSSParser::parseValueForCustomProperty(MutableStylePropertySet* declaration , const AtomicString& propertyName, const String& value, bool important, StyleSh eetContents* styleSheet) 78 bool CSSParser::parseValueForCustomProperty(MutableStylePropertySet* declaration , const AtomicString& propertyName, const String& value, bool important, StyleSh eetContents* styleSheet)
79 { 79 {
80 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::i sValidVariableName(propertyName)); 80 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::i sValidVariableName(propertyName));
81 if (value.isEmpty()) 81 if (value.isEmpty())
82 return false; 82 return false;
83 CSSParserMode parserMode = declaration->cssParserMode(); 83 CSSParserMode parserMode = declaration->cssParserMode();
84 CSSParserContext context(parserMode, 0); 84 CSSParserContext context(parserMode, 0);
85 if (styleSheet) { 85 if (styleSheet) {
86 context = styleSheet->parserContext(); 86 context = styleSheet->parserContext();
87 context.setMode(parserMode); 87 context.setMode(parserMode);
88 } 88 }
89 return CSSParserImpl::parseVariableValue(declaration, propertyName, value, i mportant, context); 89 return CSSParserImpl::parseVariableValue(declaration, propertyName, value, i mportant, context);
90 } 90 }
91 91
92 RawPtr<ImmutableStylePropertySet> CSSParser::parseCustomPropertySet(CSSParserTok enRange range) 92 ImmutableStylePropertySet* CSSParser::parseCustomPropertySet(CSSParserTokenRange range)
93 { 93 {
94 return CSSParserImpl::parseCustomPropertySet(range); 94 return CSSParserImpl::parseCustomPropertySet(range);
95 } 95 }
96 96
97 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context) 97 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context)
98 { 98 {
99 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context); 99 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context);
100 } 100 }
101 101
102 RawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID propertyID, const Str ing& string, const CSSParserContext& context) 102 CSSValue* CSSParser::parseSingleValue(CSSPropertyID propertyID, const String& st ring, const CSSParserContext& context)
103 { 103 {
104 if (string.isEmpty()) 104 if (string.isEmpty())
105 return nullptr; 105 return nullptr;
106 if (RawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(propertyID, string, context.mode())) 106 if (CSSValue* value = CSSParserFastPaths::maybeParseValue(propertyID, string , context.mode()))
107 return value; 107 return value;
108 CSSTokenizer::Scope scope(string); 108 CSSTokenizer::Scope scope(string);
109 return CSSPropertyParser::parseSingleValue(propertyID, scope.tokenRange(), c ontext); 109 return CSSPropertyParser::parseSingleValue(propertyID, scope.tokenRange(), c ontext);
110 } 110 }
111 111
112 RawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(const S tring& styleString, Element* element) 112 ImmutableStylePropertySet* CSSParser::parseInlineStyleDeclaration(const String& styleString, Element* element)
113 { 113 {
114 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element); 114 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element);
115 } 115 }
116 116
117 PassOwnPtr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& keyList ) 117 PassOwnPtr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& keyList )
118 { 118 {
119 return CSSParserImpl::parseKeyframeKeyList(keyList); 119 return CSSParserImpl::parseKeyframeKeyList(keyList);
120 } 120 }
121 121
122 RawPtr<StyleRuleKeyframe> CSSParser::parseKeyframeRule(const CSSParserContext& c ontext, const String& rule) 122 StyleRuleKeyframe* CSSParser::parseKeyframeRule(const CSSParserContext& context, const String& rule)
123 { 123 {
124 RawPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(rule, context, nul lptr, CSSParserImpl::KeyframeRules); 124 StyleRuleBase* keyframe = CSSParserImpl::parseRule(rule, context, nullptr, C SSParserImpl::KeyframeRules);
125 return toStyleRuleKeyframe(keyframe.get()); 125 return toStyleRuleKeyframe(keyframe);
126 } 126 }
127 127
128 bool CSSParser::parseSupportsCondition(const String& condition) 128 bool CSSParser::parseSupportsCondition(const String& condition)
129 { 129 {
130 CSSTokenizer::Scope scope(condition); 130 CSSTokenizer::Scope scope(condition);
131 CSSParserImpl parser(strictCSSParserContext()); 131 CSSParserImpl parser(strictCSSParserContext());
132 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported; 132 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported;
133 } 133 }
134 134
135 bool CSSParser::parseColor(Color& color, const String& string, bool strict) 135 bool CSSParser::parseColor(Color& color, const String& string, bool strict)
136 { 136 {
137 if (string.isEmpty()) 137 if (string.isEmpty())
138 return false; 138 return false;
139 139
140 // The regular color parsers don't resolve named colors, so explicitly 140 // The regular color parsers don't resolve named colors, so explicitly
141 // handle these first. 141 // handle these first.
142 Color namedColor; 142 Color namedColor;
143 if (namedColor.setNamedColor(string)) { 143 if (namedColor.setNamedColor(string)) {
144 color = namedColor; 144 color = namedColor;
145 return true; 145 return true;
146 } 146 }
147 147
148 RawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTM LStandardMode : HTMLQuirksMode); 148 CSSValue* value = CSSParserFastPaths::parseColor(string, strict ? HTMLStanda rdMode : HTMLQuirksMode);
149 // TODO(timloh): Why is this always strict mode? 149 // TODO(timloh): Why is this always strict mode?
150 if (!value) 150 if (!value)
151 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t()); 151 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t());
152 152
153 if (!value || !value->isColorValue()) 153 if (!value || !value->isColorValue())
154 return false; 154 return false;
155 color = toCSSColorValue(*value).value(); 155 color = toCSSColorValue(*value).value();
156 return true; 156 return true;
157 } 157 }
158 158
159 bool CSSParser::parseSystemColor(Color& color, const String& colorString) 159 bool CSSParser::parseSystemColor(Color& color, const String& colorString)
160 { 160 {
161 CSSParserString cssColor; 161 CSSParserString cssColor;
162 cssColor.init(colorString); 162 cssColor.init(colorString);
163 CSSValueID id = cssValueKeywordID(cssColor); 163 CSSValueID id = cssValueKeywordID(cssColor);
164 if (!CSSPropertyParser::isSystemColor(id)) 164 if (!CSSPropertyParser::isSystemColor(id))
165 return false; 165 return false;
166 166
167 color = LayoutTheme::theme().systemColor(id); 167 color = LayoutTheme::theme().systemColor(id);
168 return true; 168 return true;
169 } 169 }
170 170
171 RawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyID propertyID, co nst String& propertyValue, const CSSParserContext& context) 171 CSSValue* CSSParser::parseFontFaceDescriptor(CSSPropertyID propertyID, const Str ing& propertyValue, const CSSParserContext& context)
172 { 172 {
173 StringBuilder builder; 173 StringBuilder builder;
174 builder.appendLiteral("@font-face { "); 174 builder.appendLiteral("@font-face { ");
175 builder.append(getPropertyNameString(propertyID)); 175 builder.append(getPropertyNameString(propertyID));
176 builder.appendLiteral(" : "); 176 builder.appendLiteral(" : ");
177 builder.append(propertyValue); 177 builder.append(propertyValue);
178 builder.appendLiteral("; }"); 178 builder.appendLiteral("; }");
179 RawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder.toString()) ; 179 StyleRuleBase* rule = parseRule(context, nullptr, builder.toString());
180 if (!rule || !rule->isFontFaceRule()) 180 if (!rule || !rule->isFontFaceRule())
181 return nullptr; 181 return nullptr;
182 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 182 return toStyleRuleFontFace(rule)->properties().getPropertyCSSValue(propertyI D);
183 } 183 }
184 184
185 } // namespace blink 185 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParser.h ('k') | third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698