Bug 1215977. Only match the root scroll frame in GetNearestScrollableFrame if we encounter it. r=botond

Instead of returning the root scroll frame if we encountered the root frame (which is the parent of the root scroll frame).

This allows the use of GetNearestScrollableFrame to walk up the frame tree without getting into a infinite loop going from root scroll frame to root frame and back.

This regresses bug 1105823 in that fixed pos frames will no longer find the root scroll frame of their document. The next patch will fix that.

The only other type of frame that will be affected when calling GetNearestScrollableFrame are viewport (root) frames. However, the only user of SCROLLABLE_ALWAYS_MATCH_ROOT (APZCCallbackHelper) calls GetNearestScrollableFrame on the result of a hit test on a display list. Viewport frames never create any display items whose HitTest function could return the viewport frame.
This commit is contained in:
Timothy Nikkel 2015-11-04 19:51:03 -06:00
parent b9113902fc
commit 8fedb37cdc
2 changed files with 10 additions and 9 deletions

View File

@ -1948,12 +1948,12 @@ nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags)
return scrollableFrame;
}
}
}
if (aFlags & SCROLLABLE_ALWAYS_MATCH_ROOT) {
nsIPresShell* ps = f->PresContext()->PresShell();
if (ps->GetDocument() && ps->GetDocument()->IsRootDisplayDocument() &&
ps->GetRootFrame() == f) {
return ps->GetRootScrollFrameAsScrollable();
if (aFlags & SCROLLABLE_ALWAYS_MATCH_ROOT) {
nsIPresShell* ps = f->PresContext()->PresShell();
if (ps->GetRootScrollFrame() == f &&
ps->GetDocument() && ps->GetDocument()->IsRootDisplayDocument()) {
return scrollableFrame;
}
}
}
}

View File

@ -610,9 +610,10 @@ public:
*/
SCROLLABLE_ONLY_ASYNC_SCROLLABLE = 0x04,
/**
* If the SCROLLABLE_ALWAYS_MATCH_ROOT flag is set, then return the
* root scrollable frame for the root document (in the current process)
* if we don't hit anything else.
* If the SCROLLABLE_ALWAYS_MATCH_ROOT flag is set, then we will always
* return the root scrollable frame for the root document (in the current
* process) if we encounter it, whether or not it is async scrollable or
* overflow: hidden.
*/
SCROLLABLE_ALWAYS_MATCH_ROOT = 0x08,
};