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

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

Issue 1615093005: Move border-image related longhands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index b2e902e7239d310179ec59b96d239d7d4bb115ba..6ca22bca6a57d001061fb51cb99bb9db7024c6d1 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -6,6 +6,7 @@
#include "core/StylePropertyShorthand.h"
#include "core/css/CSSBasicShapeValues.h"
+#include "core/css/CSSBorderImage.h"
#include "core/css/CSSCalculationValue.h"
#include "core/css/CSSContentDistributionValue.h"
#include "core/css/CSSCounterValue.h"
@@ -3006,16 +3007,16 @@ static PassRefPtrWillBeRawPtr<CSSBasicShapePolygonValue> consumeBasicShapePolygo
return shape.release();
}
-static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4])
+static void complete4Sides(RefPtrWillBeRawPtr<CSSPrimitiveValue> side[4])
{
- if (radii[3])
+ if (side[3])
return;
- if (!radii[2]) {
- if (!radii[1])
- radii[1] = radii[0];
- radii[2] = radii[0];
+ if (!side[2]) {
+ if (!side[1])
+ side[1] = side[0];
+ side[2] = side[0];
}
- radii[3] = radii[1];
+ side[3] = side[1];
}
static bool consumeRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalRadii[4], RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)
@@ -3039,7 +3040,7 @@ static bool consumeRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalRadii[4
verticalRadii[0] = horizontalRadii[1];
horizontalRadii[1] = nullptr;
} else {
- completeBorderRadii(horizontalRadii);
+ complete4Sides(horizontalRadii);
for (unsigned i = 0; i < 4; ++i)
verticalRadii[i] = horizontalRadii[i];
return true;
@@ -3056,8 +3057,8 @@ static bool consumeRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalRadii[4
if (!verticalRadii[0] || !range.atEnd())
return false;
}
- completeBorderRadii(horizontalRadii);
- completeBorderRadii(verticalRadii);
+ complete4Sides(horizontalRadii);
+ complete4Sides(verticalRadii);
return true;
}
@@ -3188,6 +3189,99 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeContentDistributionOverflowPositi
return CSSContentDistributionValue::create(distribution, position, overflow);
}
+static RefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBorderImageRepeatKeyword(CSSParserTokenRange& range)
+{
+ return consumeIdent<CSSValueStretch, CSSValueRepeat, CSSValueSpace, CSSValueRound>(range);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeBorderImageRepeat(CSSParserTokenRange& range)
+{
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontal = consumeBorderImageRepeatKeyword(range);
+ if (!horizontal)
+ return nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> vertical = consumeBorderImageRepeatKeyword(range);
+ if (!vertical)
+ vertical = horizontal;
+ return CSSValuePair::create(horizontal.release(), vertical.release(), CSSValuePair::DropIdenticalValues);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range, CSSParserMode cssParserMode)
+{
+ bool fill = consumeIdent<CSSValueFill>(range);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> slices[4];
+#if ENABLE(OILPAN)
+ // Unconditionally zero initialize the arrays of raw pointers.
+ memset(slices, 0, 4 * sizeof(slices[0]));
+#endif
+ for (size_t index = 0; index < 4; ++index) {
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> value = consumePercent(range, ValueRangeNonNegative);
+ if (!value)
+ value = consumeNumber(range, ValueRangeNonNegative);
+ if (!value)
+ break;
+ slices[index] = value;
+ }
+ if (!slices[0])
+ return nullptr;
+ if (consumeIdent<CSSValueFill>(range)) {
+ if (fill)
+ return nullptr;
+ fill = true;
+ }
+ complete4Sides(slices);
+ // FIXME: For backwards compatibility, -webkit-border-image, -webkit-mask-box-image and -webkit-box-reflect have to do a fill by default.
+ // FIXME: What do we do with -webkit-box-reflect and -webkit-mask-box-image? Probably just have to leave them filling...
+ if (property == CSSPropertyWebkitBorderImage || property == CSSPropertyWebkitMaskBoxImage || property == CSSPropertyWebkitBoxReflect)
+ fill = true;
+ return CSSBorderImageSliceValue::create(CSSQuadValue::create(slices[0].release(), slices[1].release(), slices[2].release(), slices[3].release(), CSSQuadValue::SerializeAsQuad), fill);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeBorderImageOutset(CSSParserTokenRange& range)
+{
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> outsets[4];
+#if ENABLE(OILPAN)
+ // Unconditionally zero initialize the arrays of raw pointers.
+ memset(outsets, 0, 4 * sizeof(outsets[0]));
+#endif
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> value = nullptr;
+ for (size_t index = 0; index < 4; ++index) {
+ value = consumeNumber(range, ValueRangeNonNegative);
+ if (!value)
+ value = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative);
+ if (!value)
+ break;
+ outsets[index] = value;
+ }
+ if (!outsets[0])
+ return nullptr;
+ complete4Sides(outsets);
+ return CSSQuadValue::create(outsets[0].release(), outsets[1].release(), outsets[2].release(), outsets[3].release(), CSSQuadValue::SerializeAsQuad);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeBorderImageWidth(CSSParserTokenRange& range)
+{
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> widths[4];
+#if ENABLE(OILPAN)
+ // Unconditionally zero initialize the arrays of raw pointers.
+ memset(widths, 0, 4 * sizeof(widths[0]));
+#endif
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> value = nullptr;
+ for (size_t index = 0; index < 4; ++index) {
+ value = consumeNumber(range, ValueRangeNonNegative);
+ if (!value)
+ value = consumeLengthOrPercent(range, HTMLStandardMode, ValueRangeNonNegative, UnitlessQuirk::Forbid);
+ if (!value)
+ value = consumeIdent<CSSValueAuto>(range);
+ if (!value)
+ break;
+ widths[index] = value;
+ }
+ if (!widths[0])
+ return nullptr;
+ complete4Sides(widths);
+ return CSSQuadValue::create(widths[0].release(), widths[1].release(), widths[2].release(), widths[3].release(), CSSQuadValue::SerializeAsQuad);
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty)
{
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
@@ -3492,6 +3586,18 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
case CSSPropertyAlignContent:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return consumeContentDistributionOverflowPosition(m_range);
+ case CSSPropertyBorderImageRepeat:
+ case CSSPropertyWebkitMaskBoxImageRepeat:
+ return consumeBorderImageRepeat(m_range);
+ case CSSPropertyBorderImageSlice:
+ case CSSPropertyWebkitMaskBoxImageSlice:
+ return consumeBorderImageSlice(property, m_range, m_context.mode());
+ case CSSPropertyBorderImageOutset:
+ case CSSPropertyWebkitMaskBoxImageOutset:
+ return consumeBorderImageOutset(m_range);
+ case CSSPropertyBorderImageWidth:
+ case CSSPropertyWebkitMaskBoxImageWidth:
+ return consumeBorderImageWidth(m_range);
default:
CSSParserValueList valueList(m_range);
if (valueList.size()) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698