diff --git a/accessible/src/base/nsAccEvent.cpp b/accessible/src/base/nsAccEvent.cpp index 8174290384c..abe6015602d 100644 --- a/accessible/src/base/nsAccEvent.cpp +++ b/accessible/src/base/nsAccEvent.cpp @@ -256,7 +256,7 @@ nsAccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput) if (!targetNode) return; - nsCOMPtr presShell = nsCoreUtils::GetPresShellFor(targetNode); + nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(targetNode); if (!presShell) { NS_NOTREACHED("Threre should always be an pres shell for an event"); return; diff --git a/accessible/src/base/nsAccUtils.cpp b/accessible/src/base/nsAccUtils.cpp index c32141a6b87..d63d6854ba8 100644 --- a/accessible/src/base/nsAccUtils.cpp +++ b/accessible/src/base/nsAccUtils.cpp @@ -352,7 +352,7 @@ nsAccUtils::HasAccessibleChildren(nsIDOMNode *aNode) if (!content) return PR_FALSE; - nsCOMPtr presShell = nsCoreUtils::GetPresShellFor(aNode); + nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode); if (!presShell) return PR_FALSE; diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp index db193fdf087..a18c920e72c 100644 --- a/accessible/src/base/nsAccessNode.cpp +++ b/accessible/src/base/nsAccessNode.cpp @@ -705,10 +705,9 @@ nsAccessNode::GetDocAccessibleFor(nsIDocShellTreeItem *aContainer, nsDocAccessible* nsAccessNode::GetDocAccessibleFor(nsIDOMNode *aNode) { - nsCOMPtr eventShell = nsCoreUtils::GetPresShellFor(aNode); - if (eventShell) { - return GetDocAccessibleFor(eventShell->GetDocument()); - } + nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode); + if (presShell) + return GetDocAccessibleFor(presShell->GetDocument()); nsCOMPtr doc(do_QueryInterface(aNode)); if (doc) { @@ -720,7 +719,7 @@ nsAccessNode::GetDocAccessibleFor(nsIDOMNode *aNode) already_AddRefed nsAccessNode::GetCurrentFocus() { - nsCOMPtr shell = nsCoreUtils::GetPresShellFor(mDOMNode); + nsIPresShell *shell = nsCoreUtils::GetPresShellFor(mDOMNode); NS_ENSURE_TRUE(shell, nsnull); nsCOMPtr doc = shell->GetDocument(); NS_ENSURE_TRUE(doc, nsnull); diff --git a/accessible/src/base/nsCaretAccessible.cpp b/accessible/src/base/nsCaretAccessible.cpp index 030b474291b..8fc43459303 100644 --- a/accessible/src/base/nsCaretAccessible.cpp +++ b/accessible/src/base/nsCaretAccessible.cpp @@ -321,7 +321,7 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget) lastAccessNode->GetDOMNode(getter_AddRefs(lastNodeWithCaret)); NS_ENSURE_TRUE(lastNodeWithCaret, caretRect); - nsCOMPtr presShell = + nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(lastNodeWithCaret); NS_ENSURE_TRUE(presShell, caretRect); @@ -371,7 +371,7 @@ nsCaretAccessible::GetSelectionControllerForNode(nsIDOMNode *aNode) if (!aNode) return nsnull; - nsCOMPtr presShell = nsCoreUtils::GetPresShellFor(aNode); + nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode); if (!presShell) return nsnull; diff --git a/accessible/src/base/nsCoreUtils.cpp b/accessible/src/base/nsCoreUtils.cpp index 15ab5570be0..4a7784bdaa9 100644 --- a/accessible/src/base/nsCoreUtils.cpp +++ b/accessible/src/base/nsCoreUtils.cpp @@ -526,25 +526,6 @@ nsCoreUtils::IsCorrectFrameType(nsIFrame *aFrame, nsIAtom *aAtom) return aFrame->GetType() == aAtom; } -already_AddRefed -nsCoreUtils::GetPresShellFor(nsIDOMNode *aNode) -{ - nsCOMPtr domDocument; - aNode->GetOwnerDocument(getter_AddRefs(domDocument)); - - nsCOMPtr doc(do_QueryInterface(domDocument)); - if (!doc) // This is necessary when the node is the document node - doc = do_QueryInterface(aNode); - - nsIPresShell *presShell = nsnull; - if (doc) { - presShell = doc->GetPrimaryShell(); - NS_IF_ADDREF(presShell); - } - - return presShell; -} - already_AddRefed nsCoreUtils::GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer) { diff --git a/accessible/src/base/nsCoreUtils.h b/accessible/src/base/nsCoreUtils.h index 298e3df477a..fcb199e6fa9 100644 --- a/accessible/src/base/nsCoreUtils.h +++ b/accessible/src/base/nsCoreUtils.h @@ -243,7 +243,12 @@ public: /** * Return presShell for the document containing the given DOM node. */ - static already_AddRefed GetPresShellFor(nsIDOMNode *aNode); + static nsIPresShell *GetPresShellFor(nsIDOMNode *aNode) + { + nsCOMPtr node(do_QueryInterface(aNode)); + nsIDocument *document = node->GetOwnerDoc(); + return document ? document->GetPrimaryShell() : nsnull; + } /** * Return document node for the given document shell tree item. diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index ee2d09443db..43cab4a7f8e 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -507,8 +507,7 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, nsCOMPtr focusContent = do_QueryInterface(finalFocusNode); nsIFrame *focusFrame = nsnull; if (focusContent) { - nsCOMPtr shell = - nsCoreUtils::GetPresShellFor(finalFocusNode); + nsIPresShell *shell = nsCoreUtils::GetPresShellFor(finalFocusNode); NS_ASSERTION(shell, "No pres shell for final focus node!"); if (!shell) @@ -635,7 +634,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, return NS_OK; } - nsCOMPtr eventShell = nsCoreUtils::GetPresShellFor(aTargetNode); + nsIPresShell *eventShell = nsCoreUtils::GetPresShellFor(aTargetNode); if (!eventShell) { return NS_OK; } diff --git a/accessible/src/base/nsTextEquivUtils.cpp b/accessible/src/base/nsTextEquivUtils.cpp index 69825f682c1..e363f7f824a 100644 --- a/accessible/src/base/nsTextEquivUtils.cpp +++ b/accessible/src/base/nsTextEquivUtils.cpp @@ -141,7 +141,7 @@ nsTextEquivUtils::AppendTextEquivFromContent(nsIAccessible *aInitiatorAcc, gInitiatorAcc = aInitiatorAcc; nsCOMPtr DOMNode(do_QueryInterface(aContent)); - nsCOMPtr shell = nsCoreUtils::GetPresShellFor(DOMNode); + nsIPresShell *shell = nsCoreUtils::GetPresShellFor(DOMNode); if (!shell) { NS_ASSERTION(PR_TRUE, "There is no presshell!"); gInitiatorAcc = nsnull;