Bug 741681 - replaced nsAccessNode::GetPresContext() with nsDocAccessible::PresContext(), r=hub, f=surkov
authorLavina Thong <orangedaylily@gmail.com>
Wed, 11 Apr 2012 12:42:42 +0900
changeset 94691 259e39b355cf735e8e39af159d0d35802b8007fa
parent 94690 ef442645a2087d6383e3ffde70fc5a7e2ab24a60
child 94692 671cc6b005f33e41a6e292e9f017cdc3a051df65
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershub
bugs741681
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 741681 - replaced nsAccessNode::GetPresContext() with nsDocAccessible::PresContext(), r=hub, f=surkov
accessible/src/base/nsAccessNode.cpp
accessible/src/base/nsAccessNode.h
accessible/src/base/nsDocAccessible.h
accessible/src/html/nsHyperTextAccessible.cpp
accessible/src/msaa/nsTextAccessibleWrap.cpp
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/src/xul/nsXULTreeGridAccessible.cpp
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -204,27 +204,16 @@ void nsAccessNode::ShutdownXPAccessibili
   if (gApplicationAccessible) {
     gApplicationAccessible->Shutdown();
     NS_RELEASE(gApplicationAccessible);
   }
 
   NotifyA11yInitOrShutdown(false);
 }
 
-// nsAccessNode protected
-nsPresContext* nsAccessNode::GetPresContext()
-{
-  if (!mDoc)
-    return nsnull;
-
-  nsIPresShell* presShell(mDoc->PresShell());
-
-  return presShell ? presShell->GetPresContext() : nsnull;
-}
-
 nsRootAccessible*
 nsAccessNode::RootAccessible() const
 {
   nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
     nsCoreUtils::GetDocShellTreeItemFor(mContent);
   NS_ASSERTION(docShellTreeItem, "No docshell tree item for mContent");
   if (!docShellTreeItem) {
     return nsnull;
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -149,32 +149,30 @@ public:
   virtual bool IsPrimaryForNode() const;
 
   /**
    * Interface methods on nsIAccessible shared with ISimpleDOM.
    */
   void Language(nsAString& aLocale);
 
 protected:
-    nsPresContext* GetPresContext();
-
-    void LastRelease();
+  void LastRelease();
 
   nsCOMPtr<nsIContent> 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;
   nsAccessNode(const nsAccessNode&) MOZ_DELETE;
   nsAccessNode& operator =(const nsAccessNode&) MOZ_DELETE;
   
   static nsApplicationAccessible *gApplicationAccessible;
 };
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -129,16 +129,21 @@ public:
   // nsDocAccessible
 
   /**
    * Return presentation shell for this document accessible.
    */
   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.
    */
   bool IsContentLoaded() const
   {
     // eDOMLoaded flag check is used for error pages as workaround to make this
     // method return correct result since error pages do not receive 'pageshow'
     // event and as consequence nsIDocument::IsShowing() returns false.
     return mDocument && mDocument->IsVisible() &&
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -202,21 +202,17 @@ nsIntRect nsHyperTextAccessible::GetBoun
   nsIFrame *frame;
   PRInt32 startContentOffsetInFrame;
   // Get the right frame continuation -- not really a child, but a sibling of
   // the primary frame passed in
   rv = aFrame->GetChildFrameContainingOffset(startContentOffset, false,
                                              &startContentOffsetInFrame, &frame);
   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 
     // shrink based on the substring we care about within it.
     // We will then add that frame to the total screenRect we
     // are returning.
     nsIntRect frameScreenRect = frame->GetScreenRectExternal();
 
@@ -1289,23 +1285,20 @@ NS_IMETHODIMP nsHyperTextAccessible::Get
  * Gets the offset of the character located at coordinates x and y. x and y are interpreted as being relative to
  * the screen or this widget's window depending on coords.
  */
 NS_IMETHODIMP
 nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY,
                                         PRUint32 aCoordType, PRInt32 *aOffset)
 {
   *aOffset = -1;
-  if (!mDoc)
+
+  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;
   }
   nsIntRect frameScreenRect = hyperFrame->GetScreenRectExternal();
 
   nsIntPoint coords;
   nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType,
@@ -1314,18 +1307,17 @@ nsHyperTextAccessible::GetOffsetAtPoint(
 
   // coords are currently screen coordinates, and we need to turn them into
   // frame coordinates relative to the current accessible
   if (!frameScreenRect.Contains(coords.x, coords.y)) {
     return NS_OK;   // Not found, will return -1
   }
   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));
 
   // Go through the frames to check if each one has the point.
   // When one does, add up the character offsets until we have a match
 
   // We have an point in an accessible child of this, now we need to add up the
   // offsets before it to what we already have
--- a/accessible/src/msaa/nsTextAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsTextAccessibleWrap.cpp
@@ -212,18 +212,21 @@ nsIFrame* nsTextAccessibleWrap::GetPoint
 /*
  * Given an offset, the x, y, width, and height values are filled appropriately.
  */
 nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32 aEndOffset,
                                                    PRInt32* aX, PRInt32* aY, 
                                                    PRInt32* aWidth, PRInt32* aHeight) 
 {
   *aX = *aY = *aWidth = *aHeight = 0;
-  nsPresContext *presContext = GetPresContext();
-  NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
+
+  if (IsDefunct())
+    return CO_E_OBJNOTCONNECTED;
+
+  nsPresContext* presContext = mDoc->PresContext();
 
   nsIFrame *frame = GetFrame();
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
 
   nsPoint startPoint, endPoint;
   nsIFrame *startFrame = GetPointFromOffset(frame, aStartOffset, true, startPoint);
   nsIFrame *endFrame = GetPointFromOffset(frame, aEndOffset, false, endPoint);
   if (!startFrame || !endFrame) {
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -797,17 +797,17 @@ nsXULTreeItemAccessibleBase::GetBounds(P
 
   PRInt32 tcX = 0, tcY = 0;
   boxObj->GetScreenX(&tcX);
   boxObj->GetScreenY(&tcY);
 
   x = tcX;
   y += tcY;
 
-  nsPresContext *presContext = GetPresContext();
+  nsPresContext* presContext = mDoc->PresContext();
   *aX = presContext->CSSPixelsToDevPixels(x);
   *aY = presContext->CSSPixelsToDevPixels(y);
   *aWidth = presContext->CSSPixelsToDevPixels(width);
   *aHeight = presContext->CSSPixelsToDevPixels(height);
 
   return NS_OK;
 }
 
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp
@@ -919,17 +919,17 @@ nsXULTreeGridCellAccessible::GetBounds(P
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRInt32 tcX = 0, tcY = 0;
   boxObj->GetScreenX(&tcX);
   boxObj->GetScreenY(&tcY);
   x += tcX;
   y += tcY;
 
-  nsPresContext *presContext = GetPresContext();
+  nsPresContext* presContext = mDoc->PresContext();
   *aX = presContext->CSSPixelsToDevPixels(x);
   *aY = presContext->CSSPixelsToDevPixels(y);
   *aWidth = presContext->CSSPixelsToDevPixels(width);
   *aHeight = presContext->CSSPixelsToDevPixels(height);
 
   return NS_OK;
 }