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

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

Issue 2097383002: Added support of calc() for SVGLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
index f397430fb44e03be0d391ecb3d1dfda87761d647..0dd868201e2eaa1385f8e8326f14a882d42a0502 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
@@ -214,6 +214,20 @@ CSSPrimitiveValue* consumePercent(CSSParserTokenRange& range, ValueRange valueRa
return nullptr;
}
+bool canConsumeCalcValue(CalculationCategory category, CSSParserMode cssParserMode)
+{
+ if (category == CalcLength || category == CalcPercent || category == CalcPercentLength)
+ return true;
+
+ if (cssParserMode != SVGAttributeMode)
+ return false;
+
+ if (category == CalcNumber || category == CalcPercentNumber || category == CalcLengthNumber || category == CalcPercentLengthNumber)
+ return true;
+
+ return false;
+}
+
CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange& range, CSSParserMode cssParserMode, ValueRange valueRange, UnitlessQuirk unitless)
{
const CSSParserToken& token = range.peek();
@@ -223,7 +237,7 @@ CSSPrimitiveValue* consumeLengthOrPercent(CSSParserTokenRange& range, CSSParserM
return consumePercent(range, valueRange);
CalcParser calcParser(range, valueRange);
if (const CSSCalcValue* calculation = calcParser.value()) {
- if (calculation->category() == CalcLength || calculation->category() == CalcPercent || calculation->category() == CalcPercentLength)
+ if (canConsumeCalcValue(calculation->category(), cssParserMode))
return calcParser.consumeValue();
}
return nullptr;
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp ('k') | third_party/WebKit/Source/core/svg/SVGLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698