Adding do_QueryInterface() wrapper for nsCOMPtr carpool. r=scc a=sar

This commit is contained in:
mcafee%netscape.com 1999-02-17 02:08:00 +00:00
Родитель cca2821cab
Коммит 3ece48d719
12 изменённых файлов: 52 добавлений и 51 удалений

Просмотреть файл

@ -185,7 +185,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
aRange->GetStartParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -232,7 +232,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
aRange->GetEndParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -507,7 +507,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
aRange->GetStartParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -572,7 +572,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
aRange->GetEndParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;

Просмотреть файл

@ -501,8 +501,8 @@ nsGenericDOMDataNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
nsCOMPtr<nsIContent> startContent;
nsCOMPtr<nsIContent> endContent;
startContent = startNode;
endContent = endNode;
startContent = do_QueryInterface(startNode);
endContent = do_QueryInterface(endNode);
nsString buffer;

Просмотреть файл

@ -218,7 +218,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
// end of the root node, becasue it has no parent.
// so instead represent it by (node,0) and (node,numChildren)
*outParent = aNode;
nsCOMPtr<nsIContent> cN(*outParent);
nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
if (!cN)
return false;
cN->ChildCount(indx);
@ -229,7 +229,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
}
else
{
nsCOMPtr<nsIContent> cN(*outParent);
nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
if (!NS_SUCCEEDED(cN->IndexOf(aNode, indx)))
return false;
*outStartOffset = indx;
@ -1251,7 +1251,7 @@ nsRange::CloneSibsAndParents(nsCOMPtr<nsIDOMNode> parentNode, PRInt32 nodeOffset
// Make clone of parent:
if (parentNode == commonParent || !parentNode)
{
parentClone = docfrag;
parentClone = do_QueryInterface(docfrag);
}
else
{

Просмотреть файл

@ -255,14 +255,14 @@ void nsCaret::DrawCaret()
domSelection->GetFocusNodeAndOffset(getter_doesnt_AddRef(focusNode), &focusOffset);
// is this a text node?
nsCOMPtr<nsIDOMCharacterData> nodeAsText(focusNode);
nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(focusNode));
if (nodeAsText)
{
PRInt32 contentOffset = focusOffset;
if (focusNode)
{
nsCOMPtr<nsIContent>contentNode(focusNode);
nsCOMPtr<nsIContent>contentNode(do_QueryInterface(focusNode));
if (contentNode)
{

Просмотреть файл

@ -255,14 +255,14 @@ void nsCaret::DrawCaret()
domSelection->GetFocusNodeAndOffset(getter_doesnt_AddRef(focusNode), &focusOffset);
// is this a text node?
nsCOMPtr<nsIDOMCharacterData> nodeAsText(focusNode);
nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(focusNode));
if (nodeAsText)
{
PRInt32 contentOffset = focusOffset;
if (focusNode)
{
nsCOMPtr<nsIContent>contentNode(focusNode);
nsCOMPtr<nsIContent>contentNode(do_QueryInterface(focusNode));
if (contentNode)
{

Просмотреть файл

@ -185,7 +185,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
aRange->GetStartParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -232,7 +232,7 @@ nsresult nsContentIterator::Init(nsIDOMRange* aRange)
aRange->GetEndParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -507,7 +507,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
aRange->GetStartParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;
@ -572,7 +572,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
aRange->GetEndParent(getter_AddRefs(dN));
if (!dN)
return NS_ERROR_ILLEGAL_VALUE;
cN = dN;
cN = do_QueryInterface(dN);
if (!cN)
return NS_ERROR_FAILURE;

Просмотреть файл

@ -501,8 +501,8 @@ nsGenericDOMDataNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
nsCOMPtr<nsIContent> startContent;
nsCOMPtr<nsIContent> endContent;
startContent = startNode;
endContent = endNode;
startContent = do_QueryInterface(startNode);
endContent = do_QueryInterface(endNode);
nsString buffer;

Просмотреть файл

@ -218,7 +218,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
// end of the root node, becasue it has no parent.
// so instead represent it by (node,0) and (node,numChildren)
*outParent = aNode;
nsCOMPtr<nsIContent> cN(*outParent);
nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
if (!cN)
return false;
cN->ChildCount(indx);
@ -229,7 +229,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
}
else
{
nsCOMPtr<nsIContent> cN(*outParent);
nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
if (!NS_SUCCEEDED(cN->IndexOf(aNode, indx)))
return false;
*outStartOffset = indx;
@ -1251,7 +1251,7 @@ nsRange::CloneSibsAndParents(nsCOMPtr<nsIDOMNode> parentNode, PRInt32 nodeOffset
// Make clone of parent:
if (parentNode == commonParent || !parentNode)
{
parentClone = docfrag;
parentClone = do_QueryInterface(docfrag);
}
else
{

Просмотреть файл

@ -522,7 +522,7 @@ nsRangeList::HandleKeyEvent(nsIFocusTracker *aTracker, nsGUIEvent *aGuiEvent, ns
nsCOMPtr<nsIContent> content;
if (NS_FAILED(aFrame->GetContent(getter_AddRefs(content))) || !content)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMNode> domnode(content);
nsCOMPtr<nsIDOMNode> domnode(do_QueryInterface(content));
if (!domnode)
return NS_ERROR_FAILURE;
@ -634,10 +634,10 @@ compareFrames(nsIFrame *aBegin, nsIFrame *aEnd)
return 0;
nsCOMPtr<nsIContent> beginContent;
if (NS_SUCCEEDED(aBegin->GetContent(getter_AddRefs(beginContent))) && beginContent){
nsCOMPtr<nsIDOMNode>beginNode (beginContent);
nsCOMPtr<nsIDOMNode>beginNode (do_QueryInterface(beginContent));
nsCOMPtr<nsIContent> endContent;
if (NS_SUCCEEDED(aEnd->GetContent(getter_AddRefs(endContent))) && endContent){
nsCOMPtr<nsIDOMNode>endNode (endContent);
nsCOMPtr<nsIDOMNode>endNode (do_QueryInterface(endContent));
PRBool storage;
PRInt32 int1;
PRInt32 int2;
@ -700,7 +700,7 @@ nsRangeList::TakeFocus(nsIFocusTracker *aTracker, nsIFrame *aFrame, PRInt32 aOff
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIDOMNode> domNode;
if (NS_SUCCEEDED(aFrame->GetContent(getter_AddRefs(content))) && content){
domNode = content;
domNode = do_QueryInterface(content);
nsCOMPtr<nsIDOMNode> parent;
nsCOMPtr<nsIDOMNode> parent2;
if (NS_FAILED(domNode->GetParentNode(getter_AddRefs(parent))) || !parent)
@ -752,11 +752,11 @@ nsRangeList::TakeFocus(nsIFocusTracker *aTracker, nsIFrame *aFrame, PRInt32 aOff
else if (frame){ //we need to check to see what the order is.
nsCOMPtr<nsIContent>oldContent;
if (NS_SUCCEEDED(frame->GetContent(getter_AddRefs(oldContent))) && oldContent){
nsCOMPtr<nsIDOMNode> oldDomNode(oldContent);
nsCOMPtr<nsIDOMNode> oldDomNode(do_QueryInterface(oldContent));
if (oldDomNode && (oldDomNode == GetFocusNode())) {
nsCOMPtr<nsIContent> anchorContent;
if (NS_SUCCEEDED(anchor->GetContent(getter_AddRefs(anchorContent))) && anchorContent){
nsCOMPtr<nsIDOMNode>anchorDomNode(anchorContent);
nsCOMPtr<nsIDOMNode>anchorDomNode(do_QueryInterface(anchorContent));
if (anchorDomNode && anchorDomNode == GetAnchorNode()) {
@ -919,10 +919,10 @@ nsRangeList::ResetSelection(nsIFocusTracker *aTracker, nsIFrame *aStartFrame)
range->GetStartOffset(&startOffset);
range->GetEndParent(getter_AddRefs(endNode));
range->GetEndOffset(&endOffset);
nsCOMPtr<nsIContent> startContent(startNode);
nsCOMPtr<nsIContent> startContent(do_QueryInterface(startNode));
result = findFrameFromContent(aStartFrame, startContent,PR_TRUE);
if (result){
nsCOMPtr<nsIContent> endContent(endNode);
nsCOMPtr<nsIContent> endContent(do_QueryInterface(endNode));
if (endContent == startContent){
if (startContent == frameContent)
frameOffset = GetFocusOffset();
@ -995,7 +995,7 @@ nsresult nsRangeList::NotifySelectionListeners()
for (PRInt32 i = 0; i < mSelectionListeners->Count();i++)
{
nsCOMPtr<nsISupports> thisEntry(mSelectionListeners->ElementAt(i));
nsCOMPtr<nsIDOMSelectionListener> thisListener(thisEntry);
nsCOMPtr<nsIDOMSelectionListener> thisListener(do_QueryInterface(thisEntry));
if (thisListener)
thisListener->NotifySelectionChanged();
}

Просмотреть файл

@ -175,6 +175,6 @@ nsCOMPtr<nsIDOMNode> nsBaseAppCore::GetParentNodeFromDOMDoc(nsIDOMDocument * aDO
nsCOMPtr<nsIDOMElement> element;
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
if (element)
return nsCOMPtr<nsIDOMNode>(element);
return nsCOMPtr<nsIDOMNode>(do_QueryInterface(element));
return node;
} // nsToolbarCore::GetParentNodeFromDOMDoc

Просмотреть файл

@ -388,7 +388,7 @@ nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedParentFromDoc(nsIDOMDocument * a
if (!element)
return node;
nsCOMPtr<nsIDOMNode> parent(element);
nsCOMPtr<nsIDOMNode> parent(do_QueryInterface(element));
if (!parent)
return node;
@ -571,7 +571,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
if (!element)
return;
nsCOMPtr<nsIDOMNode> window(element);
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
nsresult rv;
int endCount = 0;
@ -593,7 +593,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi
nsCOMPtr<nsIDOMNode> menuNode;
menubarNode->GetFirstChild(getter_AddRefs(menuNode));
while (menuNode) {
nsCOMPtr<nsIDOMElement> menuElement(menuNode);
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
if (menuElement) {
nsString menuNodeType;
nsString menuName;
@ -618,7 +618,8 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi
nsCOMPtr<nsIDOMNode> menuitemNode;
menuNode->GetFirstChild(getter_AddRefs(menuitemNode));
while (menuitemNode) {
nsCOMPtr<nsIDOMElement> menuitemElement(menuitemNode);
nsCOMPtr<nsIDOMElement>
menuitemElement(do_QueryInterface(menuitemNode));
if (menuitemElement) {
nsString menuitemNodeType;
nsString menuitemName;
@ -789,7 +790,7 @@ nsCOMPtr<nsIDOMNode> nsWebShellWindow::GetParentNodeFromDOMDoc(nsIDOMDocument *
nsCOMPtr<nsIDOMElement> element;
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
if (element)
return nsCOMPtr<nsIDOMNode>(element);
return nsCOMPtr<nsIDOMNode>(do_QueryInterface(element));
return node;
} // nsWebShellWindow::GetParentNodeFromDOMDoc
@ -809,14 +810,14 @@ nsCOMPtr<nsIDOMDocument> nsWebShellWindow::GetNamedDOMDoc(const nsString & aWebS
if (!cv)
return domDoc;
nsCOMPtr<nsIDocumentViewer> docv(cv);
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
if (!docv)
return domDoc;
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(*getter_AddRefs(doc));
if (doc)
return nsCOMPtr<nsIDOMDocument>(doc);
return nsCOMPtr<nsIDOMDocument>(do_QueryInterface(doc));
return domDoc;
} // nsWebShellWindow::GetNamedDOMDoc
@ -925,7 +926,7 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
nsCOMPtr<nsIDOMNode> statusNode(FindNamedDOMNode(nsAutoString("#text"), parent, count, 7));
if (!statusNode)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMCharacterData> charData(statusNode);
nsCOMPtr<nsIDOMCharacterData> charData(do_QueryInterface(statusNode));
if (!charData)
return NS_ERROR_FAILURE;
mStatusText = charData;
@ -988,17 +989,17 @@ nsWebShellWindow::GetDOMNodeFromWebShell(nsIWebShell *aShell)
nsCOMPtr<nsIContentViewer> cv;
aShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIDocumentViewer> docv(cv);
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
if (docv) {
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(*getter_AddRefs(doc));
if (doc) {
nsCOMPtr<nsIDOMDocument> domdoc(doc);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc));
if (domdoc) {
nsCOMPtr<nsIDOMElement> element;
domdoc->GetDocumentElement(getter_AddRefs(element));
if (element)
node = element;
node = do_QueryInterface(element);
}
}
}
@ -1021,7 +1022,7 @@ void nsWebShellWindow::LoadCommandsInWebShell(nsIWebShell *aShell)
nsCOMPtr<nsIDOMNode> webshellNode = GetDOMNodeFromWebShell(aShell);
if (!webshellNode)
return;
nsCOMPtr<nsIDOMElement> webshellElement(webshellNode);
nsCOMPtr<nsIDOMElement> webshellElement(do_QueryInterface(webshellNode));
if (!webshellElement)
return;
@ -1035,7 +1036,7 @@ void nsWebShellWindow::LoadCommandsInWebShell(nsIWebShell *aShell)
nsCOMPtr<nsIDOMNode> commandRoot;
if (NS_FAILED(commandRootList->Item(rootCtr, getter_AddRefs(commandRoot))))
break;
nsCOMPtr<nsIDOMElement> commandRootElement(commandRoot);
nsCOMPtr<nsIDOMElement> commandRootElement(do_QueryInterface(commandRoot));
if (!commandRootElement)
break;
@ -1073,7 +1074,7 @@ void nsWebShellWindow::LoadCommandsInWebShell(nsIWebShell *aShell)
void
nsWebShellWindow::MakeOneCommand(nsIWebShell *aShell, nsCOMPtr<nsIDOMNode> aCommand)
{
nsCOMPtr<nsIDOMElement> cmdElement(aCommand);
nsCOMPtr<nsIDOMElement> cmdElement(do_QueryInterface(aCommand));
if (!cmdElement)
return;
@ -1112,7 +1113,7 @@ nsWebShellWindow::ConnectCommandsToWidgetsByType(nsIWebShell *aShell, nsString &
nsCOMPtr<nsIDOMNode> webshellNode = GetDOMNodeFromWebShell(aShell);
if (!webshellNode)
return;
nsCOMPtr<nsIDOMElement> webshellElement(webshellNode);
nsCOMPtr<nsIDOMElement> webshellElement(do_QueryInterface(webshellNode));
if (!webshellElement)
return;

Просмотреть файл

@ -150,12 +150,12 @@ NS_IMETHODIMP nsXULCommand::SetEnabled(PRBool aIsEnabled)
PRInt32 i, n = mSrcWidgets.Count();
for (i = 0; i < n; i++) {
nsCOMPtr<nsIDOMNode> node = dont_AddRef(NS_STATIC_CAST(nsIDOMNode*,mSrcWidgets.ElementAt(i)));
nsCOMPtr<nsIDOMHTMLInputElement> input ( node );
nsCOMPtr<nsIDOMHTMLInputElement> input ( do_QueryInterface(node) );
//*** rewrite this part to set an attribute on a nsIDOMElement
if ( input ) {
input->SetDisabled(aIsEnabled);
} else {
nsCOMPtr<nsIDOMHTMLButtonElement> btn ( node );
nsCOMPtr<nsIDOMHTMLButtonElement> btn ( do_QueryInterface(node) );
if ( btn )
btn->SetDisabled(!aIsEnabled);
}
@ -330,7 +330,7 @@ nsresult nsXULCommand::KeyUp(nsIDOMEvent* aKeyEvent)
if (nsIDOMEvent::VK_RETURN != type) {
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLInputElement> input ( mDOMElement );
nsCOMPtr<nsIDOMHTMLInputElement> input ( do_QueryInterface(mDOMElement) );
if ( input ) {
nsAutoString value;
input->GetValue(value);