Bug 1117983 - Part 2: Implement the max-{block,inline}-size logical properties. r=dbaron

This commit is contained in:
Cameron McCormack 2015-01-17 15:50:09 +11:00
parent 147da22f18
commit c7bda81337
5 changed files with 90 additions and 7 deletions

View File

@ -2390,6 +2390,24 @@ CSS_PROP_BACKENDONLY(
"",
0,
kPageMarksKTable)
CSS_PROP_LOGICAL(
max-block-size,
max_block_size,
MaxBlockSize,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_NONNEGATIVE |
CSS_PROPERTY_STORES_CALC |
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH |
CSS_PROPERTY_LOGICAL |
CSS_PROPERTY_LOGICAL_AXIS |
CSS_PROPERTY_LOGICAL_BLOCK_AXIS,
"layout.css.vertical-text.enabled",
VARIANT_HKLPO | VARIANT_CALC,
kWidthKTable,
MaxSize,
Position,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_POSITION(
max-height,
max_height,
@ -2404,6 +2422,23 @@ CSS_PROP_POSITION(
nullptr,
offsetof(nsStylePosition, mMaxHeight),
eStyleAnimType_Coord)
CSS_PROP_LOGICAL(
max-inline-size,
max_inline_size,
MaxInlineSize,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_NONNEGATIVE |
CSS_PROPERTY_STORES_CALC |
CSS_PROPERTY_GETCS_NEEDS_LAYOUT_FLUSH |
CSS_PROPERTY_LOGICAL |
CSS_PROPERTY_LOGICAL_AXIS,
"layout.css.vertical-text.enabled",
VARIANT_HKLPO | VARIANT_CALC,
kWidthKTable,
MaxSize,
Position,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_POSITION(
max-width,
max_width,

View File

@ -49,5 +49,6 @@ CSS_PROP_LOGICAL_GROUP_SHORTHAND(BorderColor)
CSS_PROP_LOGICAL_GROUP_SHORTHAND(BorderStyle)
CSS_PROP_LOGICAL_GROUP_SHORTHAND(BorderWidth)
CSS_PROP_LOGICAL_GROUP_SHORTHAND(Margin)
CSS_PROP_LOGICAL_GROUP_AXIS(MaxSize)
CSS_PROP_LOGICAL_GROUP_SHORTHAND(Padding)
CSS_PROP_LOGICAL_GROUP_AXIS(Size)

View File

@ -2556,6 +2556,12 @@ nsCSSProps::kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shortha
};
static const nsCSSProperty gMaxSizeLogicalGroupTable[] = {
eCSSProperty_max_height,
eCSSProperty_max_width,
eCSSProperty_UNKNOWN
};
static const nsCSSProperty gSizeLogicalGroupTable[] = {
eCSSProperty_height,
eCSSProperty_width,

View File

@ -7462,10 +7462,10 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, canStoreInRuleTree);
// We can get enumerated values for height (-moz-min-content,
// -moz-max-content, etc.) since we parse the logical block-size property
// with all the values that width accepts. If we get a value we don't
// support on height, turn it into unset.
// We can get enumerated values for {,min-,max-}height (-moz-min-content,
// -moz-max-content, etc.) since we parse the logical properties with all the
// values that width accepts. If we get a value we don't support on these
// properties, turn them into unset.
const nsCSSValue* height = aRuleData->ValueForHeight();
SetCoord(height->GetUnit() == eCSSUnit_Enumerated ?
nsCSSValue(eCSSUnit_Unset) : *height,
@ -7477,7 +7477,10 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
SETCOORD_LPAH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC |
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, canStoreInRuleTree);
SetCoord(*aRuleData->ValueForMaxHeight(), pos->mMaxHeight, parentPos->mMaxHeight,
const nsCSSValue* maxHeight = aRuleData->ValueForMaxHeight();
SetCoord(maxHeight->GetUnit() == eCSSUnit_Enumerated ?
nsCSSValue(eCSSUnit_Unset) : *maxHeight,
pos->mMaxHeight, parentPos->mMaxHeight,
SETCOORD_LPOH | SETCOORD_INITIAL_NONE | SETCOORD_STORE_CALC |
SETCOORD_UNSET_INITIAL,
aContext, mPresContext, canStoreInRuleTree);

View File

@ -4551,8 +4551,10 @@ function logical_axis_prop_get_computed(cs, property)
var orientation = writingMode.substring(0, writingMode.indexOf("-"));
var mappings = {
"block-size": { horizontal: "height", vertical: "width" },
"inline-size": { horizontal: "width", vertical: "height" },
"block-size": { horizontal: "height", vertical: "width" },
"inline-size": { horizontal: "width", vertical: "height" },
"max-block-size": { horizontal: "max-height", vertical: "max-width" },
"max-inline-size": { horizontal: "max-width", vertical: "max-height" },
};
if (!mappings[property]) {
@ -5027,6 +5029,42 @@ if (SpecialPowers.getBoolPref("layout.css.vertical-text.enabled")) {
],
invalid_values: [ "..25px", ".+5px", ".px", "-.px", "++5px", "-+4px", "+-3px", "--7px", "+-.6px", "-+.5px", "++.7px", "--.4px" ],
},
"max-block-size": {
domProp: "maxBlockSize",
inherited: false,
type: CSS_TYPE_LONGHAND,
logical: true,
axis: true,
get_computed: logical_axis_prop_get_computed,
prerequisites: { "display": "block" },
initial_values: [ "none" ],
other_values: [ "30px", "50%",
"calc(2px)",
"calc(50%)",
"calc(3*25px)",
"calc(25px*3)",
"calc(3*25px + 50%)",
],
invalid_values: ["none", "5" ]
},
"max-inline-size": {
domProp: "maxInlineSize",
inherited: false,
type: CSS_TYPE_LONGHAND,
logical: true,
axis: true,
get_computed: logical_axis_prop_get_computed,
prerequisites: { "display": "block" },
initial_values: [ "none" ],
other_values: [ "30px", "50%",
"calc(2px)",
"calc(50%)",
"calc(3*25px)",
"calc(25px*3)",
"calc(3*25px + 50%)",
],
invalid_values: ["none", "5" ]
},
"padding-block-end": {
domProp: "paddingBlockEnd",
inherited: false,