Bug 1139675 - Simplify the APIs for getting and setting the pres shell resolution. r=mstange,mattwoodrow

This commit is contained in:
Botond Ballo 2015-03-06 18:07:59 -05:00
parent 273a985304
commit 2011a05c35
18 changed files with 107 additions and 119 deletions

View File

@ -490,7 +490,7 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
}
NS_IMETHODIMP
nsDOMWindowUtils::SetResolution(float aXResolution, float aYResolution)
nsDOMWindowUtils::SetResolution(float aResolution)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
@ -503,15 +503,15 @@ nsDOMWindowUtils::SetResolution(float aXResolution, float aYResolution)
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
sf->SetResolution(gfxSize(aXResolution, aYResolution));
presShell->SetResolution(aXResolution, aYResolution);
sf->SetResolution(aResolution);
presShell->SetResolution(aResolution);
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetResolutionAndScaleTo(float aXResolution, float aYResolution)
nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
@ -524,15 +524,15 @@ nsDOMWindowUtils::SetResolutionAndScaleTo(float aXResolution, float aYResolution
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
sf->SetResolutionAndScaleTo(gfxSize(aXResolution, aYResolution));
presShell->SetResolutionAndScaleTo(aXResolution, aYResolution);
sf->SetResolutionAndScaleTo(aResolution);
presShell->SetResolutionAndScaleTo(aResolution);
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetResolution(float* aXResolution, float* aYResolution)
nsDOMWindowUtils::GetResolution(float* aResolution)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@ -543,12 +543,9 @@ nsDOMWindowUtils::GetResolution(float* aXResolution, float* aYResolution)
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
const gfxSize& res = sf->GetResolution();
*aXResolution = res.width;
*aYResolution = res.height;
*aResolution = sf->GetResolution();
} else {
*aXResolution = presShell->GetXResolution();
*aYResolution = presShell->GetYResolution();
*aResolution = presShell->GetResolution();
}
return NS_OK;

View File

