Bug 1237825. Find the root scroll frame even if the root element doesn't have a primary frame. r=mstange

Even though the content of the root scroll frame is the root element, the primary frame of the root element is never the root scroll frame. This is even true if the normal primary frame of the root element is not created (say because it is display: none). Leaving the primary frame of the root element to be null even though there are frames (the root scroll frame, and the canvas frame) that have the root element as their content.

This behaviour is more consistent by not ignoring a root scroll frame when it exists.
This commit is contained in:
Timothy Nikkel 2016-01-11 00:02:43 -06:00
parent 7240464401
commit dac35ad370

View File

@ -866,11 +866,15 @@ nsIFrame*
GetScrollFrameFromContent(nsIContent* aContent)
{
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && aContent->OwnerDoc()->GetRootElement() == aContent) {
if (aContent->OwnerDoc()->GetRootElement() == aContent) {
nsIPresShell* presShell = frame ? frame->PresContext()->PresShell() : nullptr;
if (!presShell) {
presShell = aContent->OwnerDoc()->GetShell();
}
// We want the scroll frame, the root scroll frame differs from all
// others in that the primary frame is not the scroll frame.
if (nsIFrame* rootScrollFrame =
frame->PresContext()->PresShell()->GetRootScrollFrame()) {
nsIFrame* rootScrollFrame = presShell ? presShell->GetRootScrollFrame() : nullptr;
if (rootScrollFrame) {
frame = rootScrollFrame;
}
}