diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index 8638b91071..90baa897b0 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -1086,6 +1086,16 @@ Declaration::GetPropertyValueInternal( if (*xValue == *yValue) { xValue->AppendToString(eCSSProperty_overflow_x, aValue, aSerialization); } else { + // Check if either value is clip - if so, shorthand cannot be serialized + if (xValue->GetUnit() == eCSSUnit_Enumerated && yValue->GetUnit() == eCSSUnit_Enumerated) { + int32_t xVal = xValue->GetIntValue(); + int32_t yVal = yValue->GetIntValue(); + if (xVal == NS_STYLE_OVERFLOW_CLIP || yVal == NS_STYLE_OVERFLOW_CLIP) { + // When clip is mixed with other values, shorthand cannot be serialized + aValue.Truncate(); + break; + } + } xValue->AppendToString(eCSSProperty_overflow_x, aValue, aSerialization); aValue.Append(char16_t(' ')); yValue->AppendToString(eCSSProperty_overflow_y, aValue, aSerialization); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index a593c54b15..5bba2e408a 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -6407,35 +6407,16 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct, NS_STYLE_OVERFLOW_VISIBLE); // CSS3 overflow-x and overflow-y require some fixup as well in some - // cases. NS_STYLE_OVERFLOW_VISIBLE and NS_STYLE_OVERFLOW_CLIP are - // meaningful only when used in both dimensions. + // cases. NS_STYLE_OVERFLOW_VISIBLE is meaningful only when used in both dimensions. + // NS_STYLE_OVERFLOW_CLIP is now a standard value and should be preserved. if (display->mOverflowX != display->mOverflowY && (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE || - display->mOverflowX == NS_STYLE_OVERFLOW_CLIP || - display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE || - display->mOverflowY == NS_STYLE_OVERFLOW_CLIP)) { + display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE)) { // We can't store in the rule tree since a more specific rule might // change these conditions. conditions.SetUncacheable(); - // NS_STYLE_OVERFLOW_CLIP is a deprecated value, so if it's specified - // in only one dimension, convert it to NS_STYLE_OVERFLOW_HIDDEN. - if (display->mOverflowX == NS_STYLE_OVERFLOW_CLIP) { - display->mOverflowX = NS_STYLE_OVERFLOW_HIDDEN; - } - if (display->mOverflowY == NS_STYLE_OVERFLOW_CLIP) { - display->mOverflowY = NS_STYLE_OVERFLOW_HIDDEN; - } - - // If 'visible' is specified but doesn't match the other dimension, it - // turns into 'auto'. - if (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE) { - display->mOverflowX = NS_STYLE_OVERFLOW_AUTO; - } - if (display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE) { - display->mOverflowY = NS_STYLE_OVERFLOW_AUTO; - } - + // Note: clip values are now preserved as-is when axes differ } // When 'contain: paint', update overflow from 'visible' to 'clip'.