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

Unified Diff: sky/engine/core/css/parser/CSSPropertyParser.cpp

Issue 1214633005: Remove CSS clients of ImageResource (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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: sky/engine/core/css/parser/CSSPropertyParser.cpp
diff --git a/sky/engine/core/css/parser/CSSPropertyParser.cpp b/sky/engine/core/css/parser/CSSPropertyParser.cpp
index 377b1934d633e1531b7130e8bea6a584c5c420a9..b5d00533d0e7970ffa33c1ac3ed7c91b3223d9a7 100644
--- a/sky/engine/core/css/parser/CSSPropertyParser.cpp
+++ b/sky/engine/core/css/parser/CSSPropertyParser.cpp
@@ -34,13 +34,10 @@
#include "sky/engine/core/css/CSSAspectRatioValue.h"
#include "sky/engine/core/css/CSSBasicShapes.h"
#include "sky/engine/core/css/CSSBorderImage.h"
-#include "sky/engine/core/css/CSSCrossfadeValue.h"
#include "sky/engine/core/css/CSSFontFaceSrcValue.h"
#include "sky/engine/core/css/CSSFontFeatureValue.h"
#include "sky/engine/core/css/CSSFunctionValue.h"
#include "sky/engine/core/css/CSSGradientValue.h"
-#include "sky/engine/core/css/CSSImageSetValue.h"
-#include "sky/engine/core/css/CSSImageValue.h"
#include "sky/engine/core/css/CSSInheritedValue.h"
#include "sky/engine/core/css/CSSInitialValue.h"
#include "sky/engine/core/css/CSSLineBoxContainValue.h"
@@ -304,13 +301,6 @@ inline PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveStringVal
return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRING);
}
-inline PassRefPtr<CSSValue> CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
-{
- RefPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, url);
- toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer());
- return imageValue;
-}
-
static inline bool isComma(CSSParserValue* value)
{
return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
@@ -581,21 +571,12 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId)
if (id == CSSValueNone) {
parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
m_valueList->next();
- } else if (value->unit == CSSPrimitiveValue::CSS_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->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
- parsedValue = parseImageSet(m_valueList);
- if (!parsedValue)
- return false;
- m_valueList->next();
- }
break;
case CSSPropertyWebkitTextStrokeWidth:
@@ -1582,20 +1563,10 @@ bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtr<CSS
value = cssValuePool().createIdentifierValue(CSSValueNone);
return true;
}
- if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
- value = createCSSImageValueWithReferrer(valueList->current()->string, completeURL(valueList->current()->string));
- return true;
- }
if (isGeneratedImageValue(valueList->current()))
return parseGeneratedImage(valueList, value);
- if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringCase(valueList->current()->function->name, "-webkit-image-set(")) {
- value = parseImageSet(m_valueList);
- if (value)
- return true;
- }
-
return false;
}
@@ -4241,20 +4212,12 @@ bool BorderImageParseContext::buildFromParser(CSSPropertyParser& parser, CSSProp
context.commitForwardSlashOperator();
if (!context.canAdvance() && context.allowImage()) {
- if (val->unit == CSSPrimitiveValue::CSS_URI) {
- context.commitImage(parser.createCSSImageValueWithReferrer(val->string, parser.m_context.completeURL(val->string)));
- } else if (isGeneratedImageValue(val)) {
+ if (isGeneratedImageValue(val)) {
RefPtr<CSSValue> value = nullptr;
if (parser.parseGeneratedImage(parser.m_valueList, value))
context.commitImage(value.release());
else
return false;
- } else if (val->unit == CSSParserValue::Function && equalIgnoringCase(val->function->name, "-webkit-image-set(")) {
- RefPtr<CSSValue> value = parser.parseImageSet(parser.m_valueList);
- if (value)
- context.commitImage(value.release());
- else
- return false;
} else if (val->id == CSSValueNone)
context.commitImage(cssValuePool().createIdentifierValue(CSSValueNone));
}
@@ -4946,112 +4909,9 @@ bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
if (equalIgnoringCase(val->function->name, "repeating-radial-gradient("))
return parseRadialGradient(valueList, value, Repeating);
- if (equalIgnoringCase(val->function->name, "-webkit-cross-fade("))
- return parseCrossfade(valueList, value);
-
return false;
}
-bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSSValue>& crossfade)
-{
- // Walk the arguments.
- CSSParserValueList* args = valueList->current()->function->args.get();
- if (!args || args->size() != 5)
- return false;
- RefPtr<CSSValue> fromImageValue = nullptr;
- RefPtr<CSSValue> toImageValue = nullptr;
-
- // The first argument is the "from" image. It is a fill image.
- if (!args->current() || !parseFillImage(args, fromImageValue))
- return false;
- args->next();
-
- if (!consumeComma(args))
- return false;
-
- // The second argument is the "to" image. It is a fill image.
- if (!args->current() || !parseFillImage(args, toImageValue))
- return false;
- args->next();
-
- if (!consumeComma(args))
- return false;
-
- // The third argument is the crossfade value. It is a percentage or a fractional number.
- RefPtr<CSSPrimitiveValue> percentage = nullptr;
- CSSParserValue* value = args->current();
- if (!value)
- return false;
-
- if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
- percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
- else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
- percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
- else
- return false;
-
- RefPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fromImageValue, toImageValue);
- result->setPercentage(percentage);
-
- crossfade = result;
-
- return true;
-}
-
-PassRefPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValueList* valueList)
-{
- CSSParserValue* function = valueList->current();
-
- if (function->unit != CSSParserValue::Function)
- return nullptr;
-
- CSSParserValueList* functionArgs = valueList->current()->function->args.get();
- if (!functionArgs || !functionArgs->size() || !functionArgs->current())
- return nullptr;
-
- RefPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
-
- while (functionArgs->current()) {
- CSSParserValue* arg = functionArgs->current();
- if (arg->unit != CSSPrimitiveValue::CSS_URI)
- return nullptr;
-
- RefPtr<CSSValue> image = createCSSImageValueWithReferrer(arg->string, completeURL(arg->string));
- imageSet->append(image);
-
- arg = functionArgs->next();
- if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION)
- return nullptr;
-
- double imageScaleFactor = 0;
- const String& string = arg->string;
- unsigned length = string.length();
- if (!length)
- return nullptr;
- if (string.is8Bit()) {
- const LChar* start = string.characters8();
- parseDouble(start, start + length, 'x', imageScaleFactor);
- } else {
- const UChar* start = string.characters16();
- parseDouble(start, start + length, 'x', imageScaleFactor);
- }
- if (imageScaleFactor <= 0)
- return nullptr;
- imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimitiveValue::CSS_NUMBER));
- functionArgs->next();
-
- // If there are no more arguments, we're done.
- if (!functionArgs->current())
- break;
-
- // If there are more arguments, they should be after a comma.
- if (!consumeComma(functionArgs))
- return nullptr;
- }
-
- return imageSet.release();
-}
-
PassRefPtr<CSSValue> CSSPropertyParser::parseWillChange()
{
RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
« no previous file with comments | « sky/engine/core/css/parser/CSSPropertyParser.h ('k') | sky/engine/core/css/resolver/AnimatedStyleBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698