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

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

Issue 1498553002: Cleanup <image> type handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
index ca793d08bf798be0265f1b345a14923d61cc9892..861279b43b0f460d5d0e8ba0cc8eb5bef19d3454 100644
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -288,22 +288,13 @@ static inline bool isForwardSlashOperator(CSSParserValue* value)
return value->m_unit == CSSParserValue::Operator && value->iValue == '/';
}
-static bool isGeneratedImageValue(CSSParserValue* val)
+static bool isGeneratedImageValue(CSSValueID id)
{
- if (val->m_unit != CSSParserValue::Function)
- return false;
-
- CSSValueID id = val->function->id;
- return id == CSSValueLinearGradient
- || id == CSSValueRadialGradient
- || id == CSSValueRepeatingLinearGradient
- || id == CSSValueRepeatingRadialGradient
- || id == CSSValueWebkitLinearGradient
- || id == CSSValueWebkitRadialGradient
- || id == CSSValueWebkitRepeatingLinearGradient
- || id == CSSValueWebkitRepeatingRadialGradient
- || id == CSSValueWebkitGradient
- || id == CSSValueWebkitCrossFade;
+ return id == CSSValueLinearGradient || id == CSSValueRadialGradient
+ || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadialGradient
+ || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradient
+ || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRepeatingRadialGradient
+ || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade;
}
inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPrimitive(CSSValueID identifier, CSSParserValue* value)
@@ -522,23 +513,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyListStyleImage: // <uri> | none | inherit
case CSSPropertyBorderImageSource:
case CSSPropertyWebkitMaskBoxImageSource:
- if (id == CSSValueNone) {
- parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
- m_valueList->next();
- } else if (value->m_unit == CSSParserValue::URI) {
- parsedValue = createCSSImageValueWithReferrer(value->string, completeURL(value->string));
- m_valueList->next();
- } else if (isGeneratedImageValue(value)) {
- if (parseGeneratedImage(m_valueList, parsedValue))
- m_valueList->next();
- else
- return false;
- } else if (value->m_unit == CSSParserValue::Function && value->function->id == CSSValueWebkitImageSet) {
- parsedValue = parseImageSet(m_valueList);
- if (!parsedValue)
- return false;
+ if (parseFillImage(m_valueList, parsedValue))
m_valueList->next();
- }
break;
case CSSPropertyBorderTopWidth: //// <border-width> | inherit
@@ -1448,7 +1424,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
parsedValue = parseCounterContent(args, true);
} else if (val->function->id == CSSValueWebkitImageSet) {
parsedValue = parseImageSet(m_valueList);
- } else if (isGeneratedImageValue(val)) {
+ } else if (isGeneratedImageValue(val->function->id)) {
if (!parseGeneratedImage(m_valueList, parsedValue))
return nullptr;
}
@@ -1557,13 +1533,15 @@ bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
return true;
}
- if (isGeneratedImageValue(valueList->current()))
- return parseGeneratedImage(valueList, value);
+ if (valueList->current()->m_unit == CSSParserValue::Function) {
+ if (isGeneratedImageValue(valueList->current()->function->id))
+ return parseGeneratedImage(valueList, value);
- if (valueList->current()->m_unit == CSSParserValue::Function && valueList->current()->function->id == CSSValueWebkitImageSet) {
- value = parseImageSet(m_valueList);
- if (value)
- return true;
+ if (valueList->current()->function->id == CSSValueWebkitImageSet) {
+ value = parseImageSet(m_valueList);
+ if (value)
+ return true;
+ }
}
return false;
@@ -3895,18 +3873,20 @@ bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
if (!context.canAdvance() && context.allowImage()) {
if (val->m_unit == CSSParserValue::URI) {
context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string)));
- } else if (isGeneratedImageValue(val)) {
- RefPtrWillBeRawPtr<CSSValue> value = nullptr;
- if (parseGeneratedImage(m_valueList, value))
- context.commitImage(value.release());
- else
- return false;
- } else if (val->m_unit == CSSParserValue::Function && val->function->id == CSSValueWebkitImageSet) {
- RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList);
- if (value)
- context.commitImage(value.release());
- else
- return false;
+ } else if (val->m_unit == CSSParserValue::Function) {
+ if (isGeneratedImageValue(val->function->id)) {
+ RefPtrWillBeRawPtr<CSSValue> value = nullptr;
+ if (parseGeneratedImage(m_valueList, value))
+ context.commitImage(value.release());
+ else
+ return false;
+ } else if (val->function->id == CSSValueWebkitImageSet) {
+ RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList);
+ if (value)
+ context.commitImage(value.release());
+ else
+ return false;
+ }
} else if (val->id == CSSValueNone)
context.commitImage(cssValuePool().createIdentifierValue(CSSValueNone));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698