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

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: Using a custom CSSValue to simplify parsing and style building. 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
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..13be783e2f80cc116a7788e8721a516a72d104ae 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,10 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
return false;
}
+ case CSSPropertyJustifyContent:
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+ parsedValue = parseContentDistributionOverflowPosition();
+ break;
case CSSPropertyJustifySelf:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return parseItemPositionOverflowPosition(propId, important);
@@ -4029,6 +4034,19 @@ 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;
@@ -4066,6 +4084,49 @@ 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 (value->id == CSSValueTrue || value->id == CSSValueSafe) {
Julien - ping for review 2014/10/28 17:23:05 We should add a helper function for these too!
jfernandez 2014/10/29 11:03:05 Done.
+ 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 || (value->id != CSSValueTrue && value->id != CSSValueSafe))
+ return nullptr;
+ overflow = value->id;
+ }
+
+ // [ <content-distribution>? && <content-position>? ]!
Julien - ping for review 2014/10/28 17:23:05 It would be better to state it in English: // The
jfernandez 2014/10/29 11:03:05 Done.
+ 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>? ]

Powered by Google App Engine
This is Rietveld 408576698