Bug 1376931 Part 2: Extend ContentViewer to allow reporting of effective full zoom level as determined by the device context. r=bz,heycam

MozReview-Commit-ID: EoVp1DwAl0j

--HG--
extra : rebase_source : b0bdf52adb0e44b51c4bbeb33668c35f559b8464
This commit is contained in:
Brad Werth 2017-09-27 14:06:37 -07:00
Родитель 5c41ecb223
Коммит 1450446d11
6 изменённых файлов: 53 добавлений и 0 удалений

Просмотреть файл

@ -212,6 +212,18 @@ interface nsIContentViewer : nsISupports
/** The amount by which to scale all lengths. Default is 1.0. */
attribute float fullZoom;
/**
* The actual full zoom in effect, as modified by the device context.
* For a requested full zoom, the device context may choose a slightly
* different effectiveFullZoom to accomodate integer rounding of app units
* per dev pixel. This property returns the actual zoom amount in use,
* though it may not be good user experience to report that a requested zoom
* of 90% is actually 89.1%, for example. This value is provided primarily to
* support media queries of dppx values, because those queries are matched
* against the actual native device pixel ratio and the actual full zoom.
*/
readonly attribute float deviceFullZoom;
/**
* The value used to override devicePixelRatio and media queries dppx.
* Default is 0.0, that means no overriding is done (only a positive value

Просмотреть файл

@ -3226,6 +3226,25 @@ nsDocumentViewer::GetFullZoom(float* aFullZoom)
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetDeviceFullZoom(float* aDeviceFullZoom)
{
NS_ENSURE_ARG_POINTER(aDeviceFullZoom);
#ifdef NS_PRINT_PREVIEW
if (GetIsPrintPreview()) {
// Print Preview overrides all zoom; if specified, we use the print preview
// zoom, no matter what.
*aDeviceFullZoom = mPrintPreviewZoom;
return NS_OK;
}
#endif
// If not in print preview, ask the prescontext for the device zoom, if a
// prescontext is available.
nsPresContext* pc = GetPresContext();
*aDeviceFullZoom = pc ? pc->GetDeviceFullZoom() : mPageZoom;
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::SetOverrideDPPX(float aDPPX)
{

Просмотреть файл

@ -1364,6 +1364,12 @@ nsPresContext::UpdateEffectiveTextZoom()
}
}
float
nsPresContext::GetDeviceFullZoom()
{
return mDeviceContext->GetFullZoom();
}
void
nsPresContext::SetFullZoom(float aZoom)
{

Просмотреть файл

@ -604,6 +604,12 @@ public:
}
float GetFullZoom() { return mFullZoom; }
/**
* Device full zoom differs from full zoom because it gets the zoom from
* the device context, which may be using a different zoom due to rounding
* of app units to device pixels.
*/
float GetDeviceFullZoom();
void SetFullZoom(float aZoom);
float GetOverrideDPPX() { return mOverrideDPPX; }

Просмотреть файл

@ -1422,6 +1422,9 @@ SpecialPowersAPI.prototype = {
getFullZoom(window) {
return this._getMUDV(window).fullZoom;
},
getDeviceFullZoom(window) {
return this._getMUDV(window).deviceFullZoom;
},
setFullZoom(window, zoom) {
this._getMUDV(window).fullZoom = zoom;
},

Просмотреть файл

@ -554,6 +554,13 @@
]]></setter>
</property>
<property name="deviceFullZoom"
readonly="true">
<getter><![CDATA[
return this.markupDocumentViewer.deviceFullZoom;
]]></getter>
</property>
<property name="textZoom">
<getter><![CDATA[
return this.markupDocumentViewer.textZoom;