From 12f675305773aa09386385ab5cf4c07e4c8cbb61 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Tue, 12 Jun 2012 10:48:20 -0700 Subject: [PATCH] Bug 763689: Add "auto" keyword for min-height and min-width, which for now just computes to 0. r=bz --- layout/style/nsCSSPropList.h | 4 ++-- layout/style/nsRuleNode.cpp | 13 +++++++++++-- layout/style/test/property_database.js | 8 ++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 98ffaf8160b..ea5788c3a7c 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1980,7 +1980,7 @@ CSS_PROP_POSITION( CSS_PROPERTY_VALUE_NONNEGATIVE | CSS_PROPERTY_STORES_CALC, "", - VARIANT_HLP | VARIANT_CALC, + VARIANT_AHLP | VARIANT_CALC, nsnull, offsetof(nsStylePosition, mMinHeight), eStyleAnimType_Coord) @@ -1992,7 +1992,7 @@ CSS_PROP_POSITION( CSS_PROPERTY_VALUE_NONNEGATIVE | CSS_PROPERTY_STORES_CALC, "", - VARIANT_HKLP | VARIANT_CALC, + VARIANT_AHKLP | VARIANT_CALC, kWidthKTable, offsetof(nsStylePosition, mMinWidth), eStyleAnimType_Coord) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 066842780ae..a5839ad4220 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -6383,7 +6383,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct, SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC, aContext, mPresContext, canStoreInRuleTree); SetCoord(*aRuleData->ValueForMinWidth(), pos->mMinWidth, parentPos->mMinWidth, - SETCOORD_LPEH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC, + SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC, aContext, mPresContext, canStoreInRuleTree); SetCoord(*aRuleData->ValueForMaxWidth(), pos->mMaxWidth, parentPos->mMaxWidth, SETCOORD_LPOEH | SETCOORD_INITIAL_NONE | SETCOORD_STORE_CALC, @@ -6393,12 +6393,21 @@ nsRuleNode::ComputePositionData(void* aStartStruct, SETCOORD_LPAH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC, aContext, mPresContext, canStoreInRuleTree); SetCoord(*aRuleData->ValueForMinHeight(), pos->mMinHeight, parentPos->mMinHeight, - SETCOORD_LPH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC, + SETCOORD_LPAH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC, aContext, mPresContext, canStoreInRuleTree); SetCoord(*aRuleData->ValueForMaxHeight(), pos->mMaxHeight, parentPos->mMaxHeight, SETCOORD_LPOH | SETCOORD_INITIAL_NONE | SETCOORD_STORE_CALC, aContext, mPresContext, canStoreInRuleTree); + + // Handle 'auto' values for min-width / min-height + if (pos->mMinWidth.GetUnit() == eStyleUnit_Auto) { + pos->mMinWidth.SetCoordValue(0); + } + if (pos->mMinHeight.GetUnit() == eStyleUnit_Auto) { + pos->mMinHeight.SetCoordValue(0); + } + // box-sizing: enum, inherit, initial SetDiscrete(*aRuleData->ValueForBoxSizing(), pos->mBoxSizing, canStoreInRuleTree, diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 5a4d0c4fcb0..515c2d0ffd5 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -2352,7 +2352,7 @@ var gCSSProperties = { inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "display": "block" }, - initial_values: [ "0", "-moz-calc(0em)", "-moz-calc(-2px)", "-moz-calc(-1%)" ], + initial_values: [ "auto", "0", "-moz-calc(0em)", "-moz-calc(-2px)", "-moz-calc(-1%)" ], other_values: [ "30px", "50%", "-moz-calc(2px)", "-moz-calc(50%)", @@ -2360,14 +2360,14 @@ var gCSSProperties = { "-moz-calc(25px*3)", "-moz-calc(3*25px + 50%)", ], - invalid_values: [ "auto", "none", "-moz-max-content", "-moz-min-content", "-moz-fit-content", "-moz-available" ] + invalid_values: [ "none", "-moz-max-content", "-moz-min-content", "-moz-fit-content", "-moz-available" ] }, "min-width": { domProp: "minWidth", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "display": "block" }, - initial_values: [ "0", "-moz-calc(0em)", "-moz-calc(-2px)", "-moz-calc(-1%)" ], + initial_values: [ "auto", "0", "-moz-calc(0em)", "-moz-calc(-2px)", "-moz-calc(-1%)" ], other_values: [ "30px", "50%", "-moz-max-content", "-moz-min-content", "-moz-fit-content", "-moz-available", "-moz-calc(2px)", "-moz-calc(50%)", @@ -2375,7 +2375,7 @@ var gCSSProperties = { "-moz-calc(25px*3)", "-moz-calc(3*25px + 50%)", ], - invalid_values: [ "auto", "none" ] + invalid_values: [ "none" ] }, "opacity": { domProp: "opacity",