@ -50,7 +50,7 @@ interface nsITranslationNodeList;
interface nsIJSRAIIHelper;
interface nsIContentPermissionRequest;
[scriptable, uuid(b39cb73f-ff99-4744-9780-2c26f830c6f7)]
[scriptable, uuid(dde97573-f4cf-45ce-bbb0-5af4e5f77440)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -205,15 +205,14 @@ interface nsIDOMWindowUtils : nsISupports {
*
* The effect of this API is for gfx code to allocate more or fewer
* pixels for rescalable content by a factor of |resolution| in
* either or both dimensions. The scale at which the content is
* displayed does not change; if that is desired, use
* setResolutionAndScaleTo() instead.
* both dimensions. The scale at which the content is displayed does
* not change; if that is desired, use setResolutionAndScaleTo() instead.
*
* The caller of this method must have chrome privileges.
*/
void setResolution(in float aXResolution, in float aYResolution);
void setResolution(in float aResolution);
void getResolution(out float aXResolution, out float aYResolution);
void getResolution(out float aResolution);
/**
* Similar to setResolution(), but also scales the content by the
@ -226,7 +225,7 @@ interface nsIDOMWindowUtils : nsISupports {
*
* The caller of this method must have chrome privileges.
*/
void setResolutionAndScaleTo(in float aXResolution, in float aYResolution);
void setResolutionAndScaleTo(in float aResolution);
/**
* Whether the resolution has been set by the user.

View File

@ -390,7 +390,7 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
// This is the root layer, so the cumulative resolution is the same
// as the resolution.
metrics.SetPresShellResolution(metrics.GetCumulativeResolution().ToScaleFactor().scale);
utils->SetResolutionAndScaleTo(metrics.GetPresShellResolution(), metrics.GetPresShellResolution());
utils->SetResolutionAndScaleTo(metrics.GetPresShellResolution());
CSSSize scrollPort = metrics.CalculateCompositedSizeInCssPixels();
utils->SetScrollPositionClampingScrollPortSize(scrollPort.width, scrollPort.height);
@ -917,8 +917,7 @@ TabChild::Observe(nsISupports *aSubject,
// until we we get an inner size.
if (HasValidInnerSize()) {
InitializeRootMetrics();
utils->SetResolutionAndScaleTo(mLastRootMetrics.GetPresShellResolution(),
mLastRootMetrics.GetPresShellResolution());
utils->SetResolutionAndScaleTo(mLastRootMetrics.GetPresShellResolution());
HandlePossibleViewportChange(mInnerSize);
}
}
@ -2344,7 +2343,7 @@ TabChild::GetPresShellResolution() const
if (!shell) {
return 1.0f;
}
return shell->GetXResolution();
return shell->GetResolution();
}
bool

View File

@ -230,8 +230,8 @@ nsPluginInstanceOwner::GetImageContainer()
// NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
// into, set y-flip flags, etc, so we do this at the beginning.
gfxSize resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale2D(resolution.width, resolution.height)).Size();
float resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution)).Size();
mInstance->NotifySize(nsIntSize(screenSize.width, screenSize.height));
container = LayerManager::CreateImageContainer();

View File

@ -208,7 +208,7 @@ APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
// last paint.
float presShellResolution = aMetrics.GetPresShellResolution()
* aMetrics.GetAsyncZoom().scale;
aUtils->SetResolutionAndScaleTo(presShellResolution, presShellResolution);
aUtils->SetResolutionAndScaleTo(presShellResolution);
SetDisplayPortMargins(aUtils, content, aMetrics);
}

View File

@ -4442,8 +4442,9 @@ FrameLayerBuilder::GetPaintedLayerScaleForFrame(nsIFrame* aFrame)
}
}
float presShellResolution = last->PresContext()->PresShell()->GetResolution();
return PredictScaleForContent(aFrame, last,
last->PresContext()->PresShell()->GetResolution());
gfxSize(presShellResolution, presShellResolution));
}
#ifdef MOZ_DUMP_PAINTING

View File

@ -408,16 +408,16 @@ IsElementClickableAndReadable(nsIFrame* aFrame, WidgetGUIEvent* aEvent, const Ev
nsSize frameSize = aFrame->GetSize();
nsPresContext* pc = aFrame->PresContext();
nsIPresShell* presShell = pc->PresShell();
gfxSize cumulativeResolution = presShell->GetCumulativeResolution();
if ((pc->AppUnitsToGfxUnits(frameSize.height) * cumulativeResolution.height) < limitReadableSize ||
(pc->AppUnitsToGfxUnits(frameSize.width) * cumulativeResolution.width) < limitReadableSize) {
float cumulativeResolution = presShell->GetCumulativeResolution();
if ((pc->AppUnitsToGfxUnits(frameSize.height) * cumulativeResolution) < limitReadableSize ||
(pc->AppUnitsToGfxUnits(frameSize.width) * cumulativeResolution) < limitReadableSize) {
return false;
}
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aFrame));
if (fm) {
if ((pc->AppUnitsToGfxUnits(fm->EmHeight()) * cumulativeResolution.height) < limitReadableSize) {
if ((pc->AppUnitsToGfxUnits(fm->EmHeight()) * cumulativeResolution) < limitReadableSize) {
return false;
}
}

View File

@ -800,7 +800,7 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame,
// Only the root scrollable frame for a given presShell should pick up
// the presShell's resolution. All the other frames are 1.0.
if (aScrollFrame == presShell->GetRootScrollFrame()) {
metrics.SetPresShellResolution(presShell->GetXResolution());
metrics.SetPresShellResolution(presShell->GetResolution());
} else {
metrics.SetPresShellResolution(1.0f);
}
@ -886,10 +886,10 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame,
} else {
LayoutDeviceIntSize contentSize;
if (nsLayoutUtils::GetContentViewerSize(presContext, contentSize)) {
LayoutDeviceToParentLayerScale2D scale;
LayoutDeviceToParentLayerScale scale;
if (presContext->GetParentPresContext()) {
gfxSize res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToParentLayerScale2D(res.width, res.height);
float res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToParentLayerScale(res);
}
metrics.mCompositionBounds.SizeTo(contentSize * scale);
}
@ -1640,7 +1640,7 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(nsDisplayListBuilder* aB
}
ContainerLayerParameters containerParameters
(presShell->GetXResolution(), presShell->GetYResolution());
(presShell->GetResolution(), presShell->GetResolution());
nsRefPtr<ContainerLayer> root = layerBuilder->
BuildContainerLayerFor(aBuilder, layerManager, frame, nullptr, this,
containerParameters, nullptr);
@ -4207,8 +4207,8 @@ nsDisplaySubDocument::ComputeFrameMetrics(Layer* aLayer,
bool isRootContentDocument = presContext->IsRootContentDocument();
nsIPresShell* presShell = presContext->PresShell();
ContainerLayerParameters params(
aContainerParameters.mXScale * presShell->GetXResolution(),
aContainerParameters.mYScale * presShell->GetYResolution(),
aContainerParameters.mXScale * presShell->GetResolution(),
aContainerParameters.mYScale * presShell->GetResolution(),
nsIntPoint(), aContainerParameters);
if ((mFlags & GENERATE_SCROLLABLE_LAYER) &&
rootScrollFrame->GetContent() &&
@ -4330,15 +4330,15 @@ nsDisplayResolution::BuildLayer(nsDisplayListBuilder* aBuilder,
const ContainerLayerParameters& aContainerParameters) {
nsIPresShell* presShell = mFrame->PresContext()->PresShell();
ContainerLayerParameters containerParameters(
presShell->GetXResolution(), presShell->GetYResolution(), nsIntPoint(),
presShell->GetResolution(), presShell->GetResolution(), nsIntPoint(),
aContainerParameters);
nsRefPtr<Layer> layer = nsDisplaySubDocument::BuildLayer(
aBuilder, aManager, containerParameters);
layer->SetPostScale(1.0f / presShell->GetXResolution(),
1.0f / presShell->GetYResolution());
layer->SetPostScale(1.0f / presShell->GetResolution(),
1.0f / presShell->GetResolution());
layer->AsContainerLayer()->SetScaleToResolution(
presShell->ScaleToResolution(), presShell->GetXResolution());
presShell->ScaleToResolution(), presShell->GetResolution());
return layer.forget();
}

View File

@ -1381,17 +1381,15 @@ public:
*
* The resolution defaults to 1.0.
*/
virtual nsresult SetResolution(float aXResolution, float aYResolution) = 0;
gfxSize GetResolution() { return gfxSize(mXResolution, mYResolution); }
float GetXResolution() { return mXResolution; }
float GetYResolution() { return mYResolution; }
virtual gfxSize GetCumulativeResolution() = 0;
virtual nsresult SetResolution(float aResolution) = 0;
float GetResolution() { return mResolution; }
virtual float GetCumulativeResolution() = 0;
/**
* Similar to SetResolution() but also increases the scale of the content
* by the same amount.
*/
virtual nsresult SetResolutionAndScaleTo(float aXResolution, float aYResolution) = 0;
virtual nsresult SetResolutionAndScaleTo(float aResolution) = 0;
/**
* Return whether we are scaling to the set resolution.
@ -1718,9 +1716,8 @@ protected:
nscolor mCanvasBackgroundColor;
// Used to force allocation and rendering of proportionally more or
// less pixels in the given dimension.
float mXResolution;
float mYResolution;
// less pixels in both dimensions.
float mResolution;
int16_t mSelectionFlags;

View File

@ -893,9 +893,9 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
if (isRoot) {
// the base rect for root scroll frames is specified in the parent document
// coordinate space, so it doesn't include the local resolution.
gfxSize localRes = presContext->PresShell()->GetResolution();
parentRes.xScale /= localRes.width;
parentRes.yScale /= localRes.height;
float localRes = presContext->PresShell()->GetResolution();
parentRes.xScale /= localRes;
parentRes.yScale /= localRes;
}
ScreenRect screenRect = LayoutDeviceRect::FromAppUnits(base, auPerDevPixel)
* parentRes;
@ -2815,7 +2815,7 @@ CalculateFrameMetricsForDisplayPort(nsIScrollableFrame* aScrollFrame) {
if (frame == presShell->GetRootScrollFrame()) {
// Only the root scrollable frame for a given presShell should pick up
// the presShell's resolution. All the other frames are 1.0.
resolution = presShell->GetXResolution();
resolution = presShell->GetResolution();
}
// Note: unlike in ComputeFrameMetrics(), we don't know the full cumulative
// resolution including FrameMetrics::mExtraResolution, because layout hasn't
@ -2839,8 +2839,9 @@ CalculateFrameMetricsForDisplayPort(nsIScrollableFrame* aScrollFrame) {
LayoutDeviceToParentLayerScale2D compBoundsScale;
if (frame == presShell->GetRootScrollFrame() && presContext->IsRootContentDocument()) {
if (presContext->GetParentPresContext()) {
gfxSize res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
compBoundsScale = LayoutDeviceToParentLayerScale2D(res.width, res.height);
float res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
compBoundsScale = LayoutDeviceToParentLayerScale2D(
LayoutDeviceToParentLayerScale(res));
}
} else {
compBoundsScale = cumulativeResolution * layerToParentLayerScale;
@ -7544,12 +7545,12 @@ nsLayoutUtils::CalculateCompositionSizeForFrame(nsIFrame* aFrame)
widgetBounds.height * auPerDevPixel);
#ifdef MOZ_WIDGET_ANDROID
nsRect frameRect = aFrame->GetRect();
gfxSize cumulativeResolution = presShell->GetCumulativeResolution();
LayoutDeviceToParentLayerScale2D layoutToParentLayerScale =
float cumulativeResolution = presShell->GetCumulativeResolution();
LayoutDeviceToParentLayerScale layoutToParentLayerScale =
// The ScreenToParentLayerScale should be mTransformScale which is
// not calculated yet, but we don't yet handle CSS transforms, so we
// assume it's 1 here.
LayoutDeviceToLayerScale2D(cumulativeResolution.width, cumulativeResolution.height) *
LayoutDeviceToLayerScale(cumulativeResolution) *
LayerToScreenScale(1.0) * ScreenToParentLayerScale(1.0);
ParentLayerRect frameRectPixels =
LayoutDeviceRect::FromAppUnits(frameRect, auPerDevPixel)
@ -7558,7 +7559,7 @@ nsLayoutUtils::CalculateCompositionSizeForFrame(nsIFrame* aFrame)
// Our return value is in appunits of the parent, so we need to
// include the resolution.
size.height =
NSToCoordRound(frameRect.height * cumulativeResolution.height);
NSToCoordRound(frameRect.height * cumulativeResolution);
}
#endif
} else {
@ -7605,9 +7606,9 @@ nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
// TODO: Reuse that code here.
nsIPresShell* rootPresShell = rootPresContext->PresShell();
if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) {
LayoutDeviceToLayerScale cumulativeResolution(
rootPresShell->GetCumulativeResolution().width
* nsLayoutUtils::GetTransformToAncestorScale(rootFrame).width);
LayoutDeviceToLayerScale2D cumulativeResolution(
rootPresShell->GetCumulativeResolution()
* nsLayoutUtils::GetTransformToAncestorScale(rootFrame));
int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel();
LayerSize frameSize =
(LayoutDeviceRect::FromAppUnits(rootFrame->GetRect(), rootAUPerDevPixel)
@ -7631,10 +7632,10 @@ nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
} else {
LayoutDeviceIntSize contentSize;
if (nsLayoutUtils::GetContentViewerSize(rootPresContext, contentSize)) {
LayoutDeviceToLayerScale2D scale;
LayoutDeviceToLayerScale scale;
if (rootPresContext->GetParentPresContext()) {
gfxSize res = rootPresContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToLayerScale2D(res.width, res.height);
float res = rootPresContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToLayerScale(res);
}
rootCompositionSize = contentSize * scale * LayerToScreenScale(1.0f);
}
@ -7706,9 +7707,9 @@ nsLayoutUtils::CalculateExpandedScrollableRect(nsIFrame* aFrame)
if (aFrame == aFrame->PresContext()->PresShell()->GetRootScrollFrame()) {
// the composition size for the root scroll frame does not include the
// local resolution, so we adjust.
gfxSize res = aFrame->PresContext()->PresShell()->GetResolution();
compSize.width = NSToCoordRound(compSize.width / ((float) res.width));
compSize.height = NSToCoordRound(compSize.height / ((float) res.height));
float res = aFrame->PresContext()->PresShell()->GetResolution();
compSize.width = NSToCoordRound(compSize.width / res);
compSize.height = NSToCoordRound(compSize.height / res);
}
if (scrollableRect.width < compSize.width) {

View File

@ -776,8 +776,7 @@ PresShell::PresShell()
mPresArenaAllocCount = 0;
#endif
mRenderFlags = 0;
mXResolution = 1.0;
mYResolution = 1.0;
mResolution = 1.0;
mViewportOverridden = false;
mScrollPositionClampingScrollPortSizeSet = false;
@ -5516,17 +5515,16 @@ void PresShell::SetIgnoreViewportScrolling(bool aIgnore)
SetRenderingState(state);
}
nsresult PresShell::SetResolutionImpl(float aXResolution, float aYResolution, bool aScaleToResolution)
nsresult PresShell::SetResolutionImpl(float aResolution, bool aScaleToResolution)
{
if (!(aXResolution > 0.0 && aYResolution > 0.0)) {
if (!(aResolution > 0.0)) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (aXResolution == mXResolution && aYResolution == mYResolution) {
if (aResolution == mResolution) {
return NS_OK;
}
RenderingState state(this);
state.mXResolution = aXResolution;
state.mYResolution = aYResolution;
state.mResolution = aResolution;
SetRenderingState(state);
mScaleToResolution = aScaleToResolution;
@ -5538,12 +5536,12 @@ bool PresShell::ScaleToResolution() const
return mScaleToResolution;
}
gfxSize PresShell::GetCumulativeResolution()
float PresShell::GetCumulativeResolution()
{
gfxSize resolution = GetResolution();
float resolution = GetResolution();
nsPresContext* parentCtx = GetPresContext()->GetParentPresContext();
if (parentCtx) {
resolution = resolution * parentCtx->PresShell()->GetCumulativeResolution();
resolution *= parentCtx->PresShell()->GetCumulativeResolution();
}
return resolution;
}
@ -5560,8 +5558,7 @@ void PresShell::SetRenderingState(const RenderingState& aState)
}
mRenderFlags = aState.mRenderFlags;
mXResolution = aState.mXResolution;
mYResolution = aState.mYResolution;
mResolution = aState.mResolution;
}
void PresShell::SynthesizeMouseMove(bool aFromScroll)

View File

@ -198,14 +198,14 @@ public:
virtual void SetIgnoreViewportScrolling(bool aIgnore) MOZ_OVERRIDE;
virtual nsresult SetResolution(float aXResolution, float aYResolution) MOZ_OVERRIDE {
return SetResolutionImpl(aXResolution, aYResolution, /* aScaleToResolution = */ false);
virtual nsresult SetResolution(float aResolution) MOZ_OVERRIDE {
return SetResolutionImpl(aResolution, /* aScaleToResolution = */ false);
}
virtual nsresult SetResolutionAndScaleTo(float aXResolution, float aYResolution) MOZ_OVERRIDE {
return SetResolutionImpl(aXResolution, aYResolution, /* aScaleToResolution = */ true);
virtual nsresult SetResolutionAndScaleTo(float aResolution) MOZ_OVERRIDE {
return SetResolutionImpl(aResolution, /* aScaleToResolution = */ true);
}
virtual bool ScaleToResolution() const MOZ_OVERRIDE;
virtual gfxSize GetCumulativeResolution() MOZ_OVERRIDE;
virtual float GetCumulativeResolution() MOZ_OVERRIDE;
//nsIViewObserver interface
@ -462,12 +462,10 @@ protected:
struct RenderingState {
explicit RenderingState(PresShell* aPresShell)
: mXResolution(aPresShell->mXResolution)
, mYResolution(aPresShell->mYResolution)
: mResolution(aPresShell->mResolution)
, mRenderFlags(aPresShell->mRenderFlags)
{ }
float mXResolution;
float mYResolution;
float mResolution;
RenderFlags mRenderFlags;
};
@ -480,8 +478,7 @@ protected:
~AutoSaveRestoreRenderingState()
{
mPresShell->mRenderFlags = mOldState.mRenderFlags;
mPresShell->mXResolution = mOldState.mXResolution;
mPresShell->mYResolution = mOldState.mYResolution;
mPresShell->mResolution = mOldState.mResolution;
}
PresShell* mPresShell;
@ -760,7 +757,7 @@ protected:
// A list of images that are visible or almost visible.
nsTHashtable< nsRefPtrHashKey<nsIImageLoadingContent> > mVisibleImages;
nsresult SetResolutionImpl(float aXResolution, float aYResolution, bool aScaleToResolution);
nsresult SetResolutionImpl(float aResolution, bool aScaleToResolution);
#ifdef DEBUG
// The reflow root under which we're currently reflowing. Null when

View File

@ -21,7 +21,7 @@ public:
nsPresState()
: mContentData(nullptr)
, mScrollState(0, 0)
, mResolution(1.0, 1.0)
, mResolution(1.0)
, mScaleToResolution(false)
, mDisabledSet(false)
, mDisabled(false)
@ -37,12 +37,12 @@ public:
return mScrollState;
}
void SetResolution(const gfxSize& aSize)
void SetResolution(float aSize)
{
mResolution = aSize;
}
gfxSize GetResolution() const
float GetResolution() const
{
return mResolution;
}
@ -93,7 +93,7 @@ public:
protected:
nsCOMPtr<nsISupports> mContentData;
nsPoint mScrollState;
gfxSize mResolution;
float mResolution;
bool mScaleToResolution;
bool mDisabledSet;
bool mDisabled;

View File

@ -1880,7 +1880,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mScrollPosAtLastPaint(0, 0)
, mRestorePos(-1, -1)
, mLastPos(-1, -1)
, mResolution(1.0, 1.0)
, mResolution(1.0)
, mScrollPosForLayerPixelAlignment(-1, -1)
, mLastUpdateImagesPos(-1, -1)
, mNeverHasVerticalScrollbar(false)
@ -3290,14 +3290,14 @@ ScrollFrameHelper::GetScrollPositionClampingScrollPortSize() const
return mScrollPort.Size();
}
gfxSize
float
ScrollFrameHelper::GetResolution() const
{
return mResolution;
}
void
ScrollFrameHelper::SetResolution(const gfxSize& aResolution)
ScrollFrameHelper::SetResolution(float aResolution)
{
mResolution = aResolution;
mIsResolutionSet = true;
@ -3305,7 +3305,7 @@ ScrollFrameHelper::SetResolution(const gfxSize& aResolution)
}
void
ScrollFrameHelper::SetResolutionAndScaleTo(const gfxSize& aResolution)
ScrollFrameHelper::SetResolutionAndScaleTo(float aResolution)
{
MOZ_ASSERT(mIsRoot); // This API should only be called on root scroll frames.
mResolution = aResolution;
@ -5227,9 +5227,9 @@ ScrollFrameHelper::RestoreState(nsPresState* aState)
if (mIsRoot) {
nsIPresShell* presShell = mOuter->PresContext()->PresShell();
if (mScaleToResolution) {
presShell->SetResolutionAndScaleTo(mResolution.width, mResolution.height);
presShell->SetResolutionAndScaleTo(mResolution);
} else {
presShell->SetResolution(mResolution.width, mResolution.height);
presShell->SetResolution(mResolution);
}
}
}

