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

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

Issue 636993002: [CSS Grid Layout] Upgrade justify-content parsing to CSS3 Box Alignment spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline some tests expectations. Created 6 years, 2 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 | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleAdjuster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index b1e2d1cc5495c2fe930e1888fa1f0c29ba8014eb..b948ca76ea24851283bd76c3ca56eeb61574f5c7 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -33,6 +33,7 @@
#include "core/css/CSSBasicShapes.h"
#include "core/css/CSSBorderImage.h"
#include "core/css/CSSCanvasValue.h"
+#include "core/css/CSSContentDistributionValue.h"
#include "core/css/CSSCrossfadeValue.h"
#include "core/css/CSSCursorImageValue.h"
#include "core/css/CSSFontFaceSrcValue.h"
@@ -1202,6 +1203,9 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
return false;
}
+ case CSSPropertyJustifyContent:
+ parsedValue = parseContentDistributionOverflowPosition();
+ break;
case CSSPropertyJustifySelf:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseItemPositionOverflowPosition(propId, important);
@@ -4029,11 +4033,29 @@ PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS
return shape;
}
+static bool isContentDistributionKeyword(CSSValueID id)
+{
+ return id == CSSValueSpaceBetween || id == CSSValueSpaceAround
+ || id == CSSValueSpaceEvenly || id == CSSValueStretch;
+}
+
+static bool isContentPositionKeyword(CSSValueID id)
+{
+ return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
+ || id == CSSValueFlexStart || id == CSSValueFlexEnd
+ || id == CSSValueLeft || id == CSSValueRight;
+}
+
static bool isBaselinePositionKeyword(CSSValueID id)
{
return id == CSSValueBaseline || id == CSSValueLastBaseline;
}
+static bool isAlignmentOverflowKeyword(CSSValueID id)
+{
+ return id == CSSValueTrue || id == CSSValueSafe;
+}
+
static bool isItemPositionKeyword(CSSValueID id)
{
return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
@@ -4066,6 +4088,50 @@ bool CSSPropertyParser::parseLegacyPosition(CSSPropertyID propId, bool important
return !m_valueList->next();
}
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOverflowPosition()
+{
+ // auto | <baseline-position> | [ <content-distribution>? && <content-position>? ]! && <overflow-position>?
+ // <baseline-position> = baseline | last-baseline;
+ // <content-distribution> = space-between | space-around | space-evenly | stretch;
+ // <content-position> = center | start | end | flex-start | flex-end | left | right;
+ // <overflow-position> = true | safe
+
+ // auto | <baseline-position>
+ CSSParserValue* value = m_valueList->current();
+ if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) {
+ m_valueList->next();
+ return CSSContentDistributionValue::create(CSSValueInvalid, value->id, CSSValueInvalid);
+ }
+
+ CSSValueID distribution = CSSValueInvalid;
+ CSSValueID position = CSSValueInvalid;
+ CSSValueID overflow = CSSValueInvalid;
+ if (isAlignmentOverflowKeyword(value->id)) {
+ overflow = value->id;
+ value = m_valueList->next();
+ }
+ if (value && isContentDistributionKeyword(value->id)) {
+ distribution = value->id;
+ value = m_valueList->next();
+ }
+ if (value && isContentPositionKeyword(value->id)) {
+ position = value->id;
+ value = m_valueList->next();
+ }
+ if (value) {
+ if (overflow != CSSValueInvalid || !isAlignmentOverflowKeyword(value->id))
+ return nullptr;
+ overflow = value->id;
+ }
+
+ // The grammar states that we should have at least <content-distribution> or
+ // <content-position> ([ <content-distribution>? && <content-position>? ]!).
+ if (m_valueList->next() || (position == CSSValueInvalid && distribution == CSSValueInvalid))
+ return nullptr;
+
+ return CSSContentDistributionValue::create(distribution, position, overflow);
+}
+
bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important)
{
// auto | stretch | <baseline-position> | [<item-position> && <overflow-position>? ]
@@ -4091,12 +4157,12 @@ bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId,
position = cssValuePool().createIdentifierValue(value->id);
value = m_valueList->next();
if (value) {
- if (value->id == CSSValueTrue || value->id == CSSValueSafe)
+ if (isAlignmentOverflowKeyword(value->id))
overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id);
else
return false;
}
- } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) {
+ } else if (isAlignmentOverflowKeyword(value->id)) {
overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id);
value = m_valueList->next();
if (value && isItemPositionKeyword(value->id))
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleAdjuster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698