Bug 1201529 - Ensure that zoomable scrollframes return true from WantAsyncScroll(). r=botond

This commit is contained in:
Kartikaya Gupta 2015-09-11 21:58:16 -04:00
parent 4b1cd64b05
commit 5c5b66455e
7 changed files with 54 additions and 1 deletions

View File

@ -5,6 +5,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=982141
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no">
<title>Test for Bug 982141, helper page</title>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript">
@ -87,7 +88,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=982141
}
</script>
</head>
<body style="overflow: hidden;"><!-- Make sure the root frame is not scrollable -->
<body style="overflow: hidden;"><!-- This combined with the user-scalable=no ensures the root frame is not scrollable -->
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=982141">Mozilla Bug 982141</a>
<!-- A scrollable subframe, with enough content to make it have a nonzero scroll range -->
<div style="height: 50px; width: 50px; overflow: scroll">

View File

@ -4,6 +4,11 @@
-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%">
<!-- There is a bug with MultiTiledContentClient that causes improper painting;
bug 1204076 is on file for this issue. As a temporary workaround, we set
user-scalable=no here so that WantAsyncZoom() returns false and we don't
use a MultiTiledContentClient. Once bug 1204076 is fixed, we can remove this. -->
<meta xmlns="http://www.w3.org/1999/xhtml" name="viewport" content="user-scalable=no"/>
<title>Testcase for small circles</title>
<!--From https://bugzilla.mozilla.org/show_bug.cgi?id=1143303 -->

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -215,6 +215,14 @@ ZoomConstraintsClient::RefreshZoomConstraints()
}
}
// We only ever create a ZoomConstraintsClient for an RCD, so the RSF of
// the presShell must be the RCD-RSF (if it exists).
MOZ_ASSERT(mPresShell->GetPresContext()->IsRootContentDocument());
if (nsIScrollableFrame* rcdrsf = mPresShell->GetRootScrollFrameAsScrollable()) {
ZCC_LOG("Notifying RCD-RSF that it is zoomable: %d\n", zoomConstraints.mAllowZoom);
rcdrsf->SetZoomableByAPZ(zoomConstraints.mAllowZoom);
}
ScrollableLayerGuid newGuid(0, presShellId, viewId);
if (mGuid && mGuid.value() != newGuid) {
ZCC_LOG("Clearing old constraints in %p for { %u, %" PRIu64 " }\n",

View File

@ -1108,9 +1108,26 @@ static bool IsFocused(nsIContent* aContent)
}
#endif
void
ScrollFrameHelper::SetZoomableByAPZ(bool aZoomable)
{
if (mZoomableByAPZ != aZoomable) {
// We might be changing the result of WantAsyncScroll() so schedule a
// paint to make sure we pick up the result of that change.
mZoomableByAPZ = aZoomable;
mOuter->SchedulePaint();
}
}
bool
ScrollFrameHelper::WantAsyncScroll() const
{
// If zooming is allowed, and this is a frame that's allowed to zoom, then
// we want it to be async-scrollable or zooming will not be permitted.
if (mZoomableByAPZ) {
return true;
}
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
uint32_t directions = mOuter->GetScrollTargetFrame()->GetPerceivedScrollingDirections();
bool isVScrollable = !!(directions & nsIScrollableFrame::VERTICAL) &&
@ -1831,6 +1848,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mIgnoreMomentumScroll(false)
, mScaleToResolution(false)
, mTransformingByAPZ(false)
, mZoomableByAPZ(false)
, mVelocityQueue(aOuter->PresContext())
{
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {

View File

@ -360,6 +360,8 @@ public:
bool IsTransformingByAPZ() const {
return mTransformingByAPZ;
}
void SetZoomableByAPZ(bool aZoomable);
bool UsesContainerScrolling() const;
void ScheduleSyntheticMouseMove();
@ -534,6 +536,9 @@ public:
// (as best as we can tell on the main thread, anyway).
bool mTransformingByAPZ:1;
// True if the APZ is allowed to zoom this scrollframe.
bool mZoomableByAPZ:1;
mozilla::layout::ScrollVelocityQueue mVelocityQueue;
protected:
@ -922,6 +927,9 @@ public:
bool IsTransformingByAPZ() const override {
return mHelper.IsTransformingByAPZ();
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
@ -1330,6 +1338,9 @@ public:
bool IsTransformingByAPZ() const override {
return mHelper.IsTransformingByAPZ();
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;

View File

@ -444,6 +444,11 @@ public:
virtual void SetTransformingByAPZ(bool aTransforming) = 0;
virtual bool IsTransformingByAPZ() const = 0;
/**
* Notify this scroll frame that it can be zoomed by APZ.
*/
virtual void SetZoomableByAPZ(bool aZoomable) = 0;
/**
* Whether or not this frame uses containerful scrolling.
*/

View File

@ -1,5 +1,10 @@
<!DOCTYPE HTML>
<html reftest-async-zoom="2">
<!-- There is a bug with MultiTiledContentClient that causes improper painting;
bug 1204076 is on file for this issue. As a temporary workaround, we set
user-scalable=no here so that WantAsyncZoom() returns false and we don't
use a MultiTiledContentClient. Once bug 1204076 is fixed, we can remove this. -->
<meta name="viewport" content="user-scalable=no">
<body>
<div style="position:absolute; top: 0; left: 0; width: 100px; height: 100px; background: red;"></div>
</body>