Bug 1682919 - Avoid creating a new DisplayPortMargins object as a side effect of querying the displayport. r=tnikkel

DisplayPortMargins objects are only meant to be created when setting
display port margins, not when querying them, because the object's
constructor records the visual and layout scroll offsets at the time
of construction to use for adjusting the margins to be layout-relative.

Differential Revision: https://phabricator.services.mozilla.com/D102075
This commit is contained in:
Botond Ballo 2021-01-24 04:08:00 +00:00
Родитель dc813a31cc
Коммит 7431701c98
1 изменённых файлов: 7 добавлений и 3 удалений

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

@ -551,9 +551,13 @@ static bool GetDisplayPortImpl(nsIContent* aContent, nsRect* aResult,
result = GetDisplayPortFromRectData(aContent, rectData, aMultiplier);
} else if (isDisplayportSuppressed ||
nsLayoutUtils::ShouldDisableApzForElement(aContent)) {
DisplayPortMarginsPropertyData noMargins(
DisplayPortMargins::Empty(aContent), 1,
/*painted=*/false);
// Make a copy of the margins data but set the margins to empty.
// Do not create a new DisplayPortMargins object with
// DisplayPortMargins::Empty(), because that will record the visual
// and layout scroll offsets in place right now on the DisplayPortMargins,
// and those are only meant to be recorded when the margins are stored.
DisplayPortMarginsPropertyData noMargins = *marginsData;
noMargins.mMargins.mMargins = ScreenMargin();
result = GetDisplayPortFromMarginsData(aContent, &noMargins, aMultiplier,
aOptions);
} else {