Bug 1704631 - Expand the size for background-attachmend: fixed image. r=botond,tnikkel,geckoview-reviewers,owlish

Differential Revision: https://phabricator.services.mozilla.com/D169001
This commit is contained in:
Hiroyuki Ikezoe 2023-04-19 21:08:53 +00:00
parent 7eb350d0b0
commit 80d9a64924
2 changed files with 51 additions and 1 deletions

View File

@ -2787,6 +2787,15 @@ nsRect nsCSSRendering::ComputeImageLayerPositioningArea(
positionArea.Deflate(scrollbars);
}
}
// If we have the dynamic toolbar, we need to expand the image area to
// include the region under the dynamic toolbar, otherwise we will see a
// blank space under the toolbar.
if (aPresContext->IsRootContentDocumentCrossProcess() &&
aPresContext->HasDynamicToolbar()) {
positionArea.SizeTo(nsLayoutUtils::ExpandHeightForDynamicToolbar(
aPresContext, positionArea.Size()));
}
}
}
*aAttachedToFrame = attachedToFrame;

View File

@ -636,7 +636,7 @@ class DynamicToolbarTest : BaseSessionTest() {
val dynamicToolbarMaxHeight = SCREEN_HEIGHT / 2
sessionRule.display?.run { setDynamicToolbarMaxHeight(dynamicToolbarMaxHeight) }
// Set active since setVerticalClipping call affects only for forground tab.
// Set active since setVerticalClipping call affects only for foreground tab.
mainSession.setActive(true)
mainSession.loadTestPath(BaseSessionTest.FIXED_BOTTOM)
@ -662,4 +662,45 @@ class DynamicToolbarTest : BaseSessionTest() {
assertScreenshotResult(it.capturePixels(), reference)
}
}
@WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH)
@Test
fun backgroundImageFixed() {
// Set ui.scrollbarFadeBeginDelay value to 0 to hide the overlayed scrollbars
// immediately.
sessionRule.setPrefsUntilTestEnd(
mapOf(
"ui.scrollbarFadeBeginDelay" to 0
)
)
val reference = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
val dynamicToolbarMaxHeight = SCREEN_HEIGHT / 2
sessionRule.display?.run { setDynamicToolbarMaxHeight(dynamicToolbarMaxHeight) }
// Set active since setVerticalClipping call affects only for forground tab.
mainSession.setActive(true)
mainSession.loadTestPath(BaseSessionTest.TOUCH_ACTION_HTML_PATH)
mainSession.waitForPageStop()
// Specify the root background-color to match the reference image color and specify
// `background-attachment: fixed`.
mainSession.evaluateJS("document.documentElement.style.background = 'linear-gradient(green, green) fixed'")
// Make the root element scrollable.
mainSession.evaluateJS("document.documentElement.style.height = '100vh'")
mainSession.flushApzRepaints()
// Simulate the dynamic toolbar being hidden by the scroll
sessionRule.display?.run { setVerticalClipping(-dynamicToolbarMaxHeight) }
mainSession.flushApzRepaints()
sessionRule.display?.let {
assertScreenshotResult(it.capturePixels(), reference)
}
}
}