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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 PassRefPtrWillBeRawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContex t& context, StyleSheetContents* styleSheet, const String& rule) 46 RawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContext& context, Styl eSheetContents* 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 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(res olvedProperty, string, parserMode); 67 RawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(resolvedPropert y, string, parserMode);
68 if (value) 68 if (value)
69 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele ase(), important)); 69 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele ase(), important));
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 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context) 92 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u nresolvedProperty, const String& string, bool important, const CSSParserContext& context)
93 { 93 {
94 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context); 94 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im portant, context);
95 } 95 }
96 96
97 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope rtyID, const String& string, const CSSParserContext& context) 97 RawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID propertyID, const Str ing& string, const CSSParserContext& context)
98 { 98 {
99 if (string.isEmpty()) 99 if (string.isEmpty())
100 return nullptr; 100 return nullptr;
101 if (RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue (propertyID, string, context.mode())) 101 if (RawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(propertyID, string, context.mode()))
102 return value; 102 return value;
103 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP ropertySet::create(HTMLQuirksMode); 103 RawPtr<MutableStylePropertySet> stylePropertySet = MutableStylePropertySet:: create(HTMLQuirksMode);
104 bool changed = parseValue(stylePropertySet.get(), propertyID, string, false, context); 104 bool changed = parseValue(stylePropertySet.get(), propertyID, string, false, context);
105 ASSERT_UNUSED(changed, changed == stylePropertySet->hasProperty(propertyID)) ; 105 ASSERT_UNUSED(changed, changed == stylePropertySet->hasProperty(propertyID)) ;
106 return stylePropertySet->getPropertyCSSValue(propertyID); 106 return stylePropertySet->getPropertyCSSValue(propertyID);
107 } 107 }
108 108
109 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDec laration(const String& styleString, Element* element) 109 RawPtr<ImmutableStylePropertySet> CSSParser::parseInlineStyleDeclaration(const S tring& styleString, Element* element)
110 { 110 {
111 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element); 111 return CSSParserImpl::parseInlineStyleDeclaration(styleString, element);
112 } 112 }
113 113
114 PassOwnPtr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& keyList ) 114 PassOwnPtr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& keyList )
115 { 115 {
116 return CSSParserImpl::parseKeyframeKeyList(keyList); 116 return CSSParserImpl::parseKeyframeKeyList(keyList);
117 } 117 }
118 118
119 PassRefPtrWillBeRawPtr<StyleRuleKeyframe> CSSParser::parseKeyframeRule(const CSS ParserContext& context, const String& rule) 119 RawPtr<StyleRuleKeyframe> CSSParser::parseKeyframeRule(const CSSParserContext& c ontext, const String& rule)
120 { 120 {
121 RefPtrWillBeRawPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(rule, context, nullptr, CSSParserImpl::KeyframeRules); 121 RawPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(rule, context, nul lptr, CSSParserImpl::KeyframeRules);
122 return toStyleRuleKeyframe(keyframe.get()); 122 return toStyleRuleKeyframe(keyframe.get());
123 } 123 }
124 124
125 bool CSSParser::parseSupportsCondition(const String& condition) 125 bool CSSParser::parseSupportsCondition(const String& condition)
126 { 126 {
127 CSSTokenizer::Scope scope(condition); 127 CSSTokenizer::Scope scope(condition);
128 CSSParserImpl parser(strictCSSParserContext()); 128 CSSParserImpl parser(strictCSSParserContext());
129 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported; 129 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported;
130 } 130 }
131 131
132 bool CSSParser::parseColor(Color& color, const String& string, bool strict) 132 bool CSSParser::parseColor(Color& color, const String& string, bool strict)
133 { 133 {
134 if (string.isEmpty()) 134 if (string.isEmpty())
135 return false; 135 return false;
136 136
137 // The regular color parsers don't resolve named colors, so explicitly 137 // The regular color parsers don't resolve named colors, so explicitly
138 // handle these first. 138 // handle these first.
139 Color namedColor; 139 Color namedColor;
140 if (namedColor.setNamedColor(string)) { 140 if (namedColor.setNamedColor(string)) {
141 color = namedColor; 141 color = namedColor;
142 return true; 142 return true;
143 } 143 }
144 144
145 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode); 145 RawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTM LStandardMode : HTMLQuirksMode);
146 // TODO(timloh): Why is this always strict mode? 146 // TODO(timloh): Why is this always strict mode?
147 if (!value) 147 if (!value)
148 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t()); 148 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t());
149 149
150 if (!value || !value->isColorValue()) 150 if (!value || !value->isColorValue())
151 return false; 151 return false;
152 color = toCSSColorValue(*value).value(); 152 color = toCSSColorValue(*value).value();
153 return true; 153 return true;
154 } 154 }
155 155
156 bool CSSParser::parseSystemColor(Color& color, const String& colorString) 156 bool CSSParser::parseSystemColor(Color& color, const String& colorString)
157 { 157 {
158 CSSParserString cssColor; 158 CSSParserString cssColor;
159 cssColor.init(colorString); 159 cssColor.init(colorString);
160 CSSValueID id = cssValueKeywordID(cssColor); 160 CSSValueID id = cssValueKeywordID(cssColor);
161 if (!CSSPropertyParser::isSystemColor(id)) 161 if (!CSSPropertyParser::isSystemColor(id))
162 return false; 162 return false;
163 163
164 color = LayoutTheme::theme().systemColor(id); 164 color = LayoutTheme::theme().systemColor(id);
165 return true; 165 return true;
166 } 166 }
167 167
168 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI D propertyID, const String& propertyValue, const CSSParserContext& context) 168 RawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyID propertyID, co nst String& propertyValue, const CSSParserContext& context)
169 { 169 {
170 StringBuilder builder; 170 StringBuilder builder;
171 builder.appendLiteral("@font-face { "); 171 builder.appendLiteral("@font-face { ");
172 builder.append(getPropertyNameString(propertyID)); 172 builder.append(getPropertyNameString(propertyID));
173 builder.appendLiteral(" : "); 173 builder.appendLiteral(" : ");
174 builder.append(propertyValue); 174 builder.append(propertyValue);
175 builder.appendLiteral("; }"); 175 builder.appendLiteral("; }");
176 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString()); 176 RawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder.toString()) ;
177 if (!rule || !rule->isFontFaceRule()) 177 if (!rule || !rule->isFontFaceRule())
178 return nullptr; 178 return nullptr;
179 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 179 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
180 } 180 }
181 181
182 } // namespace blink 182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698