View File

@ -177,9 +177,9 @@ public:
// Get the scroll range assuming the scrollport has size (aWidth, aHeight).
nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const;
nsSize GetScrollPositionClampingScrollPortSize() const;
gfxSize GetResolution() const;
void SetResolution(const gfxSize& aResolution);
void SetResolutionAndScaleTo(const gfxSize& aResolution);
float GetResolution() const;
void SetResolution(float aResolution);
void SetResolutionAndScaleTo(float aResolution);
void FlingSnap(const mozilla::CSSPoint& aDestination);
void ScrollSnap();
void ScrollSnap(const nsPoint &aDestination);
@ -433,7 +433,7 @@ public:
nsPoint mLastPos;
// The current resolution derived from the zoom level and device pixel ratio.
gfxSize mResolution;
float mResolution;
nsExpirationState mActivityExpirationState;
@ -689,13 +689,13 @@ public:
virtual nsSize GetScrollPositionClampingScrollPortSize() const MOZ_OVERRIDE {
return mHelper.GetScrollPositionClampingScrollPortSize();
}
virtual gfxSize GetResolution() const MOZ_OVERRIDE {
virtual float GetResolution() const MOZ_OVERRIDE {
return mHelper.GetResolution();
}
virtual void SetResolution(const gfxSize& aResolution) MOZ_OVERRIDE {
virtual void SetResolution(float aResolution) MOZ_OVERRIDE {
return mHelper.SetResolution(aResolution);
}
virtual void SetResolutionAndScaleTo(const gfxSize& aResolution) MOZ_OVERRIDE {
virtual void SetResolutionAndScaleTo(float aResolution) MOZ_OVERRIDE {
return mHelper.SetResolutionAndScaleTo(aResolution);
}
virtual nsSize GetLineScrollAmount() const MOZ_OVERRIDE {
@ -1070,13 +1070,13 @@ public:
virtual nsSize GetScrollPositionClampingScrollPortSize() const MOZ_OVERRIDE {
return mHelper.GetScrollPositionClampingScrollPortSize();
}
virtual gfxSize GetResolution() const MOZ_OVERRIDE {
virtual float GetResolution() const MOZ_OVERRIDE {
return mHelper.GetResolution();
}
virtual void SetResolution(const gfxSize& aResolution) MOZ_OVERRIDE {
virtual void SetResolution(float aResolution) MOZ_OVERRIDE {
return mHelper.SetResolution(aResolution);
}
virtual void SetResolutionAndScaleTo(const gfxSize& aResolution) MOZ_OVERRIDE {
virtual void SetResolutionAndScaleTo(float aResolution) MOZ_OVERRIDE {
return mHelper.SetResolutionAndScaleTo(aResolution);
}
virtual nsSize GetLineScrollAmount() const MOZ_OVERRIDE {

View File

@ -148,17 +148,17 @@ public:
/**
* Get the element resolution.
*/
virtual gfxSize GetResolution() const = 0;
virtual float GetResolution() const = 0;
/**
* Set the element resolution.
*/
virtual void SetResolution(const gfxSize& aResolution) = 0;
virtual void SetResolution(float aResolution) = 0;
/**
* Set the element resolution and specify that content should be scaled by
* the amount of the resolution. This is only meaningful for root scroll
* frames. See nsIDOMWindowUtils.setResolutionAndScaleTo().
*/
virtual void SetResolutionAndScaleTo(const gfxSize& aResolution) = 0;
virtual void SetResolutionAndScaleTo(float aResolution) = 0;
/**
* Return how much we would try to scroll by in each direction if
* asked to scroll by one "line" vertically and horizontally.

View File

@ -455,7 +455,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIScrollableFrame *sf = presShell->GetRootScrollFrameAsScrollable();
bool constructResolutionItem = subdocRootFrame &&
(presShell->GetXResolution() != 1.0 || presShell->GetYResolution() != 1.0);
(presShell->GetResolution() != 1.0);
bool constructZoomItem = subdocRootFrame && parentAPD != subdocAPD;
bool needsOwnLayer = false;
if (constructResolutionItem ||

View File

@ -1703,7 +1703,7 @@ AndroidBridge::GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId,
static float
GetScaleFactor(nsPresContext* aPresContext) {
nsIPresShell* presShell = aPresContext->PresShell();
LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution().width);
LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution());
return cumulativeResolution.scale;
}