Bug 1642088. Use a ResolutionChangeOrigin for when the resolution is changing by tests that overides and sets the restore resolution. r=kats

Differential Revision: https://phabricator.services.mozilla.com/D77582
This commit is contained in:
Timothy Nikkel 2020-05-30 21:34:39 +00:00
Родитель 555823e361
Коммит 6cedbd9795
4 изменённых файлов: 12 добавлений и 7 удалений

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

@ -570,8 +570,7 @@ nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution) {
return NS_ERROR_FAILURE;
}
presShell->SetResolutionAndScaleTo(aResolution,
ResolutionChangeOrigin::MainThreadRestore);
presShell->SetResolutionAndScaleTo(aResolution, ResolutionChangeOrigin::Test);
return NS_OK;
}

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

@ -211,7 +211,8 @@ interface nsIDOMWindowUtils : nsISupports {
out uint32_t aHorizontalScrollbarHeight);
/**
* Get/set the resolution at which rescalable web content is drawn.
* Get/set the resolution at which rescalable web content is drawn for
* testing purposes.
*
* Setting a new resolution does *not* trigger reflow. This API is
* entirely separate from textZoom and fullZoom; a resolution scale
@ -225,10 +226,13 @@ interface nsIDOMWindowUtils : nsISupports {
* so that it is displayed at a correspondingly larger or smaller size,
* without the need for the caller to set an additional transform.
*
* This can be used to implement a non-reflowing scale-zoom, e.g.
* for pinch-zoom on mobile platforms.
* The purpose of this API is to allow tests to simulate many of the effects
* a non-reflowing scale-zoom, e.g. for pinch-zoom on mobile platforms, and
* should be only used for testing purposes.
*
* The caller of this method must have chrome privileges.
*
* This is intended to be used by test code only!
*/
void setResolutionAndScaleTo(in float aResolution);

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

@ -110,8 +110,9 @@ void MobileViewportManager::ResolutionUpdated(
return;
}
if (!mPainted &&
aOrigin == mozilla::ResolutionChangeOrigin::MainThreadRestore) {
if ((!mPainted &&
aOrigin == mozilla::ResolutionChangeOrigin::MainThreadRestore) ||
aOrigin == mozilla::ResolutionChangeOrigin::Test) {
// Save the value, so our default zoom calculation
// can take it into account later on.
SetRestoreResolution(mContext->GetResolution());

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

@ -176,6 +176,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags)
enum class ResolutionChangeOrigin : uint8_t {
Apz,
Test,
MainThreadRestore,
MainThreadAdjustment,
};