Issue #2499 - Part 3: Add CSS clip overflow support with serialization fixes

This commit is contained in:
MeladJM 2025-07-08 05:46:54 +08:00 committed by roytam1
commit 5e8e1208e7
40 changed files with 144 additions and 97 deletions

View file

@ -6406,22 +6406,35 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
parentDisplay->mOverflowY,
NS_STYLE_OVERFLOW_VISIBLE);
// CSS3 overflow-x and overflow-y require some fixup as well in some
// 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->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE)) {
// We can't store in the rule tree since a more specific rule might
// change these conditions.
// The visible/clip values of overflow compute to auto/hidden (respectively)
// if one of overflow-x or overflow-y is neither visible nor clip.
if (display->mOverflowX != display->mOverflowY) {
conditions.SetUncacheable();
// Note: clip values are now preserved as-is when axes differ
// Convert visible->auto only when paired with non-visible, non-clip values
if (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE &&
display->mOverflowY != NS_STYLE_OVERFLOW_CLIP) {
display->mOverflowX = NS_STYLE_OVERFLOW_AUTO;
}
if (display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE &&
display->mOverflowX != NS_STYLE_OVERFLOW_CLIP) {
display->mOverflowY = NS_STYLE_OVERFLOW_AUTO;
}
// Convert clip->hidden when paired with non-visible, non-clip values
if (display->mOverflowX == NS_STYLE_OVERFLOW_CLIP &&
display->mOverflowY != NS_STYLE_OVERFLOW_VISIBLE) {
display->mOverflowX = NS_STYLE_OVERFLOW_HIDDEN;
}
if (display->mOverflowY == NS_STYLE_OVERFLOW_CLIP &&
display->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE) {
display->mOverflowY = NS_STYLE_OVERFLOW_HIDDEN;
}
}
// When 'contain: paint', update overflow from 'visible' to 'clip'.
if (display->IsContainPaint()) {
// XXX This actually sets overflow-[x|y] to -moz-hidden-unscrollable.
// XXX This actually sets overflow-[x|y] to clip.
if (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE) {
// This uncacheability (and the one below) could be fixed by adding
// mOriginalOverflowX and mOriginalOverflowY fields, if necessary.