mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 974242 - Bring FullZoom into nsDocument::GetViewportInfo. r=mbrubeck, r=kats
--HG-- extra : rebase_source : 4fd84defb47c9eb5bcea849fde61e6e09dc5e9a3
This commit is contained in:
parent
11654569cc
commit
c9284798c3
@ -26,8 +26,10 @@ class MOZ_STACK_CLASS nsViewportInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsViewportInfo(const mozilla::ScreenIntSize& aDisplaySize,
|
nsViewportInfo(const mozilla::ScreenIntSize& aDisplaySize,
|
||||||
bool aAllowZoom = true, bool aAllowDoubleTapZoom = true) :
|
const mozilla::CSSToScreenScale& aDefaultZoom,
|
||||||
mDefaultZoom(1.0),
|
bool aAllowZoom,
|
||||||
|
bool aAllowDoubleTapZoom) :
|
||||||
|
mDefaultZoom(aDefaultZoom),
|
||||||
mAutoSize(true),
|
mAutoSize(true),
|
||||||
mAllowZoom(aAllowZoom),
|
mAllowZoom(aAllowZoom),
|
||||||
mAllowDoubleTapZoom(aAllowDoubleTapZoom)
|
mAllowDoubleTapZoom(aAllowDoubleTapZoom)
|
||||||
|
@ -7501,15 +7501,27 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||||||
nsViewportInfo
|
nsViewportInfo
|
||||||
nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
||||||
{
|
{
|
||||||
|
nsPresContext* context = mPresShell->GetPresContext();
|
||||||
|
float fullZoom = context ? context->GetFullZoom() : 1.0;
|
||||||
|
fullZoom = (fullZoom == 0.0) ? 1.0 : fullZoom;
|
||||||
|
CSSToScreenScale defaultScale = CSSToLayoutDeviceScale(fullZoom) *
|
||||||
|
LayoutDeviceToScreenScale(1.0);
|
||||||
|
|
||||||
// In cases where the width of the CSS viewport is less than or equal to the width
|
// In cases where the width of the CSS viewport is less than or equal to the width
|
||||||
// of the display (i.e. width <= device-width) then we disable double-tap-to-zoom
|
// of the display (i.e. width <= device-width) then we disable double-tap-to-zoom
|
||||||
// behaviour. See bug 941995 for details.
|
// behaviour. See bug 941995 for details.
|
||||||
|
|
||||||
switch (mViewportType) {
|
switch (mViewportType) {
|
||||||
case DisplayWidthHeight:
|
case DisplayWidthHeight:
|
||||||
return nsViewportInfo(aDisplaySize);
|
return nsViewportInfo(aDisplaySize,
|
||||||
|
defaultScale,
|
||||||
|
/*allowZoom*/ true,
|
||||||
|
/*allowDoubleTapZoom*/ true);
|
||||||
case DisplayWidthHeightNoZoom:
|
case DisplayWidthHeightNoZoom:
|
||||||
return nsViewportInfo(aDisplaySize, /*allowZoom*/ false, /*allowDoubleTapZoom*/ false);
|
return nsViewportInfo(aDisplaySize,
|
||||||
|
defaultScale,
|
||||||
|
/*allowZoom*/ false,
|
||||||
|
/*allowDoubleTapZoom*/ false);
|
||||||
case Unknown:
|
case Unknown:
|
||||||
{
|
{
|
||||||
nsAutoString viewport;
|
nsAutoString viewport;
|
||||||
@ -7529,7 +7541,10 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
|||||||
{
|
{
|
||||||
// We're making an assumption that the docType can't change here
|
// We're making an assumption that the docType can't change here
|
||||||
mViewportType = DisplayWidthHeight;
|
mViewportType = DisplayWidthHeight;
|
||||||
return nsViewportInfo(aDisplaySize, /*allowZoom*/true, /*allowDoubleTapZoom*/false);
|
return nsViewportInfo(aDisplaySize,
|
||||||
|
defaultScale,
|
||||||
|
/*allowZoom*/true,
|
||||||
|
/*allowDoubleTapZoom*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7538,7 +7553,10 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
|||||||
GetHeaderData(nsGkAtoms::handheldFriendly, handheldFriendly);
|
GetHeaderData(nsGkAtoms::handheldFriendly, handheldFriendly);
|
||||||
if (handheldFriendly.EqualsLiteral("true")) {
|
if (handheldFriendly.EqualsLiteral("true")) {
|
||||||
mViewportType = DisplayWidthHeight;
|
mViewportType = DisplayWidthHeight;
|
||||||
return nsViewportInfo(aDisplaySize, /*allowZoom*/true, /*allowDoubleTapZoom*/false);
|
return nsViewportInfo(aDisplaySize,
|
||||||
|
defaultScale,
|
||||||
|
/*allowZoom*/true,
|
||||||
|
/*allowDoubleTapZoom*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug 940036. This is bad. When FirefoxOS was built, apps installed
|
// Bug 940036. This is bad. When FirefoxOS was built, apps installed
|
||||||
@ -7561,7 +7579,10 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
|||||||
"ImplicitMetaViewportTagFallback");
|
"ImplicitMetaViewportTagFallback");
|
||||||
}
|
}
|
||||||
mViewportType = DisplayWidthHeightNoZoom;
|
mViewportType = DisplayWidthHeightNoZoom;
|
||||||
return nsViewportInfo(aDisplaySize, /*allowZoom*/false, /*allowDoubleTapZoom*/false);
|
return nsViewportInfo(aDisplaySize,
|
||||||
|
defaultScale,
|
||||||
|
/*allowZoom*/false,
|
||||||
|
/*allowDoubleTapZoom*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7652,8 +7673,11 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
|||||||
if (mValidHeight && !aDisplaySize.IsEmpty()) {
|
if (mValidHeight && !aDisplaySize.IsEmpty()) {
|
||||||
size.width = size.height * aDisplaySize.width / aDisplaySize.height;
|
size.width = size.height * aDisplaySize.width / aDisplaySize.height;
|
||||||
} else {
|
} else {
|
||||||
|
// Stretch CSS pixel size of viewport to keep device pixel size
|
||||||
|
// unchanged after full zoom applied.
|
||||||
|
// See bug 974242.
|
||||||
size.width = Preferences::GetInt("browser.viewport.desktopWidth",
|
size.width = Preferences::GetInt("browser.viewport.desktopWidth",
|
||||||
kViewportDefaultScreenWidth);
|
kViewportDefaultScreenWidth) / fullZoom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7664,10 +7688,13 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
|||||||
size.height = size.width;
|
size.height = size.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now convert the scale into device pixels per CSS pixel.
|
|
||||||
|
// Now convert the scale into device pixels per CSS pixel base on this formula
|
||||||
|
// CSSPixel x widget scale x full zoom = LayoutDevicePixel
|
||||||
nsIWidget *widget = nsContentUtils::WidgetForDocument(this);
|
nsIWidget *widget = nsContentUtils::WidgetForDocument(this);
|
||||||
CSSToLayoutDeviceScale pixelRatio = widget ? widget->GetDefaultScale()
|
CSSToLayoutDeviceScale pixelRatio = CSSToLayoutDeviceScale(
|
||||||
: CSSToLayoutDeviceScale(1.0f);
|
(widget ? widget->GetDefaultScale().scale : 1.0f) * fullZoom);
|
||||||
|
|
||||||
CSSToScreenScale scaleFloat = mScaleFloat * pixelRatio;
|
CSSToScreenScale scaleFloat = mScaleFloat * pixelRatio;
|
||||||
CSSToScreenScale scaleMinFloat = mScaleMinFloat * pixelRatio;
|
CSSToScreenScale scaleMinFloat = mScaleMinFloat * pixelRatio;
|
||||||
CSSToScreenScale scaleMaxFloat = mScaleMaxFloat * pixelRatio;
|
CSSToScreenScale scaleMaxFloat = mScaleMaxFloat * pixelRatio;
|
||||||
|
Loading…
Reference in New Issue
Block a user