Bug 959847. Part 11. Use nsLayoutUtils::ViewportHasDisplayPort instead of repeating boilerplate code. r=roc

This commit is contained in:
Timothy Nikkel 2014-02-27 16:01:54 -06:00
parent c98b478ef2
commit 00358747ba
2 changed files with 13 additions and 16 deletions

View File

@ -3494,9 +3494,9 @@ nsDisplaySubDocument::BuildLayer(nsDisplayListBuilder* aBuilder,
nsRect
nsDisplaySubDocument::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
{
nsIFrame* rootScrollFrame = mFrame->PresContext()->PresShell()->GetRootScrollFrame();
nsIContent* content = rootScrollFrame ? rootScrollFrame->GetContent() : nullptr;
bool usingDisplayPort = content && nsLayoutUtils::GetDisplayPort(content);
bool usingDisplayPort =
nsLayoutUtils::ViewportHasDisplayPort(mFrame->PresContext());
if ((mFlags & GENERATE_SCROLLABLE_LAYER) && usingDisplayPort) {
*aSnap = false;
return mFrame->GetRect() + aBuilder->ToReferenceFrame(mFrame);
@ -3510,11 +3510,9 @@ nsDisplaySubDocument::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion)
{
nsIFrame* rootScrollFrame = mFrame->PresContext()->PresShell()->GetRootScrollFrame();
nsIContent* content = rootScrollFrame ? rootScrollFrame->GetContent() : nullptr;
nsRect displayport;
bool usingDisplayPort = content &&
nsLayoutUtils::GetDisplayPort(content, &displayport);
bool usingDisplayPort =
nsLayoutUtils::ViewportHasDisplayPort(mFrame->PresContext(), &displayport);
if (!(mFlags & GENERATE_SCROLLABLE_LAYER) || !usingDisplayPort) {
return nsDisplayWrapList::ComputeVisibility(aBuilder, aVisibleRegion,
@ -3542,9 +3540,9 @@ nsDisplaySubDocument::ComputeVisibility(nsDisplayListBuilder* aBuilder,
bool
nsDisplaySubDocument::ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder)
{
nsIFrame* rootScrollFrame = mFrame->PresContext()->PresShell()->GetRootScrollFrame();
nsIContent* content = rootScrollFrame ? rootScrollFrame->GetContent() : nullptr;
bool usingDisplayPort = content && nsLayoutUtils::GetDisplayPort(content);
bool usingDisplayPort =
nsLayoutUtils::ViewportHasDisplayPort(mFrame->PresContext());
if ((mFlags & GENERATE_SCROLLABLE_LAYER) && usingDisplayPort) {
return true;
}
@ -3555,9 +3553,9 @@ nsDisplaySubDocument::ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBui
nsRegion
nsDisplaySubDocument::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, bool* aSnap)
{
nsIFrame* rootScrollFrame = mFrame->PresContext()->PresShell()->GetRootScrollFrame();
nsIContent* content = rootScrollFrame ? rootScrollFrame->GetContent() : nullptr;
bool usingDisplayPort = content && nsLayoutUtils::GetDisplayPort(content);
bool usingDisplayPort =
nsLayoutUtils::ViewportHasDisplayPort(mFrame->PresContext());
if ((mFlags & GENERATE_SCROLLABLE_LAYER) && usingDisplayPort) {
*aSnap = false;
return nsRegion();

View File

@ -376,10 +376,8 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
bool ignoreViewportScrolling = false;
nsIFrame* savedIgnoreScrollFrame = nullptr;
if (subdocRootFrame) {
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
nsIContent* content = rootScrollFrame ? rootScrollFrame->GetContent() : nullptr;
nsRect displayPort;
if (content && nsLayoutUtils::GetDisplayPort(content, &displayPort)) {
if (nsLayoutUtils::ViewportHasDisplayPort(presContext, &displayPort)) {
haveDisplayPort = true;
dirty = displayPort;
} else {
@ -389,6 +387,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
dirty = dirty.ConvertAppUnitsRoundOut(parentAPD, subdocAPD);
}
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
ignoreViewportScrolling =
rootScrollFrame && presShell->IgnoringViewportScrolling();
if (ignoreViewportScrolling) {