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

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

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: comments 1 Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSParser.cpp
index b0c557b4aa6e67c6121052b44112280a222c9f0e..37f8bd70213e2a6cdc6fa911335b3222bed2f391 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParser.cpp
@@ -21,21 +21,21 @@
namespace blink {
-bool CSSParser::parseDeclarationList(const CSSParserContext& context,
+bool CSSParser::parseDeclarationList(const CSSParserContext* context,
MutableStylePropertySet* propertySet,
const String& declaration) {
return CSSParserImpl::parseDeclarationList(propertySet, declaration, context);
}
void CSSParser::parseDeclarationListForInspector(
- const CSSParserContext& context,
+ const CSSParserContext* context,
const String& declaration,
CSSParserObserver& observer) {
CSSParserImpl::parseDeclarationListForInspector(declaration, context,
observer);
}
-CSSSelectorList CSSParser::parseSelector(const CSSParserContext& context,
+CSSSelectorList CSSParser::parseSelector(const CSSParserContext* context,
StyleSheetContents* styleSheetContents,
const String& selector) {
CSSTokenizer tokenizer(selector);
@@ -44,7 +44,7 @@ CSSSelectorList CSSParser::parseSelector(const CSSParserContext& context,
}
CSSSelectorList CSSParser::parsePageSelector(
- const CSSParserContext& context,
+ const CSSParserContext* context,
StyleSheetContents* styleSheetContents,
const String& selector) {
CSSTokenizer tokenizer(selector);
@@ -52,14 +52,14 @@ CSSSelectorList CSSParser::parsePageSelector(
styleSheetContents);
}
-StyleRuleBase* CSSParser::parseRule(const CSSParserContext& context,
+StyleRuleBase* CSSParser::parseRule(const CSSParserContext* context,
StyleSheetContents* styleSheet,
const String& rule) {
return CSSParserImpl::parseRule(rule, context, styleSheet,
CSSParserImpl::AllowImportRules);
}
-void CSSParser::parseSheet(const CSSParserContext& context,
+void CSSParser::parseSheet(const CSSParserContext* context,
StyleSheetContents* styleSheet,
const String& text,
bool deferPropertyParsing) {
@@ -67,7 +67,7 @@ void CSSParser::parseSheet(const CSSParserContext& context,
deferPropertyParsing);
}
-void CSSParser::parseSheetForInspector(const CSSParserContext& context,
+void CSSParser::parseSheetForInspector(const CSSParserContext* context,
StyleSheetContents* styleSheet,
const String& text,
CSSParserObserver& observer) {
@@ -79,6 +79,15 @@ MutableStylePropertySet::SetResult CSSParser::parseValue(
MutableStylePropertySet* declaration,
CSSPropertyID unresolvedProperty,
const String& string,
+ bool important) {
+ return parseValue(declaration, unresolvedProperty, string, important,
+ static_cast<StyleSheetContents*>(nullptr));
haraken 2017/01/12 04:51:13 What is this change for?
Bret 2017/01/13 02:15:28 There were some calls that were trying to pass in
+}
+
+MutableStylePropertySet::SetResult CSSParser::parseValue(
+ MutableStylePropertySet* declaration,
+ CSSPropertyID unresolvedProperty,
+ const String& string,
bool important,
StyleSheetContents* styleSheet) {
if (string.isEmpty()) {
@@ -97,10 +106,12 @@ MutableStylePropertySet::SetResult CSSParser::parseValue(
CSSProperty(resolvedProperty, *value, important));
return MutableStylePropertySet::SetResult{didParse, didChange};
}
- CSSParserContext context(parserMode, nullptr);
+ CSSParserContext* context;
if (styleSheet) {
- context = styleSheet->parserContext();
- context.setMode(parserMode);
+ context = new CSSParserContext(styleSheet->parserContext(), nullptr);
+ context->setMode(parserMode);
+ } else {
+ context = new CSSParserContext(parserMode);
}
return parseValue(declaration, unresolvedProperty, string, important,
context);
@@ -121,10 +132,12 @@ MutableStylePropertySet::SetResult CSSParser::parseValueForCustomProperty(
return MutableStylePropertySet::SetResult{didParse, didChange};
}
CSSParserMode parserMode = declaration->cssParserMode();
- CSSParserContext context(parserMode, nullptr);
+ CSSParserContext* context;
if (styleSheet) {
- context = styleSheet->parserContext();
- context.setMode(parserMode);
+ context = new CSSParserContext(styleSheet->parserContext(), nullptr);
+ context->setMode(parserMode);
+ } else {
+ context = new CSSParserContext(parserMode);
}
return CSSParserImpl::parseVariableValue(declaration, propertyName, registry,
value, important, context,
@@ -141,18 +154,18 @@ MutableStylePropertySet::SetResult CSSParser::parseValue(
CSSPropertyID unresolvedProperty,
const String& string,
bool important,
- const CSSParserContext& context) {
+ const CSSParserContext* context) {
return CSSParserImpl::parseValue(declaration, unresolvedProperty, string,
important, context);
}
const CSSValue* CSSParser::parseSingleValue(CSSPropertyID propertyID,
const String& string,
- const CSSParserContext& context) {
+ const CSSParserContext* context) {
if (string.isEmpty())
return nullptr;
if (CSSValue* value = CSSParserFastPaths::maybeParseValue(propertyID, string,
- context.mode()))
+ context->mode()))
return value;
CSSTokenizer tokenizer(string);
return CSSPropertyParser::parseSingleValue(propertyID, tokenizer.tokenRange(),
@@ -170,7 +183,7 @@ std::unique_ptr<Vector<double>> CSSParser::parseKeyframeKeyList(
return CSSParserImpl::parseKeyframeKeyList(keyList);
}
-StyleRuleKeyframe* CSSParser::parseKeyframeRule(const CSSParserContext& context,
+StyleRuleKeyframe* CSSParser::parseKeyframeRule(const CSSParserContext* context,
const String& rule) {
StyleRuleBase* keyframe = CSSParserImpl::parseRule(
rule, context, nullptr, CSSParserImpl::KeyframeRules);
@@ -221,7 +234,7 @@ bool CSSParser::parseSystemColor(Color& color, const String& colorString) {
const CSSValue* CSSParser::parseFontFaceDescriptor(
CSSPropertyID propertyID,
const String& propertyValue,
- const CSSParserContext& context) {
+ const CSSParserContext* context) {
StringBuilder builder;
builder.append("@font-face { ");
builder.append(getPropertyNameString(propertyID));

Powered by Google App Engine
This is Rietveld 408576698