From 5d01aa84ac12a9c21626ccf3eb03258d94ac0151 Mon Sep 17 00:00:00 2001 From: Lavina Thong Date: Mon, 9 Apr 2012 22:54:00 -0700 Subject: [PATCH] Bug 741681 - replaced nsAccessNode::GetPresContext() with nsDocAccessible::PresContext() r=hub --- accessible/src/base/nsAccessNode.cpp | 11 ----------- accessible/src/base/nsAccessNode.h | 18 ++++++++---------- accessible/src/base/nsDocAccessible.h | 5 +++++ accessible/src/html/nsHyperTextAccessible.cpp | 17 +++++------------ accessible/src/xul/nsXULTreeAccessible.cpp | 2 +- accessible/src/xul/nsXULTreeGridAccessible.cpp | 2 +- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index f60034af218..909abb0cd79 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -209,17 +209,6 @@ void nsAccessNode::ShutdownXPAccessibility() NotifyA11yInitOrShutdown(false); } -// nsAccessNode protected -nsPresContext* nsAccessNode::GetPresContext() -{ - if (!mDoc) - return nsnull; - - nsIPresShell* presShell(mDoc->PresShell()); - - return presShell ? presShell->GetPresContext() : nsnull; -} - nsRootAccessible* nsAccessNode::RootAccessible() const { diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h index b2b17cfd425..ebc9b582730 100644 --- a/accessible/src/base/nsAccessNode.h +++ b/accessible/src/base/nsAccessNode.h @@ -154,22 +154,20 @@ public: void Language(nsAString& aLocale); protected: - nsPresContext* GetPresContext(); - - void LastRelease(); + void LastRelease(); nsCOMPtr mContent; nsDocAccessible* mDoc; - /** - * Notify global nsIObserver's that a11y is getting init'd or shutdown - */ - static void NotifyA11yInitOrShutdown(bool aIsInit); + /** + * Notify global nsIObserver's that a11y is getting init'd or shutdown + */ + static void NotifyA11yInitOrShutdown(bool aIsInit); - // Static data, we do our own refcounting for our static data - static nsIStringBundle *gStringBundle; + // Static data, we do our own refcounting for our static data + static nsIStringBundle* gStringBundle; - static bool gIsFormFillEnabled; + static bool gIsFormFillEnabled; private: nsAccessNode() MOZ_DELETE; diff --git a/accessible/src/base/nsDocAccessible.h b/accessible/src/base/nsDocAccessible.h index 47449cf81c6..2a77cf73c56 100644 --- a/accessible/src/base/nsDocAccessible.h +++ b/accessible/src/base/nsDocAccessible.h @@ -142,6 +142,11 @@ public: */ nsIPresShell* PresShell() const { return mPresShell; } + /** + * Return the presentation shell's context. + */ + nsPresContext* PresContext() const { return mPresShell->GetPresContext(); } + /** * Return true if associated DOM document was loaded and isn't unloading. */ diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index c3d456c26b0..07e6eac4e20 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -208,10 +208,7 @@ nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRUint32 a NS_ENSURE_SUCCESS(rv, screenRect); NS_ENSURE_TRUE(mDoc, screenRect); - nsIPresShell* shell = mDoc->PresShell(); - NS_ENSURE_TRUE(shell, screenRect); - - nsPresContext *context = shell->GetPresContext(); + nsPresContext* context = mDoc->PresContext(); while (frame && startContentOffset < endContentOffset) { // Start with this frame's screen rect, which we will @@ -1294,13 +1291,10 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, PRUint32 aCoordType, PRInt32 *aOffset) { *aOffset = -1; - if (!mDoc) - return NS_ERROR_FAILURE; + + if (IsDefunct()) + return NS_ERROR_FAILURE; - nsIPresShell* shell = mDoc->PresShell(); - if (!shell) { - return NS_ERROR_FAILURE; - } nsIFrame *hyperFrame = GetFrame(); if (!hyperFrame) { return NS_ERROR_FAILURE; @@ -1319,8 +1313,7 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, } nsIntPoint pxInHyperText(coords.x - frameScreenRect.x, coords.y - frameScreenRect.y); - nsPresContext *context = GetPresContext(); - NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); + nsPresContext* context = mDoc->PresContext(); nsPoint pointInHyperText(context->DevPixelsToAppUnits(pxInHyperText.x), context->DevPixelsToAppUnits(pxInHyperText.y)); diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 4a358eac68d..724df2ebb2b 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -803,7 +803,7 @@ nsXULTreeItemAccessibleBase::GetBounds(PRInt32 *aX, PRInt32 *aY, x = tcX; y += tcY; - nsPresContext *presContext = GetPresContext(); + nsPresContext* presContext = mDoc->PresContext(); *aX = presContext->CSSPixelsToDevPixels(x); *aY = presContext->CSSPixelsToDevPixels(y); *aWidth = presContext->CSSPixelsToDevPixels(width); diff --git a/accessible/src/xul/nsXULTreeGridAccessible.cpp b/accessible/src/xul/nsXULTreeGridAccessible.cpp index 744fe453764..d0af3b5164d 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -924,7 +924,7 @@ nsXULTreeGridCellAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY, x += tcX; y += tcY; - nsPresContext *presContext = GetPresContext(); + nsPresContext* presContext = mDoc->PresContext(); *aX = presContext->CSSPixelsToDevPixels(x); *aY = presContext->CSSPixelsToDevPixels(y); *aWidth = presContext->CSSPixelsToDevPixels(width);