DeCOMify GetParent/GetBindingParent/GetDocument on nsIContent. Bug 213823,

r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2003-07-28 21:35:53 +00:00
parent 79965b5b97
commit 5fa37ec6f3
40 changed files with 102 additions and 214 deletions

View File

@ -59,8 +59,7 @@ nsAccessibleHyperText::nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakRefere
mIndex = -1;
nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
if (content) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = content->GetParent();
if (parentContent)
parentContent->IndexOf(content, mIndex);
}

View File

@ -507,21 +507,16 @@ nsHTMLTableAccessibleWrap::GetTableLayout(nsITableLayout **aLayoutObject)
nsCOMPtr<nsIContent> content(do_QueryInterface(tableNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> document;
rv = content->GetDocument(getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPresShell> presShell;
rv = document->GetShellAt(0, getter_AddRefs(presShell));
rv = content->GetDocument()->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_SUCCESS(rv, rv);
nsISupports *layoutObject = nsnull;
rv = presShell->GetLayoutObjectFor(content, &layoutObject);
nsCOMPtr<nsISupports> layoutObject;
rv = presShell->GetLayoutObjectFor(content, getter_AddRefs(layoutObject));
NS_ENSURE_SUCCESS(rv, rv);
*aLayoutObject = nsnull;
return layoutObject->QueryInterface(NS_GET_IID(nsITableLayout),
(void **)aLayoutObject);
return CallQueryInterface(layoutObject, aLayoutObject);
}
nsresult

View File

@ -223,8 +223,7 @@ nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIW
*aNode = node;
NS_IF_ADDREF(*aNode);
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
if (!document)
return NS_ERROR_FAILURE;
@ -1484,7 +1483,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
nsCOMPtr<nsIDocument> doc;
if (content) {
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
}
else {// Could be document node
doc = do_QueryInterface(aNode);

View File

@ -505,7 +505,7 @@ nsresult nsAccessible::GetFocusedNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aFo
nsCOMPtr<nsIDocument> document;
nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentNode));
if (content)
content->GetDocument(getter_AddRefs(document));
document = content->GetDocument();
if (!document)
document = do_QueryInterface(aCurrentNode);
@ -1022,8 +1022,7 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIContent> parentContent;
aContent->GetParent(getter_AddRefs(parentContent));
nsCOMPtr<nsIContent> parentContent = aContent->GetParent();
if (parentContent) {
nsresult rv = shell->GetPrimaryFrameFor(parentContent, &frame);
if (NS_SUCCEEDED(rv)) {
@ -1082,9 +1081,7 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
// so that an error shows when the image doesn't load.
// We don't want that text.
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIImageDocument> imageDoc(do_QueryInterface(doc));
nsCOMPtr<nsIImageDocument> imageDoc(do_QueryInterface(aContent->GetDocument()));
if (imageDoc) // We don't want this faux error text
textEquivalent.Truncate();
}
@ -1227,8 +1224,7 @@ NS_IMETHODIMP nsAccessible::GetHTMLAccName(nsAString& _retval)
if (formElement) {
break;
}
nsCOMPtr<nsIContent> nextParent;
walkUpContent->GetParent(getter_AddRefs(nextParent));
nsCOMPtr<nsIContent> nextParent = walkUpContent->GetParent();
if (!nextParent) {
break;
}
@ -1307,7 +1303,7 @@ NS_IMETHODIMP nsAccessible::GetXULAccName(nsAString& _retval)
//
// nsCOMPtr<nsIDocument> doc;
// nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
// content->GetDocument(getter_AddRefs(doc));
// doc = content->GetDocument();
// nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
// if (xulDoc) {
// nsCOMPtr<nsIDOMNodeList>labelList;
@ -1471,8 +1467,7 @@ nsresult nsAccessible::GetParentBlockNode(nsIDOMNode *aCurrentNode, nsIDOMNode *
if (!content)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;

View File

@ -295,13 +295,12 @@ PRBool nsLinkableAccessible::IsALink()
if (mIsALinkCached) // Cached answer?
return mLinkContent? PR_TRUE: PR_FALSE;
nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
if (walkUpContent) {
nsCOMPtr<nsIContent> tempContent = walkUpContent;
while (walkUpContent) {
for (nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
walkUpContent;
walkUpContent = walkUpContent->GetParent()) {
nsCOMPtr<nsILink> link(do_QueryInterface(walkUpContent));
if (link) {
mLinkContent = tempContent;
mLinkContent = walkUpContent;
mIsALinkCached = PR_TRUE;
nsLinkState linkState;
link->GetLinkState(linkState);
@ -309,9 +308,6 @@ PRBool nsLinkableAccessible::IsALink()
mIsLinkVisited = PR_TRUE;
return PR_TRUE;
}
walkUpContent->GetParent(getter_AddRefs(tempContent));
walkUpContent = tempContent;
}
}
mIsALinkCached = PR_TRUE; // Cached that there is no link
return PR_FALSE;

View File

@ -102,8 +102,7 @@ NS_IMETHODIMP nsOuterDocAccessible::Init()
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ASSERTION(content, "No nsIContent for <browser>/<iframe>/<editor> dom node");
nsCOMPtr<nsIDocument> outerDoc;
content->GetDocument(getter_AddRefs(outerDoc));
nsCOMPtr<nsIDocument> outerDoc = content->GetDocument();
NS_ENSURE_TRUE(outerDoc, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> innerDoc;

View File

@ -730,8 +730,7 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNod
NS_ASSERTION(aListNode, "Called GetFocusedOptionNode without a valid list node");
nsCOMPtr<nsIContent> content(do_QueryInterface(aListNode));
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
nsCOMPtr<nsIPresShell> shell;
if (document)
document->GetShellAt(0,getter_AddRefs(shell));

View File

@ -225,10 +225,7 @@ STDMETHODIMP nsAccessNodeWrap::get_attributesForNames(
if (!domElement || !content)
return E_FAIL;
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
if (!doc)
if (!content->GetDocument())
return E_FAIL;
nsCOMPtr<nsINameSpaceManager> nameSpaceManager =
@ -267,7 +264,7 @@ NS_IMETHODIMP nsAccessNodeWrap::GetComputedStyleDeclaration(nsIDOMCSSStyleDeclar
nsCOMPtr<nsIDocument> doc;
if (content)
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
if (!doc) {
return NS_ERROR_FAILURE;
@ -383,7 +380,7 @@ ISimpleDOMNode* nsAccessNodeWrap::MakeAccessNode(nsIDOMNode *node)
nsCOMPtr<nsIDocument> doc;
if (content)
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
else {
// Get the document via QueryInterface, since there is no content node
doc = do_QueryInterface(node);

View File

@ -3108,8 +3108,7 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes
char* token = nsCRT::strtok( str, ", ", &newStr );
while (token) {
nsCOMPtr<nsIContent> content(do_QueryInterface(elt));
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
nsCOMPtr<nsIURI> docURL;
doc->GetDocumentURL(getter_AddRefs(docURL));
nsCOMPtr<nsIURI> url;

View File

@ -612,8 +612,7 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent,
aURI->SchemeIs("data", &isData);
if (isJS || isData) {
nsCOMPtr<nsIDocument> sourceDoc;
aContent->GetDocument(getter_AddRefs(sourceDoc));
nsCOMPtr<nsIDocument> sourceDoc = aContent->GetDocument();
if (!sourceDoc) {
// The source is in a 'zombie' document, or not part of a

View File

@ -4320,7 +4320,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
nsCOMPtr<nsIDocument> doc;
if (content) {
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
}
if (!doc) {
@ -4373,10 +4373,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
}
if (!native_parent) {
nsCOMPtr<nsIContent> parentContent;
content->GetParent(getter_AddRefs(parentContent));
native_parent = parentContent;
native_parent = content->GetParent();
if (!native_parent) {
native_parent = doc;
@ -4612,9 +4609,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsCOMPtr<nsIContent> content(do_QueryInterface(native));
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc) {
// There's no baseclass that cares about this call so we just
@ -5358,10 +5353,7 @@ nsHTMLFormElementSH::FindNamedItem(nsIForm *aForm, JSString *str,
nsCOMPtr<nsIContent> content(do_QueryInterface(aForm));
nsCOMPtr<nsIDOMHTMLFormElement> form_element(do_QueryInterface(aForm));
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIHTMLDocument> html_doc(do_QueryInterface(doc));
nsCOMPtr<nsIHTMLDocument> html_doc(do_QueryInterface(content->GetDocument()));
if (html_doc && form_element) {
html_doc->ResolveName(name, form_element, aResult);
@ -5649,9 +5641,7 @@ nsHTMLExternalObjSH::GetPluginInstance(nsIXPConnectWrappedNative *wrapper,
nsCOMPtr<nsIContent> content(do_QueryInterface(native));
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc) {
// No document, no plugin.

View File

@ -222,12 +222,12 @@ nsFocusController::MoveFocus(PRBool aForward, nsIDOMElement* aElt)
nsCOMPtr<nsIContent> content;
if (aElt) {
content = do_QueryInterface(aElt);
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
}
else {
if (mCurrentElement) {
content = do_QueryInterface(mCurrentElement);
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
content = nsnull;
}
else if (mCurrentWindow) {

View File

@ -4173,8 +4173,7 @@ GlobalWindowImpl::GetPrivateParent(nsPIDOMWindow ** aParent)
if (!chromeElement)
return NS_OK; // This is ok, just means a null parent.
nsCOMPtr<nsIDocument> doc;
chromeElement->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = chromeElement->GetDocument();
if (!doc)
return NS_OK; // This is ok, just means a null parent.
@ -4215,8 +4214,7 @@ GlobalWindowImpl::GetPrivateRoot(nsIDOMWindowInternal ** aParent)
nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
if (chromeElement) {
nsCOMPtr<nsIDocument> doc;
chromeElement->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = chromeElement->GetDocument();
if (doc) {
nsCOMPtr<nsIScriptGlobalObject> globalObject;
doc->GetScriptGlobalObject(getter_AddRefs(globalObject));

View File

@ -1631,14 +1631,14 @@ nsHTMLEditor::GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver)
if (content)
{
nsCOMPtr<nsIContent> parent;
if (NS_SUCCEEDED(content->GetParent(getter_AddRefs(parent))) && parent)
nsIContent* parent = content->GetParent();
if (parent)
{
PRInt32 index;
if (NS_FAILED(parent->IndexOf(content, index)) || index < 0 )
{
rootElement = do_QueryInterface(parent); //this will put listener on the form element basically
result = rootElement->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), (void **)aEventReceiver);
result = CallQueryInterface(rootElement, aEventReceiver);
}
else
rootElement = 0; // Let the event receiver work on the document instead of the root element

View File

@ -961,7 +961,7 @@ IsTargetFocused(nsIDOMEventTarget* aTarget)
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIContent> content = do_QueryInterface(aTarget);
if (content)
content->GetDocument(getter_AddRefs(doc));
doc = content->GetDocument();
else
doc = do_QueryInterface(aTarget);

View File

@ -764,14 +764,14 @@ nsPlaintextEditor::GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver)
nsCOMPtr<nsIContent> content = do_QueryInterface(rootElement);
if (content)
{
nsCOMPtr<nsIContent> parent;
if (NS_SUCCEEDED(content->GetParent(getter_AddRefs(parent))) && parent)
nsCOMPtr<nsIContent> parent = content->GetParent();
if (parent)
{
PRInt32 index;
if (NS_FAILED(parent->IndexOf(content, index)) || index < 0 )
{
rootElement = do_QueryInterface(parent); //this will put listener on the form element basically
result = rootElement->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), (void **)aEventReceiver);
result = CallQueryInterface(rootElement, aEventReceiver);
}
else
rootElement = 0; // Let the event receiver work on the document instead of the root element

View File

@ -214,13 +214,12 @@ ContentToParentOffset(nsIContent *aContent, nsIDOMNode **aParent, PRInt32 *aOffs
if (!aContent)
return;
nsCOMPtr<nsIContent> parent;
nsresult rv = aContent->GetParent(getter_AddRefs(parent));
nsIContent* parent = aContent->GetParent();
if (NS_FAILED(rv) || !parent)
if (!parent)
return;
rv = parent->IndexOf(aContent, *aOffset);
nsresult rv = parent->IndexOf(aContent, *aOffset);
if (NS_FAILED(rv))
return;

View File

@ -3224,19 +3224,8 @@ nsTextServicesDocument::IsBlockNode(nsIContent *aContent)
PRBool
nsTextServicesDocument::HasSameBlockNodeParent(nsIContent *aContent1, nsIContent *aContent2)
{
nsCOMPtr<nsIContent> p1;
nsCOMPtr<nsIContent> p2;
nsresult result;
result = aContent1->GetParent(getter_AddRefs(p1));
if (NS_FAILED(result))
return PR_FALSE;
result = aContent2->GetParent(getter_AddRefs(p2));
if (NS_FAILED(result))
return PR_FALSE;
nsIContent* p1 = aContent1->GetParent();
nsIContent* p2 = aContent2->GetParent();
// Quick test:
@ -3245,26 +3234,14 @@ nsTextServicesDocument::HasSameBlockNodeParent(nsIContent *aContent1, nsIContent
// Walk up the parent hierarchy looking for closest block boundary node:
nsCOMPtr<nsIContent> tmp;
while (p1 && !IsBlockNode(p1))
{
result = p1->GetParent(getter_AddRefs(tmp));
if (NS_FAILED(result))
return PR_FALSE;
p1 = tmp;
p1 = p1->GetParent();
}
while (p2 && !IsBlockNode(p2))
{
result = p2->GetParent(getter_AddRefs(tmp));
if (NS_FAILED(result))
return PR_FALSE;
p2 = tmp;
p2 = p2->GetParent();
}
return p1 == p2;

View File

@ -248,8 +248,7 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode * aDOMNode, imgIRequest
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
// Get Document
nsCOMPtr<nsIDocument> document;
content->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = content->GetDocument();
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
// Get shell

View File

@ -471,8 +471,7 @@ PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
if (!content)
return PR_FALSE;
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return PR_FALSE;

View File

@ -156,8 +156,8 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRInt32 aContentType,
NS_ASSERTION(content, "no content available");
if (content) {
// XXXbz GetOwnerDocument
rv = content->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv) || !doc) {
doc = content->GetDocument();
if (!doc) {
rv = content->GetNodeInfo(getter_AddRefs(nodeinfo));
if (NS_FAILED(rv) || !nodeinfo) return rv;

View File

@ -316,10 +316,7 @@ inDOMView::GetCellProperties(PRInt32 row, const PRUnichar *colID, nsISupportsArr
if (!node) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content = do_QueryInterface(node->node);
if (content) {
nsCOMPtr<nsIContent> bparent;
content->GetBindingParent(getter_AddRefs(bparent));
if (bparent)
if (content && content->GetBindingParent()) {
properties->AppendElement(kAnonymousAtom);
}

View File

@ -174,8 +174,7 @@ inLayoutUtils::GetScreenOrigin(nsIDOMElement* aElement)
nsRect* rect = new nsRect(0,0,0,0);
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc) {
// Get Presentation shell 0
@ -260,8 +259,7 @@ inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (content) {
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (doc) {
nsCOMPtr<nsIDocument> sub_doc;
doc->GetSubDocumentFor(content, getter_AddRefs(sub_doc));

View File

@ -344,9 +344,7 @@ PRInt32 Node::lookupNamespaceID(nsIAtom* aPrefix)
return nsId;
}
nsCOMPtr<nsIContent> temp(elem);
rv = temp->GetParent(getter_AddRefs(elem));
NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown);
elem = elem->GetParent();
}
if (aPrefix == txXMLAtoms::xmlns) {

View File

@ -1651,9 +1651,9 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange,
}
// Get the parent
nsCOMPtr<nsIContent> parent, parentsFirstChild;
startContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = startContent->GetParent();
if (parent) {
nsCOMPtr<nsIContent> parentsFirstChild;
parent->ChildAt(0, getter_AddRefs(parentsFirstChild));
nsCOMPtr<nsITextContent> textContent =
do_QueryInterface(parentsFirstChild);
@ -2490,8 +2490,8 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent,
// ---------- Is the keystroke in a new window? -------------------
nsCOMPtr<nsIDocument> doc;
if (NS_FAILED(targetContent->GetDocument(getter_AddRefs(doc))) || !doc) {
nsCOMPtr<nsIDocument> doc = targetContent->GetDocument();
if (!doc) {
return NS_OK;
}

View File

@ -3907,8 +3907,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) {
/* get url name as ascii string */
nsAutoString strippedURLNameUCS2;
nsCOMPtr<nsIDocument> doc;
currentForm->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = currentForm->GetDocument();
if (!doc) {
return;
}

View File

@ -100,10 +100,9 @@ static void GetPrimaryPresShell(nsIFrame* aFrame, nsIPresShell** aResult)
if (!aFrame)
return;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
content->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = content->GetDocument();
if (doc)
doc->GetShellAt(0, aResult); // Addref happens here.
}

View File

@ -307,10 +307,9 @@ static void GetPrimaryPresShell(nsIFrame* aFrame, nsIPresShell** aResult)
if (!aFrame)
return;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
content->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = content->GetDocument);
if (doc)
doc->GetShellAt(0, aResult); // Addref happens here.
}

View File

@ -3108,8 +3108,7 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes
char* token = nsCRT::strtok( str, ", ", &newStr );
while (token) {
nsCOMPtr<nsIContent> content(do_QueryInterface(elt));
nsCOMPtr<nsIDocument> doc;
content->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = content->GetDocument();
nsCOMPtr<nsIURI> docURL;
doc->GetDocumentURL(getter_AddRefs(docURL));
nsCOMPtr<nsIURI> url;

View File

@ -325,8 +325,7 @@ nsSecureBrowserUIImpl::Notify(nsIContent* formNode,
if (!window || !actionURL || !formNode)
return NS_OK;
nsCOMPtr<nsIDocument> document;
formNode->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDocument> document = formNode->GetDocument();
if (!document) return NS_OK;
nsCOMPtr<nsIURI> formURL;

View File

@ -249,9 +249,7 @@ nsMenuBarX :: RegisterAsDocumentObserver ( nsIWebShell* inWebShell )
void
nsMenuBarX :: AquifyMenuBar ( )
{
nsCOMPtr<nsIDocument> containingDoc;
mMenuBarContent->GetDocument ( getter_AddRefs(containingDoc) );
nsCOMPtr<nsIDOMDocument> domDoc ( do_QueryInterface(containingDoc) );
nsCOMPtr<nsIDOMDocument> domDoc ( do_QueryInterface(mMenuBarContent->GetDocument()) );
if ( domDoc ) {
// remove quit item and its separator
HideItem ( domDoc, NS_LITERAL_STRING("menu_FileQuitSeparator"), nsnull );
@ -618,8 +616,7 @@ nsMenuBarX :: CreateAppleMenu ( nsIMenu* inMenu )
nsCOMPtr<nsIContent> menu;
inMenu->GetMenuContent(getter_AddRefs(menu));
if (menu) {
nsCOMPtr<nsIDocument> doc;
menu->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = menu->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc ( do_QueryInterface(doc) );
if ( domdoc ) {
@ -759,8 +756,7 @@ nsMenuBarX::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aContainer, aNewIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -813,8 +809,7 @@ nsMenuBarX::ContentRemoved( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentRemoved ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -839,8 +834,7 @@ nsMenuBarX::ContentInserted( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )

View File

@ -272,9 +272,7 @@ NS_METHOD nsMenuItemX::DoCommand()
nsAutoString command;
mContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
@ -335,8 +333,7 @@ nsMenuItemX :: UncheckRadioSiblings(nsIContent* inCheckedContent)
if ( ! myGroupName.Length() ) // no groupname, nothing to do
return;
nsCOMPtr<nsIContent> parent;
inCheckedContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = inCheckedContent->GetParent();
if ( !parent )
return;

View File

@ -871,11 +871,8 @@ void nsMenuX::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent
inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::key, keyValue);
// Try to find the key node. Get the document so we can do |GetElementByID|
nsCOMPtr<nsIDocument> document;
inMenuItemContent->GetDocument(getter_AddRefs(document));
if ( !document )
return;
nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(document);
nsCOMPtr<nsIDOMDocument> domDocument =
do_QueryInterface(inMenuItemContent->GetDocument());
if ( !domDocument )
return;
@ -1020,9 +1017,7 @@ nsMenuX::OnCreate()
// a command attribute. If so, several apptributes must potentially
// be updated.
if (popupContent) {
nsCOMPtr<nsIDocument> doc;
popupContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(popupContent->GetDocument()));
PRInt32 count;
popupContent->ChildCount(count);

View File

@ -554,8 +554,7 @@ nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
// Go find the about menu item
if (!mMenuContent)
return nsEventStatus_eConsumeNoDefault;
nsCOMPtr<nsIDocument> doc;
mMenuContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = mMenuContent->GetDocument();
if (!doc)
return nsEventStatus_eConsumeNoDefault;
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
@ -1063,11 +1062,8 @@ nsMenu::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent )
inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::key, keyValue);
// Try to find the key node. Get the document so we can do |GetElementByID|
nsCOMPtr<nsIDocument> document;
inMenuItemContent->GetDocument(getter_AddRefs(document));
if ( !document )
return;
nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(document);
nsCOMPtr<nsIDOMDocument> domDocument =
do_QueryInterface(inMenuItemContent->GetDocument());
if ( !domDocument )
return;
@ -1211,9 +1207,7 @@ nsMenu::OnCreate()
// a command attribute. If so, several apptributes must potentially
// be updated.
if (popupContent) {
nsCOMPtr<nsIDocument> doc;
popupContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(popupContent->GetDocument()));
PRInt32 count;
popupContent->ChildCount(count);

View File

@ -477,8 +477,7 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu)
nsCOMPtr<nsIContent> menu;
aMenu->GetMenuContent(getter_AddRefs(menu));
if (menu) {
nsCOMPtr<nsIDocument> doc;
menu->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = menu->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc ( do_QueryInterface(doc) );
if ( domdoc ) {
@ -654,8 +653,7 @@ nsMenuBar::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aContainer, aNewIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -708,8 +706,7 @@ nsMenuBar::ContentRemoved( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentRemoved ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -734,8 +731,7 @@ nsMenuBar::ContentInserted( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )

View File

@ -628,8 +628,7 @@ nsMenuBarX :: CreateAppleMenu ( nsIMenu* inMenu )
nsCOMPtr<nsIContent> menu;
inMenu->GetMenuContent(getter_AddRefs(menu));
if (menu) {
nsCOMPtr<nsIDocument> doc;
menu->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = menu->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc ( do_QueryInterface(doc) );
if ( domdoc ) {
@ -769,8 +768,7 @@ nsMenuBarX::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aContainer, aNewIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -823,8 +821,7 @@ nsMenuBarX::ContentRemoved( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentRemoved ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -849,8 +846,7 @@ nsMenuBarX::ContentInserted( nsIDocument * aDocument, nsIContent * aContainer,
if ( obs )
obs->ContentInserted ( aDocument, aChild, aIndexInContainer );
else {
nsCOMPtr<nsIContent> parent;
aContainer->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = aContainer->GetParent();
if(parent) {
Lookup ( parent, getter_AddRefs(obs) );
if ( obs )
@ -1013,9 +1009,7 @@ MenuHelpersX::DispatchCommandTo(nsIWeakReference* aWebShellWeakRef,
nsAutoString command;
aTargetContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDocument> doc;
aTargetContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aTargetContent->GetDocument()));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));

View File

@ -298,9 +298,7 @@ NS_METHOD nsMenuItem::DoCommand()
nsAutoString command;
mContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::command, command);
if (!command.IsEmpty()) {
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMElement> commandElt;
domDoc->GetElementById(command, getter_AddRefs(commandElt));
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));

View File

@ -306,8 +306,7 @@ nsMenuItemX :: UncheckRadioSiblings(nsIContent* inCheckedContent)
if ( ! myGroupName.Length() ) // no groupname, nothing to do
return;
nsCOMPtr<nsIContent> parent;
inCheckedContent->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIContent> parent = inCheckedContent->GetParent();
if ( !parent )
return;

View File

@ -877,11 +877,8 @@ void nsMenuX::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent
inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::key, keyValue);
// Try to find the key node. Get the document so we can do |GetElementByID|
nsCOMPtr<nsIDocument> document;
inMenuItemContent->GetDocument(getter_AddRefs(document));
if ( !document )
return;
nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(document);
nsCOMPtr<nsIDOMDocument> domDocument =
do_QueryInterface(inMenuItemContent->GetDocument());
if ( !domDocument )
return;
@ -1026,9 +1023,7 @@ nsMenuX::OnCreate()
// a command attribute. If so, several apptributes must potentially
// be updated.
if (popupContent) {
nsCOMPtr<nsIDocument> doc;
popupContent->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(popupContent->GetDocument()));
PRInt32 count;
popupContent->ChildCount(count);

View File

@ -258,10 +258,9 @@ nsBaseDragService :: GetFrameFromNode ( nsIDOMNode* inNode, nsIFrame** outFrame,
if ( !inNode || !outContext )
return;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIContent> contentNode = do_QueryInterface(inNode);
if (contentNode) {
contentNode->GetDocument(getter_AddRefs(doc));
nsIDocument* doc = contentNode->GetDocument();
if (doc) {
nsCOMPtr<nsIPresShell> presShell;
doc->GetShellAt(0, getter_AddRefs(presShell));