Diff
Modified: trunk/LayoutTests/ChangeLog (205806 => 205807)
--- trunk/LayoutTests/ChangeLog 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/LayoutTests/ChangeLog 2016-09-12 11:46:57 UTC (rev 205807)
@@ -1,3 +1,18 @@
+2016-09-12 Javier Fernandez <[email protected]>
+
+ [css-align] Initial values are parsed as invalid for some Alignment properties
+ https://bugs.webkit.org/show_bug.cgi?id=161303
+
+ Reviewed by Darin Adler.
+
+ Test to verify the "initial" values of the CSS Box Alignment properties
+ are parsed as valid independently of whether Grid Layout is enabled or not.
+
+ * fast/css/ensure-flexbox-compatibility-with-initial-values-expected.txt: Added.
+ * fast/css/ensure-flexbox-compatibility-with-initial-values.html: Added.
+ * fast/css/resources/alignment-parsing-utils.js:
+ (checkSupportedValues):
+
2016-09-11 Chris Dumez <[email protected]>
HTMLTrackElement.kind's invalid value default should be the metadata state
Added: trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values-expected.txt (0 => 205807)
--- trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values-expected.txt 2016-09-12 11:46:57 UTC (rev 205807)
@@ -0,0 +1,45 @@
+Test to verify initial values of alignment properties are backward-comaptible with flexbox implementation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Verifying initial values are supported when grid is ENABLED.
+PASS CSS.supports('align-items', 'normal') is true
+PASS CSS.supports('align-self', 'normal') is true
+PASS CSS.supports('align-content', 'normal') is true
+PASS CSS.supports('justify-content', 'normal') is true
+PASS CSS.supports('align-items', 'normal') is true
+PASS CSS.supports('align-self', 'normal') is true
+PASS CSS.supports('align-content', 'normal') is true
+PASS CSS.supports('justify-content', 'normal') is true
+PASS CSS.supports('align-items', 'normal') is true
+PASS CSS.supports('align-self', 'normal') is true
+PASS CSS.supports('align-content', 'normal') is true
+PASS CSS.supports('justify-content', 'normal') is true
+PASS CSS.supports('align-items', 'normal') is true
+PASS CSS.supports('align-self', 'normal') is true
+PASS CSS.supports('align-content', 'normal') is true
+PASS CSS.supports('justify-content', 'normal') is true
+
+Verifying initial values are supported when grid is DISABLED.
+PASS CSS.supports('align-items', 'stretch') is true
+PASS CSS.supports('align-self', 'stretch') is true
+PASS CSS.supports('align-content', 'flex-start') is true
+PASS CSS.supports('justify-content', 'flex-start') is true
+PASS CSS.supports('align-items', 'stretch') is true
+PASS CSS.supports('align-self', 'stretch') is true
+PASS CSS.supports('align-content', 'flex-start') is true
+PASS CSS.supports('justify-content', 'flex-start') is true
+PASS CSS.supports('align-items', 'stretch') is true
+PASS CSS.supports('align-self', 'stretch') is true
+PASS CSS.supports('align-content', 'flex-start') is true
+PASS CSS.supports('justify-content', 'flex-start') is true
+PASS CSS.supports('align-items', 'stretch') is true
+PASS CSS.supports('align-self', 'stretch') is true
+PASS CSS.supports('align-content', 'flex-start') is true
+PASS CSS.supports('justify-content', 'flex-start') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values.html (0 => 205807)
--- trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values.html (rev 0)
+++ trunk/LayoutTests/fast/css/ensure-flexbox-compatibility-with-initial-values.html 2016-09-12 11:46:57 UTC (rev 205807)
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<body>
+<script>
+description('Test to verify initial values of alignment properties are backward-comaptible with flexbox implementation.');
+
+function setInitialValues(element)
+{
+ element.style.alignItems = "initial";
+ element.style.alignContent = "initial";
+ element.style.justifyContent = "initial";
+}
+
+function checkSupportedInitialValues(element)
+{
+ checkSupportedValues(element.id, "align-items");
+ checkSupportedValues(element.id, "align-self");
+ checkSupportedValues(element.id, "align-content");
+ checkSupportedValues(element.id, "justify-content");
+}
+
+function checkInitialValues(gridEnabled)
+{
+ if (window.internals)
+ window.internals.setCSSGridLayoutEnabled(gridEnabled);
+
+ var root = document.createElement("div");
+ document.body.appendChild(root);
+
+ var container = document.createElement("div");
+ container.id = "container";
+ root.appendChild(container);
+ var item = document.createElement("div");
+ item.id = "item";
+ container.appendChild(item);
+
+ var flexContainer = document.createElement("div");
+ flexContainer.id = "flexContainer";
+ flexContainer.style.display = "flex";
+ root.appendChild(flexContainer);
+ var flexItem = document.createElement("div");
+ flexItem.id = "flexItem";
+ flexContainer.appendChild(flexItem);
+
+ setInitialValues(root);
+ setInitialValues(container);
+ setInitialValues(item);
+ setInitialValues(flexContainer);
+ setInitialValues(flexItem);
+
+ checkSupportedInitialValues(container);
+ checkSupportedInitialValues(item);
+ checkSupportedInitialValues(flexContainer);
+ checkSupportedInitialValues(flexItem);
+
+ document.body.removeChild(root);
+}
+
+debug('<br>Verifying initial values are supported when grid is ENABLED.');
+checkInitialValues(true);
+
+debug('<br>Verifying initial values are supported when grid is DISABLED.');
+checkInitialValues(false);
+</script>
+</body>
Modified: trunk/LayoutTests/fast/css/resources/alignment-parsing-utils.js (205806 => 205807)
--- trunk/LayoutTests/fast/css/resources/alignment-parsing-utils.js 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/LayoutTests/fast/css/resources/alignment-parsing-utils.js 2016-09-12 11:46:57 UTC (rev 205807)
@@ -46,3 +46,9 @@
parentElement.appendChild(element);
checkValues(element, property, propertyID, "", value);
}
+
+function checkSupportedValues(elementID, property)
+{
+ var value = eval("window.getComputedStyle(" + elementID + " , '').getPropertyValue('" + property + "')");
+ shouldBeTrue("CSS.supports('" + property + "', '" + value + "')");
+}
Modified: trunk/Source/WebCore/ChangeLog (205806 => 205807)
--- trunk/Source/WebCore/ChangeLog 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/ChangeLog 2016-09-12 11:46:57 UTC (rev 205807)
@@ -1,3 +1,42 @@
+2016-09-12 Javier Fernandez <[email protected]>
+
+ [css-align] Initial values are parsed as invalid for some Alignment properties
+ https://bugs.webkit.org/show_bug.cgi?id=161303
+
+ Reviewed by Darin Adler.
+
+ Due to the implementation of the new CSS Box Alignment specification,
+ some properties have now new values allowed, which are not valid
+ according to the Flexible Box Layout specification.
+
+ In r205102 we have get back the keywordID parsing, originally implemented for
+ the Flexbible Box Layout specification. Even though the new valued would be
+ parsed as invalid when they are set, the 'initial' values will be assigned
+ in any case.
+
+ This patch verifies that the 'initial' values depend on whether the Grid
+ Layout is enabled or not and verifying such values are parsed as valid.
+
+ Additionally, it gets back as well they keywordID parsing for the Content
+ Alignment properties (align-content and justify-content). This required to
+ touch a bit the StyleBuilderConverter logic, since we will have to deal with
+ either the complex CSSContentDistributionValue complex or the simpler
+ CSSPrimitiveValue.
+
+ Test: fast/css/ensure-flexbox-compatibility-with-initial-values.html
+
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::convertContentAlignmentData): Handling a primitive value if Grid Layout is not enabled.
+ * css/parser/CSSParser.cpp:
+ (WebCore::isValidKeywordPropertyAndValue): Simpler parsing of alignment properties if Grid Layout is not enabled.
+ (WebCore::isKeywordPropertyID): Alignment properties are defined as keyword if Grid Layout is no enabled.
+ (WebCore::CSSParser::parseValue): Assert Grid Layout is enabled when using the complex parsing.
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::RenderStyle::isCSSGridLayoutEnabled): Checking out the Grid Layout runtime flags.
+ * rendering/style/RenderStyle.h:
+ (WebCore::RenderStyle::initialDefaultAlignment): Initial value will depend on whether Grid Layout is enabled or not.
+ (WebCore::RenderStyle::initialContentAlignment): Initial value will depend on whether Grid Layout is enabled or not.
+
2016-09-12 Chris Dumez <[email protected]>
ol.start may return incorrect value for reversed lists when not explicitly set
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (205806 => 205807)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-09-12 11:46:57 UTC (rev 205807)
@@ -46,6 +46,7 @@
#include "LengthRepeat.h"
#include "Pair.h"
#include "QuotesData.h"
+#include "RuntimeEnabledFeatures.h"
#include "SVGURIReference.h"
#include "Settings.h"
#include "StyleResolver.h"
@@ -1253,13 +1254,33 @@
inline StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(StyleResolver&, CSSValue& value)
{
StyleContentAlignmentData alignmentData = RenderStyle::initialContentAlignment();
- auto& contentValue = downcast<CSSContentDistributionValue>(value);
- if (contentValue.distribution()->getValueID() != CSSValueInvalid)
- alignmentData.setDistribution(contentValue.distribution().get());
- if (contentValue.position()->getValueID() != CSSValueInvalid)
- alignmentData.setPosition(contentValue.position().get());
- if (contentValue.overflow()->getValueID() != CSSValueInvalid)
- alignmentData.setOverflow(contentValue.overflow().get());
+#if ENABLE(CSS_GRID_LAYOUT)
+ if (RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled()) {
+ auto& contentValue = downcast<CSSContentDistributionValue>(value);
+ if (contentValue.distribution()->getValueID() != CSSValueInvalid)
+ alignmentData.setDistribution(contentValue.distribution().get());
+ if (contentValue.position()->getValueID() != CSSValueInvalid)
+ alignmentData.setPosition(contentValue.position().get());
+ if (contentValue.overflow()->getValueID() != CSSValueInvalid)
+ alignmentData.setOverflow(contentValue.overflow().get());
+ return alignmentData;
+ }
+#endif
+ auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+ switch (primitiveValue.getValueID()) {
+ case CSSValueStretch:
+ case CSSValueSpaceBetween:
+ case CSSValueSpaceAround:
+ alignmentData.setDistribution(primitiveValue);
+ break;
+ case CSSValueFlexStart:
+ case CSSValueFlexEnd:
+ case CSSValueCenter:
+ alignmentData.setPosition(primitiveValue);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
return alignmentData;
}
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (205806 => 205807)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2016-09-12 11:46:57 UTC (rev 205807)
@@ -819,6 +819,10 @@
if (valueID == CSSValueAuto || valueID == CSSValueBalance)
return true;
break;
+ case CSSPropertyAlignContent:
+ // FIXME: Per CSS alignment, this property should accept an optional <overflow-position>. We should share this parsing code with 'justify-self'.
+ // FIXME: For now, we will do it behind the GRID_LAYOUT compile flag.
+ return valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch;
case CSSPropertyAlignItems:
// FIXME: Per CSS alignment, this property should accept the same arguments as 'justify-self' so we should share its parsing code.
// FIXME: For now, we will do it behind the GRID_LAYOUT compile flag.
@@ -839,6 +843,10 @@
if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == CSSValueWrapReverse)
return true;
break;
+ case CSSPropertyJustifyContent:
+ // FIXME: Per CSS alignment, this property should accept an optional <overflow-position>. We should share this parsing code with 'justify-self'.
+ // FIXME: For now, we will do it behind the GRID_LAYOUT compile flag.
+ return valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround;
case CSSPropertyWebkitFontKerning:
if (valueID == CSSValueAuto || valueID == CSSValueNormal || valueID == CSSValueNone)
return true;
@@ -1155,6 +1163,8 @@
case CSSPropertyFontVariantCaps:
case CSSPropertyFontVariantAlternates:
return true;
+ case CSSPropertyJustifyContent:
+ case CSSPropertyAlignContent:
case CSSPropertyAlignItems:
case CSSPropertyAlignSelf:
#if ENABLE(CSS_GRID_LAYOUT)
@@ -2738,10 +2748,11 @@
}
return false;
}
+#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyJustifyContent:
+ ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
parsedValue = parseContentDistributionOverflowPosition();
break;
-#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyJustifySelf:
if (!isCSSGridLayoutEnabled())
return false;
@@ -3162,10 +3173,11 @@
parsedValue = parseImageResolution();
break;
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyAlignContent:
+ ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
parsedValue = parseContentDistributionOverflowPosition();
break;
-#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyAlignSelf:
ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
return parseItemPositionOverflowPosition(propId, important);
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (205806 => 205807)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2016-09-12 11:46:57 UTC (rev 205807)
@@ -1398,7 +1398,11 @@
// yet for FlexibleBox.
// Defaulting to Stretch for now, as it what most of FlexBox based renders
// expect as default.
+#if ENABLE(CSS_GRID_LAYOUT)
ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
+#else
+ ASSERT_NOT_REACHED();
+#endif
FALLTHROUGH;
case ItemPositionStretch: {
applyStretchAlignmentToChild(*child, lineCrossAxisExtent);
@@ -1434,7 +1438,11 @@
case ItemPositionRight:
// FIXME: https://webkit.org/b/135460 - The extended grammar is not supported
// yet for FlexibleBox.
+#if ENABLE(CSS_GRID_LAYOUT)
ASSERT(RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled());
+#else
+ ASSERT_NOT_REACHED();
+#endif
break;
default:
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (205806 => 205807)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2016-09-12 11:46:57 UTC (rev 205807)
@@ -37,6 +37,7 @@
#include "QuotesData.h"
#include "RenderObject.h"
#include "RenderTheme.h"
+#include "RuntimeEnabledFeatures.h"
#include "ScaleTransformOperation.h"
#include "ShadowData.h"
#include "StyleImage.h"
@@ -190,6 +191,15 @@
#endif
}
+bool RenderStyle::isCSSGridLayoutEnabled()
+{
+#if ENABLE(CSS_GRID_LAYOUT)
+ return RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled();
+#else
+ return false;
+#endif
+}
+
static StyleSelfAlignmentData resolvedSelfAlignment(const StyleSelfAlignmentData& value, ItemPosition normalValueBehavior)
{
ASSERT(value.position() != ItemPositionAuto);
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (205806 => 205807)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2016-09-12 09:28:52 UTC (rev 205806)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2016-09-12 11:46:57 UTC (rev 205807)
@@ -2001,8 +2001,8 @@
static Length initialFlexBasis() { return Length(Auto); }
static int initialOrder() { return 0; }
static StyleSelfAlignmentData initialSelfAlignment() { return StyleSelfAlignmentData(ItemPositionAuto, OverflowAlignmentDefault); }
- static StyleSelfAlignmentData initialDefaultAlignment() { return StyleSelfAlignmentData(ItemPositionNormal, OverflowAlignmentDefault); }
- static StyleContentAlignmentData initialContentAlignment() { return StyleContentAlignmentData(ContentPositionNormal, ContentDistributionDefault, OverflowAlignmentDefault); }
+ static StyleSelfAlignmentData initialDefaultAlignment() { return StyleSelfAlignmentData(isCSSGridLayoutEnabled() ? ItemPositionNormal : ItemPositionStretch, OverflowAlignmentDefault); }
+ static StyleContentAlignmentData initialContentAlignment() { return StyleContentAlignmentData(isCSSGridLayoutEnabled() ? ContentPositionNormal : ContentPositionFlexStart, ContentDistributionDefault, OverflowAlignmentDefault); }
static EFlexDirection initialFlexDirection() { return FlowRow; }
static EFlexWrap initialFlexWrap() { return FlexNoWrap; }
static int initialMarqueeLoopCount() { return -1; }
@@ -2066,6 +2066,8 @@
static QuotesData* initialQuotes() { return nullptr; }
static const AtomicString& initialContentAltText() { return emptyAtom; }
+ static bool isCSSGridLayoutEnabled();
+
static WillChangeData* initialWillChange() { return nullptr; }
#if ENABLE(TOUCH_EVENTS)