Bug 1523500 - Don't use cross-doc checks for perspective scrolling. r=mattwoodrow

Would be pretty surprising if a perspective transform scrolled stuff in an
iframe for example.

Differential Revision: https://phabricator.services.mozilla.com/D17905

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-01-29 19:39:50 +00:00
Родитель 1b7e29eab8
Коммит 15995b8b40
4 изменённых файлов: 26 добавлений и 8 удалений

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

@ -1489,15 +1489,23 @@ bool nsLayoutUtils::IsAncestorFrameCrossDoc(const nsIFrame* aAncestorFrame,
return aCommonAncestor == aAncestorFrame;
}
bool nsLayoutUtils::IsAncestorFrame(const nsIFrame* aAncestorFrame,
const nsIFrame* aFrame,
const nsIFrame* aCommonAncestor) {
for (const nsIFrame* f = aFrame; f != aCommonAncestor; f = f->GetParent()) {
if (f == aAncestorFrame) {
return true;
}
}
return aCommonAncestor == aAncestorFrame;
}
// static
bool nsLayoutUtils::IsProperAncestorFrame(const nsIFrame* aAncestorFrame,
const nsIFrame* aFrame,
const nsIFrame* aCommonAncestor) {
if (aFrame == aAncestorFrame) return false;
for (const nsIFrame* f = aFrame; f != aCommonAncestor; f = f->GetParent()) {
if (f == aAncestorFrame) return true;
}
return aCommonAncestor == aAncestorFrame;
return aFrame != aAncestorFrame &&
IsAncestorFrame(aAncestorFrame, aFrame, aCommonAncestor);
}
// static

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

@ -532,6 +532,17 @@ class nsLayoutUtils {
const nsIFrame* aFrame,
const nsIFrame* aCommonAncestor = nullptr);
/**
* IsAncestorFrame checks whether aAncestorFrame is an ancestor
* of aFrame or equal to aFrame.
* @param aCommonAncestor nullptr, or a common ancestor of aFrame and
* aAncestorFrame. If non-null, this can bound the search and speed up
* the function
*/
static bool IsAncestorFrame(const nsIFrame* aAncestorFrame,
const nsIFrame* aFrame,
const nsIFrame* aCommonAncestor = nullptr);
/**
* Like IsProperAncestorFrame, but looks across document boundaries.
*

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

@ -4267,8 +4267,7 @@ static const ActiveScrolledRoot* GetASRForPerspective(
const ActiveScrolledRoot* aASR, nsIFrame* aPerspectiveFrame) {
for (const ActiveScrolledRoot* asr = aASR; asr; asr = asr->mParent) {
nsIFrame* scrolledFrame = asr->mScrollableFrame->GetScrolledFrame();
if (nsLayoutUtils::IsAncestorFrameCrossDoc(scrolledFrame,
aPerspectiveFrame)) {
if (nsLayoutUtils::IsAncestorFrame(scrolledFrame, aPerspectiveFrame)) {
return asr;
}
}

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

@ -8500,7 +8500,7 @@ bool nsDisplayPerspective::CreateWebRenderCommands(
Maybe<uint64_t> scrollingRelativeTo;
for (auto* asr = GetActiveScrolledRoot(); asr; asr = asr->mParent) {
if (nsLayoutUtils::IsAncestorFrameCrossDoc(
if (nsLayoutUtils::IsAncestorFrame(
asr->mScrollableFrame->GetScrolledFrame(), perspectiveFrame)) {
scrollingRelativeTo.emplace(asr->GetViewId());
break;