Bug 770041 - Revert GetRootPresContext to pre-DLBI behaviour and add GetDisplayRootPresContext for DLBI. r=roc

This commit is contained in:
Matt Woodrow 2012-07-03 13:02:30 +12:00
parent f3464518e0
commit 9c93632805
3 changed files with 31 additions and 14 deletions

View File

@ -143,7 +143,8 @@ nsPresContext::IsDOMPaintEventPending()
if (!mInvalidateRequests.mRequests.IsEmpty()) {
return true;
}
if (GetRootPresContext()->mRefreshDriver->ViewManagerFlushIsPending()) {
nsRootPresContext* rpc = GetDisplayRootPresContext();
if (rpc && rpc->mRefreshDriver->ViewManagerFlushIsPending()) {
// Since we're promising that there will be a MozAfterPaint event
// fired, we record an empty invalidation in case display list
// invalidation doesn't invalidate anything further.
@ -1197,18 +1198,6 @@ nsPresContext::GetParentPresContext()
return f->PresContext();
}
}
// Not sure if this is always strictly the parent, but it works for GetRootPresContext
// where the current pres context has no frames.
nsIDocument *doc = Document();
if (doc) {
doc = doc->GetParentDocument();
if (doc) {
shell = doc->GetShell();
if (shell) {
return shell->GetPresContext();
}
}
}
return nsnull;
}
@ -1233,6 +1222,33 @@ nsPresContext::GetRootPresContext()
nsPresContext* pc = this;
for (;;) {
nsPresContext* parent = pc->GetParentPresContext();
if (!parent)
break;
pc = parent;
}
return pc->IsRoot() ? static_cast<nsRootPresContext*>(pc) : nsnull;
}
nsRootPresContext*
nsPresContext::GetDisplayRootPresContext()
{
nsPresContext* pc = this;
for (;;) {
nsPresContext* parent = pc->GetParentPresContext();
if (!parent) {
// Not sure if this is always strictly the parent, but it works for GetRootPresContext
// where the current pres context has no frames.
nsIDocument *doc = pc->Document();
if (doc) {
doc = doc->GetParentDocument();
if (doc) {
nsIPresShell* shell = doc->GetShell();
if (shell) {
parent = shell->GetPresContext();
}
}
}
}
if (!parent || parent == pc)
break;
pc = parent;

View File

@ -198,6 +198,7 @@ public:
* be found (e.g. it's detached).
*/
nsRootPresContext* GetRootPresContext();
nsRootPresContext* GetDisplayRootPresContext();
virtual bool IsRoot() { return false; }
nsIDocument* Document() const

View File

@ -4670,7 +4670,7 @@ nsIFrame::IsInvalid()
void
nsIFrame::SchedulePaint(PRUint32 aFlags)
{
nsPresContext *pres = PresContext()->GetRootPresContext();
nsPresContext *pres = PresContext()->GetDisplayRootPresContext();
if (HasAnyStateBits(NS_FRAME_IN_POPUP) || !pres) {
nsIFrame *displayRoot = nsLayoutUtils::GetDisplayRootFrame(this);
NS_ASSERTION(displayRoot, "Need a display root to schedule a paint!");