зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652190 - Don't expand the composition size including the dynamic toolbar height if the root content is not scrollable. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D83601
This commit is contained in:
Родитель
a6522ef178
Коммит
2cec69d8c5
|
@ -784,6 +784,42 @@ function* pinchZoomInTouchSequence(focusX, focusY) {
|
|||
yield* synthesizeNativeTouchSequences(document.body, zoom_in, null, touchIds);
|
||||
}
|
||||
|
||||
// Synthesizes a native touch sequence of events corresponding to a
|
||||
// pinch-zoom-out at the center of the window.
|
||||
function* pinchZoomOutTouchSequenceAtCenter() {
|
||||
// Divide the half of visual viewport size by 8, then cause touch events
|
||||
// starting from the 7th furthest away from the center towards the center.
|
||||
const deltaX = window.visualViewport.width / 16;
|
||||
const deltaY = window.visualViewport.height / 16;
|
||||
const centerX =
|
||||
window.visualViewport.pageLeft + window.visualViewport.width / 2;
|
||||
const centerY =
|
||||
window.visualViewport.pageTop + window.visualViewport.height / 2;
|
||||
// prettier-ignore
|
||||
var zoom_out = [
|
||||
[ { x: centerX - (deltaX * 6), y: centerY - (deltaY * 6) },
|
||||
{ x: centerX + (deltaX * 6), y: centerY + (deltaY * 6) } ],
|
||||
[ { x: centerX - (deltaX * 5), y: centerY - (deltaY * 5) },
|
||||
{ x: centerX + (deltaX * 5), y: centerY + (deltaY * 5) } ],
|
||||
[ { x: centerX - (deltaX * 4), y: centerY - (deltaY * 4) },
|
||||
{ x: centerX + (deltaX * 4), y: centerY + (deltaY * 4) } ],
|
||||
[ { x: centerX - (deltaX * 3), y: centerY - (deltaY * 3) },
|
||||
{ x: centerX + (deltaX * 3), y: centerY + (deltaY * 3) } ],
|
||||
[ { x: centerX - (deltaX * 2), y: centerY - (deltaY * 2) },
|
||||
{ x: centerX + (deltaX * 2), y: centerY + (deltaY * 2) } ],
|
||||
[ { x: centerX - (deltaX * 1), y: centerY - (deltaY * 1) },
|
||||
{ x: centerX + (deltaX * 1), y: centerY + (deltaY * 1) } ],
|
||||
];
|
||||
|
||||
var touchIds = [0, 1];
|
||||
yield* synthesizeNativeTouchSequences(
|
||||
document.body,
|
||||
zoom_out,
|
||||
null,
|
||||
touchIds
|
||||
);
|
||||
}
|
||||
|
||||
// Returns a promise that is resolved when the observer service dispatches a
|
||||
// message with the given topic.
|
||||
function promiseTopic(aTopic) {
|
||||
|
@ -824,3 +860,23 @@ async function pinchZoomInWithTouch(focusX, focusY) {
|
|||
// Wait for TransformEnd to fire.
|
||||
await transformEndPromise;
|
||||
}
|
||||
|
||||
// This generates a touch-based pinch zoom-out gesture that is expected
|
||||
// to succeed. It returns after APZ has completed the zoom and reaches the end
|
||||
// of the transform.
|
||||
async function pinchZoomOutWithTouchAtCenter() {
|
||||
// Register the listener for the TransformEnd observer topic
|
||||
let transformEndPromise = promiseTopic("APZ:TransformEnd");
|
||||
|
||||
// Dispatch all the touch events
|
||||
let generator = pinchZoomOutTouchSequenceAtCenter();
|
||||
while (true) {
|
||||
let yieldResult = generator.next();
|
||||
if (yieldResult.done) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for TransformEnd to fire.
|
||||
await transformEndPromise;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Zooming out to the initial scale with the dynamic toolbar</title>
|
||||
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
|
||||
<script type="application/javascript" src="apz_test_utils.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<style>
|
||||
html,body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
async function test() {
|
||||
SpecialPowers.getDOMWindowUtils(window).setDynamicToolbarMaxHeight(100);
|
||||
|
||||
is(visualViewport.scale, 1.0, "The initial scale value should be 1.0");
|
||||
|
||||
// Do a pinch-zoom in at the center of the visual viewport.
|
||||
await pinchZoomInWithTouch(visualViewport.width / 2,
|
||||
visualViewport.height / 2);
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
ok(window.visualViewport.scale > 1.0,
|
||||
"The scale value should be greater than 1.0");
|
||||
|
||||
// Do a pinch-zoom out to restore the initial scale.
|
||||
await pinchZoomOutWithTouchAtCenter();
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
is(visualViewport.scale, 1.0,
|
||||
"The initial scale value should be restored to 1.0");
|
||||
}
|
||||
|
||||
waitUntilApzStable()
|
||||
.then(test)
|
||||
.finally(subtestDone);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -37,6 +37,7 @@ var prefs = [
|
|||
var subtests = [
|
||||
{"file": "helper_bug1280013.html", "prefs": prefs},
|
||||
{"file": "helper_zoom_restore_position_tabswitch.html", "prefs": prefs},
|
||||
{"file": "helper_zoom_with_dynamic_toolbar.html", "prefs": prefs},
|
||||
];
|
||||
|
||||
if (isApzEnabled()) {
|
||||
|
|
|
@ -717,3 +717,14 @@ void MobileViewportManager::ShrinkToDisplaySizeIfNeeded() {
|
|||
UpdateResolutionForContentSizeChange(scrollableRect->Size());
|
||||
}
|
||||
}
|
||||
|
||||
CSSSize MobileViewportManager::GetIntrinsicCompositionSize() const {
|
||||
ScreenIntSize displaySize = ViewAs<ScreenPixel>(
|
||||
mDisplaySize, PixelCastJustification::LayoutDeviceIsScreenForBounds);
|
||||
ScreenIntSize compositionSize = GetCompositionSize(displaySize);
|
||||
CSSToScreenScale intrinsicScale =
|
||||
ComputeIntrinsicScale(mContext->GetViewportInfo(displaySize),
|
||||
compositionSize, mMobileViewportSize);
|
||||
|
||||
return ScreenSize(compositionSize) / intrinsicScale;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,12 @@ class MobileViewportManager final : public nsIDOMEventListener,
|
|||
*/
|
||||
void UpdateVisualViewportSizeForPotentialScrollbarChange();
|
||||
|
||||
/*
|
||||
* Returns the composition size in CSS units when zoomed to the intrinsic
|
||||
* scale.
|
||||
*/
|
||||
mozilla::CSSSize GetIntrinsicCompositionSize() const;
|
||||
|
||||
private:
|
||||
~MobileViewportManager();
|
||||
|
||||
|
|
|
@ -8686,7 +8686,8 @@ bool nsLayoutUtils::GetContentViewerSize(
|
|||
nsIntRect bounds;
|
||||
cv->GetBounds(bounds);
|
||||
|
||||
if (aSubtractDynamicToolbar == SubtractDynamicToolbar::Yes &&
|
||||
if (aPresContext->IsRootContentDocumentCrossProcess() &&
|
||||
aSubtractDynamicToolbar == SubtractDynamicToolbar::Yes &&
|
||||
aPresContext->HasDynamicToolbar() && !bounds.IsEmpty()) {
|
||||
MOZ_ASSERT(aPresContext->IsRootContentDocumentCrossProcess());
|
||||
bounds.height -= aPresContext->GetDynamicToolbarMaxHeight();
|
||||
|
@ -8704,9 +8705,31 @@ bool nsLayoutUtils::GetContentViewerSize(
|
|||
|
||||
bool nsLayoutUtils::UpdateCompositionBoundsForRCDRSF(
|
||||
ParentLayerRect& aCompBounds, nsPresContext* aPresContext) {
|
||||
SubtractDynamicToolbar shouldSubtractDynamicToolbar =
|
||||
SubtractDynamicToolbar::Yes;
|
||||
|
||||
if (RefPtr<MobileViewportManager> MVM =
|
||||
aPresContext->PresShell()->GetMobileViewportManager()) {
|
||||
CSSSize intrinsicCompositionSize = MVM->GetIntrinsicCompositionSize();
|
||||
|
||||
if (nsIScrollableFrame* rootScrollableFrame =
|
||||
aPresContext->PresShell()->GetRootScrollFrameAsScrollable()) {
|
||||
// Expand the composition size to include the area initially covered by
|
||||
// the dynamic toolbar only if the content is taller than the intrinsic
|
||||
// composition size (i.e. the dynamic toolbar should be able to move only
|
||||
// if the content is vertically scrollable).
|
||||
if (intrinsicCompositionSize.height <
|
||||
CSSPixel::FromAppUnits(
|
||||
CalculateScrollableRectForFrame(rootScrollableFrame, nullptr)
|
||||
.Height())) {
|
||||
shouldSubtractDynamicToolbar = SubtractDynamicToolbar::No;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LayoutDeviceIntSize contentSize;
|
||||
if (!GetContentViewerSize(aPresContext, contentSize,
|
||||
SubtractDynamicToolbar::No)) {
|
||||
shouldSubtractDynamicToolbar)) {
|
||||
return false;
|
||||
}
|
||||
aCompBounds = ParentLayerRect(ViewAs<ParentLayerPixel>(
|
||||
|
|
Загрузка…
Ссылка в новой задаче