Bug 1237813. Refactor nsLayoutUtils::FindScrollableFrameFor to use GetScrollFrameFromContent. r=botond

This commit is contained in:
Timothy Nikkel 2016-01-12 00:14:30 -06:00
Родитель 9162bd85e1
Коммит 50fcf29623
1 изменённых файлов: 21 добавлений и 26 удалений

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

@ -751,6 +751,25 @@ nsLayoutUtils::FindContentFor(ViewID aId)
}
}
nsIFrame*
GetScrollFrameFromContent(nsIContent* aContent)
{
nsIFrame* frame = aContent->GetPrimaryFrame();
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.
nsIFrame* rootScrollFrame = presShell ? presShell->GetRootScrollFrame() : nullptr;
if (rootScrollFrame) {
frame = rootScrollFrame;
}
}
return frame;
}
nsIScrollableFrame*
nsLayoutUtils::FindScrollableFrameFor(ViewID aId)
{
@ -759,13 +778,8 @@ nsLayoutUtils::FindScrollableFrameFor(ViewID aId)
return nullptr;
}
nsIFrame* scrolledFrame = content->GetPrimaryFrame();
if (scrolledFrame && content->OwnerDoc()->GetRootElement() == content) {
// The content is the root element of a subdocument, so return the root scrollable
// for the subdocument.
scrolledFrame = scrolledFrame->PresContext()->PresShell()->GetRootScrollFrame();
}
return scrolledFrame ? scrolledFrame->GetScrollTargetFrame() : nullptr;
nsIFrame* scrollFrame = GetScrollFrameFromContent(content);
return scrollFrame ? scrollFrame->GetScrollTargetFrame() : nullptr;
}
static nsRect
@ -862,25 +876,6 @@ GetDisplayPortFromRectData(nsIContent* aContent,
return ApplyRectMultiplier(aRectData->mRect, aMultiplier);
}
nsIFrame*
GetScrollFrameFromContent(nsIContent* aContent)
{
nsIFrame* frame = aContent->GetPrimaryFrame();
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.
nsIFrame* rootScrollFrame = presShell ? presShell->GetRootScrollFrame() : nullptr;
if (rootScrollFrame) {
frame = rootScrollFrame;
}
}
return frame;
}
static nsRect
GetDisplayPortFromMarginsData(nsIContent* aContent,
DisplayPortMarginsPropertyData* aMarginsData,