Bug 1002992. Part 2. Handle display ports and ignore viewport scrolling for image visibility display lists the same way we do for painting display lists. r=mats

This commit is contained in:
Timothy Nikkel 2014-06-06 21:23:20 -05:00
parent b92f05ed72
commit ad28cfc802
4 changed files with 35 additions and 2 deletions

View File

@ -5738,8 +5738,23 @@ PresShell::UpdateImageVisibility()
// We could walk the frame tree directly and skip creating a display list for
// better perf.
nsRect updateRect(nsPoint(0, 0), rootFrame->GetSize());
nsDisplayListBuilder builder(rootFrame, nsDisplayListBuilder::IMAGE_VISIBILITY, true);
nsRect updateRect(nsPoint(0, 0), rootFrame->GetSize());
nsIFrame* rootScroll = GetRootScrollFrame();
if (rootScroll) {
nsIContent* content = rootScroll->GetContent();
if (content) {
nsLayoutUtils::GetDisplayPort(content, &updateRect);
}
if (IgnoringViewportScrolling()) {
builder.SetIgnoreScrollFrame(rootScroll);
// The ExpandRect that the root scroll frame would do gets short circuited
// due to us ignoring the root scroll frame, so we do it here.
nsIScrollableFrame* rootScrollable = do_QueryFrame(rootScroll);
updateRect = rootScrollable->ExpandRect(updateRect);
}
}
builder.IgnorePaintSuppression();
builder.EnterPresShell(rootFrame, updateRect);
nsDisplayList list;

View File

@ -279,6 +279,7 @@ public:
void UpdateSticky();
bool IsRectNearlyVisible(const nsRect& aRect) const;
nsRect ExpandRect(const nsRect& aRect) const;
// adjust the scrollbar rectangle aRect to account for any visible resizer.
// aHasResizer specifies if there is a content resizer, however this method
@ -420,7 +421,6 @@ protected:
nsIAtom *aOrigin, // nullptr indicates "other" origin
const nsRect* aRange);
nsRect ExpandRect(const nsRect& aRect) const;
static void EnsureImageVisPrefsCached();
static bool sImageVisPrefsCached;
// The number of scrollports wide/high to expand when looking for images.
@ -671,6 +671,9 @@ public:
virtual bool IsRectNearlyVisible(const nsRect& aRect) MOZ_OVERRIDE {
return mHelper.IsRectNearlyVisible(aRect);
}
virtual nsRect ExpandRect(const nsRect& aRect) const MOZ_OVERRIDE {
return mHelper.ExpandRect(aRect);
}
virtual nsIAtom* OriginOfLastScroll() MOZ_OVERRIDE {
return mHelper.OriginOfLastScroll();
}
@ -987,6 +990,9 @@ public:
virtual bool IsRectNearlyVisible(const nsRect& aRect) MOZ_OVERRIDE {
return mHelper.IsRectNearlyVisible(aRect);
}
virtual nsRect ExpandRect(const nsRect& aRect) const MOZ_OVERRIDE {
return mHelper.ExpandRect(aRect);
}
virtual nsIAtom* OriginOfLastScroll() MOZ_OVERRIDE {
return mHelper.OriginOfLastScroll();
}

View File

@ -286,6 +286,11 @@ public:
* visibility heuristics for how close it is to the visible scrollport.
*/
virtual bool IsRectNearlyVisible(const nsRect& aRect) = 0;
/**
* Expand the given rect taking into account which directions we can scroll
* and how far we want to expand for image visibility purposes.
*/
virtual nsRect ExpandRect(const nsRect& aRect) const = 0;
/**
* Returns the origin passed in to the last ScrollToImpl call that took
* effect.

View File

@ -397,6 +397,13 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
if (ignoreViewportScrolling) {
savedIgnoreScrollFrame = aBuilder->GetIgnoreScrollFrame();
aBuilder->SetIgnoreScrollFrame(rootScrollFrame);
if (aBuilder->IsForImageVisibility()) {
// The ExpandRect that the root scroll frame would do gets short circuited
// due to us ignoring the root scroll frame, so we do it here.
nsIScrollableFrame* rootScrollableFrame = do_QueryFrame(rootScrollFrame);
dirty = rootScrollableFrame->ExpandRect(dirty);
}
}
}