Issue #2124/2662: Optimize overflow shorthand parsing and serialization

This commit is contained in:
erixreyes 2025-07-05 05:47:31 +08:00 committed by roytam1
commit 7626c99ceb
2 changed files with 24 additions and 6 deletions

View file

@ -4750,15 +4750,26 @@ nsComputedDOMStyle::DoGetOverflow()
{
const nsStyleDisplay* display = StyleDisplay();
if (display->mOverflowX != display->mOverflowY) {
// No value to return. We can't express this combination of
// values as a shorthand.
return nullptr;
if (display->mOverflowX == display->mOverflowY) {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable));
return val.forget();
}
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable));
nsAutoString result;
nsCSSKeyword xKeyword = nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
nsCSSProps::kOverflowKTable);
nsCSSKeyword yKeyword = nsCSSProps::ValueToKeywordEnum(display->mOverflowY,
nsCSSProps::kOverflowKTable);
result.AppendASCII(nsCSSKeywords::GetStringValue(xKeyword).get());
result.Append(char16_t(' '));
result.AppendASCII(nsCSSKeywords::GetStringValue(yKeyword).get());
val->SetString(result);
return val.forget();
}