Fix for bug 183999 (Modernize content). r=caillon, sr=bz.

This commit is contained in:
peterv%netscape.com 2002-12-11 14:24:49 +00:00
parent 976d27bd73
commit d96051a4a2
107 changed files with 1197 additions and 1703 deletions

View File

@ -1048,9 +1048,9 @@ nsContentAreaDragDrop::GetImageFrame(nsIContent* aContent, nsIDocument *aDocumen
if (NS_SUCCEEDED(rv) && frame) { if (NS_SUCCEEDED(rv) && frame) {
nsCOMPtr<nsIAtom> type; nsCOMPtr<nsIAtom> type;
frame->GetFrameType(getter_AddRefs(type)); frame->GetFrameType(getter_AddRefs(type));
if (type.get() == nsLayoutAtoms::imageFrame) { if (type == nsLayoutAtoms::imageFrame) {
nsIImageFrame* imageFrame; nsIImageFrame* imageFrame;
rv = frame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame); rv = CallQueryInterface(frame, &imageFrame);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("Should not happen - frame is not image frame even though type is nsLayoutAtoms::imageFrame"); NS_WARNING("Should not happen - frame is not image frame even though type is nsLayoutAtoms::imageFrame");
return rv; return rv;
@ -1108,10 +1108,11 @@ nsContentAreaDragDrop::GetImageFromDOMNode(nsIDOMNode* inNode, nsIImage**outImag
if (imgContainer) { if (imgContainer) {
nsCOMPtr<gfxIImageFrame> imgFrame; nsCOMPtr<gfxIImageFrame> imgFrame;
imgContainer->GetFrameAt(0, getter_AddRefs(imgFrame)); imgContainer->GetFrameAt(0, getter_AddRefs(imgFrame));
if ( imgFrame ) { if (imgFrame) {
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(imgFrame); nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(imgFrame);
if ( ir ) if (ir) {
rv = ir->GetInterface(NS_GET_IID(nsIImage), (void**)outImage); // will addreff rv = CallGetInterface(ir.get(), outImage);
}
} }
} }
} }

View File

@ -284,18 +284,22 @@ public:
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult) nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult)
{ {
nsContentIterator * iter = new nsContentIterator(); nsContentIterator * iter = new nsContentIterator();
if (iter) if (!iter) {
return iter->QueryInterface(NS_GET_IID(nsIContentIterator), (void**) aInstancePtrResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(iter, aInstancePtrResult);
} }
nsresult NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult) nsresult NS_NewPreContentIterator(nsIContentIterator** aInstancePtrResult)
{ {
nsContentIterator * iter = new nsPreContentIterator(); nsContentIterator * iter = new nsPreContentIterator();
if (iter) if (!iter) {
return iter->QueryInterface(NS_GET_IID(nsIContentIterator), (void**) aInstancePtrResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(iter, aInstancePtrResult);
} }
@ -1218,11 +1222,11 @@ nsresult nsContentIterator::PositionAt(nsIContent* aCurNode)
nsresult nsContentIterator::CurrentNode(nsIContent **aNode) nsresult nsContentIterator::CurrentNode(nsIContent **aNode)
{ {
if (!mCurNode) if (!mCurNode || mIsDone) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (mIsDone) }
return NS_ERROR_FAILURE;
return mCurNode->QueryInterface(NS_GET_IID(nsIContent), (void**) aNode); return CallQueryInterface(mCurNode, aNode);
} }
@ -1298,9 +1302,11 @@ nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult);
nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult) nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult)
{ {
nsContentIterator * iter = new nsContentSubtreeIterator(); nsContentIterator * iter = new nsContentSubtreeIterator();
if (iter) if (!iter) {
return iter->QueryInterface(NS_GET_IID(nsIContentIterator), (void**) aInstancePtrResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(iter, aInstancePtrResult);
} }

View File

@ -396,9 +396,7 @@ nsContentUtils::GetClassInfoInstance(nsDOMClassInfoID aID)
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID); NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
nsServiceManager::GetService(kDOMScriptObjectFactoryCID, CallGetService(kDOMScriptObjectFactoryCID, &sDOMScriptObjectFactory);
NS_GET_IID(nsIDOMScriptObjectFactory),
(nsISupports **)&sDOMScriptObjectFactory);
if (!sDOMScriptObjectFactory) { if (!sDOMScriptObjectFactory) {
return nsnull; return nsnull;

View File

@ -190,8 +190,7 @@ nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
NS_ENSURE_ARG_POINTER(aOwnerElement); NS_ENSURE_ARG_POINTER(aOwnerElement);
if (mContent) { if (mContent) {
return mContent->QueryInterface(NS_GET_IID(nsIDOMElement), return CallQueryInterface(mContent, aOwnerElement);
(void **)aOwnerElement);
} }
*aOwnerElement = nsnull; *aOwnerElement = nsnull;
@ -292,13 +291,13 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
nsCOMPtr<nsITextContent> content; nsCOMPtr<nsITextContent> content;
result = NS_NewTextNode(getter_AddRefs(content)); result = NS_NewTextNode(getter_AddRefs(content));
if (NS_OK != result) { if (NS_FAILED(result)) {
return result; return result;
} }
result = content->QueryInterface(NS_GET_IID(nsIDOMText), (void**)&mChild); result = CallQueryInterface(content, &mChild);
} }
mChild->SetData(value); mChild->SetData(value);
result = mChild->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aFirstChild); result = CallQueryInterface(mChild, aFirstChild);
} }
else { else {
*aFirstChild = nsnull; *aFirstChild = nsnull;
@ -387,7 +386,7 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return newAttr->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); return CallQueryInterface(newAttr, aReturn);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -395,11 +394,9 @@ nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
{ {
nsresult result = NS_OK; nsresult result = NS_OK;
if (mContent) { if (mContent) {
nsIDOMNode* node; nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mContent, &result);
result = mContent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = node->GetOwnerDocument(aOwnerDocument); result = node->GetOwnerDocument(aOwnerDocument);
NS_RELEASE(node);
} }
} }
else { else {
@ -434,7 +431,7 @@ nsDOMAttribute::SetPrefix(const nsAString& aPrefix)
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix))
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
rv = mNodeInfo->PrefixChanged(prefix, *getter_AddRefs(newNodeInfo)); rv = mNodeInfo->PrefixChanged(prefix, *getter_AddRefs(newNodeInfo));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -104,8 +104,7 @@ nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
domAttribute = new nsDOMAttribute(mContent, ni, value); domAttribute = new nsDOMAttribute(mContent, ni, value);
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aAttribute);
(void **)aAttribute);
} }
} }
@ -159,8 +158,7 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} }
attribute->GetValue(value); attribute->GetValue(value);
@ -204,8 +202,7 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} else { } else {
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
} }
@ -247,8 +244,7 @@ nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
nsDOMAttribute* domAttribute = new nsDOMAttribute(mContent, ni, value); nsDOMAttribute* domAttribute = new nsDOMAttribute(mContent, ni, value);
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} }
else { else {
*aReturn = nsnull; *aReturn = nsnull;
@ -284,7 +280,7 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (mContent) { if (mContent) {
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
PRInt32 nameSpaceID = kNameSpaceID_None; PRInt32 nameSpaceID = kNameSpaceID_None;
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
@ -318,8 +314,7 @@ nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI,
domAttribute = new nsDOMAttribute(mContent, ni, value); domAttribute = new nsDOMAttribute(mContent, ni, value);
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} }
} }
@ -377,8 +372,7 @@ nsDOMAttributeMap::SetNamedItemNS(nsIDOMNode* aArg, nsIDOMNode** aReturn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} }
attribute->GetValue(value); attribute->GetValue(value);
@ -400,7 +394,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (mContent) { if (mContent) {
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
PRInt32 nameSpaceID = kNameSpaceID_None; PRInt32 nameSpaceID = kNameSpaceID_None;
nsCOMPtr<nsIDOMNode> attribute; nsCOMPtr<nsIDOMNode> attribute;
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
@ -436,8 +430,7 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr), rv = CallQueryInterface(domAttribute, aReturn);
(void **)aReturn);
} else { } else {
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
} }

View File

@ -198,10 +198,11 @@ nsDOMDocumentType::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
mPublicId, mPublicId,
mSystemId, mSystemId,
mInternalSubset); mInternalSubset);
if (nsnull == it) { if (!it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aReturn);
return CallQueryInterface(it, aReturn);
} }
#ifdef DEBUG #ifdef DEBUG

View File

@ -319,9 +319,11 @@ NS_EXPORT nsresult
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult) NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult)
{ {
nsDOMImplementation* domImpl = new nsDOMImplementation(); nsDOMImplementation* domImpl = new nsDOMImplementation();
if (domImpl == nsnull) if (!domImpl) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
return domImpl->QueryInterface(NS_GET_IID(nsIDOMDOMImplementation), (void**) aInstancePtrResult); }
return CallQueryInterface(domImpl, aInstancePtrResult);
} }
nsDOMImplementation::nsDOMImplementation(nsIURI* aBaseURI) nsDOMImplementation::nsDOMImplementation(nsIURI* aBaseURI)
@ -448,14 +450,14 @@ nsDocumentChildNodes::GetLength(PRUint32* aLength)
NS_IMETHODIMP NS_IMETHODIMP
nsDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsDocumentChildNodes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{ {
nsresult result = NS_OK;
nsCOMPtr<nsIContent> content;
*aReturn = nsnull; *aReturn = nsnull;
if (nsnull != mDocument) {
nsresult result = NS_OK;
if (mDocument) {
nsCOMPtr<nsIContent> content;
result = mDocument->ChildAt(aIndex, *getter_AddRefs(content)); result = mDocument->ChildAt(aIndex, *getter_AddRefs(content));
if ((NS_OK == result) && (nsnull != content)) { if (NS_SUCCEEDED(result) && content) {
result = content->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); result = CallQueryInterface(content, aReturn);
} }
} }
@ -516,9 +518,7 @@ nsDocument::nsDocument() : mSubDocuments(nsnull),
mInDestructor = PR_FALSE; mInDestructor = PR_FALSE;
mHeaderData = nsnull; mHeaderData = nsnull;
mChildNodes = nsnull; mChildNodes = nsnull;
mModCount = 0;
mNextContentID = NS_CONTENT_ID_COUNTER_BASE; mNextContentID = NS_CONTENT_ID_COUNTER_BASE;
mDTD = 0;
mBoxObjectTable = nsnull; mBoxObjectTable = nsnull;
mNumCapturers = 0; mNumCapturers = 0;
#ifdef IBMBIDI #ifdef IBMBIDI
@ -615,8 +615,6 @@ nsDocument::~nsDocument()
mHeaderData = nsnull; mHeaderData = nsnull;
} }
NS_IF_RELEASE(mDTD);
delete mBoxObjectTable; delete mBoxObjectTable;
if (mNodeInfoManager) { if (mNodeInfoManager) {
@ -2285,8 +2283,7 @@ nsDocument::GetDoctype(nsIDOMDocumentType** aDoctype)
node->GetNodeType(&nodeType); node->GetNodeType(&nodeType);
if (nodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) { if (nodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) {
return node->QueryInterface(NS_GET_IID(nsIDOMDocumentType), return CallQueryInterface(node, aDoctype);
(void **)aDoctype);
} }
} }
} }
@ -2300,11 +2297,11 @@ nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
// For now, create a new implementation every time. This shouldn't // For now, create a new implementation every time. This shouldn't
// be a high bandwidth operation // be a high bandwidth operation
nsDOMImplementation* impl = new nsDOMImplementation(mDocumentURL); nsDOMImplementation* impl = new nsDOMImplementation(mDocumentURL);
if (nsnull == impl) { if (!impl) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return impl->QueryInterface(NS_GET_IID(nsIDOMDOMImplementation), (void**)aImplementation); return CallQueryInterface(impl, aImplementation);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -2352,7 +2349,7 @@ nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn)
nsresult rv = NS_NewTextNode(getter_AddRefs(text)); nsresult rv = NS_NewTextNode(getter_AddRefs(text));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
rv = text->QueryInterface(NS_GET_IID(nsIDOMText), (void**)aReturn); rv = CallQueryInterface(text, aReturn);
(*aReturn)->AppendData(aData); (*aReturn)->AppendData(aData);
} }
@ -2371,8 +2368,8 @@ nsDocument::CreateComment(const nsAString& aData, nsIDOMComment** aReturn)
nsCOMPtr<nsIContent> comment; nsCOMPtr<nsIContent> comment;
nsresult rv = NS_NewCommentNode(getter_AddRefs(comment)); nsresult rv = NS_NewCommentNode(getter_AddRefs(comment));
if (NS_OK == rv) { if (NS_SUCCEEDED(rv)) {
rv = comment->QueryInterface(NS_GET_IID(nsIDOMComment), (void**)aReturn); rv = CallQueryInterface(comment, aReturn);
(*aReturn)->AppendData(aData); (*aReturn)->AppendData(aData);
} }
@ -2413,7 +2410,7 @@ nsDocument::CreateAttribute(const nsAString& aName,
attribute = new nsDOMAttribute(nsnull, nodeInfo, value); attribute = new nsDOMAttribute(nsnull, nodeInfo, value);
NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY);
return attribute->QueryInterface(NS_GET_IID(nsIDOMAttr), (void**)aReturn); return CallQueryInterface(attribute, aReturn);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -2437,7 +2434,7 @@ NS_IMETHODIMP
nsDocument::GetElementsByTagName(const nsAString& aTagname, nsDocument::GetElementsByTagName(const nsAString& aTagname,
nsIDOMNodeList** aReturn) nsIDOMNodeList** aReturn)
{ {
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aTagname))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
nsCOMPtr<nsIContentList> list; nsCOMPtr<nsIContentList> list;
NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown, nsnull, NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown, nsnull,
@ -2470,7 +2467,7 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
} }
if (!list) { if (!list) {
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
NS_GetContentList(this, nameAtom, nameSpaceId, nsnull, NS_GetContentList(this, nameAtom, nameSpaceId, nsnull,
getter_AddRefs(list)); getter_AddRefs(list));
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
@ -2614,7 +2611,7 @@ GetElementByAttribute(nsIContent* aContent,
nsresult rv = aContent->GetAttr(kNameSpaceID_None, aAttrName, value); nsresult rv = aContent->GetAttr(kNameSpaceID_None, aAttrName, value);
if (rv == NS_CONTENT_ATTR_HAS_VALUE) { if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (aUniversalMatch || value.Equals(aAttrValue)) if (aUniversalMatch || value.Equals(aAttrValue))
return aContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aResult); return CallQueryInterface(aContent, aResult);
} }
PRInt32 childCount; PRInt32 childCount;
@ -2647,7 +2644,7 @@ nsDocument::GetAnonymousElementByAttribute(nsIDOMElement* aElement,
if (!nodeList) if (!nodeList)
return NS_OK; return NS_OK;
nsCOMPtr<nsIAtom> attribute = getter_AddRefs(NS_NewAtom(aAttrName)); nsCOMPtr<nsIAtom> attribute = do_GetAtom(aAttrName);
PRUint32 length; PRUint32 length;
nodeList->GetLength(&length); nodeList->GetLength(&length);
@ -2737,15 +2734,10 @@ nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
rv = ctx->GetContainer(getter_AddRefs(container)); rv = ctx->GetContainer(getter_AddRefs(container));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv);
nsCOMPtr<nsIInterfaceRequestor> ifrq(do_QueryInterface(container)); nsCOMPtr<nsIDOMWindowInternal> window = do_GetInterface(container);
NS_ENSURE_TRUE(ifrq, NS_OK);
nsCOMPtr<nsIDOMWindowInternal> window;
ifrq->GetInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_OK); NS_ENSURE_TRUE(window, NS_OK);
window->QueryInterface(NS_GET_IID(nsIDOMAbstractView), CallQueryInterface(window, aDefaultView);
(void **)aDefaultView);
return NS_OK; return NS_OK;
} }
@ -3022,15 +3014,15 @@ nsDocument::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes) nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
{ {
if (nsnull == mChildNodes) { if (!mChildNodes) {
mChildNodes = new nsDocumentChildNodes(this); mChildNodes = new nsDocumentChildNodes(this);
if (nsnull == mChildNodes) { if (!mChildNodes) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
NS_ADDREF(mChildNodes); NS_ADDREF(mChildNodes);
} }
return mChildNodes->QueryInterface(NS_GET_IID(nsIDOMNodeList), (void**)aChildNodes); return CallQueryInterface(mChildNodes, aChildNodes);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -3461,7 +3453,7 @@ nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
nsresult nsDocument::GetListenerManager(nsIEventListenerManager **aInstancePtrResult) nsresult nsDocument::GetListenerManager(nsIEventListenerManager **aInstancePtrResult)
{ {
if (nsnull != mListenerManager) { if (nsnull != mListenerManager) {
return mListenerManager->QueryInterface(NS_GET_IID(nsIEventListenerManager), (void**) aInstancePtrResult); return CallQueryInterface(mListenerManager, aInstancePtrResult);
} }
if (NS_OK == NS_NewEventListenerManager(aInstancePtrResult)) { if (NS_OK == NS_NewEventListenerManager(aInstancePtrResult)) {
mListenerManager = *aInstancePtrResult; mListenerManager = *aInstancePtrResult;
@ -3539,12 +3531,12 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
nsrefcnt rc; nsrefcnt rc;
NS_RELEASE2(*aDOMEvent, rc); NS_RELEASE2(*aDOMEvent, rc);
if (0 != rc) { if (0 != rc) {
//Okay, so someone in the DOM loop (a listener, JS object) still has a ref to the DOM Event but // Okay, so someone in the DOM loop (a listener, JS object) still has
//the internal data hasn't been malloc'd. Force a copy of the data here so the DOM Event is still valid. // a ref to the DOM Event but the internal data hasn't been malloc'd.
nsIPrivateDOMEvent *mPrivateEvent; // Force a copy of the data here so the DOM Event is still valid.
if (NS_OK == (*aDOMEvent)->QueryInterface(NS_GET_IID(nsIPrivateDOMEvent), (void**)&mPrivateEvent)) { nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
mPrivateEvent->DuplicatePrivateData(); if (privateEvent) {
NS_RELEASE(mPrivateEvent); privateEvent->DuplicatePrivateData();
} }
} }
aDOMEvent = nsnull; aDOMEvent = nsnull;

View File

@ -657,14 +657,8 @@ protected:
PRBool mBidiEnabled; PRBool mBidiEnabled;
#endif // IBMBIDI #endif // IBMBIDI
// disk file members
nsCOMPtr<nsIURI> mDocumentURI;
PRInt32 mModCount;
nsIDTD* mDTD;
nsCOMPtr<nsIBindingManager> mBindingManager; nsCOMPtr<nsIBindingManager> mBindingManager;
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager; // OWNER nsCOMPtr<nsINodeInfoManager> mNodeInfoManager;
PRBool mIsGoingAway; // True if the document is being destroyed. PRBool mIsGoingAway; // True if the document is being destroyed.

View File

@ -527,7 +527,7 @@ static nsresult ChildAt(nsIDOMNode* aNode, PRInt32 aIndex, nsIDOMNode*& aChild)
node->ChildAt(aIndex, *getter_AddRefs(child)); node->ChildAt(aIndex, *getter_AddRefs(child));
if (child) if (child)
child->QueryInterface(NS_GET_IID(nsIDOMNode), (void **)&aChild); return CallQueryInterface(child, &aChild);
return NS_OK; return NS_OK;
} }

View File

@ -345,8 +345,7 @@ nsDocumentFragment::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
return NS_OK; return NS_OK;
} }
return mOwnerDocument->QueryInterface(NS_GET_IID(nsIDOMDocument), return CallQueryInterface(mOwnerDocument, aOwnerDocument);
(void **)aOwnerDocument);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -1785,7 +1785,7 @@ DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent,
// do a breadth search across all siblings // do a breadth search across all siblings
PRInt32 inx; PRInt32 inx;
for (inx=0;inx<numChildren;inx++) { for (inx = 0; inx < numChildren; ++inx) {
nsCOMPtr<nsIContent> child; nsCOMPtr<nsIContent> child;
if (NS_SUCCEEDED(aParentContent->ChildAt(inx, *getter_AddRefs(child))) && child) { if (NS_SUCCEEDED(aParentContent->ChildAt(inx, *getter_AddRefs(child))) && child) {
nsCOMPtr<nsISupports> temp; nsCOMPtr<nsISupports> temp;
@ -1869,7 +1869,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
nsISupports* data = (nsISupports*)clientData; nsISupports* data = (nsISupports*)clientData;
if (data) { if (data) {
data->QueryInterface(NS_GET_IID(nsIView), (void **)&containerView); CallQueryInterface(data, &containerView);
} }
} }

View File

@ -188,9 +188,11 @@ private:
nsresult NS_NewGenRegularIterator(nsIContentIterator ** aInstancePtrResult) nsresult NS_NewGenRegularIterator(nsIContentIterator ** aInstancePtrResult)
{ {
nsGeneratedContentIterator * iter = new nsGeneratedContentIterator(); nsGeneratedContentIterator * iter = new nsGeneratedContentIterator();
if (iter) if (!iter) {
return iter->QueryInterface(NS_GET_IID(nsIContentIterator), (void**) aInstancePtrResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(iter, aInstancePtrResult);
} }
@ -825,13 +827,15 @@ nsresult nsGeneratedContentIterator::PositionAt(nsIContent* aCurNode)
nsresult nsGeneratedContentIterator::CurrentNode(nsIContent **aNode) nsresult nsGeneratedContentIterator::CurrentNode(nsIContent **aNode)
{ {
if (!mCurNode) if (!mCurNode || mIsDone) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (mIsDone) }
return NS_ERROR_FAILURE;
if (mGenIter) if (mGenIter) {
return mGenIter->CurrentNode(aNode); return mGenIter->CurrentNode(aNode);
return mCurNode->QueryInterface(NS_GET_IID(nsIContent), (void**) aNode); }
return CallQueryInterface(mCurNode, aNode);
} }
@ -893,9 +897,11 @@ nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult);
nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult) nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult)
{ {
nsGeneratedSubtreeIterator * iter = new nsGeneratedSubtreeIterator(); nsGeneratedSubtreeIterator * iter = new nsGeneratedSubtreeIterator();
if (iter) if (!iter) {
return iter->QueryInterface(NS_GET_IID(nsIContentIterator), (void**) aInstancePtrResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(iter, aInstancePtrResult);
} }

View File

@ -1146,7 +1146,7 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn)
} }
} }
return newNode->QueryInterface(NS_GET_IID(nsIDOMText), (void**)aReturn); return CallQueryInterface(newNode, aReturn);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1221,7 +1221,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer,
// XXX Handle the setting of prevValue! // XXX Handle the setting of prevValue!
nsAutoString newVal(aBuffer); nsAutoString newVal(aBuffer);
if (!newVal.IsEmpty()) if (!newVal.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(newVal)); mutation.mNewAttrValue = do_GetAtom(newVal);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
HandleDOMEvent(nsnull, &mutation, nsnull, HandleDOMEvent(nsnull, &mutation, nsnull,
NS_EVENT_FLAG_INIT, &status); NS_EVENT_FLAG_INIT, &status);
@ -1263,7 +1263,7 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRInt32 aLength,
// XXX Handle the setting of prevValue! // XXX Handle the setting of prevValue!
nsAutoString newVal; newVal.AssignWithConversion(aBuffer); nsAutoString newVal; newVal.AssignWithConversion(aBuffer);
if (!newVal.IsEmpty()) if (!newVal.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(newVal)); mutation.mNewAttrValue = do_GetAtom(newVal);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
HandleDOMEvent(nsnull, &mutation, nsnull, HandleDOMEvent(nsnull, &mutation, nsnull,
NS_EVENT_FLAG_INIT, &status); NS_EVENT_FLAG_INIT, &status);
@ -1302,7 +1302,7 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr,
// XXX Handle the setting of prevValue! // XXX Handle the setting of prevValue!
nsAutoString newVal(aStr); nsAutoString newVal(aStr);
if (!newVal.IsEmpty()) if (!newVal.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(newVal)); mutation.mNewAttrValue = do_GetAtom(newVal);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
HandleDOMEvent(nsnull, &mutation, nsnull, HandleDOMEvent(nsnull, &mutation, nsnull,
NS_EVENT_FLAG_INIT, &status); NS_EVENT_FLAG_INIT, &status);

View File

@ -147,22 +147,17 @@ nsChildContentList::GetLength(PRUint32* aLength)
NS_IMETHODIMP NS_IMETHODIMP
nsChildContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) nsChildContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{ {
nsIContent *content; *aReturn = nsnull;
nsresult res = NS_OK;
if (nsnull != mContent) { if (mContent) {
mContent->ChildAt(aIndex, content); nsCOMPtr<nsIContent> content;
if (nsnull != content) { mContent->ChildAt(aIndex, *getter_AddRefs(content));
res = content->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); if (content) {
NS_RELEASE(content); return CallQueryInterface(content, aReturn);
} else {
*aReturn = nsnull;
} }
} else {
*aReturn = nsnull;
} }
return res; return NS_OK;
} }
void void
@ -380,7 +375,7 @@ nsNode3Tearoff::LookupNamespaceURI(const nsAString& aNamespacePrefix,
nsCOMPtr<nsIAtom> name; nsCOMPtr<nsIAtom> name;
if (!aNamespacePrefix.IsEmpty()) { if (!aNamespacePrefix.IsEmpty()) {
name = dont_AddRef(NS_NewAtom(aNamespacePrefix)); name = do_GetAtom(aNamespacePrefix);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
} else { } else {
name = nsLayoutAtoms::xmlnsNameSpace; name = nsLayoutAtoms::xmlnsNameSpace;
@ -968,14 +963,14 @@ nsGenericElement::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP NS_IMETHODIMP
nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling) nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
{ {
nsIContent* sibling = nsnull; *aPrevSibling = nsnull;
nsresult result = NS_OK;
nsCOMPtr<nsIContent> sibling;
if (mParent) { if (mParent) {
PRInt32 pos; PRInt32 pos;
mParent->IndexOf(this, pos); mParent->IndexOf(this, pos);
if (pos > 0 ) { if (pos > 0 ) {
mParent->ChildAt(--pos, sibling); mParent->ChildAt(--pos, *getter_AddRefs(sibling));
} }
} else if (mDocument) { } else if (mDocument) {
// Nodes that are just below the document (their parent is the // Nodes that are just below the document (their parent is the
@ -983,17 +978,14 @@ nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
PRInt32 pos; PRInt32 pos;
mDocument->IndexOf(this, pos); mDocument->IndexOf(this, pos);
if (pos > 0 ) { if (pos > 0 ) {
mDocument->ChildAt(--pos, sibling); mDocument->ChildAt(--pos, *getter_AddRefs(sibling));
} }
} }
nsresult result = NS_OK;
if (sibling) { if (sibling) {
result = sibling->QueryInterface(NS_GET_IID(nsIDOMNode), result = CallQueryInterface(sibling, aPrevSibling);
(void**)aPrevSibling); NS_ASSERTION(*aPrevSibling, "Must be a DOM Node");
NS_ASSERTION(NS_OK == result, "Must be a DOM Node");
NS_RELEASE(sibling); // balance the AddRef in ChildAt()
} else {
*aPrevSibling = nsnull;
} }
return result; return result;
@ -1002,14 +994,14 @@ nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling)
NS_IMETHODIMP NS_IMETHODIMP
nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling) nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
{ {
nsIContent* sibling = nsnull; *aNextSibling = nsnull;
nsresult result = NS_OK;
nsCOMPtr<nsIContent> sibling;
if (mParent) { if (mParent) {
PRInt32 pos; PRInt32 pos;
mParent->IndexOf(this, pos); mParent->IndexOf(this, pos);
if (pos > -1 ) { if (pos > -1 ) {
mParent->ChildAt(++pos, sibling); mParent->ChildAt(++pos, *getter_AddRefs(sibling));
} }
} else if (mDocument) { } else if (mDocument) {
// Nodes that are just below the document (their parent is the // Nodes that are just below the document (their parent is the
@ -1017,17 +1009,14 @@ nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling)
PRInt32 pos; PRInt32 pos;
mDocument->IndexOf(this, pos); mDocument->IndexOf(this, pos);
if (pos > -1 ) { if (pos > -1 ) {
mDocument->ChildAt(++pos, sibling); mDocument->ChildAt(++pos, *getter_AddRefs(sibling));
} }
} }
nsresult result = NS_OK;
if (sibling) { if (sibling) {
result = sibling->QueryInterface(NS_GET_IID(nsIDOMNode), result = CallQueryInterface(sibling, aNextSibling);
(void**)aNextSibling); NS_ASSERTION(*aNextSibling, "Must be a DOM Node");
NS_ASSERTION(NS_OK == result, "Must be a DOM Node");
NS_RELEASE(sibling); // balance the AddRef in ChildAt()
} else {
*aNextSibling = nsnull;
} }
return result; return result;
@ -1076,7 +1065,7 @@ nsGenericElement::SetPrefix(const nsAString& aPrefix)
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) { if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -1338,7 +1327,7 @@ nsGenericElement::GetElementsByTagName(const nsAString& aTagname,
{ {
nsCOMPtr<nsIAtom> nameAtom; nsCOMPtr<nsIAtom> nameAtom;
nameAtom = dont_AddRef(NS_NewAtom(aTagname)); nameAtom = do_GetAtom(aTagname);
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIContentList> list; nsCOMPtr<nsIContentList> list;
@ -1357,7 +1346,7 @@ nsGenericElement::GetAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
nsAString& aReturn) nsAString& aReturn)
{ {
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
PRInt32 nsid; PRInt32 nsid;
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid);
@ -1396,7 +1385,7 @@ nsresult
nsGenericElement::RemoveAttributeNS(const nsAString& aNamespaceURI, nsGenericElement::RemoveAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName) const nsAString& aLocalName)
{ {
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
PRInt32 nsid; PRInt32 nsid;
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid);
@ -1465,7 +1454,7 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
nsIDOMNodeList** aReturn) nsIDOMNodeList** aReturn)
{ {
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
PRInt32 nameSpaceId = kNameSpaceID_Unknown; PRInt32 nameSpaceId = kNameSpaceID_Unknown;
@ -1519,7 +1508,7 @@ nsGenericElement::HasAttributeNS(const nsAString& aNamespaceURI,
{ {
NS_ENSURE_ARG_POINTER(aReturn); NS_ENSURE_ARG_POINTER(aReturn);
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
PRInt32 nsid; PRInt32 nsid;
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid);
@ -2880,8 +2869,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild,
} }
} }
return replacedChild->QueryInterface(NS_GET_IID(nsIDOMNode), return CallQueryInterface(replacedChild, aReturn);
(void **)aReturn);
} }
@ -3045,8 +3033,8 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
const nsAString& aValue) const nsAString& aValue)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
nsCOMPtr<nsIScriptContext> context = nsnull; nsCOMPtr<nsIScriptContext> context;
nsCOMPtr<nsIScriptGlobalObject> global = nsnull; nsCOMPtr<nsIScriptGlobalObject> global;
JSContext* cx = nsnull; JSContext* cx = nsnull;
//Try to get context from doc //Try to get context from doc
@ -3212,25 +3200,20 @@ nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent,
PRInt32 count = mChildren.Count(); PRInt32 count = mChildren.Count();
for (index = 0; index < count; index++) { for (index = 0; index < count; index++) {
nsIContent* child = (nsIContent*)mChildren.ElementAt(index); nsIContent* child = (nsIContent*)mChildren.ElementAt(index);
if (nsnull != child) { if (child) {
nsIDOMNode* node; nsCOMPtr<nsIDOMNode> node = do_QueryInterface(child, &result);
result = child->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node); if (NS_SUCCEEDED(result)) {
if (NS_OK == result) { nsCOMPtr<nsIDOMNode> newNode;
nsIDOMNode* newNode;
result = node->CloneNode(aDeep, &newNode); result = node->CloneNode(aDeep, getter_AddRefs(newNode));
if (NS_OK == result) { if (NS_SUCCEEDED(result)) {
nsIContent* newContent; nsCOMPtr<nsIContent> newContent = do_QueryInterface(newNode,
&result);
result = newNode->QueryInterface(NS_GET_IID(nsIContent), if (NS_SUCCEEDED(result)) {
(void**)&newContent);
if (NS_OK == result) {
result = aDst->AppendChildTo(newContent, PR_FALSE, PR_FALSE); result = aDst->AppendChildTo(newContent, PR_FALSE, PR_FALSE);
NS_RELEASE(newContent);
} }
NS_RELEASE(newNode);
} }
NS_RELEASE(node);
} }
if (NS_OK != result) { if (NS_OK != result) {
@ -3274,13 +3257,15 @@ nsresult
nsGenericContainerElement::GetFirstChild(nsIDOMNode** aNode) nsGenericContainerElement::GetFirstChild(nsIDOMNode** aNode)
{ {
nsIContent *child = (nsIContent *)mChildren.SafeElementAt(0); nsIContent *child = (nsIContent *)mChildren.SafeElementAt(0);
if (nsnull != child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
*aNode = nsnull; *aNode = nsnull;
return NS_OK; return NS_OK;
} }
@ -3289,14 +3274,16 @@ nsGenericContainerElement::GetLastChild(nsIDOMNode** aNode)
{ {
if (mChildren.Count() != 0) { if (mChildren.Count() != 0) {
nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1); nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1);
if (nsnull != child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
} }
*aNode = nsnull; *aNode = nsnull;
return NS_OK; return NS_OK;
} }
@ -3462,11 +3449,11 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo,
mutation.mAttrName = name; mutation.mAttrName = name;
if (!oldValue.IsEmpty()) { if (!oldValue.IsEmpty()) {
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValue)); mutation.mPrevAttrValue = do_GetAtom(oldValue);
} }
if (!aValue.IsEmpty()) { if (!aValue.IsEmpty()) {
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue)); mutation.mNewAttrValue = do_GetAtom(aValue);
} }
if (modification) { if (modification) {
@ -3607,7 +3594,7 @@ nsGenericContainerElement::UnsetAttr(PRInt32 aNameSpaceID,
mutation.mAttrName = aName; mutation.mAttrName = aName;
if (!attr->mValue.IsEmpty()) if (!attr->mValue.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(attr->mValue)); mutation.mPrevAttrValue = do_GetAtom(attr->mValue);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL; mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;

View File

@ -75,7 +75,7 @@ nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIContentSerializer), (void**)aSerializer); return CallQueryInterface(it, aSerializer);
} }
nsHTMLContentSerializer::nsHTMLContentSerializer() nsHTMLContentSerializer::nsHTMLContentSerializer()

View File

@ -226,7 +226,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
{ {
NS_ENSURE_ARG(!aName.IsEmpty()); NS_ENSURE_ARG(!aName.IsEmpty());
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo); return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo);
@ -240,13 +240,13 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
{ {
NS_ENSURE_ARG(!aName.IsEmpty()); NS_ENSURE_ARG(!aName.IsEmpty());
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -262,13 +262,13 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
{ {
NS_ENSURE_ARG(!aName.IsEmpty()); NS_ENSURE_ARG(!aName.IsEmpty());
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -295,13 +295,13 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
name.Cut(0, nsoffset+1); name.Cut(0, nsoffset+1);
} }
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(name))); nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(name);
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIAtom> prefixAtom; nsCOMPtr<nsIAtom> prefixAtom;
if (!prefix.IsEmpty()) { if (!prefix.IsEmpty()) {
prefixAtom = dont_AddRef(NS_NewAtom(prefix)); prefixAtom = do_GetAtom(prefix);
NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY);
} }

View File

@ -91,8 +91,7 @@ nsresult NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIContentSerializer), return CallQueryInterface(it, aSerializer);
(void**)aSerializer);
} }
nsPlainTextSerializer::nsPlainTextSerializer() nsPlainTextSerializer::nsPlainTextSerializer()

View File

@ -4788,19 +4788,18 @@ int RemoveFilesInDir(const char * aDir)
*/ */
static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
{ {
if((nsnull == aPresContext) || (nsnull == out)) if (!aPresContext || !out)
return; return;
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell)); aPresContext->GetShell(getter_AddRefs(shell));
if (nsnull != shell) { if (shell) {
nsIFrame* frame; nsIFrame* frame;
shell->GetRootFrame(&frame); shell->GetRootFrame(&frame);
if(nsnull != frame) { if (frame) {
nsIFrameDebug* debugFrame; nsIFrameDebug* debugFrame;
nsresult rv; nsresult rv = CallQueryInterface(frame, &debugFrame);
rv = frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&debugFrame); if (NS_SUCCEEDED(rv))
if(NS_SUCCEEDED(rv))
debugFrame->List(aPresContext, out, aIndent); debugFrame->List(aPresContext, out, aIndent);
} }
} }

View File

@ -306,14 +306,14 @@ PRBool GetNodeBracketPoints(nsIContent* aNode,
nsresult nsresult
NS_NewRangeUtils(nsIRangeUtils** aResult) NS_NewRangeUtils(nsIRangeUtils** aResult)
{ {
NS_PRECONDITION(aResult != nsnull, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsRangeUtils* rangeUtil = new nsRangeUtils(); nsRangeUtils* rangeUtil = new nsRangeUtils();
if (rangeUtil) if (!rangeUtil) {
return rangeUtil->QueryInterface(NS_GET_IID(nsIRangeUtils), (void**) aResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(rangeUtil, aResult);
} }
/****************************************************** /******************************************************
@ -400,15 +400,16 @@ nsRangeUtils::CompareNodeToRange(nsIContent* aNode,
nsresult nsresult
NS_NewRange(nsIDOMRange** aResult) NS_NewRange(nsIDOMRange** aResult)
{ {
NS_PRECONDITION(aResult != nsnull, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsRange * range = new nsRange(); nsRange * range = new nsRange();
if (range) if (!range) {
return range->QueryInterface(NS_GET_IID(nsIDOMRange), (void**) aResult); return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY; }
return CallQueryInterface(range, aResult);
} }
/****************************************************** /******************************************************
* constructor/destructor * constructor/destructor
******************************************************/ ******************************************************/
@ -609,9 +610,8 @@ nsresult nsRange::AddToListOf(nsIDOMNode* aNode)
if (!aNode) if (!aNode)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContent> cN; nsresult res;
nsCOMPtr<nsIContent> cN = do_QueryInterface(aNode, &res);
nsresult res = aNode->QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(cN));
if (NS_FAILED(res)) if (NS_FAILED(res))
return res; return res;
@ -625,9 +625,8 @@ nsresult nsRange::RemoveFromListOf(nsIDOMNode* aNode)
if (!aNode) if (!aNode)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContent> cN; nsresult res;
nsCOMPtr<nsIContent> cN = do_QueryInterface(aNode, &res);
nsresult res = aNode->QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(cN));
if (NS_FAILED(res)) if (NS_FAILED(res))
return res; return res;
@ -836,29 +835,26 @@ PRBool nsRange::IsIncreasing(nsIDOMNode* aStartN, PRInt32 aStartOffset,
PRInt32 nsRange::IndexOf(nsIDOMNode* aChildNode) PRInt32 nsRange::IndexOf(nsIDOMNode* aChildNode)
{ {
nsCOMPtr<nsIDOMNode> parentNode;
nsCOMPtr<nsIContent> contentChild;
nsCOMPtr<nsIContent> contentParent;
PRInt32 theIndex = nsnull;
if (!aChildNode) if (!aChildNode)
return 0; return 0;
// get the parent node // get the parent node
nsCOMPtr<nsIDOMNode> parentNode;
nsresult res = aChildNode->GetParentNode(getter_AddRefs(parentNode)); nsresult res = aChildNode->GetParentNode(getter_AddRefs(parentNode));
if (NS_FAILED(res)) if (NS_FAILED(res))
return 0; return 0;
// convert node and parent to nsIContent, so that we can find the child index // convert node and parent to nsIContent, so that we can find the child index
res = parentNode->QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(contentParent)); nsCOMPtr<nsIContent> contentParent = do_QueryInterface(parentNode, &res);
if (NS_FAILED(res)) if (NS_FAILED(res))
return 0; return 0;
res = aChildNode->QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(contentChild)); nsCOMPtr<nsIContent> contentChild = do_QueryInterface(aChildNode, &res);
if (NS_FAILED(res)) if (NS_FAILED(res))
return 0; return 0;
// finally we get the index // finally we get the index
PRInt32 theIndex = 0;
res = contentParent->IndexOf(contentChild,theIndex); res = contentParent->IndexOf(contentChild,theIndex);
if (NS_FAILED(res)) if (NS_FAILED(res))
return 0; return 0;
@ -2585,168 +2581,155 @@ NS_IMETHODIMP
nsRange::CreateContextualFragment(const nsAString& aFragment, nsRange::CreateContextualFragment(const nsAString& aFragment,
nsIDOMDocumentFragment** aReturn) nsIDOMDocumentFragment** aReturn)
{ {
nsresult result = NS_OK;
nsCOMPtr<nsIParser> parser;
nsVoidArray tagStack;
if (!mIsPositioned) { if (!mIsPositioned) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Create a new parser for this entire operation // Create a new parser for this entire operation
result = nsComponentManager::CreateInstance(kCParserCID, nsresult result;
nsnull, nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &result);
NS_GET_IID(nsIParser), NS_ENSURE_SUCCESS(result, result);
(void **)getter_AddRefs(parser));
nsCOMPtr<nsIContent> content = do_QueryInterface(mStartParent, &result);
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIDocument> document;
nsCOMPtr<nsIDOMDocument> domDocument;
result = content->GetDocument(*getter_AddRefs(document));
domDocument = do_QueryInterface(document, &result);
NS_ENSURE_SUCCESS(result, result);
nsVoidArray tagStack;
nsCOMPtr<nsIDOMNode> parent = mStartParent;
while (parent &&
(parent != domDocument) &&
NS_SUCCEEDED(result)) {
PRUint16 nodeType;
parent->GetNodeType(&nodeType);
if (nsIDOMNode::ELEMENT_NODE == nodeType) {
nsAutoString tagName;
parent->GetNodeName(tagName);
// XXX Wish we didn't have to allocate here
PRUnichar* name = ToNewUnicode(tagName);
if (name) {
tagStack.AppendElement(name);
nsCOMPtr<nsIDOMNode> temp = parent;
result = temp->GetParentNode(getter_AddRefs(parent));
}
else {
result = NS_ERROR_OUT_OF_MEMORY;
}
}
else {
nsCOMPtr<nsIDOMNode> temp = parent;
result = temp->GetParentNode(getter_AddRefs(parent));
}
}
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
nsCAutoString contentType;
nsCOMPtr<nsIHTMLFragmentContentSink> sink;
nsCOMPtr<nsIDOMNode> parent; result = NS_NewHTMLFragmentContentSink(getter_AddRefs(sink));
nsCOMPtr<nsIContent> content(do_QueryInterface(mStartParent, &result));
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIDocument> document; parser->SetContentSink(sink);
nsCOMPtr<nsIDOMDocument> domDocument; nsCOMPtr<nsIDOMNSDocument> domnsDocument(do_QueryInterface(document));
if (domnsDocument) {
result = content->GetDocument(*getter_AddRefs(document)); nsAutoString buf;
if (document && NS_SUCCEEDED(result)) { domnsDocument->GetContentType(buf);
domDocument = do_QueryInterface(document, &result); CopyUCS2toASCII(buf, contentType);
}
else {
// Who're we kidding. This only works for html.
contentType = NS_LITERAL_CSTRING("text/html");
} }
parent = mStartParent; // If there's no JS or system JS running,
while (parent && // push the current document's context on the JS context stack
(parent != domDocument) && // so that event handlers in the fragment do not get
NS_SUCCEEDED(result)) { // compiled with the system principal.
nsCOMPtr<nsIDOMNode> temp; nsCOMPtr<nsIJSContextStack> ContextStack;
nsAutoString tagName; nsCOMPtr<nsIScriptSecurityManager> secMan;
PRUnichar* name = nsnull; secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result);
PRUint16 nodeType; if (document && NS_SUCCEEDED(result)) {
nsCOMPtr<nsIPrincipal> sysPrin;
nsCOMPtr<nsIPrincipal> subjectPrin;
parent->GetNodeType(&nodeType); // Just to compare, not to use!
if (nsIDOMNode::ELEMENT_NODE == nodeType) { result = secMan->GetSystemPrincipal(getter_AddRefs(sysPrin));
parent->GetNodeName(tagName); if (NS_SUCCEEDED(result))
// XXX Wish we didn't have to allocate here result = secMan->GetSubjectPrincipal(getter_AddRefs(subjectPrin));
name = ToNewUnicode(tagName); // If there's no subject principal, there's no JS running, so we're in system code.
if (name) { // (just in case...null subject principal will probably never happen)
tagStack.AppendElement(name); if (NS_SUCCEEDED(result) &&
temp = parent; (!subjectPrin || sysPrin.get() == subjectPrin.get())) {
result = temp->GetParentNode(getter_AddRefs(parent)); nsCOMPtr<nsIScriptGlobalObject> globalObj;
result = document->GetScriptGlobalObject(getter_AddRefs(globalObj));
nsCOMPtr<nsIScriptContext> scriptContext;
if (NS_SUCCEEDED(result) && globalObj) {
result = globalObj->GetContext(getter_AddRefs(scriptContext));
} }
else {
result = NS_ERROR_OUT_OF_MEMORY; JSContext* cx = nsnull;
if (NS_SUCCEEDED(result) && scriptContext) {
cx = (JSContext*)scriptContext->GetNativeContext();
}
if(cx) {
ContextStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1", &result);
if(NS_SUCCEEDED(result)) {
result = ContextStack->Push(cx);
}
} }
} }
else { }
temp = parent;
result = temp->GetParentNode(getter_AddRefs(parent)); nsDTDMode mode = eDTDMode_autodetect;
nsCOMPtr<nsIDOMDocument> ownerDoc;
mStartParent->GetOwnerDocument(getter_AddRefs(ownerDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(ownerDoc));
if (htmlDoc) {
nsCompatibility compatMode;
htmlDoc->GetCompatibilityMode(compatMode);
switch (compatMode) {
case eCompatibility_NavQuirks:
mode = eDTDMode_quirks;
break;
case eCompatibility_AlmostStandards:
mode = eDTDMode_almost_standards;
break;
case eCompatibility_FullStandards:
mode = eDTDMode_full_standards;
break;
default:
NS_NOTREACHED("unknown mode");
break;
} }
} }
result = parser->ParseFragment(aFragment, (void*)0,
tagStack,
0, contentType, mode);
if (ContextStack) {
JSContext *notused;
ContextStack->Pop(&notused);
}
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
nsCAutoString contentType; sink->GetFragment(aReturn);
nsIHTMLFragmentContentSink* sink;
result = NS_NewHTMLFragmentContentSink(&sink);
if (NS_SUCCEEDED(result)) {
parser->SetContentSink(sink);
nsCOMPtr<nsIDOMNSDocument> domnsDocument(do_QueryInterface(document));
if (domnsDocument) {
nsAutoString buf;
domnsDocument->GetContentType(buf);
CopyUCS2toASCII(buf, contentType);
}
else {
// Who're we kidding. This only works for html.
contentType = NS_LITERAL_CSTRING("text/html");
}
// If there's no JS or system JS running,
// push the current document's context on the JS context stack
// so that event handlers in the fragment do not get
// compiled with the system principal.
nsCOMPtr<nsIJSContextStack> ContextStack;
nsCOMPtr<nsIScriptSecurityManager> secMan;
secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result);
if (document && NS_SUCCEEDED(result)) {
nsCOMPtr<nsIPrincipal> sysPrin;
nsCOMPtr<nsIPrincipal> subjectPrin;
// Just to compare, not to use!
result = secMan->GetSystemPrincipal(getter_AddRefs(sysPrin));
if (NS_SUCCEEDED(result))
result = secMan->GetSubjectPrincipal(getter_AddRefs(subjectPrin));
// If there's no subject principal, there's no JS running, so we're in system code.
// (just in case...null subject principal will probably never happen)
if (NS_SUCCEEDED(result) &&
(!subjectPrin || sysPrin.get() == subjectPrin.get())) {
nsCOMPtr<nsIScriptGlobalObject> globalObj;
result = document->GetScriptGlobalObject(getter_AddRefs(globalObj));
nsCOMPtr<nsIScriptContext> scriptContext;
if (NS_SUCCEEDED(result) && globalObj) {
result = globalObj->GetContext(getter_AddRefs(scriptContext));
}
JSContext* cx = nsnull;
if (NS_SUCCEEDED(result) && scriptContext) {
cx = (JSContext*)scriptContext->GetNativeContext();
}
if(cx) {
ContextStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1", &result);
if(NS_SUCCEEDED(result)) {
result = ContextStack->Push(cx);
}
}
}
}
nsDTDMode mode = eDTDMode_autodetect;
nsCOMPtr<nsIDOMDocument> ownerDoc;
mStartParent->GetOwnerDocument(getter_AddRefs(ownerDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(ownerDoc));
if (htmlDoc) {
nsCompatibility compatMode;
htmlDoc->GetCompatibilityMode(compatMode);
switch (compatMode) {
case eCompatibility_NavQuirks:
mode = eDTDMode_quirks;
break;
case eCompatibility_AlmostStandards:
mode = eDTDMode_almost_standards;
break;
case eCompatibility_FullStandards:
mode = eDTDMode_full_standards;
break;
default:
NS_NOTREACHED("unknown mode");
break;
}
}
result = parser->ParseFragment(aFragment, (void*)0,
tagStack,
0, contentType, mode);
if (ContextStack) {
JSContext *notused;
ContextStack->Pop(&notused);
}
if (NS_SUCCEEDED(result)) {
sink->GetFragment(aReturn);
}
NS_RELEASE(sink);
}
} }
} }
}
// XXX Ick! Delete strings we allocated above. // XXX Ick! Delete strings we allocated above.
PRInt32 count = tagStack.Count(); PRInt32 count = tagStack.Count();
for (PRInt32 i = 0; i < count; i++) { for (PRInt32 i = 0; i < count; i++) {
PRUnichar* str = (PRUnichar*)tagStack.ElementAt(i); PRUnichar* str = (PRUnichar*)tagStack.ElementAt(i);
if (str) { if (str) {
nsCRT::free(str); nsCRT::free(str);
}
} }
} }

View File

@ -101,11 +101,12 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
#include "nsIEventQueue.h" #include "nsIEventQueue.h"
#include "nsIEventQueueService.h" #include "nsIEventQueueService.h"
//nodtifications // notifications
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsISelectionController.h"//for the enums #include "nsISelectionController.h"//for the enums
#include "nsHTMLAtoms.h"
#define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;} #define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;}
@ -532,12 +533,6 @@ private:
PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened
PRPackedBool mDesiredXSet; PRPackedBool mDesiredXSet;
short mReason; //reason for notifications of selection changing short mReason; //reason for notifications of selection changing
public:
static nsIAtom *sTableAtom;
static nsIAtom *sRowAtom;
static nsIAtom *sCellAtom;
static nsIAtom *sTbodyAtom;
static PRInt32 sInstanceCount;
}; };
class nsSelectionIterator : public nsIBidirectionalEnumerator class nsSelectionIterator : public nsIBidirectionalEnumerator
@ -715,13 +710,6 @@ nsresult NS_NewDomSelection(nsISelection **aDomSelection)
return NS_OK; return NS_OK;
} }
//Horrible statics but no choice
nsIAtom *nsSelection::sTableAtom = 0;
nsIAtom *nsSelection::sRowAtom = 0;
nsIAtom *nsSelection::sCellAtom = 0;
nsIAtom *nsSelection::sTbodyAtom = 0;
PRInt32 nsSelection::sInstanceCount = 0;
static PRInt8 static PRInt8
GetIndexFromSelectionType(SelectionType aType) GetIndexFromSelectionType(SelectionType aType)
{ {
@ -978,15 +966,7 @@ nsSelection::nsSelection()
mMouseDoubleDownState = PR_FALSE; mMouseDoubleDownState = PR_FALSE;
if (sInstanceCount <= 0)
{
sTableAtom = NS_NewAtom("table");
sRowAtom = NS_NewAtom("tr");
sCellAtom = NS_NewAtom("td");
sTbodyAtom = NS_NewAtom("tbody");
}
mHint = HINTLEFT; mHint = HINTLEFT;
sInstanceCount ++;
mDragSelectingCells = PR_FALSE; mDragSelectingCells = PR_FALSE;
mSelectingTableCellMode = 0; mSelectingTableCellMode = 0;
mSelectedCellIndex = 0; mSelectedCellIndex = 0;
@ -1024,19 +1004,11 @@ nsSelection::nsSelection()
nsSelection::~nsSelection() nsSelection::~nsSelection()
{ {
if (sInstanceCount <= 1)
{
NS_IF_RELEASE(sTableAtom);
NS_IF_RELEASE(sRowAtom);
NS_IF_RELEASE(sCellAtom);
NS_IF_RELEASE(sTbodyAtom);
}
PRInt32 i; PRInt32 i;
for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){ for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){
if (mDomSelections[i]) if (mDomSelections[i])
NS_IF_RELEASE(mDomSelections[i]); NS_IF_RELEASE(mDomSelections[i]);
} }
sInstanceCount--;
} }
@ -1445,8 +1417,7 @@ ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
if (!aNode || !aParent || !aChildOffset) if (!aNode || !aParent || !aChildOffset)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsresult result = NS_OK; nsresult result = NS_OK;
nsCOMPtr<nsIContent> content; nsCOMPtr<nsIContent> content = do_QueryInterface(aNode, &result);
result = aNode->QueryInterface(NS_GET_IID(nsIContent),getter_AddRefs(content));
if (NS_SUCCEEDED(result) && content) if (NS_SUCCEEDED(result) && content)
{ {
nsCOMPtr<nsIContent> parent; nsCOMPtr<nsIContent> parent;
@ -1454,8 +1425,9 @@ ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
if (NS_SUCCEEDED(result) && parent) if (NS_SUCCEEDED(result) && parent)
{ {
result = parent->IndexOf(content, *aChildOffset); result = parent->IndexOf(content, *aChildOffset);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result)) {
result = parent->QueryInterface(NS_GET_IID(nsIDOMNode),(void **)aParent); result = CallQueryInterface(parent, aParent);
}
} }
} }
return result; return result;
@ -1474,7 +1446,7 @@ GetCellParent(nsIDOMNode *aDomNode)
while(current) while(current)
{ {
tag = GetTag(current); tag = GetTag(current);
if (tag == nsSelection::sCellAtom) if (tag == nsHTMLAtoms::td)
return current; return current;
if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent) if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent)
return 0; return 0;
@ -1892,11 +1864,12 @@ nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
{ {
thisBlock = blockFrame; thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame); result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame){ if (NS_SUCCEEDED(result) && blockFrame) {
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIteratorNavigator),getter_AddRefs(it)); it = do_QueryInterface(blockFrame, &result);
} }
else else {
blockFrame = nsnull; blockFrame = nsnull;
}
} }
if (!blockFrame || !it) if (!blockFrame || !it)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -2345,11 +2318,12 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
{ {
thisBlock = blockFrame; thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame); result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame){ if (NS_SUCCEEDED(result) && blockFrame) {
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIteratorNavigator),getter_AddRefs(it)); it = do_QueryInterface(blockFrame, &result);
} }
else else {
blockFrame = nsnull; blockFrame = nsnull;
}
} }
if (!blockFrame || !it) if (!blockFrame || !it)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -3416,19 +3390,21 @@ static PRBool IsCell(nsIContent *aContent)
{ {
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
aContent->GetTag(*getter_AddRefs(tag)); aContent->GetTag(*getter_AddRefs(tag));
return (tag != 0 && tag.get() == nsSelection::sCellAtom); return (tag == nsHTMLAtoms::td);
} }
nsITableCellLayout* nsITableCellLayout*
nsSelection::GetCellLayout(nsIContent *aCellContent) nsSelection::GetCellLayout(nsIContent *aCellContent)
{ {
// Get frame for cell // Get frame for cell
nsIFrame *cellFrame = nsnull; nsIFrame *cellFrame = nsnull;
nsresult result = GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame); GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame);
if (!cellFrame) return nsnull; if (!cellFrame)
return nsnull;
nsITableCellLayout *cellLayoutObject = nsnull; nsITableCellLayout *cellLayoutObject = nsnull;
result = cellFrame->QueryInterface(NS_GET_IID(nsITableCellLayout), (void**)(&cellLayoutObject)); CallQueryInterface(cellFrame, &cellLayoutObject);
if (NS_FAILED(result)) return nsnull;
return cellLayoutObject; return cellLayoutObject;
} }
@ -3436,12 +3412,14 @@ nsITableLayout*
nsSelection::GetTableLayout(nsIContent *aTableContent) nsSelection::GetTableLayout(nsIContent *aTableContent)
{ {
// Get frame for table // Get frame for table
nsIFrame *tableFrame = nsnull; nsIFrame *tableFrame = nsnull;
nsresult result = GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame); GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame);
if (!tableFrame) return nsnull; if (!tableFrame)
return nsnull;
nsITableLayout *tableLayoutObject = nsnull; nsITableLayout *tableLayoutObject = nsnull;
result = tableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void**)(&tableLayoutObject)); CallQueryInterface(tableFrame, &tableLayoutObject);
if (NS_FAILED(result)) return nsnull;
return tableLayoutObject; return tableLayoutObject;
} }
@ -4180,7 +4158,7 @@ nsSelection::GetParentTable(nsIContent *aCell, nsIContent **aTable)
{ {
nsIAtom *tag; nsIAtom *tag;
parent->GetTag(tag); parent->GetTag(tag);
if (tag && tag == nsSelection::sTableAtom) if (tag == nsHTMLAtoms::table)
{ {
*aTable = parent; *aTable = parent;
NS_ADDREF(*aTable); NS_ADDREF(*aTable);
@ -4381,7 +4359,7 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
content->GetTag(*getter_AddRefs(atom)); content->GetTag(*getter_AddRefs(atom));
if (!atom) return NS_ERROR_FAILURE; if (!atom) return NS_ERROR_FAILURE;
if (atom.get() == nsSelection::sRowAtom) if (atom == nsHTMLAtoms::tr)
{ {
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL;
} }
@ -4395,9 +4373,9 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
child->GetTag(*getter_AddRefs(atom)); child->GetTag(*getter_AddRefs(atom));
if (!atom) return NS_ERROR_FAILURE; if (!atom) return NS_ERROR_FAILURE;
if (atom.get() == nsSelection::sTableAtom) if (atom == nsHTMLAtoms::table)
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
else if (atom.get() == nsSelection::sRowAtom) else if (atom == nsHTMLAtoms::tr)
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW;
} }
return result; return result;
@ -5119,8 +5097,9 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
mFrameSelection->GetTableCellSelection(&tablesel); mFrameSelection->GetTableCellSelection(&tablesel);
if (tablesel) if (tablesel)
{ {
nsITableCellLayout *tcl; nsITableCellLayout *tcl = nsnull;
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITableCellLayout),(void **)&tcl)) && tcl) CallQueryInterface(frame, &tcl);
if (tcl)
{ {
return NS_OK; return NS_OK;
} }
@ -5181,28 +5160,25 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange
return NS_OK;//nothing to do return NS_OK;//nothing to do
if (!aRange || !aPresContext) if (!aRange || !aPresContext)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContentIterator> iter;
nsCOMPtr<nsIContentIterator> inneriter; nsresult result;
nsresult result = nsComponentManager::CreateInstance( nsCOMPtr<nsIContentIterator> iter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
kCGenSubtreeIteratorCID, kCGenSubtreeIteratorCID,
#else #else
kCSubtreeIteratorCID, kCSubtreeIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
nsnull, &result);
NS_GET_IID(nsIContentIterator),
getter_AddRefs(iter));
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
result = nsComponentManager::CreateInstance(
nsCOMPtr<nsIContentIterator> inneriter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
kCGenContentIteratorCID, kCGenContentIteratorCID,
#else #else
kCContentIteratorCID, kCContentIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
nsnull, &result);
NS_GET_IID(nsIContentIterator),
getter_AddRefs(inneriter));
if ((NS_SUCCEEDED(result)) && iter && inneriter) if ((NS_SUCCEEDED(result)) && iter && inneriter)
{ {
@ -5504,11 +5480,10 @@ nsTypedSelection::GetClosestScrollableView(nsIView *aView, nsIScrollableView **a
while (!*aScrollableView && aView) while (!*aScrollableView && aView)
{ {
nsresult result = aView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)aScrollableView); CallQueryInterface(aView, aScrollableView);
if (!*aScrollableView) if (!*aScrollableView)
{ {
result = aView->GetParent(aView); nsresult result = aView->GetParent(aView);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
@ -5759,7 +5734,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
nsIView *scrolledView = 0; nsIView *scrolledView = 0;
nsIView *view = 0; nsIView *view = 0;
result = scrollableView->QueryInterface(NS_GET_IID(nsIView), (void**)&view); CallQueryInterface(scrollableView, &view);
if (view) if (view)
{ {
@ -5819,13 +5794,11 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
// //
view = 0; view = 0;
result = scrollableView->QueryInterface(NS_GET_IID(nsIView), (void**)&view); result = CallQueryInterface(scrollableView, &view);
if (!view)
if (NS_FAILED(result))
return result; return result;
if (view) view->GetParent(view);
view->GetParent(view);
} }
} }
} }
@ -6290,7 +6263,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
// if end node is a tbody then all bets are off we cannot select "rows" // if end node is a tbody then all bets are off we cannot select "rows"
nsCOMPtr<nsIAtom> atom; nsCOMPtr<nsIAtom> atom;
atom = GetTag(endNode); atom = GetTag(endNode);
if (atom.get() == nsSelection::sTbodyAtom) if (atom == nsHTMLAtoms::tbody)
return NS_ERROR_FAILURE; //cannot select INTO row node ony cells return NS_ERROR_FAILURE; //cannot select INTO row node ony cells
//get common parent //get common parent
@ -6336,7 +6309,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
while (tempNode != parent) while (tempNode != parent)
{ {
atom = GetTag(tempNode); atom = GetTag(tempNode);
if (atom.get() == nsSelection::sTableAtom) //select whole table if in cell mode, wait for cell if (atom == nsHTMLAtoms::table) //select whole table if in cell mode, wait for cell
{ {
result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset);
if (NS_FAILED(result)) if (NS_FAILED(result))
@ -6346,7 +6319,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
dirtystart = PR_TRUE; dirtystart = PR_TRUE;
cellMode = PR_FALSE; cellMode = PR_FALSE;
} }
else if (atom.get() == nsSelection::sCellAtom) //you are in "cell" mode put selection to end of cell else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell
{ {
cellMode = PR_TRUE; cellMode = PR_TRUE;
result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset);
@ -6373,7 +6346,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
while (tempNode != parent) while (tempNode != parent)
{ {
atom = GetTag(tempNode); atom = GetTag(tempNode);
if (atom.get() == nsSelection::sTableAtom) //select whole table if in cell mode, wait for cell if (atom == nsHTMLAtoms::table) //select whole table if in cell mode, wait for cell
{ {
if (!cellMode) if (!cellMode)
{ {
@ -6387,7 +6360,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
else else
found = PR_FALSE; //didnt find the right cell yet found = PR_FALSE; //didnt find the right cell yet
} }
else if (atom.get() == nsSelection::sCellAtom) //you are in "cell" mode put selection to end of cell else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell
{ {
result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset); result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset);
if (NS_FAILED(result)) if (NS_FAILED(result))
@ -7141,7 +7114,7 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi
// XXX Deal with the case where there is a scrolled element, e.g., a // XXX Deal with the case where there is a scrolled element, e.g., a
// DIV in the middle... // DIV in the middle...
while ((closestView != nsnull) && (closestView != scrolledView)) { while (closestView && closestView != scrolledView) {
nscoord dx, dy; nscoord dx, dy;
// Update the offset // Update the offset
@ -7610,14 +7583,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// //
nsIView *view = 0; nsIView *view = 0;
rv = CallQueryInterface(aScrollableView, &view);
rv = aScrollableView->QueryInterface(NS_GET_IID(nsIView), (void **)&view);
if (NS_FAILED(rv))
return rv;
if (!view) if (!view)
return NS_ERROR_FAILURE; return rv;
rv = view->GetParent(view); rv = view->GetParent(view);

View File

@ -864,7 +864,7 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent)
******************************************************************************/ ******************************************************************************/
void nsStyleContext::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) void nsStyleContext::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{ {
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null"); NS_ASSERTION(aSizeOfHandler, "SizeOf handler cannot be null");
// first get the unique items collection // first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems); UNIQUE_STYLE_ITEMS(uniqueItems);
@ -878,7 +878,7 @@ void nsStyleContext::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("nsStyleContext")); tag = do_GetAtom("nsStyleContext");
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
// add in the size of the member mPseudoTag // add in the size of the member mPseudoTag
@ -1191,9 +1191,10 @@ NS_NewStyleContext(nsIStyleContext** aInstancePtrResult,
nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag, nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag,
aRuleNode, aPresContext); aRuleNode, aPresContext);
if (nsnull == context) { if (!context) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return context->QueryInterface(NS_GET_IID(nsIStyleContext), (void **) aInstancePtrResult);
return CallQueryInterface(context, aInstancePtrResult);
} }

View File

@ -905,8 +905,7 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
nsCOMPtr<nsIStyleSheet> sheet; nsCOMPtr<nsIStyleSheet> sheet;
sheet = getter_AddRefs(GetAgentStyleSheetAt(i)); sheet = getter_AddRefs(GetAgentStyleSheetAt(i));
if (sheet) { if (sheet) {
nsCOMPtr<nsICSSStyleSheet> cssSheet; nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(sheet);
sheet->QueryInterface(NS_GET_IID(nsICSSStyleSheet), getter_AddRefs(cssSheet));
if (cssSheet) { if (cssSheet) {
nsCOMPtr<nsIStyleSheet> quirkSheet; nsCOMPtr<nsIStyleSheet> quirkSheet;
PRBool bHasSheet = PR_FALSE; PRBool bHasSheet = PR_FALSE;
@ -1774,17 +1773,16 @@ void StyleSetImpl::ListContexts(nsIStyleContext* aRootContext, FILE* out, PRInt3
NS_EXPORT nsresult NS_EXPORT nsresult
NS_NewStyleSet(nsIStyleSet** aInstancePtrResult) NS_NewStyleSet(nsIStyleSet** aInstancePtrResult)
{ {
if (aInstancePtrResult == nsnull) { if (!aInstancePtrResult) {
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
StyleSetImpl *it = new StyleSetImpl(); StyleSetImpl *it = new StyleSetImpl();
if (!it) {
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIStyleSet), (void **) aInstancePtrResult); return CallQueryInterface(it, aInstancePtrResult);
} }
// nsITimeRecorder implementation // nsITimeRecorder implementation
@ -1822,16 +1820,17 @@ StyleSetImpl::DisableTimer(PRUint32 aTimerID)
NS_IMETHODIMP NS_IMETHODIMP
StyleSetImpl::IsTimerEnabled(PRBool *aIsEnabled, PRUint32 aTimerID) StyleSetImpl::IsTimerEnabled(PRBool *aIsEnabled, PRUint32 aTimerID)
{ {
NS_ASSERTION(aIsEnabled != nsnull, "aIsEnabled paramter cannot be null" ); NS_ASSERTION(aIsEnabled, "aIsEnabled parameter cannot be null" );
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (NS_TIMER_STYLE_RESOLUTION == aTimerID) { if (NS_TIMER_STYLE_RESOLUTION == aTimerID) {
if (*aIsEnabled != nsnull) { if (*aIsEnabled) {
*aIsEnabled = mTimerEnabled; *aIsEnabled = mTimerEnabled;
} }
} }
else else {
rv = NS_ERROR_NOT_IMPLEMENTED; rv = NS_ERROR_NOT_IMPLEMENTED;
}
return rv; return rv;
} }
@ -1987,7 +1986,7 @@ StyleSetImpl::AttributeAffectsStyle(nsIAtom *aAttribute, nsIContent *aContent,
******************************************************************************/ ******************************************************************************/
void StyleSetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) void StyleSetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{ {
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null"); NS_ASSERTION(aSizeOfHandler, "SizeOf handler cannot be null");
// first get the unique items collection // first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems); UNIQUE_STYLE_ITEMS(uniqueItems);
@ -1998,8 +1997,7 @@ void StyleSetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
return; return;
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("StyleSet");
tag = getter_AddRefs(NS_NewAtom("StyleSet"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(StyleSetImpl); aSize = sizeof(StyleSetImpl);

View File

@ -298,7 +298,7 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(document); nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(document);
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE); NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
nsWeakPtr requestWeak = getter_AddRefs(NS_GetWeakReference(NS_STATIC_CAST(nsIDOMLoadListener*, this))); nsWeakPtr requestWeak = do_GetWeakReference(NS_STATIC_CAST(nsIDOMLoadListener*, this));
txLoadListenerProxy* proxy = new txLoadListenerProxy(requestWeak); txLoadListenerProxy* proxy = new txLoadListenerProxy(requestWeak);
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);

View File

@ -72,8 +72,7 @@ NS_NewTreeWalker(nsIDOMNode *aRoot,
aEntityReferenceExpansion); aEntityReferenceExpansion);
NS_ENSURE_TRUE(walker, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(walker, NS_ERROR_OUT_OF_MEMORY);
return walker->QueryInterface(NS_GET_IID(nsIDOMTreeWalker), return CallQueryInterface(walker, aInstancePtrResult);
(void**) aInstancePtrResult);
} }
nsTreeWalker::nsTreeWalker(nsIDOMNode *aRoot, nsTreeWalker::nsTreeWalker(nsIDOMNode *aRoot,

View File

@ -71,7 +71,7 @@ nsresult NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIContentSerializer), (void**)aSerializer); return CallQueryInterface(it, aSerializer);
} }
nsXMLContentSerializer::nsXMLContentSerializer() nsXMLContentSerializer::nsXMLContentSerializer()

View File

@ -146,7 +146,8 @@ NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult)
if (!it) { if (!it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIDocumentLoaderFactory), (void**)aResult);
return CallQueryInterface(it, aResult);
} }
nsContentDLF::nsContentDLF() nsContentDLF::nsContentDLF()
@ -415,9 +416,7 @@ nsContentDLF::CreateDocument(const char* aCommand,
nsCOMPtr<nsIDocumentViewer> docv; nsCOMPtr<nsIDocumentViewer> docv;
do { do {
// Create the document // Create the document
rv = nsComponentManager::CreateInstance(aDocumentCID, nsnull, doc = do_CreateInstance(aDocumentCID, &rv);
NS_GET_IID(nsIDocument),
getter_AddRefs(doc));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
break; break;
@ -482,9 +481,7 @@ nsContentDLF::CreateRDFDocument(nsISupports* aExtraInfo,
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
// Create the XUL document // Create the XUL document
rv = nsComponentManager::CreateInstance(kXULDocumentCID, nsnull, *doc = do_CreateInstance(kXULDocumentCID, &rv);
NS_GET_IID(nsIDocument),
getter_AddRefs(*doc));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// Create the image content viewer... // Create the image content viewer...

View File

@ -276,8 +276,7 @@ nsDOMEvent::~nsDOMEvent()
PR_DELETE(mEvent); PR_DELETE(mEvent);
} }
if (mText!=nsnull) delete mText;
delete mText;
} }
NS_IMPL_ADDREF(nsDOMEvent) NS_IMPL_ADDREF(nsDOMEvent)
@ -334,7 +333,8 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget)
} }
if (targetContent) { if (targetContent) {
if (NS_OK == targetContent->QueryInterface(NS_GET_IID(nsIDOMEventTarget), (void**)&mTarget)) { CallQueryInterface(targetContent, &mTarget);
if (mTarget) {
*aTarget = mTarget; *aTarget = mTarget;
NS_ADDREF(*aTarget); NS_ADDREF(*aTarget);
} }
@ -342,14 +342,15 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget)
else { else {
//Always want a target. Use document if nothing else. //Always want a target. Use document if nothing else.
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
if (mPresContext && NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { if (mPresContext && NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) {
if (NS_SUCCEEDED(presShell->GetDocument(getter_AddRefs(doc))) && doc) { if (NS_SUCCEEDED(presShell->GetDocument(getter_AddRefs(doc))) && doc) {
if (NS_SUCCEEDED(doc->QueryInterface(NS_GET_IID(nsIDOMEventTarget), (void**)&mTarget))) { CallQueryInterface(doc, &mTarget);
*aTarget = mTarget; if (mTarget) {
NS_ADDREF(mTarget); *aTarget = mTarget;
} NS_ADDREF(*aTarget);
} }
}
} }
} }
@ -483,14 +484,10 @@ nsDOMEvent::GetView(nsIDOMAbstractView** aView)
rv = mPresContext->GetContainer(getter_AddRefs(container)); rv = mPresContext->GetContainer(getter_AddRefs(container));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv);
nsCOMPtr<nsIInterfaceRequestor> ifrq(do_QueryInterface(container)); nsCOMPtr<nsIDOMWindowInternal> window = do_GetInterface(container);
NS_ENSURE_TRUE(ifrq, NS_OK);
nsCOMPtr<nsIDOMWindowInternal> window;
ifrq->GetInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_OK); NS_ENSURE_TRUE(window, NS_OK);
window->QueryInterface(NS_GET_IID(nsIDOMAbstractView), (void **)aView); CallQueryInterface(container, aView);
} }
return rv; return rv;
@ -866,25 +863,25 @@ NS_METHOD nsDOMEvent::GetButton(PRUint16* aButton)
NS_METHOD nsDOMEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget) NS_METHOD nsDOMEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
{ {
nsIEventStateManager *manager; *aRelatedTarget = nsnull;
nsIContent *relatedContent = nsnull;
nsresult ret = NS_OK;
if (mPresContext && if (!mPresContext) {
(NS_OK == mPresContext->GetEventStateManager(&manager))) { return NS_OK;
manager->GetEventRelatedContent(&relatedContent);
NS_RELEASE(manager);
} }
if (relatedContent) { nsCOMPtr<nsIEventStateManager> manager;
ret = relatedContent->QueryInterface(NS_GET_IID(nsIDOMEventTarget), (void**)aRelatedTarget); mPresContext->GetEventStateManager(getter_AddRefs(manager));
NS_RELEASE(relatedContent); if (!manager) {
} return NS_OK;
else {
*aRelatedTarget = nsnull;
} }
return ret; nsCOMPtr<nsIContent> relatedContent;
manager->GetEventRelatedContent(getter_AddRefs(relatedContent));
if (!relatedContent) {
return NS_OK;
}
return CallQueryInterface(relatedContent, aRelatedTarget);
} }
// nsINSEventInterface // nsINSEventInterface
@ -1027,32 +1024,31 @@ NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
NS_METHOD nsDOMEvent::GetRangeParent(nsIDOMNode** aRangeParent) NS_METHOD nsDOMEvent::GetRangeParent(nsIDOMNode** aRangeParent)
{ {
nsIFrame* targetFrame = nsnull; nsIFrame* targetFrame = nsnull;
nsIEventStateManager* manager; nsCOMPtr<nsIEventStateManager> manager;
if (mPresContext && if (mPresContext &&
(NS_OK == mPresContext->GetEventStateManager(&manager))) { (NS_OK == mPresContext->GetEventStateManager(getter_AddRefs(manager)))) {
manager->GetEventTarget(&targetFrame); manager->GetEventTarget(&targetFrame);
NS_RELEASE(manager);
} }
*aRangeParent = nsnull;
if (targetFrame) { if (targetFrame) {
nsIContent* parent = nsnull; nsCOMPtr<nsIContent> parent;
PRInt32 offset, endOffset; PRInt32 offset, endOffset;
PRBool beginOfContent; PRBool beginOfContent;
if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext, if (NS_SUCCEEDED(targetFrame->GetContentAndOffsetsFromPoint(mPresContext,
mEvent->point, mEvent->point,
&parent, getter_AddRefs(parent),
offset, offset,
endOffset, endOffset,
beginOfContent))) { beginOfContent))) {
if (parent && NS_SUCCEEDED(parent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aRangeParent))) { if (parent) {
NS_RELEASE(parent); return CallQueryInterface(parent, aRangeParent);
return NS_OK;
} }
NS_IF_RELEASE(parent);
} }
} }
*aRangeParent = nsnull;
return NS_OK; return NS_OK;
} }
@ -1143,7 +1139,7 @@ NS_METHOD nsDOMEvent::GetPreventDefault(PRBool* aReturn)
nsresult nsresult
nsDOMEvent::SetEventType(const nsAString& aEventTypeArg) nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
{ {
nsCOMPtr<nsIAtom> atom(dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + aEventTypeArg))); nsCOMPtr<nsIAtom> atom= do_GetAtom(NS_LITERAL_STRING("on") + aEventTypeArg);
if (atom == nsLayoutAtoms::onmousedown && mEvent->eventStructType == NS_MOUSE_EVENT) { if (atom == nsLayoutAtoms::onmousedown && mEvent->eventStructType == NS_MOUSE_EVENT) {
mEvent->message = NS_MOUSE_LEFT_BUTTON_DOWN; mEvent->message = NS_MOUSE_LEFT_BUTTON_DOWN;
@ -1522,7 +1518,7 @@ nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIDOMEvent), (void **) aInstancePtrResult); return CallQueryInterface(it, aInstancePtrResult);
} }
nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent) nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent)

View File

@ -158,11 +158,11 @@ nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, PRBool aCanBubb
if (mutation) { if (mutation) {
mutation->mRelatedNode = aRelatedNodeArg; mutation->mRelatedNode = aRelatedNodeArg;
if (!aPrevValueArg.IsEmpty()) if (!aPrevValueArg.IsEmpty())
mutation->mPrevAttrValue = getter_AddRefs(NS_NewAtom(aPrevValueArg)); mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
if (!aNewValueArg.IsEmpty()) if (!aNewValueArg.IsEmpty())
mutation->mNewAttrValue = getter_AddRefs(NS_NewAtom(aNewValueArg)); mutation->mNewAttrValue = do_GetAtom(aNewValueArg);
if (!aAttrNameArg.IsEmpty()) { if (!aAttrNameArg.IsEmpty()) {
mutation->mAttrName = getter_AddRefs(NS_NewAtom(aAttrNameArg)); mutation->mAttrName = do_GetAtom(aAttrNameArg);
} }
mutation->mAttrChange = aAttrChangeArg; mutation->mAttrChange = aAttrChangeArg;
} }
@ -179,5 +179,5 @@ nsresult NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIDOMEvent), (void **) aInstancePtrResult); return CallQueryInterface(it, aInstancePtrResult);
} }

View File

@ -126,7 +126,7 @@ GenericListenersHashEnum(nsHashKey *aKey, void *aData, void* closure)
PRBool* scriptOnly = NS_STATIC_CAST(PRBool*, closure); PRBool* scriptOnly = NS_STATIC_CAST(PRBool*, closure);
for (i = count-1; i >= 0; --i) { for (i = count-1; i >= 0; --i) {
ls = (nsListenerStruct*)listeners->ElementAt(i); ls = (nsListenerStruct*)listeners->ElementAt(i);
if (ls != nsnull) { if (ls) {
if (*scriptOnly) { if (*scriptOnly) {
if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) { if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) {
NS_RELEASE(ls->mListener); NS_RELEASE(ls->mListener);
@ -375,7 +375,7 @@ void nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners, PRBool a
nsListenerStruct *ls; nsListenerStruct *ls;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
ls = (nsListenerStruct*)(*aListeners)->ElementAt(i); ls = (nsListenerStruct*)(*aListeners)->ElementAt(i);
if (ls != nsnull) { if (ls) {
if (aScriptOnly) { if (aScriptOnly) {
if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) { if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) {
NS_RELEASE(ls->mListener); NS_RELEASE(ls->mListener);
@ -801,8 +801,7 @@ nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener,
{ {
PRInt32 subType; PRInt32 subType;
EventArrayType arrayType; EventArrayType arrayType;
nsCOMPtr<nsIAtom> atom = nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + aType));
if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) { if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) {
AddEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp); AddEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp);
@ -824,8 +823,7 @@ nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener
{ {
PRInt32 subType; PRInt32 subType;
EventArrayType arrayType; EventArrayType arrayType;
nsCOMPtr<nsIAtom> atom = nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + aType));
if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) { if (NS_OK == GetIdentifiersForType(atom, &arrayType, &subType)) {
RemoveEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp); RemoveEventListener(aListener, arrayType, subType, nsnull, aFlags, aEvtGrp);
@ -1199,7 +1197,7 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
nsAutoString eventString; nsAutoString eventString;
if (NS_SUCCEEDED(aDOMEvent->GetType(eventString))) { if (NS_SUCCEEDED(aDOMEvent->GetType(eventString))) {
nsCOMPtr<nsIAtom> atom = dont_AddRef(NS_NewAtom(NS_LITERAL_STRING("on") + eventString)); nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + eventString);
result = CompileEventHandlerInternal(scriptCX, target, atom, result = CompileEventHandlerInternal(scriptCX, target, atom,
aListenerStruct, aSubType); aListenerStruct, aSubType);

View File

@ -1630,7 +1630,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
if (svp) { if (svp) {
svp->GetScrollableView(&sv); svp->GetScrollableView(&sv);
if (sv) if (sv)
sv->QueryInterface(NS_GET_IID(nsIView), (void**) &focusView); CallQueryInterface(sv, &focusView);
} else { } else {
focusFrame->GetView(aPresContext, &focusView); focusFrame->GetView(aPresContext, &focusView);
if (!focusView) { if (!focusView) {
@ -2228,16 +2228,16 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
nsIScrollableView* nsIScrollableView*
nsEventStateManager::GetNearestScrollingView(nsIView* aView) nsEventStateManager::GetNearestScrollingView(nsIView* aView)
{ {
nsIScrollableView* sv; nsIScrollableView* sv = nsnull;
if (NS_OK == aView->QueryInterface(NS_GET_IID(nsIScrollableView), CallQueryInterface(aView, &sv);
(void**)&sv)) { if (sv) {
return sv; return sv;
} }
nsIView* parent; nsIView* parent;
aView->GetParent(parent); aView->GetParent(parent);
if (nsnull != parent) { if (parent) {
return GetNearestScrollingView(parent); return GetNearestScrollingView(parent);
} }
@ -4544,8 +4544,7 @@ nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
if (nsnull == manager) { if (nsnull == manager) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
rv = manager->QueryInterface(NS_GET_IID(nsIEventStateManager), rv = CallQueryInterface(manager, aInstancePtrResult);
(void **) aInstancePtrResult);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return manager->Init(); return manager->Init();

View File

@ -42,11 +42,9 @@
GenericElementCollection::GenericElementCollection(nsIContent *aParent, GenericElementCollection::GenericElementCollection(nsIContent *aParent,
nsIAtom *aTag) nsIAtom *aTag)
: nsGenericDOMHTMLCollection() : mParent(aParent),
mTag(aTag)
{ {
mParent = aParent;
mTag = aTag;
NS_IF_ADDREF(aTag);
} }
GenericElementCollection::~GenericElementCollection() GenericElementCollection::~GenericElementCollection()
@ -55,88 +53,74 @@ GenericElementCollection::~GenericElementCollection()
// release it! this is to avoid circular references. The // release it! this is to avoid circular references. The
// instantiator who provided mParent is responsible for managing our // instantiator who provided mParent is responsible for managing our
// reference for us. // reference for us.
// Release reference on the tag
NS_IF_RELEASE(mTag);
} }
// we re-count every call. A better implementation would be to set ourselves up as // we re-count every call. A better implementation would be to set ourselves
// an observer of contentAppended, contentInserted, and contentDeleted // up as an observer of contentAppended, contentInserted, and contentDeleted.
NS_IMETHODIMP NS_IMETHODIMP
GenericElementCollection::GetLength(PRUint32* aLength) GenericElementCollection::GetLength(PRUint32* aLength)
{ {
if (nsnull==aLength) NS_ENSURE_ARG_POINTER(aLength);
return NS_ERROR_NULL_POINTER;
*aLength=0; *aLength = 0;
nsresult result = NS_OK;
if (nsnull!=mParent) if (mParent) {
{ nsCOMPtr<nsIContent> child;
nsIContent *child=nsnull; PRUint32 childIndex = 0;
PRUint32 childIndex=0; mParent->ChildAt(childIndex, *getter_AddRefs(child));
mParent->ChildAt(childIndex, child); while (child) {
while (nsnull!=child) nsCOMPtr<nsIAtom> childTag;
{ child->GetTag(*getter_AddRefs(childTag));
nsIAtom *childTag; if (mTag == childTag) {
child->GetTag(childTag); ++(*aLength);
if (mTag==childTag)
{
(*aLength)++;
} }
NS_RELEASE(childTag); mParent->ChildAt(++childIndex, *getter_AddRefs(child));
NS_RELEASE(child);
childIndex++;
mParent->ChildAt(childIndex, child);
} }
} }
return result;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
GenericElementCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn) GenericElementCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{ {
*aReturn=nsnull; NS_ENSURE_ARG_POINTER(aReturn);
PRUint32 theIndex = 0;
nsresult rv = NS_OK; *aReturn = nsnull;
if (nsnull!=mParent)
{ if (mParent) {
nsIContent *child=nsnull; nsCOMPtr<nsIContent> child;
PRUint32 childIndex=0; PRUint32 childIndex = 0;
mParent->ChildAt(childIndex, child); mParent->ChildAt(childIndex, *getter_AddRefs(child));
while (nsnull!=child)
{ PRUint32 theIndex = 0;
nsIAtom *childTag; while (child) {
child->GetTag(childTag); nsCOMPtr<nsIAtom> childTag;
if (mTag==childTag) child->GetTag(*getter_AddRefs(childTag));
{ if (mTag == childTag) {
if (aIndex==theIndex) if (aIndex == theIndex) {
{ CallQueryInterface(child, aReturn);
child->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); // out-param addref NS_ASSERTION(aReturn, "content element must be an nsIDOMNode");
NS_ASSERTION(nsnull!=aReturn, "content element must be an nsIDOMNode");
NS_RELEASE(childTag); return NS_OK;
NS_RELEASE(child);
break;
} }
theIndex++; ++theIndex;
} }
NS_RELEASE(childTag); mParent->ChildAt(++childIndex, *getter_AddRefs(child));
NS_RELEASE(child);
childIndex++;
mParent->ChildAt(childIndex, child);
} }
} }
return rv;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
GenericElementCollection::NamedItem(const nsAString& aName, nsIDOMNode** aReturn) GenericElementCollection::NamedItem(const nsAString& aName, nsIDOMNode** aReturn)
{ {
NS_ENSURE_ARG_POINTER(aReturn); NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull; *aReturn = nsnull;
nsresult rv = NS_OK;
if (nsnull!=mParent) return NS_OK;
{
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -144,6 +128,7 @@ GenericElementCollection::ParentDestroyed()
{ {
// see comment in destructor, do NOT release mParent! // see comment in destructor, do NOT release mParent!
mParent = nsnull; mParent = nsnull;
return NS_OK; return NS_OK;
} }
@ -152,8 +137,10 @@ nsresult
GenericElementCollection::SizeOf(nsISizeOfHandler* aSizer, GenericElementCollection::SizeOf(nsISizeOfHandler* aSizer,
PRUint32* aResult) const PRUint32* aResult) const
{ {
if (!aResult) return NS_ERROR_NULL_POINTER; NS_ENSURE_ARG_POINTER(aResult);
*aResult = sizeof(*this); *aResult = sizeof(*this);
return NS_OK; return NS_OK;
} }
#endif #endif

View File

@ -40,10 +40,12 @@
#define GenericElementCollection_h__ #define GenericElementCollection_h__
#include "nsGenericDOMHTMLCollection.h" #include "nsGenericDOMHTMLCollection.h"
#include "nsIAtom.h"
class nsIContent; class nsIContent;
class nsIAtom; #ifdef DEBUG
class nsISizeOfHandler; class nsISizeOfHandler;
#endif
/** /**
* This class provides a late-bound collection of elements that are * This class provides a late-bound collection of elements that are
@ -54,22 +56,22 @@ class GenericElementCollection : public nsGenericDOMHTMLCollection
{ {
public: public:
GenericElementCollection(nsIContent *aParent, GenericElementCollection(nsIContent *aParent,
nsIAtom *aTag); nsIAtom *aTag);
virtual ~GenericElementCollection(); virtual ~GenericElementCollection();
NS_IMETHOD GetLength(PRUint32* aLength); NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn); NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn); NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn);
NS_IMETHOD ParentDestroyed(); NS_IMETHOD ParentDestroyed();
#ifdef DEBUG #ifdef DEBUG
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const; nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif #endif
protected: protected:
nsIContent * mParent; nsIContent* mParent;
nsIAtom * mTag; nsCOMPtr<nsIAtom> mTag;
}; };
#endif #endif

View File

@ -242,16 +242,14 @@ public:
nsresult nsresult
NS_NewAttributeContent(nsIContent** aContent) NS_NewAttributeContent(nsIContent** aContent)
{ {
NS_PRECONDITION(aContent, "null OUT ptr"); NS_ENSURE_ARG_POINTER(aContent);
if (nsnull == aContent) {
return NS_ERROR_NULL_POINTER;
}
nsAttributeContent* it = new nsAttributeContent; nsAttributeContent* it = new nsAttributeContent;
if (nsnull == it) { if (!it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return NS_SUCCEEDED(it->QueryInterface(NS_GET_IID(nsIContent), (void **)aContent)) ?
NS_OK : NS_ERROR_FAILURE; return CallQueryInterface(it, aContent);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -542,7 +540,7 @@ nsAttributeContent::CloneContent(PRBool aCloneText, nsITextContent** aReturn)
if (nsnull == it) { if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
result = it->QueryInterface(NS_GET_IID(nsITextContent), (void**) aReturn); result = CallQueryInterface(it, aReturn);
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
return result; return result;
} }

View File

@ -849,8 +849,7 @@ nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent)
nsresult res = GetOffsetRect(rcFrame, getter_AddRefs(parent)); nsresult res = GetOffsetRect(rcFrame, getter_AddRefs(parent));
if (NS_SUCCEEDED(res)) { if (NS_SUCCEEDED(res)) {
if (parent) { if (parent) {
res = parent->QueryInterface(NS_GET_IID(nsIDOMElement), res = CallQueryInterface(parent, aOffsetParent);
(void**)aOffsetParent);
} else { } else {
*aOffsetParent = nsnull; *aOffsetParent = nsnull;
} }
@ -1699,9 +1698,9 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID,
mutation.mAttrName = aAttribute; mutation.mAttrName = aAttribute;
if (!strValue.IsEmpty()) if (!strValue.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(strValue)); mutation.mPrevAttrValue = do_GetAtom(strValue);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue)); mutation.mNewAttrValue = do_GetAtom(aValue);
if (modification) if (modification)
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION; mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
else else
@ -1799,9 +1798,9 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo,
mutation.mAttrName = localName; mutation.mAttrName = localName;
if (!strValue.IsEmpty()) if (!strValue.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(strValue)); mutation.mPrevAttrValue = do_GetAtom(strValue);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue)); mutation.mNewAttrValue = do_GetAtom(aValue);
if (modification) if (modification)
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION; mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
else else
@ -1975,9 +1974,9 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
nsAutoString newValueStr; nsAutoString newValueStr;
GetAttr(kNameSpaceID_None, aAttribute, newValueStr); GetAttr(kNameSpaceID_None, aAttribute, newValueStr);
if (!newValueStr.IsEmpty()) if (!newValueStr.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(newValueStr)); mutation.mNewAttrValue = do_GetAtom(newValueStr);
if (!oldValueStr.IsEmpty()) if (!oldValueStr.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValueStr)); mutation.mPrevAttrValue = do_GetAtom(oldValueStr);
if (modification) if (modification)
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION; mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
else else
@ -2066,7 +2065,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
nsAutoString attr; nsAutoString attr;
GetAttr(aNameSpaceID, aAttribute, attr); GetAttr(aNameSpaceID, aAttribute, attr);
if (!attr.IsEmpty()) if (!attr.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(attr)); mutation.mPrevAttrValue = do_GetAtom(attr);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL; mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
@ -2420,13 +2419,12 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
PRInt32 index; PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out); for (index = aIndent; --index >= 0; ) fputs(" ", out);
nsIAtom* tag; nsCOMPtr<nsIAtom> tag;
GetTag(tag); GetTag(*getter_AddRefs(tag));
if (tag != nsnull) { if (tag) {
nsAutoString buf; nsAutoString buf;
tag->ToString(buf); tag->ToString(buf);
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out); fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
NS_RELEASE(tag);
} }
fprintf(out, "@%p", (void*)this); fprintf(out, "@%p", (void*)this);
@ -2460,10 +2458,10 @@ nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) co
PRInt32 index; PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out); for (index = aIndent; --index >= 0; ) fputs(" ", out);
nsIAtom* tag;
nsAutoString buf; nsAutoString buf;
GetTag(tag); nsCOMPtr<nsIAtom> tag;
if (tag != nsnull) { GetTag(*getter_AddRefs(tag));
if (tag) {
tag->ToString(buf); tag->ToString(buf);
fputs("<",out); fputs("<",out);
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out); fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
@ -2471,7 +2469,6 @@ nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) co
if(aDumpAll) ListAttributes(out); if(aDumpAll) ListAttributes(out);
fputs(">",out); fputs(">",out);
NS_RELEASE(tag);
} }
PRBool canHaveKids; PRBool canHaveKids;
@ -2961,9 +2958,7 @@ nsGenericHTMLElement::GetPrimaryPresState(nsIHTMLContent* aContent,
// Get the pres state for this key, if it doesn't exist, create one // Get the pres state for this key, if it doesn't exist, create one
result = history->GetState(key, aPresState); result = history->GetState(key, aPresState);
if (!*aPresState) { if (!*aPresState) {
result = nsComponentManager::CreateInstance(kPresStateCID, nsnull, result = CallCreateInstance(kPresStateCID, aPresState);
NS_GET_IID(nsIPresState),
(void**)aPresState);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = history->AddState(key, *aPresState); result = history->AddState(key, *aPresState);
} }
@ -3877,12 +3872,13 @@ nsGenericHTMLContainerElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
{ {
nsDOMSlots *slots = GetDOMSlots(); nsDOMSlots *slots = GetDOMSlots();
if (nsnull == slots->mChildNodes) { if (!slots->mChildNodes) {
slots->mChildNodes = new nsChildContentList(this); slots->mChildNodes = new nsChildContentList(this);
// XXX Need to check for out-of-memory
NS_ADDREF(slots->mChildNodes); NS_ADDREF(slots->mChildNodes);
} }
return slots->mChildNodes->QueryInterface(NS_GET_IID(nsIDOMNodeList), (void **)aChildNodes); return CallQueryInterface(slots->mChildNodes, aChildNodes);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -3902,10 +3898,9 @@ nsGenericHTMLContainerElement::GetFirstChild(nsIDOMNode** aNode)
{ {
nsIContent *child = (nsIContent *)mChildren.SafeElementAt(0); nsIContent *child = (nsIContent *)mChildren.SafeElementAt(0);
if (child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
*aNode = nsnull; *aNode = nsnull;
@ -3918,10 +3913,9 @@ nsGenericHTMLContainerElement::GetLastChild(nsIDOMNode** aNode)
if (0 != mChildren.Count()) { if (0 != mChildren.Count()) {
nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1); nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1);
if (child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
} }

View File

@ -308,7 +308,7 @@ void BodyRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("BodyRule")); tag = do_GetAtom("BodyRule");
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag, aSize); aSizeOfHandler->AddSize(tag, aSize);
@ -645,11 +645,12 @@ void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleDat
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc)); presShell->GetDocument(getter_AddRefs(doc));
if (doc) { if (doc) {
nsIHTMLContentContainer* htmlContainer; nsCOMPtr<nsIHTMLContentContainer> htmlContainer =
if (NS_OK == doc->QueryInterface(NS_GET_IID(nsIHTMLContentContainer), do_QueryInterface(doc);
(void**)&htmlContainer)) { if (htmlContainer) {
nsIHTMLStyleSheet* styleSheet; nsCOMPtr<nsIHTMLStyleSheet> styleSheet;
if (NS_OK == htmlContainer->GetAttributeStyleSheet(&styleSheet)) { htmlContainer->GetAttributeStyleSheet(getter_AddRefs(styleSheet));
if (styleSheet) {
aAttributes->GetAttribute(nsHTMLAtoms::link, value); aAttributes->GetAttribute(nsHTMLAtoms::link, value);
if ((eHTMLUnit_Color == value.GetUnit()) || if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) { (eHTMLUnit_ColorName == value.GetUnit())) {
@ -667,10 +668,7 @@ void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleDat
(eHTMLUnit_ColorName == value.GetUnit())) { (eHTMLUnit_ColorName == value.GetUnit())) {
styleSheet->SetVisitedLinkColor(value.GetColorValue()); styleSheet->SetVisitedLinkColor(value.GetColorValue());
} }
NS_RELEASE(styleSheet);
} }
NS_RELEASE(htmlContainer);
} }
} }
} }

View File

@ -1795,9 +1795,7 @@ nsFormControlList::AddElementToTable(nsIFormControl* aChild,
// Add the new child too // Add the new child too
list->AppendElement(newChild); list->AppendElement(newChild);
nsCOMPtr<nsISupports> listSupports; nsCOMPtr<nsISupports> listSupports = do_QueryInterface(list);
list->QueryInterface(NS_GET_IID(nsISupports),
getter_AddRefs(listSupports));
// Replace the element with the list. // Replace the element with the list.
mNameLookupTable.Put(&key, listSupports); mNameLookupTable.Put(&key, listSupports);

View File

@ -1023,8 +1023,7 @@ nsHTMLSelectElement::GetSelectFrame()
nsISelectControlFrame *select_frame = nsnull; nsISelectControlFrame *select_frame = nsnull;
if (form_control_frame) { if (form_control_frame) {
form_control_frame->QueryInterface(NS_GET_IID(nsISelectControlFrame), CallQueryInterface(form_control_frame, &select_frame);
(void **)&select_frame);
} }
return select_frame; return select_frame;
@ -1917,8 +1916,7 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsIFrame* formFrame = nsnull; nsIFrame* formFrame = nsnull;
if (formControlFrame && if (formControlFrame &&
NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame), NS_SUCCEEDED(CallQueryInterface(formControlFrame, &formFrame)) &&
(void **)&formFrame)) &&
formFrame) formFrame)
{ {
const nsStyleUserInterface* uiStyle; const nsStyleUserInterface* uiStyle;

View File

@ -200,8 +200,7 @@ nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
GetParentNode(getter_AddRefs(rowNode)); GetParentNode(getter_AddRefs(rowNode));
if (rowNode) { if (rowNode) {
rowNode->QueryInterface(NS_GET_IID(nsIDOMHTMLTableRowElement), CallQueryInterface(rowNode, aRow);
(void**)aRow);
} }
} }

View File

@ -662,8 +662,7 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsIFrame* formFrame = nsnull; nsIFrame* formFrame = nsnull;
if (formControlFrame && if (formControlFrame &&
NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame), NS_SUCCEEDED(CallQueryInterface(formControlFrame, &formFrame)) &&
(void **)&formFrame)) &&
formFrame) { formFrame) {
const nsStyleUserInterface* uiStyle; const nsStyleUserInterface* uiStyle;
formFrame->GetStyleData(eStyleStruct_UserInterface, formFrame->GetStyleData(eStyleStruct_UserInterface,
@ -804,15 +803,10 @@ nsHTMLTextAreaElement::GetControllers(nsIControllers** aResult)
if (!mControllers) if (!mControllers)
{ {
NS_ENSURE_SUCCESS (
nsComponentManager::CreateInstance(kXULControllersCID,
nsnull,
NS_GET_IID(nsIControllers),
getter_AddRefs(mControllers)),
NS_ERROR_FAILURE);
if (!mControllers) { return NS_ERROR_NULL_POINTER; }
nsresult rv; nsresult rv;
mControllers = do_CreateInstance(kXULControllersCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv); nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;

View File

@ -83,7 +83,7 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
nsCOMPtr<nsIDOMElement> element; nsCOMPtr<nsIDOMElement> element;
domDoc->GetElementById(usemap,getter_AddRefs(element)); domDoc->GetElementById(usemap,getter_AddRefs(element));
if (element) { if (element) {
element->QueryInterface(NS_GET_IID(nsIDOMHTMLMapElement),(void**)aMap); CallQueryInterface(element, aMap);
} }
} }
} }

View File

@ -858,7 +858,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
k.Assign(key); k.Assign(key);
ToLowerCase(k); ToLowerCase(k);
nsCOMPtr<nsIAtom> keyAtom(dont_AddRef(NS_NewAtom(k))); nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
if (!aContent->HasAttr(kNameSpaceID_None, keyAtom)) { if (!aContent->HasAttr(kNameSpaceID_None, keyAtom)) {
// Get value and remove mandatory quotes // Get value and remove mandatory quotes
@ -1033,7 +1033,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,
NS_ASSERTION(name_str, "What? No string in atom?!?"); NS_ASSERTION(name_str, "What? No string in atom?!?");
if (nsCRT::strcmp(tag, name_str) != 0) { if (nsCRT::strcmp(tag, name_str) != 0) {
nsCOMPtr<nsIAtom> atom(dont_AddRef(NS_NewAtom(tag))); nsCOMPtr<nsIAtom> atom = do_GetAtom(tag);
rv = aNodeInfo->NameChanged(atom, *getter_AddRefs(kungFuDeathGrip)); rv = aNodeInfo->NameChanged(atom, *getter_AddRefs(kungFuDeathGrip));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -2382,12 +2382,7 @@ IsScriptEnabled(nsIDocument *aDoc, nsIWebShell *aContainer)
// Getting context is tricky if the document hasn't had it's // Getting context is tricky if the document hasn't had it's
// GlobalObject set yet // GlobalObject set yet
if (!globalObject) { if (!globalObject) {
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(aContainer)); nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(aContainer);
NS_ENSURE_TRUE(requestor, PR_TRUE);
nsCOMPtr<nsIScriptGlobalObjectOwner> owner;
requestor->GetInterface(NS_GET_IID(nsIScriptGlobalObjectOwner),
getter_AddRefs(owner));
NS_ENSURE_TRUE(owner, PR_TRUE); NS_ENSURE_TRUE(owner, PR_TRUE);
owner->GetScriptGlobalObject(getter_AddRefs(globalObject)); owner->GetScriptGlobalObject(getter_AddRefs(globalObject));
@ -2436,7 +2431,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
NS_ADDREF(aDoc); NS_ADDREF(aDoc);
aDoc->AddObserver(this); aDoc->AddObserver(this);
aDoc->QueryInterface(NS_GET_IID(nsIHTMLDocument), (void**)&mHTMLDocument); CallQueryInterface(aDoc, &mHTMLDocument);
rv = mDocument->GetNodeInfoManager(*getter_AddRefs(mNodeInfoManager)); rv = mDocument->GetNodeInfoManager(*getter_AddRefs(mNodeInfoManager));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -5022,7 +5017,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
if (!result.IsEmpty()) { if (!result.IsEmpty()) {
ToLowerCase(header); ToLowerCase(header);
nsCOMPtr<nsIAtom> fieldAtom(dont_AddRef(NS_NewAtom(header))); nsCOMPtr<nsIAtom> fieldAtom = do_GetAtom(header);
rv = ProcessHeaderData(fieldAtom, result, it); rv = ProcessHeaderData(fieldAtom, result, it);
} }
} }
@ -5059,7 +5054,7 @@ HTMLContentSink::ProcessHTTPHeaders(nsIChannel* aChannel)
while (*name) { while (*name) {
rv = httpchannel->GetResponseHeader(nsDependentCString(*name), tmp); rv = httpchannel->GetResponseHeader(nsDependentCString(*name), tmp);
if (NS_SUCCEEDED(rv) && !tmp.IsEmpty()) { if (NS_SUCCEEDED(rv) && !tmp.IsEmpty()) {
nsCOMPtr<nsIAtom> key(dont_AddRef(NS_NewAtom(*name))); nsCOMPtr<nsIAtom> key = do_GetAtom(*name);
ProcessHeaderData(key, NS_ConvertASCIItoUCS2(tmp)); ProcessHeaderData(key, NS_ConvertASCIItoUCS2(tmp));
} }
name++; name++;

View File

@ -124,13 +124,11 @@
#include "nsICachingChannel.h" #include "nsICachingChannel.h"
#include "nsICacheEntryDescriptor.h" #include "nsICacheEntryDescriptor.h"
#include "nsIXMLContent.h" //for createelementNS #include "nsIXMLContent.h" //for createelementNS
#include "nsHTMLParts.h" //for createelementNS
#include "nsIJSContextStack.h" #include "nsIJSContextStack.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsIWyciwygChannel.h" #include "nsIWyciwygChannel.h"
#include "nsContentCID.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
//AHMED 12-2 //AHMED 12-2
#ifdef IBMBIDI #ifdef IBMBIDI
@ -168,8 +166,6 @@ IsNamedItem(nsIContent* aContent, nsIAtom *aTag, nsAString& aName);
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
static NS_DEFINE_CID(kHTMLStyleSheetCID,NS_HTMLSTYLESHEET_CID);
nsIRDFService* nsHTMLDocument::gRDF; nsIRDFService* nsHTMLDocument::gRDF;
nsrefcnt nsHTMLDocument::gRefCntRDFService = 0; nsrefcnt nsHTMLDocument::gRefCntRDFService = 0;
@ -287,8 +283,6 @@ IdAndNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
nsHTMLDocument::nsHTMLDocument() nsHTMLDocument::nsHTMLDocument()
: nsMarkupDocument(), : nsMarkupDocument(),
mAttrStyleSheet(nsnull),
mStyleAttrStyleSheet(nsnull),
mBaseURL(nsnull), mBaseURL(nsnull),
mBaseTarget(nsnull), mBaseTarget(nsnull),
mLastModified(nsnull), mLastModified(nsnull),
@ -319,13 +313,7 @@ nsHTMLDocument::nsHTMLDocument()
if (gRefCntRDFService++ == 0) if (gRefCntRDFService++ == 0)
{ {
nsresult rv; CallGetService(kRDFServiceCID, &gRDF);
rv = nsServiceManager::GetService(kRDFServiceCID,
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDF);
//nsCOMPtr<nsIRDFService> gRDF(do_GetService(kRDFServiceCID,
//&rv));
} }
} }
@ -363,9 +351,8 @@ nsHTMLDocument::~nsHTMLDocument()
mCSSLoader->DropDocumentReference(); // release weak ref mCSSLoader->DropDocumentReference(); // release weak ref
} }
if (--gRefCntRDFService == 0) if (--gRefCntRDFService == 0) {
{ NS_IF_RELEASE(gRDF);
nsServiceManager::ReleaseService("@mozilla.org/rdf/rdf-service;1", gRDF);
} }
if (mIdAndNameHashIsLive) { if (mIdAndNameHashIsLive) {
@ -454,16 +441,8 @@ nsHTMLDocument::BaseResetToURI(nsIURI *aURL)
if (aURL) { if (aURL) {
if (!mAttrStyleSheet) { if (!mAttrStyleSheet) {
//result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, aURL, this); result = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), aURL,
result = nsComponentManager::CreateInstance(kHTMLStyleSheetCID, nsnull, this);
NS_GET_IID(nsIHTMLStyleSheet),
getter_AddRefs(mAttrStyleSheet));
if (NS_SUCCEEDED(result)) {
result = mAttrStyleSheet->Init(aURL, this);
if (NS_FAILED(result)) {
mAttrStyleSheet = nsnull;
}
}
} }
else { else {
result = mAttrStyleSheet->Reset(aURL); result = mAttrStyleSheet->Reset(aURL);
@ -561,7 +540,7 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
} else if (aDocInfo) { } else if (aDocInfo) {
nsCOMPtr<nsIAtom> csAtom; nsCOMPtr<nsIAtom> csAtom;
aDocInfo->GetForcedCharset(getter_AddRefs(csAtom)); aDocInfo->GetForcedCharset(getter_AddRefs(csAtom));
if (csAtom.get() != nsnull) { if (csAtom) {
csAtom->ToString(aCharset); csAtom->ToString(aCharset);
aCharsetSource = kCharsetFromUserForced; aCharsetSource = kCharsetFromUserForced;
aDocInfo->SetForcedCharset(nsnull); aDocInfo->SetForcedCharset(nsnull);
@ -880,9 +859,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
} }
if (needsParser) { if (needsParser) {
rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, rv = CallCreateInstance(kCParserCID, &mParser);
NS_GET_IID(nsIParser),
(void **)&mParser);
if (NS_FAILED(rv)) { return rv; } if (NS_FAILED(rv)) { return rv; }
} }
@ -1019,8 +996,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// Set the parser as the stream listener for the document loader... // Set the parser as the stream listener for the document loader...
if (mParser) { if (mParser) {
rv = mParser->QueryInterface(NS_GET_IID(nsIStreamListener), rv = CallQueryInterface(mParser, aDocListener);
(void**)aDocListener);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -1205,10 +1181,8 @@ nsHTMLDocument::GetImageMap(const nsString& aMapName,
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult) nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
{ {
NS_PRECONDITION(aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mAttrStyleSheet; *aResult = mAttrStyleSheet;
if (!mAttrStyleSheet) { if (!mAttrStyleSheet) {
return NS_ERROR_NOT_AVAILABLE; // probably not the right error... return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
@ -1221,10 +1195,8 @@ nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult) nsHTMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
{ {
NS_PRECONDITION(aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mStyleAttrStyleSheet; *aResult = mStyleAttrStyleSheet;
if (!mStyleAttrStyleSheet) { if (!mStyleAttrStyleSheet) {
return NS_ERROR_NOT_AVAILABLE; // probably not the right error... return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
@ -1670,7 +1642,7 @@ nsHTMLDocument::CreateElement(const nsAString& aTagName,
PR_FALSE); PR_FALSE);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
content->SetContentID(mNextContentID++); content->SetContentID(mNextContentID++);
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aReturn); rv = CallQueryInterface(content, aReturn);
} }
return rv; return rv;
} }
@ -2513,9 +2485,7 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
mRootContent = root; mRootContent = root;
} }
result = nsComponentManager::CreateInstance(kCParserCID, nsnull, result = CallCreateInstance(kCParserCID, &mParser);
NS_GET_IID(nsIParser),
(void **)&mParser);
mIsWriting = 1; mIsWriting = 1;
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
@ -3025,9 +2995,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
// just use the view size itself // just use the view size itself
if (view) { if (view) {
nsIScrollableView* scrollableView = nsnull; nsIScrollableView* scrollableView = nsnull;
CallQueryInterface(view, &scrollableView);
view->QueryInterface(NS_GET_IID(nsIScrollableView),
(void**)&scrollableView);
if (scrollableView) { if (scrollableView) {
scrollableView->GetScrolledView(view); scrollableView->GetScrolledView(view);
@ -3912,7 +3880,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
list = fc_list; list = fc_list;
} }
return list->QueryInterface(NS_GET_IID(nsISupports), (void **)aResult); return CallQueryInterface(list, aResult);
} }
} }
@ -3979,12 +3947,11 @@ nsHTMLDocument::GetBodyContent()
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody) nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody)
{ {
if (!mBodyContent && PR_FALSE == GetBodyContent()) { if (!mBodyContent && !GetBodyContent()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
return mBodyContent->QueryInterface(NS_GET_IID(nsIDOMHTMLBodyElement), return CallQueryInterface(mBodyContent, aBody);
(void**)aBody);
} }
// forms related stuff // forms related stuff

View File

@ -173,43 +173,31 @@ public:
nsresult nsresult
NS_NewHTMLFragmentContentSink2(nsIHTMLFragmentContentSink** aResult) NS_NewHTMLFragmentContentSink2(nsIHTMLFragmentContentSink** aResult)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
nsHTMLFragmentContentSink2* it;
NS_NEWXPCOM(it, nsHTMLFragmentContentSink2);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = it->Init();
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return it->QueryInterface(NS_GET_IID(nsIHTMLFragmentContentSink), (void **)aResult); nsCOMPtr<nsHTMLFragmentContentSink2> it;
NS_NEWXPCOM(it, nsHTMLFragmentContentSink2);
NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = it->Init();
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(it, aResult);
} }
nsresult nsresult
NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aResult) NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aResult)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
nsHTMLFragmentContentSink* it;
NS_NEWXPCOM(it, nsHTMLFragmentContentSink);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = it->Init();
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return it->QueryInterface(NS_GET_IID(nsIHTMLFragmentContentSink), (void **)aResult); nsCOMPtr<nsHTMLFragmentContentSink> it;
NS_NEWXPCOM(it, nsHTMLFragmentContentSink);
NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = it->Init();
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(it, aResult);
} }
nsHTMLFragmentContentSink::nsHTMLFragmentContentSink() nsHTMLFragmentContentSink::nsHTMLFragmentContentSink()
@ -302,18 +290,15 @@ nsresult nsHTMLFragmentContentSink::Init()
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLFragmentContentSink::WillBuildModel(void) nsHTMLFragmentContentSink::WillBuildModel(void)
{ {
nsresult result = NS_OK; if (mRoot) {
return NS_OK;
if (nsnull == mRoot) {
nsIDOMDocumentFragment* frag;
result = NS_NewDocumentFragment(&frag, nsnull);
if (NS_SUCCEEDED(result)) {
result = frag->QueryInterface(NS_GET_IID(nsIContent), (void**)&mRoot);
NS_RELEASE(frag);
}
} }
return result;
nsCOMPtr<nsIDOMDocumentFragment> frag;
nsresult rv = NS_NewDocumentFragment(getter_AddRefs(frag), nsnull);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(frag, &mRoot);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -710,10 +695,9 @@ nsHTMLFragmentContentSink::AddComment(const nsIParserNode& aNode)
FlushText(); FlushText();
result = NS_NewCommentNode(&comment); result = NS_NewCommentNode(&comment);
if (NS_OK == result) { if (NS_SUCCEEDED(result)) {
result = comment->QueryInterface(NS_GET_IID(nsIDOMComment), result = CallQueryInterface(comment, &domComment);
(void **)&domComment); if (NS_SUCCEEDED(result)) {
if (NS_OK == result) {
domComment->AppendData(aNode.GetText()); domComment->AppendData(aNode.GetText());
NS_RELEASE(domComment); NS_RELEASE(domComment);
@ -757,13 +741,13 @@ nsHTMLFragmentContentSink::DoFragment(PRBool aFlag)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLFragmentContentSink::GetFragment(nsIDOMDocumentFragment** aFragment) nsHTMLFragmentContentSink::GetFragment(nsIDOMDocumentFragment** aFragment)
{ {
if (nsnull != mRoot) { if (mRoot) {
return mRoot->QueryInterface(NS_GET_IID(nsIDOMDocumentFragment), (void**)aFragment); return CallQueryInterface(mRoot, aFragment);
}
else {
*aFragment = nsnull;
return NS_OK;
} }
*aFragment = nsnull;
return NS_OK;
} }
nsIContent* nsIContent*
@ -938,7 +922,7 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
k.Assign(key); k.Assign(key);
ToLowerCase(k); ToLowerCase(k);
nsIAtom* keyAtom = NS_NewAtom(k); nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
if (NS_CONTENT_ATTR_NOT_THERE == if (NS_CONTENT_ATTR_NOT_THERE ==
aContent->GetAttr(kNameSpaceID_None, keyAtom, v)) { aContent->GetAttr(kNameSpaceID_None, keyAtom, v)) {
@ -948,7 +932,6 @@ nsHTMLFragmentContentSink::AddAttributes(const nsIParserNode& aNode,
// Add attribute to content // Add attribute to content
aContent->SetAttr(kNameSpaceID_None, keyAtom, v, PR_FALSE); aContent->SetAttr(kNameSpaceID_None, keyAtom, v, PR_FALSE);
} }
NS_RELEASE(keyAtom);
} }
return NS_OK; return NS_OK;
} }

View File

@ -144,8 +144,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(ImageListener, nsIStreamListener)
NS_IMETHODIMP NS_IMETHODIMP
ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt) ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
{ {
nsresult rv;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request); nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (!channel) return NS_ERROR_NULL_POINTER; if (!channel) return NS_ERROR_NULL_POINTER;
@ -428,18 +426,12 @@ nsresult nsImageDocument::UpdateTitle( void )
// so instead we just get the image-extension // so instead we just get the image-extension
// - get the URL interface, get the extension, convert to upper-case // - get the URL interface, get the extension, convert to upper-case
// Unless the Imagerequest or Image can tell us the type this is the best we can do. // Unless the Imagerequest or Image can tell us the type this is the best we can do.
nsIURL *pURL=nsnull; nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURL);
if(NS_SUCCEEDED(mDocumentURL->QueryInterface(NS_GET_IID(nsIURL),(void **)&pURL))) { if (url) {
char *pExtension=nsnull; nsXPIDLCString extension;
pURL->GetFileExtension(&pExtension); url->GetFileExtension(getter_Copies(extension));
if(pExtension){ ToUpperCase(extension);
nsString strExt; strExt.AssignWithConversion(pExtension); titleStr.AppendWithConversion(extension);
ToUpperCase(strExt);
titleStr.Append(strExt);
nsCRT::free(pExtension);
pExtension=nsnull;
}
NS_IF_RELEASE(pURL);
} }
#endif #endif

View File

@ -78,18 +78,15 @@ nsWyciwygProtocolHandler::NewURI(const nsACString &aSpec,
{ {
nsresult rv; nsresult rv;
nsIURI* url; nsCOMPtr<nsIURI> url = do_CreateInstance(kSimpleURICID, &rv);
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull, NS_ENSURE_SUCCESS(rv, rv);
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aSpec); rv = url->SetSpec(aSpec);
if (NS_FAILED(rv)) { NS_ENSURE_SUCCESS(rv, rv);
NS_RELEASE(url);
return rv;
}
*result = url; *result = url;
NS_ADDREF(*result);
return rv; return rv;
} }

View File

@ -6117,8 +6117,7 @@ void nsCSSDeclaration::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSDeclaration");
tag = getter_AddRefs(NS_NewAtom("nsCSSDeclaration"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);

View File

@ -1097,9 +1097,8 @@ PRBool CSSParserImpl::GatherMedia(PRInt32& aErrorCode, nsString& aMedia,
} }
ToLowerCase(mToken.mIdent); // case insensitive from CSS - must be lower cased ToLowerCase(mToken.mIdent); // case insensitive from CSS - must be lower cased
if (aMediaAtoms) { if (aMediaAtoms) {
nsIAtom* medium = NS_NewAtom(mToken.mIdent); nsCOMPtr<nsIAtom> medium = do_GetAtom(mToken.mIdent);
aMediaAtoms->AppendElement(medium); aMediaAtoms->AppendElement(medium);
NS_RELEASE(medium);
} }
aMedia.Append(mToken.mIdent); aMedia.Append(mToken.mIdent);
first = PR_FALSE; first = PR_FALSE;
@ -1323,7 +1322,7 @@ PRBool CSSParserImpl::ProcessNameSpace(PRInt32& aErrorCode, const nsString& aPre
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
} }
NS_NewCSSNameSpaceRule(getter_AddRefs(rule), prefix, aURLSpec); NS_NewCSSNameSpaceRule(getter_AddRefs(rule), prefix, aURLSpec);
@ -1838,12 +1837,10 @@ void CSSParserImpl::ParseTypeOrUniversalSelector(PRInt32& aDataMask,
aDataMask |= SEL_MASK_NSPACE; aDataMask |= SEL_MASK_NSPACE;
PRInt32 nameSpaceID = kNameSpaceID_Unknown; PRInt32 nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(buffer); // always case insensitive, since stays within CSS ToLowerCase(buffer); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(buffer); nsCOMPtr<nsIAtom> prefix = do_GetAtom(buffer);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") + REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +
buffer + NS_LITERAL_STRING("'.")); buffer + NS_LITERAL_STRING("'."));
@ -2027,12 +2024,10 @@ void CSSParserImpl::ParseAttributeSelector(PRInt32& aDataMask,
if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // was a namespace if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // was a namespace
nameSpaceID = kNameSpaceID_Unknown; nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(attr); // always case insensitive, since stays within CSS ToLowerCase(attr); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(attr); nsCOMPtr<nsIAtom> prefix = do_GetAtom(attr);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") + REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +
attr + NS_LITERAL_STRING("'.")); attr + NS_LITERAL_STRING("'."));
@ -2690,7 +2685,7 @@ PRBool CSSParserImpl::ParseTreePseudoElement(PRInt32& aErrorCode,
return PR_FALSE; return PR_FALSE;
} }
else if (eCSSToken_Ident == mToken.mType) { else if (eCSSToken_Ident == mToken.mType) {
nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_NewAtom(mToken.mIdent)); nsCOMPtr<nsIAtom> pseudo = do_GetAtom(mToken.mIdent);
aSelector.AddPseudoClass(pseudo); aSelector.AddPseudoClass(pseudo);
} }
else if (eCSSToken_Symbol == mToken.mType) { else if (eCSSToken_Symbol == mToken.mType) {
@ -3252,12 +3247,10 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // namespace if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // namespace
PRInt32 nameSpaceID = kNameSpaceID_Unknown; PRInt32 nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(holdIdent); // always case insensitive, since stays within CSS ToLowerCase(holdIdent); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(holdIdent); nsCOMPtr<nsIAtom> prefix = do_GetAtom(holdIdent);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
return PR_FALSE; return PR_FALSE;
} }

View File

@ -271,8 +271,7 @@ void CSSCharsetRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSCharsetRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSCharsetRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
// add the string for encoding value // add the string for encoding value
@ -295,7 +294,7 @@ CSSCharsetRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSCharsetRuleImpl* clone = new CSSCharsetRuleImpl(*this); CSSCharsetRuleImpl* clone = new CSSCharsetRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -520,8 +519,7 @@ void CSSImportRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSImportRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSImportRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -546,7 +544,7 @@ CSSImportRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSImportRuleImpl* clone = new CSSImportRuleImpl(*this); CSSImportRuleImpl* clone = new CSSImportRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -935,8 +933,7 @@ void CSSMediaRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSMediaRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSMediaRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -981,7 +978,7 @@ CSSMediaRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSMediaRuleImpl* clone = new CSSMediaRuleImpl(*this); CSSMediaRuleImpl* clone = new CSSMediaRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -1380,8 +1377,7 @@ void CSSNameSpaceRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aS
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSNameSpaceRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSNameSpaceRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -1410,7 +1406,7 @@ CSSNameSpaceRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSNameSpaceRuleImpl* clone = new CSSNameSpaceRuleImpl(*this); CSSNameSpaceRuleImpl* clone = new CSSNameSpaceRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;

View File

@ -6117,8 +6117,7 @@ void nsCSSDeclaration::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSDeclaration");
tag = getter_AddRefs(NS_NewAtom("nsCSSDeclaration"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);

View File

@ -336,8 +336,7 @@ void nsAttrSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsAttrSelector");
tag = getter_AddRefs(NS_NewAtom("nsAttrSelector"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -655,8 +654,7 @@ void nsCSSSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSSelector");
tag = getter_AddRefs(NS_NewAtom("nsCSSSelector"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -1071,8 +1069,7 @@ void CSSImportantRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSImportantRule");
tag = getter_AddRefs(NS_NewAtom("CSSImportantRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSImportantRule); aSize = sizeof(CSSImportantRule);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -1377,13 +1374,14 @@ DOMCSSDeclarationImpl::ParseDeclaration(const nsAString& aDecl,
nsresult nsresult
DOMCSSDeclarationImpl::GetParent(nsISupports **aParent) DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
{ {
if (nsnull != mRule) { NS_ENSURE_ARG_POINTER(aParent);
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
} else { if (mRule) {
NS_ENSURE_ARG_POINTER(aParent); return CallQueryInterface(mRule, aParent);
*aParent = nsnull;
} }
*aParent = nsnull;
return NS_OK; return NS_OK;
} }
@ -1698,7 +1696,7 @@ CSSStyleRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this); CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2446,8 +2444,7 @@ void CSSStyleRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSStyleRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
// remove the sizeof the mSelector's class since we count it seperately below // remove the sizeof the mSelector's class since we count it seperately below
@ -2509,8 +2506,8 @@ CSSStyleRuleImpl::SetCssText(const nsAString& aCssText)
NS_IMETHODIMP NS_IMETHODIMP
CSSStyleRuleImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet) CSSStyleRuleImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
{ {
if (nsnull != mSheet) { if (mSheet) {
return mSheet->QueryInterface(NS_GET_IID(nsIDOMCSSStyleSheet), (void**)aSheet); return CallQueryInterface(mSheet, aSheet);
} }
*aSheet = nsnull; *aSheet = nsnull;
return NS_OK; return NS_OK;
@ -2566,10 +2563,10 @@ NS_EXPORT nsresult
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector); CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector);
if (!it) {
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsICSSStyleRule), (void **) aInstancePtrResult);
return CallQueryInterface(it, aInstancePtrResult);
} }

View File

@ -1317,7 +1317,7 @@ DOMMediaListImpl::Delete(const nsAString& aOldMedium)
if (aOldMedium.IsEmpty()) if (aOldMedium.IsEmpty())
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
nsCOMPtr<nsIAtom> old(dont_AddRef(NS_NewAtom(aOldMedium))); nsCOMPtr<nsIAtom> old = do_GetAtom(aOldMedium);
NS_ENSURE_TRUE(old, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(old, NS_ERROR_OUT_OF_MEMORY);
PRInt32 indx = IndexOf(old); PRInt32 indx = IndexOf(old);
@ -1337,7 +1337,7 @@ DOMMediaListImpl::Append(const nsAString& aNewMedium)
if (aNewMedium.IsEmpty()) if (aNewMedium.IsEmpty())
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
nsCOMPtr<nsIAtom> media(dont_AddRef(NS_NewAtom(aNewMedium))); nsCOMPtr<nsIAtom> media = do_GetAtom(aNewMedium);
NS_ENSURE_TRUE(media, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(media, NS_ERROR_OUT_OF_MEMORY);
PRInt32 indx = IndexOf(media); PRInt32 indx = IndexOf(media);
@ -1453,14 +1453,14 @@ CSSImportsCollectionImpl::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn)
nsresult result = NS_OK; nsresult result = NS_OK;
*aReturn = nsnull; *aReturn = nsnull;
if (nsnull != mStyleSheet) {
nsICSSStyleSheet *sheet;
result = mStyleSheet->GetStyleSheetAt(aIndex, sheet); if (mStyleSheet) {
if (NS_OK == result) { nsCOMPtr<nsICSSStyleSheet> sheet;
result = sheet->QueryInterface(NS_GET_IID(nsIDOMStyleSheet), (void **)aReturn);
result = mStyleSheet->GetStyleSheetAt(aIndex, *getter_AddRefs(sheet));
if (NS_SUCCEEDED(result)) {
result = CallQueryInterface(sheet, aReturn);
} }
NS_RELEASE(sheet);
} }
return result; return result;
@ -1667,8 +1667,7 @@ void CSSStyleSheetInner::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
PRBool rulesCounted=PR_FALSE; PRBool rulesCounted=PR_FALSE;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleSheetInner");
tag = getter_AddRefs(NS_NewAtom("CSSStyleSheetInner"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSStyleSheetInner); aSize = sizeof(CSSStyleSheetInner);
@ -2588,8 +2587,7 @@ void CSSStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleSheet");
tag = getter_AddRefs(NS_NewAtom("CSSStyleSheet"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSStyleSheetImpl); aSize = sizeof(CSSStyleSheetImpl);
@ -4350,13 +4348,13 @@ void CascadeSizeEnumFunc(RuleCascadeData *cascade, CascadeSizeEnumData *pData)
// next add up the selectors and the weighted rules for the cascade // next add up the selectors and the weighted rules for the cascade
nsCOMPtr<nsIAtom> stateSelectorSizeTag; nsCOMPtr<nsIAtom> stateSelectorSizeTag;
stateSelectorSizeTag = getter_AddRefs(NS_NewAtom("CascadeStateSelectors")); stateSelectorSizeTag = do_GetAtom("CascadeStateSelectors");
CascadeSizeEnumData stateData(pData->handler,pData->uniqueItems,stateSelectorSizeTag); CascadeSizeEnumData stateData(pData->handler,pData->uniqueItems,stateSelectorSizeTag);
cascade->mStateSelectors.EnumerateForwards(StateSelectorsSizeEnumFunc, &stateData); cascade->mStateSelectors.EnumerateForwards(StateSelectorsSizeEnumFunc, &stateData);
if(cascade->mWeightedRules){ if(cascade->mWeightedRules){
nsCOMPtr<nsIAtom> weightedRulesSizeTag; nsCOMPtr<nsIAtom> weightedRulesSizeTag;
weightedRulesSizeTag = getter_AddRefs(NS_NewAtom("CascadeWeightedRules")); weightedRulesSizeTag = do_GetAtom("CascadeWeightedRules");
CascadeSizeEnumData stateData2(pData->handler,pData->uniqueItems,weightedRulesSizeTag); CascadeSizeEnumData stateData2(pData->handler,pData->uniqueItems,weightedRulesSizeTag);
cascade->mWeightedRules->EnumerateForwards(WeightedRulesSizeEnumFunc, &stateData2); cascade->mWeightedRules->EnumerateForwards(WeightedRulesSizeEnumFunc, &stateData2);
} }
@ -4387,8 +4385,7 @@ void CSSRuleProcessor::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSRuleProcessor");
tag = getter_AddRefs(NS_NewAtom("CSSRuleProcessor"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSRuleProcessor); aSize = sizeof(CSSRuleProcessor);
@ -4413,7 +4410,7 @@ void CSSRuleProcessor::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
// and for the medium cascade table we account for the hash table overhead, // and for the medium cascade table we account for the hash table overhead,
// and then compute the sizeof each rule-cascade in the table // and then compute the sizeof each rule-cascade in the table
{ {
nsCOMPtr<nsIAtom> tag2 = getter_AddRefs(NS_NewAtom("RuleCascade")); nsCOMPtr<nsIAtom> tag2 = do_GetAtom("RuleCascade");
CascadeSizeEnumData data(aSizeOfHandler, uniqueItems, tag2); CascadeSizeEnumData data(aSizeOfHandler, uniqueItems, tag2);
for (RuleCascadeData *cascadeData = mRuleCascades; for (RuleCascadeData *cascadeData = mRuleCascades;
cascadeData; cascadeData;

View File

@ -205,7 +205,7 @@ nsComputedDOMStyle::Init(nsIDOMElement *aElement,
} }
if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty()) { if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty()) {
mPseudo = dont_AddRef(NS_NewAtom(aPseudoElt)); mPseudo = do_GetAtom(aPseudoElt);
NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY);
} }

View File

@ -158,7 +158,7 @@ nsDOMCSSDeclaration::GetParentRule(nsIDOMCSSRule** aParentRule)
GetParent(getter_AddRefs(parent)); GetParent(getter_AddRefs(parent));
if (parent) { if (parent) {
parent->QueryInterface(NS_GET_IID(nsIDOMCSSRule), (void **)aParentRule); CallQueryInterface(parent, aParentRule);
} }
return NS_OK; return NS_OK;

View File

@ -819,7 +819,7 @@ void nsHTMLMappedAttributes::SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult)
return; return;
} }
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("HTMLMappedAttributes")); tag = do_GetAtom("HTMLMappedAttributes");
aResult = sizeof(*this); aResult = sizeof(*this);
aSizer->AddSize(tag, aResult); aSizer->AddSize(tag, aResult);
} }
@ -1625,7 +1625,7 @@ void nsHTMLAttributes::SizeOf(nsISizeOfHandler* aSizer, PRUint32 &aResult)
aResult = sum; aResult = sum;
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("nsHTMLAttributes")); tag = do_GetAtom("nsHTMLAttributes");
aSizer->AddSize(tag, aResult); aSizer->AddSize(tag, aResult);
} }
#endif #endif

View File

@ -157,7 +157,7 @@ void CSSFirstLineRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("CSSFirstLine-LetterRule")); tag = do_GetAtom("CSSFirstLine-LetterRule");
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -523,7 +523,7 @@ void HTMLCSSStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("HTMLCSSStyleSheet")); tag = do_GetAtom("HTMLCSSStyleSheet");
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(HTMLCSSStyleSheetImpl); aSize = sizeof(HTMLCSSStyleSheetImpl);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -534,13 +534,13 @@ void HTMLCSSStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
if(mFirstLineRule && uniqueItems->AddItem((void*)mFirstLineRule)){ if(mFirstLineRule && uniqueItems->AddItem((void*)mFirstLineRule)){
localSize = sizeof(*mFirstLineRule); localSize = sizeof(*mFirstLineRule);
aSize += localSize; aSize += localSize;
tag = getter_AddRefs(NS_NewAtom("FirstLineRule")); tag = do_GetAtom("FirstLineRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(mFirstLetterRule && uniqueItems->AddItem((void*)mFirstLetterRule)){ if(mFirstLetterRule && uniqueItems->AddItem((void*)mFirstLetterRule)){
localSize = sizeof(*mFirstLetterRule); localSize = sizeof(*mFirstLetterRule);
aSize += localSize; aSize += localSize;
tag = getter_AddRefs(NS_NewAtom("FirstLetterRule")); tag = do_GetAtom("FirstLetterRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
} }

View File

@ -83,7 +83,7 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
nsCOMPtr<nsIDOMElement> element; nsCOMPtr<nsIDOMElement> element;
domDoc->GetElementById(usemap,getter_AddRefs(element)); domDoc->GetElementById(usemap,getter_AddRefs(element));
if (element) { if (element) {
element->QueryInterface(NS_GET_IID(nsIDOMHTMLMapElement),(void**)aMap); CallQueryInterface(element, aMap);
} }
} }
} }

View File

@ -225,7 +225,7 @@ nsSVGAttribute::SetPrefix(const nsAString& aPrefix)
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -346,8 +346,7 @@ nsSVGAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
nsIContent *content; nsIContent *content;
if (mOwner && (content = mOwner->GetContent())) { if (mOwner && (content = mOwner->GetContent())) {
return content->QueryInterface(NS_GET_IID(nsIDOMElement), return CallQueryInterface(content, aOwnerElement);
(void **)aOwnerElement);
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -644,13 +643,14 @@ nsSVGAttributes::SetAttr(nsINodeInfo* aNodeInfo,
mutation.message = NS_MUTATION_ATTRMODIFIED; mutation.message = NS_MUTATION_ATTRMODIFIED;
mutation.mTarget = node; mutation.mTarget = node;
//XXX mutation.mRelatedNode = do_QueryInterface(attr); CallQueryInterface(attr,
attr->QueryInterface(NS_GET_IID(nsIDOMNode), getter_AddRefs(mutation.mRelatedNode)); NS_STATIC_CAST(nsIDOMNode**,
getter_AddRefs(mutation.mRelatedNode)));
mutation.mAttrName = name; mutation.mAttrName = name;
if (!oldValue.IsEmpty()) if (!oldValue.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValue)); mutation.mPrevAttrValue = do_GetAtom(oldValue);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
mutation.mNewAttrValue = getter_AddRefs(NS_NewAtom(aValue)); mutation.mNewAttrValue = do_GetAtom(aValue);
mutation.mAttrChange = modification ? nsIDOMMutationEvent::MODIFICATION : mutation.mAttrChange = modification ? nsIDOMMutationEvent::MODIFICATION :
nsIDOMMutationEvent::ADDITION; nsIDOMMutationEvent::ADDITION;
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
@ -707,13 +707,14 @@ nsSVGAttributes::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
mutation.message = NS_MUTATION_ATTRMODIFIED; mutation.message = NS_MUTATION_ATTRMODIFIED;
mutation.mTarget = node; mutation.mTarget = node;
//XXX mutation.mRelatedNode = do_QueryInterface(attr); CallQueryInterface(attr,
attr->QueryInterface(NS_GET_IID(nsIDOMNode), getter_AddRefs(mutation.mRelatedNode)); NS_STATIC_CAST(nsIDOMNode**,
getter_AddRefs(mutation.mRelatedNode)));
mutation.mAttrName = aName; mutation.mAttrName = aName;
nsAutoString str; nsAutoString str;
attr->GetValue()->GetValueString(str); attr->GetValue()->GetValueString(str);
if (!str.IsEmpty()) if (!str.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(str)); mutation.mPrevAttrValue = do_GetAtom(str);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL; mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;

View File

@ -503,11 +503,11 @@ NS_IMETHODIMP
nsSVGElement::GetParentNode(nsIDOMNode** aParentNode) nsSVGElement::GetParentNode(nsIDOMNode** aParentNode)
{ {
if (mParent) { if (mParent) {
return mParent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aParentNode); return CallQueryInterface(mParent, aParentNode);
} }
else if (mDocument) { if (mDocument) {
// we're the root content // we're the root content
return mDocument->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aParentNode); return CallQueryInterface(mDocument, aParentNode);
} }
// A standalone element (i.e. one without a parent or a document) // A standalone element (i.e. one without a parent or a document)
@ -520,26 +520,24 @@ nsSVGElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
{ {
nsDOMSlots *slots = GetDOMSlots(); nsDOMSlots *slots = GetDOMSlots();
if (nsnull == slots->mChildNodes) { if (!slots->mChildNodes) {
slots->mChildNodes = new nsChildContentList(this); slots->mChildNodes = new nsChildContentList(this);
if (nsnull == slots->mChildNodes) { if (!slots->mChildNodes) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
NS_ADDREF(slots->mChildNodes); NS_ADDREF(slots->mChildNodes);
} }
return slots->mChildNodes->QueryInterface(NS_GET_IID(nsIDOMNodeList), return CallQueryInterface(slots->mChildNodes, aChildNodes);
(void **)aChildNodes);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsSVGElement::GetFirstChild(nsIDOMNode** aNode) nsSVGElement::GetFirstChild(nsIDOMNode** aNode)
{ {
nsIContent *child = (nsIContent *)mChildren.ElementAt(0); nsIContent *child = (nsIContent *)mChildren.ElementAt(0);
if (nsnull != child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
*aNode = nsnull; *aNode = nsnull;
@ -550,10 +548,9 @@ NS_IMETHODIMP
nsSVGElement::GetLastChild(nsIDOMNode** aNode) nsSVGElement::GetLastChild(nsIDOMNode** aNode)
{ {
nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1); nsIContent *child = (nsIContent *)mChildren.ElementAt(mChildren.Count()-1);
if (nsnull != child) { if (child) {
nsresult res = child->QueryInterface(NS_GET_IID(nsIDOMNode), nsresult res = CallQueryInterface(child, aNode);
(void**)aNode); NS_ASSERTION(NS_SUCCEEDED(res), "Must be a DOM Node"); // must be a DOM Node
NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node
return res; return res;
} }
*aNode = nsnull; *aNode = nsnull;

View File

@ -577,7 +577,7 @@ PRUint16 nsSVGLength::GetUnitTypeForString(const char* unitStr)
{ {
if (!unitStr || *unitStr=='\0') return SVG_LENGTHTYPE_NUMBER; if (!unitStr || *unitStr=='\0') return SVG_LENGTHTYPE_NUMBER;
nsCOMPtr<nsIAtom> unitAtom = NS_NewAtom(unitStr); nsCOMPtr<nsIAtom> unitAtom = do_GetAtom(unitStr);
if (unitAtom == nsSVGAtoms::px) if (unitAtom == nsSVGAtoms::px)
return SVG_LENGTHTYPE_PX; return SVG_LENGTHTYPE_PX;

View File

@ -501,7 +501,7 @@ nsSVGSVGElement::SuspendRedraw(PRUint32 max_wait_milliseconds, PRUint32 *_retval
#endif #endif
if (frame) { if (frame) {
nsISVGFrame* svgframe; nsISVGFrame* svgframe;
frame->QueryInterface(NS_GET_IID(nsISVGFrame),(void**)&svgframe); CallQueryInterface(frame, &svgframe);
NS_ASSERTION(svgframe, "wrong frame type"); NS_ASSERTION(svgframe, "wrong frame type");
if (svgframe) { if (svgframe) {
svgframe->NotifyRedrawSuspended(); svgframe->NotifyRedrawSuspended();
@ -548,7 +548,7 @@ nsSVGSVGElement::UnsuspendRedrawAll()
#endif #endif
if (frame) { if (frame) {
nsISVGFrame* svgframe; nsISVGFrame* svgframe;
frame->QueryInterface(NS_GET_IID(nsISVGFrame),(void**)&svgframe); CallQueryInterface(frame, &svgframe);
NS_ASSERTION(svgframe, "wrong frame type"); NS_ASSERTION(svgframe, "wrong frame type");
if (svgframe) { if (svgframe) {
svgframe->NotifyRedrawUnsuspended(); svgframe->NotifyRedrawUnsuspended();
@ -995,7 +995,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
if (view) { if (view) {
// handle scrolled views along the way: // handle scrolled views along the way:
nsIScrollableView* scrollableView = nsnull; nsIScrollableView* scrollableView = nsnull;
view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView); CallQueryInterface(view, &scrollableView);
if (scrollableView) { if (scrollableView) {
nscoord scrollX, scrollY; nscoord scrollX, scrollY;
scrollableView->GetScrollPosition(scrollX, scrollY); scrollableView->GetScrollPosition(scrollX, scrollY);

View File

@ -204,7 +204,7 @@ nsSVGTransformList::SetValueString(const nsAString& aValue)
break; break;
} }
nsCOMPtr<nsIAtom> keyatom = dont_AddRef(NS_NewAtom(keyword)); nsCOMPtr<nsIAtom> keyatom = do_GetAtom(keyword);
if (keyatom == nsSVGAtoms::translate) { if (keyatom == nsSVGAtoms::translate) {
char* arg1 = nsCRT::strtok(args, delimiters3, &args); char* arg1 = nsCRT::strtok(args, delimiters3, &args);

View File

@ -142,8 +142,7 @@ NS_EXPORT nsresult
NS_NewSVGDocument(nsIDocument** aInstancePtrResult) NS_NewSVGDocument(nsIDocument** aInstancePtrResult)
{ {
nsSVGDocument* doc = new nsSVGDocument(); nsSVGDocument* doc = new nsSVGDocument();
if (!doc) NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
return NS_ERROR_OUT_OF_MEMORY;
return doc->QueryInterface(NS_GET_IID(nsIDocument), return CallQueryInterface(doc, aInstancePtrResult);
(void**) aInstancePtrResult);
} }

View File

@ -130,7 +130,7 @@ private:
nsISupportsArray* mElements; nsISupportsArray* mElements;
}; };
MOZ_DECL_CTOR_COUNTER(nsAnonymousContentList); MOZ_DECL_CTOR_COUNTER(nsAnonymousContentList)
NS_IMPL_ISUPPORTS_INHERITED1(nsAnonymousContentList, nsGenericDOMNodeList, nsIAnonymousContentList) NS_IMPL_ISUPPORTS_INHERITED1(nsAnonymousContentList, nsGenericDOMNodeList, nsIAnonymousContentList)
@ -191,7 +191,7 @@ nsAnonymousContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
nsCOMPtr<nsIContent> result; nsCOMPtr<nsIContent> result;
rv = point->ChildAt(aIndex, getter_AddRefs(result)); rv = point->ChildAt(aIndex, getter_AddRefs(result));
if (result && NS_SUCCEEDED(rv)) if (result && NS_SUCCEEDED(rv))
return result->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); return CallQueryInterface(result, aReturn);
else return rv; else return rv;
} }
} }

View File

@ -1465,7 +1465,7 @@ nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName,
nsAutoString eventStr(NS_LITERAL_STRING("on")); nsAutoString eventStr(NS_LITERAL_STRING("on"));
eventStr += val; eventStr += val;
nsCOMPtr<nsIAtom> eventName = getter_AddRefs(NS_NewAtom(eventStr)); nsCOMPtr<nsIAtom> eventName = do_GetAtom(eventStr);
nsresult rv; nsresult rv;
nsCOMPtr<nsIDocument> document; nsCOMPtr<nsIDocument> document;

View File

@ -63,17 +63,16 @@ NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIURI* aURL, nsIURI* aURL,
nsIWebShell* aWebShell) nsIWebShell* aWebShell)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (!aResult)
return NS_ERROR_NULL_POINTER;
nsXBLContentSink* it; nsXBLContentSink* it;
NS_NEWXPCOM(it, nsXBLContentSink); NS_NEWXPCOM(it, nsXBLContentSink);
if (!it) NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = it->Init(aDoc, aURL, aWebShell); nsresult rv = it->Init(aDoc, aURL, aWebShell);
if (NS_FAILED(rv)) NS_ENSURE_SUCCESS(rv, rv);
return rv;
return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult); return CallQueryInterface(it, aResult);
} }
nsXBLContentSink::nsXBLContentSink() nsXBLContentSink::nsXBLContentSink()
@ -800,7 +799,7 @@ nsXBLContentSink::AddAttributesToXULPrototype(const PRUnichar **aAtts,
if (kNameSpaceID_Unknown == nameSpaceID) { if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; nameSpaceID = kNameSpaceID_None;
nameAtom = dont_AddRef(NS_NewAtom(key)); nameAtom = do_GetAtom(key);
nameSpacePrefix = nsnull; nameSpacePrefix = nsnull;
} }
@ -831,12 +830,8 @@ nsXBLContentSink::AddAttributesToXULPrototype(const PRUnichar **aAtts,
if (rv == NS_CONTENT_ATTR_HAS_VALUE) { if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (!mCSSParser) { if (!mCSSParser) {
rv = nsComponentManager::CreateInstance(kCSSParserCID, mCSSParser = do_CreateInstance(kCSSParserCID, &rv);
nsnull, NS_ENSURE_SUCCESS(rv, rv);
NS_GET_IID(nsICSSParser),
getter_AddRefs(mCSSParser));
if (NS_FAILED(rv)) return rv;
} }
rv = mCSSParser->ParseStyleAttribute(value, mDocumentURL, rv = mCSSParser->ParseStyleAttribute(value, mDocumentURL,

View File

@ -45,7 +45,7 @@
#include "nsIXBLPrototypeHandler.h" #include "nsIXBLPrototypeHandler.h"
#include "nsXBLProtoImplMember.h" #include "nsXBLProtoImplMember.h"
MOZ_DECL_CTOR_COUNTER(nsXBLProtoImpl); MOZ_DECL_CTOR_COUNTER(nsXBLProtoImpl)
class nsXBLProtoImpl class nsXBLProtoImpl
{ {

View File

@ -47,7 +47,7 @@
#include "nsXBLProtoImplField.h" #include "nsXBLProtoImplField.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
MOZ_DECL_CTOR_COUNTER(nsXBLProtoImplField); MOZ_DECL_CTOR_COUNTER(nsXBLProtoImplField)
nsXBLProtoImplField::nsXBLProtoImplField(const PRUnichar* aName, const PRUnichar* aReadOnly) nsXBLProtoImplField::nsXBLProtoImplField(const PRUnichar* aName, const PRUnichar* aReadOnly)
: nsXBLProtoImplMember(aName), : nsXBLProtoImplMember(aName),

View File

@ -47,7 +47,7 @@
#include "nsString.h" #include "nsString.h"
#include "nsXBLProtoImplMember.h" #include "nsXBLProtoImplMember.h"
MOZ_DECL_CTOR_COUNTER(nsXBLParameter); MOZ_DECL_CTOR_COUNTER(nsXBLParameter)
struct nsXBLParameter { struct nsXBLParameter {
nsXBLParameter* mNext; nsXBLParameter* mNext;
@ -66,7 +66,7 @@ struct nsXBLParameter {
} }
}; };
MOZ_DECL_CTOR_COUNTER(nsXBLUncompiledMethod); MOZ_DECL_CTOR_COUNTER(nsXBLUncompiledMethod)
struct nsXBLUncompiledMethod { struct nsXBLUncompiledMethod {
nsXBLParameter* mParameters; nsXBLParameter* mParameters;

View File

@ -1135,12 +1135,13 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement)
attrTok.Left(left, index); attrTok.Left(left, index);
attrTok.Right(right, attrTok.Length()-index-1); attrTok.Right(right, attrTok.Length()-index-1);
atom = getter_AddRefs(NS_NewAtom(right.get())); atom = do_GetAtom(right);
attribute = getter_AddRefs(NS_NewAtom(left.get())); attribute = do_GetAtom(left);
} }
else { else {
nsAutoString tok; tok.AssignWithConversion(token); nsAutoString tok;
atom = getter_AddRefs(NS_NewAtom(tok.get())); tok.AssignWithConversion(token);
atom = do_GetAtom(tok);
attribute = atom; attribute = atom;
} }
@ -1230,11 +1231,11 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent)
char* token = nsCRT::strtok( str, "| ", &newStr ); char* token = nsCRT::strtok( str, "| ", &newStr );
while( token != NULL ) { while( token != NULL ) {
// Build an atom out of this string. nsAutoString tok;
nsCOMPtr<nsIAtom> atom; tok.AssignWithConversion(token);
nsAutoString tok; tok.AssignWithConversion(token); // Build an atom out of this string.
atom = getter_AddRefs(NS_NewAtom(tok.get())); nsCOMPtr<nsIAtom> atom = do_GetAtom(tok);
nsISupportsKey key(atom); nsISupportsKey key(atom);
mInsertionPointTable->Put(&key, xblIns); mInsertionPointTable->Put(&key, xblIns);

View File

@ -334,7 +334,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
nsAutoString str; nsAutoString str;
mEventName->ToString(str); mEventName->ToString(str);
onEvent += str; onEvent += str;
nsCOMPtr<nsIAtom> onEventAtom = getter_AddRefs(NS_NewAtom(onEvent)); nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(onEvent);
void* handler = nsnull; void* handler = nsnull;
@ -869,7 +869,7 @@ nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement,
return; return;
} }
mEventName = getter_AddRefs(NS_NewAtom(event)); mEventName = do_GetAtom(event);
if (aPhase) { if (aPhase) {
const nsDependentString phase(aPhase); const nsDependentString phase(aPhase);

View File

@ -53,7 +53,7 @@
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
MOZ_DECL_CTOR_COUNTER(nsXBLPrototypeResources); MOZ_DECL_CTOR_COUNTER(nsXBLPrototypeResources)
nsXBLPrototypeResources::nsXBLPrototypeResources(nsIXBLPrototypeBinding* aBinding) nsXBLPrototypeResources::nsXBLPrototypeResources(nsIXBLPrototypeBinding* aBinding)
:mStyleSheetList(nsnull) :mStyleSheetList(nsnull)
@ -112,11 +112,8 @@ nsXBLPrototypeResources::FlushSkinSheets()
// they'll still be in the chrome cache. // they'll still be in the chrome cache.
mRuleProcessors->Clear(); mRuleProcessors->Clear();
nsCOMPtr<nsICSSLoader> loader; nsresult rv;
nsresult rv = nsComponentManager::CreateInstance(kCSSLoaderCID, nsCOMPtr<nsICSSLoader> loader = do_CreateInstance(kCSSLoaderCID, &rv);
nsnull,
NS_GET_IID(nsICSSLoader),
getter_AddRefs(loader));
if (NS_FAILED(rv) || !loader) return rv; if (NS_FAILED(rv) || !loader) return rv;
nsCOMPtr<nsISupportsArray> newSheets; nsCOMPtr<nsISupportsArray> newSheets;

View File

@ -52,7 +52,7 @@ class nsXBLPrototypeResources;
// *********************************************************************/ // *********************************************************************/
// The XBLResourceLoader class // The XBLResourceLoader class
MOZ_DECL_CTOR_COUNTER(nsXBLResource); MOZ_DECL_CTOR_COUNTER(nsXBLResource)
struct nsXBLResource { struct nsXBLResource {
nsXBLResource* mNext; nsXBLResource* mNext;

View File

@ -194,9 +194,7 @@ protected:
gRefCnt++; gRefCnt++;
if (gRefCnt == 1) { if (gRefCnt == 1) {
nsServiceManager::GetService("@mozilla.org/xbl;1", CallGetService("@mozilla.org/xbl;1", &gXBLService);
NS_GET_IID(nsIXBLService),
(nsISupports**) &gXBLService);
} }
} }
@ -204,8 +202,7 @@ protected:
{ {
gRefCnt--; gRefCnt--;
if (gRefCnt == 0) { if (gRefCnt == 0) {
nsServiceManager::ReleaseService("@mozilla.org/xbl;1", gXBLService); NS_IF_RELEASE(gXBLService);
gXBLService = nsnull;
} }
} }
@ -280,10 +277,8 @@ nsXBLStreamListener::nsXBLStreamListener(nsXBLService* aXBLService,
mBindingDocument = aBindingDocument; mBindingDocument = aBindingDocument;
gRefCnt++; gRefCnt++;
if (gRefCnt == 1) { if (gRefCnt == 1) {
nsresult rv; nsresult rv = CallGetService("@mozilla.org/xul/xul-prototype-cache;1",
rv = nsServiceManager::GetService("@mozilla.org/xul/xul-prototype-cache;1", &gXULCache);
NS_GET_IID(nsIXULPrototypeCache),
(nsISupports**) &gXULCache);
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
} }
} }
@ -293,10 +288,7 @@ nsXBLStreamListener::~nsXBLStreamListener()
/* destructor code */ /* destructor code */
gRefCnt--; gRefCnt--;
if (gRefCnt == 0) { if (gRefCnt == 0) {
if (gXULCache) { NS_IF_RELEASE(gXULCache);
nsServiceManager::ReleaseService("@mozilla.org/xul/xul-prototype-cache;1", gXULCache);
gXULCache = nsnull;
}
} }
} }
@ -936,7 +928,7 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
nsAutoString nameSpace; nsAutoString nameSpace;
if (!prefix.IsEmpty()) { if (!prefix.IsEmpty()) {
nsCOMPtr<nsIAtom> prefixAtom = getter_AddRefs(NS_NewAtom(prefix)); nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(prefix);
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(child)); nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(child));
@ -956,7 +948,7 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(nameSpace, nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(nameSpace,
nameSpaceID); nameSpaceID);
nsCOMPtr<nsIAtom> tagName = getter_AddRefs(NS_NewAtom(display)); nsCOMPtr<nsIAtom> tagName = do_GetAtom(display);
protoBinding->SetBaseTag(nameSpaceID, tagName); protoBinding->SetBaseTag(nameSpaceID, tagName);
} }
} }

View File

@ -682,7 +682,7 @@ nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
CopyInnerTo(this, it, aDeep); CopyInnerTo(this, it, aDeep);
rv = it->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aReturn); rv = CallQueryInterface(it, aReturn);
NS_RELEASE(it); NS_RELEASE(it);
return rv; return rv;
} }

View File

@ -150,7 +150,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult,
delete it; delete it;
return rv; return rv;
} }
return it->QueryInterface(NS_GET_IID(nsIXMLContentSink), (void **)aResult); return CallQueryInterface(it, aResult);
} }
nsXMLContentSink::nsXMLContentSink() nsXMLContentSink::nsXMLContentSink()
@ -233,10 +233,9 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
mState = eXMLContentSinkState_InProlog; mState = eXMLContentSinkState_InProlog;
mDocElement = nsnull; mDocElement = nsnull;
nsIHTMLContentContainer* htmlContainer = nsnull; nsCOMPtr<nsIHTMLContentContainer> htmlContainer = do_QueryInterface(aDoc);
if (NS_SUCCEEDED(aDoc->QueryInterface(NS_GET_IID(nsIHTMLContentContainer), (void**)&htmlContainer))) { if (htmlContainer) {
htmlContainer->GetCSSLoader(mCSSLoader); htmlContainer->GetCSSLoader(mCSSLoader);
NS_RELEASE(htmlContainer);
} }
ProcessHTTPHeaders(aChannel); ProcessHTTPHeaders(aChannel);
@ -1200,7 +1199,7 @@ nsXMLContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) {
while(*name) { while(*name) {
rv = httpchannel->GetResponseHeader(nsDependentCString(*name), tmp); rv = httpchannel->GetResponseHeader(nsDependentCString(*name), tmp);
if (NS_SUCCEEDED(rv) && !tmp.IsEmpty()) { if (NS_SUCCEEDED(rv) && !tmp.IsEmpty()) {
nsCOMPtr<nsIAtom> key(dont_AddRef(NS_NewAtom(*name))); nsCOMPtr<nsIAtom> key = do_GetAtom(*name);
ProcessHeaderData(key,NS_ConvertASCIItoUCS2(tmp),nsnull); ProcessHeaderData(key,NS_ConvertASCIItoUCS2(tmp),nsnull);
} }
name++; name++;
@ -1384,11 +1383,10 @@ nsXMLContentSink::StartLayout()
// If the document we are loading has a reference or it is a top level // If the document we are loading has a reference or it is a top level
// frameset document, disable the scroll bars on the views. // frameset document, disable the scroll bars on the views.
nsCAutoString ref; nsCAutoString ref;
nsIURL* url; nsresult rv;
nsresult rv = mDocumentURL->QueryInterface(NS_GET_IID(nsIURL), (void**)&url); nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURL, &rv);
if (NS_SUCCEEDED(rv)) { if (url) {
rv = url->GetRef(ref); rv = url->GetRef(ref);
NS_RELEASE(url);
} }
if (rv == NS_OK) { if (rv == NS_OK) {
NS_UnescapeURL(ref); // XXX this may result in random non-ASCII bytes! NS_UnescapeURL(ref); // XXX this may result in random non-ASCII bytes!
@ -1420,10 +1418,10 @@ nsXMLContentSink::StartLayout()
if (vm) { if (vm) {
nsIView* rootView = nsnull; nsIView* rootView = nsnull;
vm->GetRootView(rootView); vm->GetRootView(rootView);
if (nsnull != rootView) { if (rootView) {
nsIScrollableView* sview = nsnull; nsIScrollableView* sview = nsnull;
rootView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**) &sview); CallQueryInterface(rootView, &sview);
if (nsnull != sview) { if (sview) {
sview->SetScrollPreference(nsScrollPreference_kNeverScroll); sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
} }
} }
@ -1837,21 +1835,15 @@ nsXMLContentSink::HandleComment(const PRUnichar *aName)
{ {
FlushText(); FlushText();
nsIContent *comment; nsCOMPtr<nsIContent> comment;
nsIDOMComment *domComment; nsresult result = NS_NewCommentNode(getter_AddRefs(comment));
nsresult result = NS_OK; if (comment) {
nsCOMPtr<nsIDOMComment> domComment = do_QueryInterface(comment, &result);
result = NS_NewCommentNode(&comment); if (domComment) {
if (NS_OK == result) {
result = comment->QueryInterface(NS_GET_IID(nsIDOMComment), (void **)&domComment);
if (NS_OK == result) {
domComment->AppendData(nsDependentString(aName)); domComment->AppendData(nsDependentString(aName));
NS_RELEASE(domComment);
comment->SetDocument(mDocument, PR_FALSE, PR_TRUE); comment->SetDocument(mDocument, PR_FALSE, PR_TRUE);
result = AddContentAsLeaf(comment); result = AddContentAsLeaf(comment);
} }
NS_RELEASE(comment);
} }
return result; return result;
@ -1863,25 +1855,19 @@ nsXMLContentSink::HandleCDataSection(const PRUnichar *aData,
{ {
FlushText(); FlushText();
nsIContent *cdata;
nsIDOMCDATASection *domCDATA;
nsresult result = NS_OK;
if (mInTitle) { if (mInTitle) {
mTitleText.Append(aData, aLength); mTitleText.Append(aData, aLength);
} }
result = NS_NewXMLCDATASection(&cdata); nsCOMPtr<nsIContent> cdata;
if (NS_OK == result) { nsresult result = NS_NewXMLCDATASection(getter_AddRefs(cdata));
result = cdata->QueryInterface(NS_GET_IID(nsIDOMCDATASection), (void **)&domCDATA); if (cdata) {
if (NS_OK == result) { nsCOMPtr<nsIDOMCDATASection> domCDATA = do_QueryInterface(cdata);
if (domCDATA) {
domCDATA->SetData(nsDependentString(aData, aLength)); domCDATA->SetData(nsDependentString(aData, aLength));
NS_RELEASE(domCDATA);
cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE); cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE);
result = AddContentAsLeaf(cdata); result = AddContentAsLeaf(cdata);
} }
NS_RELEASE(cdata);
} }
return result; return result;
@ -2143,8 +2129,7 @@ nsXMLContentSink::PushNameSpacesFrom(const PRUnichar** aAtts)
if (*start == ':') { if (*start == ':') {
++start; ++start;
prefixAtom = prefixAtom = do_GetAtom(Substring(start, end));
dont_AddRef(NS_NewAtom(nsDependentSubstring(start, end)));
} }
} }
@ -2200,7 +2185,7 @@ nsXMLContentSink::AddAttributes(const PRUnichar** aAtts,
if (kNameSpaceID_Unknown == nameSpaceID) { if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; nameSpaceID = kNameSpaceID_None;
nameAtom = dont_AddRef(NS_NewAtom(key)); nameAtom = do_GetAtom(key);
nameSpacePrefix = nsnull; nameSpacePrefix = nsnull;
} }

View File

@ -80,7 +80,6 @@
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "nsIAggregatePrincipal.h" #include "nsIAggregatePrincipal.h"
#include "nsLayoutCID.h" #include "nsLayoutCID.h"
#include "nsContentCID.h"
#include "nsDOMAttribute.h" #include "nsDOMAttribute.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsFIXptr.h" #include "nsFIXptr.h"
@ -96,8 +95,6 @@
#include "nsIAuthPrompt.h" #include "nsIAuthPrompt.h"
#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptGlobalObjectOwner.h"
static NS_DEFINE_CID(kHTMLStyleSheetCID,NS_HTMLSTYLESHEET_CID);
// XXX The XML world depends on the html atoms // XXX The XML world depends on the html atoms
#include "nsHTMLAtoms.h" #include "nsHTMLAtoms.h"
@ -182,8 +179,7 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
} }
nsXMLDocument::nsXMLDocument() nsXMLDocument::nsXMLDocument()
: mAttrStyleSheet(nsnull), mInlineStyleSheet(nsnull), : mCountCatalogSheets(0), mParser(nsnull),
mCountCatalogSheets(0), mParser(nsnull),
mCrossSiteAccessEnabled(PR_FALSE), mXMLDeclarationBits(0) mCrossSiteAccessEnabled(PR_FALSE), mXMLDeclarationBits(0)
{ {
} }
@ -193,11 +189,9 @@ nsXMLDocument::~nsXMLDocument()
NS_IF_RELEASE(mParser); NS_IF_RELEASE(mParser);
if (mAttrStyleSheet) { if (mAttrStyleSheet) {
mAttrStyleSheet->SetOwningDocument(nsnull); mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
} }
if (mInlineStyleSheet) { if (mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull); mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
} }
if (mCSSLoader) { if (mCSSLoader) {
mCSSLoader->DropDocumentReference(); mCSSLoader->DropDocumentReference();
@ -224,20 +218,20 @@ NS_IMETHODIMP
nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
{ {
nsresult result = nsDocument::Reset(aChannel, aLoadGroup); nsresult result = nsDocument::Reset(aChannel, aLoadGroup);
if (NS_FAILED(result)) return result; if (NS_FAILED(result))
return result;
nsCOMPtr<nsIURI> url; nsCOMPtr<nsIURI> url;
if (aChannel) { if (aChannel) {
result = aChannel->GetURI(getter_AddRefs(url)); result = aChannel->GetURI(getter_AddRefs(url));
if (NS_FAILED(result)) return result; if (NS_FAILED(result))
return result;
} }
if (nsnull != mAttrStyleSheet) { if (mAttrStyleSheet) {
mAttrStyleSheet->SetOwningDocument(nsnull); mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
} }
if (nsnull != mInlineStyleSheet) { if (mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull); mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
} }
result = SetDefaultStylesheets(url); result = SetDefaultStylesheets(url);
@ -377,7 +371,7 @@ nsXMLDocument::Load(const nsAString& aUrl)
if (NS_SUCCEEDED(stack->Peek(&cx)) && cx) { if (NS_SUCCEEDED(stack->Peek(&cx)) && cx) {
nsISupports *priv = (nsISupports *)::JS_GetContextPrivate(cx); nsISupports *priv = (nsISupports *)::JS_GetContextPrivate(cx);
if (priv) { if (priv) {
priv->QueryInterface(NS_GET_IID(nsIScriptContext), getter_AddRefs(mScriptContext)); mScriptContext = do_QueryInterface(priv);
} }
} }
} }
@ -398,13 +392,14 @@ nsXMLDocument::Load(const nsAString& aUrl)
mPrincipal = nsnull; mPrincipal = nsnull;
nsCOMPtr<nsISupports> channelOwner; nsCOMPtr<nsISupports> channelOwner;
rv = channel->GetOwner(getter_AddRefs(channelOwner)); rv = channel->GetOwner(getter_AddRefs(channelOwner));
if (NS_SUCCEEDED(rv) && channelOwner) if (NS_SUCCEEDED(rv) && channelOwner) {
mPrincipal = do_QueryInterface(channelOwner, &rv); mPrincipal = do_QueryInterface(channelOwner, &rv);
}
if (NS_FAILED(rv) || !channelOwner) if (NS_FAILED(rv) || !channelOwner)
{ {
rv = secMan->GetCodebasePrincipal(uri, getter_AddRefs(mPrincipal)); rv = secMan->GetCodebasePrincipal(uri, getter_AddRefs(mPrincipal));
if (!mPrincipal) return rv; NS_ENSURE_TRUE(mPrincipal, rv);
} }
// Prepare for loading the XML document "into oneself" // Prepare for loading the XML document "into oneself"
@ -490,9 +485,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, rv = CallCreateInstance(kCParserCID, &mParser);
NS_GET_IID(nsIParser),
(void **)&mParser);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIXMLContentSink> sink; nsCOMPtr<nsIXMLContentSink> sink;
@ -516,11 +509,11 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, nsnull, aChannel); rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, nsnull, aChannel);
} }
if (NS_OK == rv) { if (NS_SUCCEEDED(rv)) {
// Set the parser as the stream listener for the document loader... // Set the parser as the stream listener for the document loader...
rv = mParser->QueryInterface(NS_GET_IID(nsIStreamListener), (void**)aDocListener); rv = CallQueryInterface(mParser, aDocListener);
if (NS_OK == rv) { if (NS_SUCCEEDED(rv)) {
SetDocumentCharacterSet(charset); SetDocumentCharacterSet(charset);
mParser->SetDocumentCharset(charset, charsetSource); mParser->SetDocumentCharset(charset, charsetSource);
mParser->SetCommand(aCommand); mParser->SetCommand(aCommand);
@ -563,34 +556,26 @@ nsXMLDocument::EndLoad()
NS_IMETHODIMP NS_IMETHODIMP
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult) nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mAttrStyleSheet; *aResult = mAttrStyleSheet;
if (nsnull == mAttrStyleSheet) { NS_ENSURE_TRUE(mAttrStyleSheet, NS_ERROR_NOT_AVAILABLE); // probably not the right error...
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
} NS_ADDREF(*aResult);
else {
NS_ADDREF(mAttrStyleSheet);
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult) nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mInlineStyleSheet; *aResult = mInlineStyleSheet;
if (nsnull == mInlineStyleSheet) { NS_ENSURE_TRUE(mInlineStyleSheet, NS_ERROR_NOT_AVAILABLE); // probably not the right error...
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
} NS_ADDREF(*aResult);
else {
NS_ADDREF(mInlineStyleSheet);
}
return NS_OK; return NS_OK;
} }
@ -691,13 +676,12 @@ nsXMLDocument::CreateCDATASection(const nsAString& aData, nsIDOMCDATASection** a
if (FindInReadable(NS_LITERAL_STRING("]]>"),begin,end)) if (FindInReadable(NS_LITERAL_STRING("]]>"),begin,end))
return NS_ERROR_DOM_INVALID_CHARACTER_ERR; return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
nsIContent* content; nsCOMPtr<nsIContent> content;
nsresult rv = NS_NewXMLCDATASection(&content); nsresult rv = NS_NewXMLCDATASection(getter_AddRefs(content));
if (NS_OK == rv) { if (NS_SUCCEEDED(rv)) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMCDATASection), (void**)aReturn); rv = CallQueryInterface(content, aReturn);
(*aReturn)->AppendData(aData); (*aReturn)->AppendData(aData);
NS_RELEASE(content);
} }
return rv; return rv;
@ -720,17 +704,14 @@ nsXMLDocument::CreateProcessingInstruction(const nsAString& aTarget,
NS_ENSURE_ARG_POINTER(aReturn); NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull; *aReturn = nsnull;
nsIContent* content; nsCOMPtr<nsIContent> content;
nsresult rv = NS_NewXMLProcessingInstruction(&content, aTarget, aData); nsresult rv = NS_NewXMLProcessingInstruction(getter_AddRefs(content),
aTarget, aData);
if (NS_OK != rv) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
rv = content->QueryInterface(NS_GET_IID(nsIDOMProcessingInstruction), (void**)aReturn); return CallQueryInterface(content, aReturn);
NS_RELEASE(content);
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -817,7 +798,7 @@ nsXMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
} }
} }
return newDoc->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn); return CallQueryInterface(newDoc, aReturn);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -842,12 +823,10 @@ nsXMLDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsAutoString value; nsAutoString value;
nsDOMAttribute* attribute; nsDOMAttribute* attribute = new nsDOMAttribute(nsnull, nodeInfo, value);
attribute = new nsDOMAttribute(nsnull, nodeInfo, value);
NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY);
return attribute->QueryInterface(NS_GET_IID(nsIDOMAttr), (void**)aReturn); return CallQueryInterface(attribute, aReturn);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -929,7 +908,7 @@ nsXMLDocument::GetElementById(const nsAString& aElementId,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (content) { if (content) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn); rv = CallQueryInterface(content, aReturn);
} }
return rv; return rv;
@ -941,19 +920,11 @@ nsXMLDocument::SetDefaultStylesheets(nsIURI* aUrl)
{ {
nsresult result = NS_OK; nsresult result = NS_OK;
if (aUrl) { if (aUrl) {
//result = NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl, this); result = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), aUrl, this);
result = nsComponentManager::CreateInstance(kHTMLStyleSheetCID,nsnull,NS_GET_IID(nsIHTMLStyleSheet),(void**)&mAttrStyleSheet);
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mAttrStyleSheet->Init(aUrl,this); result = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mInlineStyleSheet), aUrl, this);
if (NS_FAILED(result)) {
NS_RELEASE(mAttrStyleSheet);
}
}
if (NS_OK == result) {
AddStyleSheet(mAttrStyleSheet, 0); // tell the world about our new style sheet AddStyleSheet(mAttrStyleSheet, 0); // tell the world about our new style sheet
if (NS_SUCCEEDED(result)) {
result = NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, aUrl, this);
if (NS_OK == result) {
AddStyleSheet(mInlineStyleSheet, 0); // tell the world about our new style sheet AddStyleSheet(mInlineStyleSheet, 0); // tell the world about our new style sheet
} }
} }

View File

@ -144,8 +144,8 @@ protected:
// For HTML elements in our content model // For HTML elements in our content model
// XXX This is not clean, but is there a better way? // XXX This is not clean, but is there a better way?
nsIHTMLStyleSheet* mAttrStyleSheet; nsCOMPtr<nsIHTMLStyleSheet> mAttrStyleSheet;
nsIHTMLCSSStyleSheet* mInlineStyleSheet; nsCOMPtr<nsIHTMLCSSStyleSheet> mInlineStyleSheet;
// For additional catalog sheets (if any) needed to layout the XML vocabulary // For additional catalog sheets (if any) needed to layout the XML vocabulary
// of the document. Catalog sheets are kept at the beginning of our array of // of the document. Catalog sheets are kept at the beginning of our array of
// style sheets and this counter is used as an offset to distinguish them // style sheets and this counter is used as an offset to distinguish them

View File

@ -95,7 +95,7 @@ nsresult nsXULAttributeValue::SetValue(const nsAString& aValue,
if (len && ((len <= kMaxAtomValueLength) || forceAtom)) if (len && ((len <= kMaxAtomValueLength) || forceAtom))
{ {
newAtom = getter_AddRefs( NS_NewAtom(aValue) ); newAtom = do_GetAtom(aValue);
} }
// Release the old value // Release the old value

View File

@ -309,7 +309,7 @@ nsXULAttribute::SetPrefix(const nsAString& aPrefix)
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -469,8 +469,7 @@ nsXULAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
{ {
NS_ENSURE_ARG_POINTER(aOwnerElement); NS_ENSURE_ARG_POINTER(aOwnerElement);
return mContent->QueryInterface(NS_GET_IID(nsIDOMElement), return CallQueryInterface(mContent, aOwnerElement);
(void **)aOwnerElement);
} }

View File

@ -461,10 +461,7 @@ nsXULElement::Init()
if (gRefCnt++ == 0) { if (gRefCnt++ == 0) {
nsresult rv; nsresult rv;
rv = nsServiceManager::GetService(kRDFServiceCID, rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -496,10 +493,7 @@ nsXULElement::~nsXULElement()
if (--gRefCnt == 0) { if (--gRefCnt == 0) {
FinishEventHandlerMap(); FinishEventHandlerMap();
if (gRDFService) { NS_IF_RELEASE(gRDFService);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
} }
} }
@ -715,7 +709,7 @@ NS_IMETHODIMP
nsXULElement::GetParentNode(nsIDOMNode** aParentNode) nsXULElement::GetParentNode(nsIDOMNode** aParentNode)
{ {
if (mParent) { if (mParent) {
return mParent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aParentNode); return CallQueryInterface(mParent, aParentNode);
} }
if (mDocument) { if (mDocument) {
@ -729,7 +723,7 @@ nsXULElement::GetParentNode(nsIDOMNode** aParentNode)
// If we don't have a parent, and we're the root content // If we don't have a parent, and we're the root content
// of the document, DOM says that our parent is the // of the document, DOM says that our parent is the
// document. // document.
return mDocument->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aParentNode); return CallQueryInterface(mDocument, aParentNode);
} }
} }
@ -761,9 +755,8 @@ nsXULElement::GetChildNodes(nsIDOMNodeList** aChildNodes)
if (NS_FAILED(rv)) if (NS_FAILED(rv))
break; break;
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(child);
rv = child->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) getter_AddRefs(domNode)); if (!domNode) {
if (NS_FAILED(rv)) {
NS_WARNING("child content doesn't support nsIDOMNode"); NS_WARNING("child content doesn't support nsIDOMNode");
continue; continue;
} }
@ -787,8 +780,8 @@ nsXULElement::GetFirstChild(nsIDOMNode** aFirstChild)
nsCOMPtr<nsIContent> child; nsCOMPtr<nsIContent> child;
rv = ChildAt(0, *getter_AddRefs(child)); rv = ChildAt(0, *getter_AddRefs(child));
if (NS_SUCCEEDED(rv) && (child != nsnull)) { if (child) {
rv = child->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aFirstChild); rv = CallQueryInterface(child, aFirstChild);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node"); NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node");
return rv; return rv;
} }
@ -810,10 +803,10 @@ nsXULElement::GetLastChild(nsIDOMNode** aLastChild)
nsCOMPtr<nsIContent> child; nsCOMPtr<nsIContent> child;
rv = ChildAt(count - 1, *getter_AddRefs(child)); rv = ChildAt(count - 1, *getter_AddRefs(child));
NS_ASSERTION(child != nsnull, "no child"); NS_ASSERTION(child, "no child");
if (child) { if (child) {
rv = child->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aLastChild); rv = CallQueryInterface(child, aLastChild);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node"); NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node");
return rv; return rv;
} }
@ -834,8 +827,8 @@ nsXULElement::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
nsCOMPtr<nsIContent> prev; nsCOMPtr<nsIContent> prev;
mParent->ChildAt(--pos, *getter_AddRefs(prev)); mParent->ChildAt(--pos, *getter_AddRefs(prev));
if (prev) { if (prev) {
nsresult rv = prev->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aPreviousSibling); nsresult rv = CallQueryInterface(prev, aPreviousSibling);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM node"); NS_ASSERTION(*aPreviousSibling, "not a DOM node");
return rv; return rv;
} }
} }
@ -858,8 +851,8 @@ nsXULElement::GetNextSibling(nsIDOMNode** aNextSibling)
nsCOMPtr<nsIContent> next; nsCOMPtr<nsIContent> next;
mParent->ChildAt(++pos, *getter_AddRefs(next)); mParent->ChildAt(++pos, *getter_AddRefs(next));
if (next) { if (next) {
nsresult res = next->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aNextSibling); nsresult res = CallQueryInterface(next, aNextSibling);
NS_ASSERTION(NS_OK == res, "not a DOM Node"); NS_ASSERTION(*aNextSibling, "not a DOM Node");
return res; return res;
} }
} }
@ -943,7 +936,7 @@ nsXULElement::SetPrefix(const nsAString& aPrefix)
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) { if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix)) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
} }
@ -1362,14 +1355,12 @@ nsXULElement::GetAttributeNode(const nsAString& aName,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (node) { if (node) {
rv = node->QueryInterface(NS_GET_IID(nsIDOMAttr), (void**) aReturn); return CallQueryInterface(node, aReturn);
}
else {
*aReturn = nsnull;
rv = NS_OK;
} }
return rv; *aReturn = nsnull;
return NS_OK;
} }
@ -1430,7 +1421,7 @@ nsXULElement::GetAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
nsAString& aReturn) nsAString& aReturn)
{ {
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
PRInt32 nsid; PRInt32 nsid;
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI,
@ -1469,7 +1460,7 @@ nsXULElement::RemoveAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName) const nsAString& aLocalName)
{ {
PRInt32 nameSpaceId; PRInt32 nameSpaceId;
nsCOMPtr<nsIAtom> tag = dont_AddRef(NS_NewAtom(aLocalName)); nsCOMPtr<nsIAtom> tag = do_GetAtom(aLocalName);
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI,
nameSpaceId); nameSpaceId);
@ -1495,14 +1486,12 @@ nsXULElement::GetAttributeNodeNS(const nsAString& aNamespaceURI,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (node) { if (node) {
rv = node->QueryInterface(NS_GET_IID(nsIDOMAttr), (void**) aReturn); return CallQueryInterface(node, aReturn);
}
else {
*aReturn = nsnull;
rv = NS_OK;
} }
return rv; *aReturn = nsnull;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1580,7 +1569,7 @@ nsXULElement::HasAttributeNS(const nsAString& aNamespaceURI,
{ {
NS_ENSURE_ARG_POINTER(aReturn); NS_ENSURE_ARG_POINTER(aReturn);
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aLocalName))); nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
PRInt32 nsid; PRInt32 nsid;
nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid); nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, nsid);
@ -1761,14 +1750,12 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName,
NS_IMETHODIMP NS_IMETHODIMP
nsXULElement::GetListenerManager(nsIEventListenerManager** aResult) nsXULElement::GetListenerManager(nsIEventListenerManager** aResult)
{ {
if (! mListenerManager) { if (!mListenerManager) {
nsresult rv; nsresult rv;
mListenerManager = do_CreateInstance(kEventListenerManagerCID, &rv);
if (NS_FAILED(rv))
return rv;
rv = nsComponentManager::CreateInstance(kEventListenerManagerCID,
nsnull,
NS_GET_IID(nsIEventListenerManager),
getter_AddRefs(mListenerManager));
if (NS_FAILED(rv)) return rv;
mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIStyledContent*, this)); mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIStyledContent*, this));
} }
@ -2629,9 +2616,9 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
mutation.mAttrName = attrName; mutation.mAttrName = attrName;
if (!oldValue.IsEmpty()) if (!oldValue.IsEmpty())
mutation.mPrevAttrValue = dont_AddRef(NS_NewAtom(oldValue)); mutation.mPrevAttrValue = do_GetAtom(oldValue);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
mutation.mNewAttrValue = dont_AddRef(NS_NewAtom(aValue)); mutation.mNewAttrValue = do_GetAtom(aValue);
if (modification) if (modification)
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION; mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
else else
@ -2878,7 +2865,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID,
mutation.mAttrName = aName; mutation.mAttrName = aName;
if (!oldValue.IsEmpty()) if (!oldValue.IsEmpty())
mutation.mPrevAttrValue = getter_AddRefs(NS_NewAtom(oldValue)); mutation.mPrevAttrValue = do_GetAtom(oldValue);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL; mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status); HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status);
@ -3421,10 +3408,10 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext,
// still has a ref to the DOM Event but the internal data // still has a ref to the DOM Event but the internal data
// hasn't been malloc'd. Force a copy of the data here so the // hasn't been malloc'd. Force a copy of the data here so the
// DOM Event is still valid. // DOM Event is still valid.
nsIPrivateDOMEvent *privateEvent; nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
if (NS_OK == (*aDOMEvent)->QueryInterface(NS_GET_IID(nsIPrivateDOMEvent), (void**)&privateEvent)) { do_QueryInterface(*aDOMEvent);
if (privateEvent) {
privateEvent->DuplicatePrivateData(); privateEvent->DuplicatePrivateData();
NS_RELEASE(privateEvent);
} }
} }
aDOMEvent = nsnull; aDOMEvent = nsnull;
@ -4551,11 +4538,8 @@ nsXULElement::AddPopupListener(nsIAtom* aName)
// Add a popup listener to the element // Add a popup listener to the element
nsresult rv; nsresult rv;
nsCOMPtr<nsIXULPopupListener> popupListener; nsCOMPtr<nsIXULPopupListener> popupListener =
rv = nsComponentManager::CreateInstance(kXULPopupListenerCID, do_CreateInstance(kXULPopupListenerCID, &rv);
nsnull,
NS_GET_IID(nsIXULPopupListener),
getter_AddRefs(popupListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to create an instance of the popup listener object."); NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to create an instance of the popup listener object.");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;

View File

@ -158,7 +158,7 @@ nsXULCommandDispatcher::GetFocusedWindow(nsIDOMWindow** aWindow)
nsresult rv = mFocusController->GetFocusedWindow(getter_AddRefs(window)); nsresult rv = mFocusController->GetFocusedWindow(getter_AddRefs(window));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && window, rv); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && window, rv);
return window->QueryInterface(NS_GET_IID(nsIDOMWindow), (void **)aWindow); return CallQueryInterface(window, aWindow);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -553,10 +553,9 @@ XULContentSinkImpl::ProcessStyleLink(nsIContent* aElement,
if (mPreferredStyle.IsEmpty()) { if (mPreferredStyle.IsEmpty()) {
mPreferredStyle = aTitle; mPreferredStyle = aTitle;
mCSSLoader->SetPreferredSheet(aTitle); mCSSLoader->SetPreferredSheet(aTitle);
nsIAtom* defaultStyle = NS_NewAtom("default-style"); nsCOMPtr<nsIAtom> defaultStyle = do_GetAtom("default-style");
if (defaultStyle) { if (defaultStyle) {
mPrototype->SetHeaderData(defaultStyle, aTitle); mPrototype->SetHeaderData(defaultStyle, aTitle);
NS_RELEASE(defaultStyle);
} }
} }
} }
@ -614,7 +613,7 @@ XULContentSinkImpl::Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aProto
// XXX this presumes HTTP header info is already set in document // XXX this presumes HTTP header info is already set in document
// XXX if it isn't we need to set it here... // XXX if it isn't we need to set it here...
nsCOMPtr<nsIAtom> defaultStyle = dont_AddRef( NS_NewAtom("default-style") ); nsCOMPtr<nsIAtom> defaultStyle = do_GetAtom("default-style");
if (! defaultStyle) if (! defaultStyle)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -725,7 +724,7 @@ XULContentSinkImpl::NormalizeAttributeString(const nsAFlatString& aText,
if (!FindCharInReadable(kNameSpaceSeparator, colon, end)) { if (!FindCharInReadable(kNameSpaceSeparator, colon, end)) {
colon = start; // No ':' found, reset colon colon = start; // No ':' found, reset colon
} else if (start != colon) { } else if (start != colon) {
prefix = dont_AddRef(NS_NewAtom(Substring(start, colon))); prefix = do_GetAtom(Substring(start, colon));
nsCOMPtr<nsINameSpace> ns; nsCOMPtr<nsINameSpace> ns;
GetTopNameSpace(address_of(ns)); GetTopNameSpace(address_of(ns));
@ -1166,8 +1165,7 @@ XULContentSinkImpl::PushNameSpacesFrom(const PRUnichar** aAttributes)
start.advance(xmlns_len); start.advance(xmlns_len);
if (*start == ':' && ++start != end) { if (*start == ':' && ++start != end) {
prefixAtom = prefixAtom = do_GetAtom(Substring(start, end));
dont_AddRef(NS_NewAtom(Substring(start, end)));
} else { } else {
NS_WARNING("Bad XML namespace declaration 'xmlns:' " NS_WARNING("Bad XML namespace declaration 'xmlns:' "
"found!"); "found!");
@ -1240,7 +1238,7 @@ XULContentSinkImpl::ParseTag(const PRUnichar* aText,
if (!FindCharInReadable(kNameSpaceSeparator, colon, end)) { if (!FindCharInReadable(kNameSpaceSeparator, colon, end)) {
colon = start; // No ':' found, reset colon colon = start; // No ':' found, reset colon
} else if (colon != start) { } else if (colon != start) {
prefix = dont_AddRef(NS_NewAtom(Substring(start, colon))); prefix = do_GetAtom(Substring(start, colon));
++colon; // Step over ':' ++colon; // Step over ':'
} }
@ -1539,11 +1537,8 @@ XULContentSinkImpl::AddAttributes(const PRUnichar** aAttributes,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) { if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (! mCSSParser) { if (!mCSSParser) {
rv = nsComponentManager::CreateInstance(kCSSParserCID, mCSSParser = do_CreateInstance(kCSSParserCID, &rv);
nsnull,
NS_GET_IID(nsICSSParser),
getter_AddRefs(mCSSParser));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }

View File

@ -499,10 +499,7 @@ nsXULDocument::~nsXULDocument()
mListenerManager->SetListenerTarget(nsnull); mListenerManager->SetListenerTarget(nsnull);
if (--gRefCnt == 0) { if (--gRefCnt == 0) {
if (gRDFService) { NS_IF_RELEASE(gRDFService);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
gRDFService = nsnull;
}
NS_IF_RELEASE(kNC_persist); NS_IF_RELEASE(kNC_persist);
NS_IF_RELEASE(kNC_attribute); NS_IF_RELEASE(kNC_attribute);
@ -519,8 +516,7 @@ nsXULDocument::~nsXULDocument()
if (mDocumentURL) if (mDocumentURL)
gXULCache->RemoveFromFastLoadSet(mDocumentURL); gXULCache->RemoveFromFastLoadSet(mDocumentURL);
nsServiceManager::ReleaseService(kXULPrototypeCacheCID, gXULCache); NS_RELEASE(gXULCache);
gXULCache = nsnull;
} }
} }
@ -650,41 +646,24 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
mStyleSheets.Clear(); mStyleSheets.Clear();
// Create an HTML style sheet for the HTML content. // Create an HTML style sheet for the HTML content.
nsCOMPtr<nsIHTMLStyleSheet> sheet; rv = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), anURL, this);
if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLStyleSheetCID,
nsnull,
NS_GET_IID(nsIHTMLStyleSheet),
getter_AddRefs(sheet)))) {
if (NS_SUCCEEDED(rv = sheet->Init(anURL, this))) {
mAttrStyleSheet = sheet;
AddStyleSheet(mAttrStyleSheet, 0);
}
}
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("unable to add HTML style sheet"); NS_ERROR("unable to add HTML style sheet");
return rv; return rv;
} }
AddStyleSheet(mAttrStyleSheet, 0);
// Create an inline style sheet for inline content that contains a style // Create an inline style sheet for inline content that contains a style
// attribute. // attribute.
nsIHTMLCSSStyleSheet* inlineSheet; rv = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mInlineStyleSheet), anURL, this);
if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLCSSStyleSheetCID,
nsnull,
NS_GET_IID(nsIHTMLCSSStyleSheet),
(void**)&inlineSheet))) {
if (NS_SUCCEEDED(rv = inlineSheet->Init(anURL, this))) {
mInlineStyleSheet = dont_QueryInterface(inlineSheet);
AddStyleSheet(mInlineStyleSheet, 0);
}
NS_RELEASE(inlineSheet);
}
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_ERROR("unable to add inline style sheet"); NS_ERROR("unable to add inline style sheet");
return rv; return rv;
} }
AddStyleSheet(mInlineStyleSheet, 0);
return NS_OK; return NS_OK;
} }
@ -959,25 +938,19 @@ nsXULDocument::RemoveCharSetObserver(nsIObserver* aObserver)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetLineBreaker(nsILineBreaker** aResult) nsXULDocument::GetLineBreaker(nsILineBreaker** aResult)
{ {
if(! mLineBreaker) { if (!mLineBreaker) {
// no line breaker, find a default one // no line breaker, find a default one
nsILineBreakerFactory *lf; nsresult rv;
nsresult result; nsCOMPtr<nsILineBreakerFactory> lf = do_GetService(kLWBrkCID, &rv);
result = nsServiceManager::GetService(kLWBrkCID, if (lf) {
NS_GET_IID(nsILineBreakerFactory),
(nsISupports **)&lf);
if (NS_SUCCEEDED(result)) {
nsILineBreaker *lb = nsnull ;
nsAutoString lbarg; nsAutoString lbarg;
result = lf->GetBreaker(lbarg, &lb); lf->GetBreaker(lbarg, getter_AddRefs(mLineBreaker));
if(NS_SUCCEEDED(result)) { }
mLineBreaker = dont_AddRef(lb);
}
result = nsServiceManager::ReleaseService(kLWBrkCID, lf);
}
} }
*aResult = mLineBreaker; *aResult = mLineBreaker;
NS_IF_ADDREF(*aResult); NS_IF_ADDREF(*aResult);
return NS_OK; // XXX we should do error handling here return NS_OK; // XXX we should do error handling here
} }
@ -990,25 +963,19 @@ nsXULDocument::SetLineBreaker(nsILineBreaker* aLineBreaker)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetWordBreaker(nsIWordBreaker** aResult) nsXULDocument::GetWordBreaker(nsIWordBreaker** aResult)
{ {
if (! mWordBreaker) { if (!mWordBreaker) {
// no line breaker, find a default one // no line breaker, find a default one
nsIWordBreakerFactory *lf; nsresult rv;
nsresult result; nsCOMPtr<nsIWordBreakerFactory> lf = do_GetService(kLWBrkCID, &rv);
result = nsServiceManager::GetService(kLWBrkCID, if (lf) {
NS_GET_IID(nsIWordBreakerFactory),
(nsISupports **)&lf);
if (NS_SUCCEEDED(result)) {
nsIWordBreaker *lb = nsnull ;
nsAutoString lbarg; nsAutoString lbarg;
result = lf->GetBreaker(lbarg, &lb); rv = lf->GetBreaker(lbarg, getter_AddRefs(mWordBreaker));
if(NS_SUCCEEDED(result)) { }
mWordBreaker = dont_AddRef(lb);
}
result = nsServiceManager::ReleaseService(kLWBrkCID, lf);
}
} }
*aResult = mWordBreaker; *aResult = mWordBreaker;
NS_IF_ADDREF(*aResult); NS_IF_ADDREF(*aResult);
return NS_OK; // XXX we should do error handling here return NS_OK; // XXX we should do error handling here
} }
@ -1363,7 +1330,7 @@ nsXULDocument::AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
if (!aSheet) if (!aSheet)
return; return;
if (aSheet == mAttrStyleSheet.get()) { // always first if (aSheet == mAttrStyleSheet) { // always first
mStyleSheets.InsertElementAt(aSheet, 0); mStyleSheets.InsertElementAt(aSheet, 0);
} }
else if (aSheet == (nsIHTMLCSSStyleSheet*)mInlineStyleSheet) { // always last else if (aSheet == (nsIHTMLCSSStyleSheet*)mInlineStyleSheet) { // always last
@ -1562,11 +1529,8 @@ NS_IMETHODIMP
nsXULDocument::GetCSSLoader(nsICSSLoader*& aLoader) nsXULDocument::GetCSSLoader(nsICSSLoader*& aLoader)
{ {
nsresult result = NS_OK; nsresult result = NS_OK;
if (! mCSSLoader) { if (!mCSSLoader) {
result = nsComponentManager::CreateInstance(kCSSLoaderCID, mCSSLoader = do_CreateInstance(kCSSLoaderCID, &result);
nsnull,
NS_GET_IID(nsICSSLoader),
getter_AddRefs(mCSSLoader));
if (NS_SUCCEEDED(result)) { if (NS_SUCCEEDED(result)) {
result = mCSSLoader->Init(this); result = mCSSLoader->Init(this);
mCSSLoader->SetCaseSensitive(PR_TRUE); mCSSLoader->SetCaseSensitive(PR_TRUE);
@ -1883,7 +1847,7 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
} }
else { else {
// Find out if the attribute is even present at all. // Find out if the attribute is even present at all.
nsCOMPtr<nsIAtom> name = dont_AddRef(NS_NewAtom(aAttr)); nsCOMPtr<nsIAtom> name = do_GetAtom(aAttr);
nsAutoString value; nsAutoString value;
nsresult rv = broadcaster->GetAttr(kNameSpaceID_None, name, value); nsresult rv = broadcaster->GetAttr(kNameSpaceID_None, name, value);
@ -1966,7 +1930,7 @@ nsXULDocument::AddBroadcastListenerFor(nsIDOMElement* aBroadcaster,
} }
// Only add the listener if it's not there already! // Only add the listener if it's not there already!
nsCOMPtr<nsIAtom> attr = dont_AddRef(NS_NewAtom(aAttr)); nsCOMPtr<nsIAtom> attr = do_GetAtom(aAttr);
BroadcastListener* bl; BroadcastListener* bl;
for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) { for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) {
@ -2005,7 +1969,7 @@ nsXULDocument::RemoveBroadcastListenerFor(nsIDOMElement* aBroadcaster,
PL_DHASH_LOOKUP)); PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) { if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
nsCOMPtr<nsIAtom> attr = dont_AddRef(NS_NewAtom(aAttr)); nsCOMPtr<nsIAtom> attr = do_GetAtom(aAttr);
for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) { for (PRInt32 i = entry->mListeners.Count() - 1; i >= 0; --i) {
BroadcastListener* bl = BroadcastListener* bl =
NS_STATIC_CAST(BroadcastListener*, entry->mListeners[i]); NS_STATIC_CAST(BroadcastListener*, entry->mListeners[i]);
@ -2610,12 +2574,12 @@ nsXULDocument::HandleDOMEvent(nsIPresContext* aPresContext,
nsrefcnt rc; nsrefcnt rc;
NS_RELEASE2(*aDOMEvent, rc); NS_RELEASE2(*aDOMEvent, rc);
if (0 != rc) { if (0 != rc) {
//Okay, so someone in the DOM loop (a listener, JS object) still has a ref to the DOM Event but // Okay, so someone in the DOM loop (a listener, JS object) still has
//the internal data hasn't been malloc'd. Force a copy of the data here so the DOM Event is still valid. // a ref to the DOM Event but the internal data hasn't been malloc'd.
nsIPrivateDOMEvent *privateEvent; // Force a copy of the data here so the DOM Event is still valid.
if (NS_OK == (*aDOMEvent)->QueryInterface(NS_GET_IID(nsIPrivateDOMEvent), (void**)&privateEvent)) { nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
if (privateEvent) {
privateEvent->DuplicatePrivateData(); privateEvent->DuplicatePrivateData();
NS_RELEASE(privateEvent);
} }
} }
} }
@ -2817,10 +2781,7 @@ NS_IMETHODIMP
nsXULDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation) nsXULDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
{ {
nsresult rv; nsresult rv;
rv = nsComponentManager::CreateInstance(kDOMImplementationCID, rv = CallCreateInstance(kDOMImplementationCID, aImplementation);
nsnull,
NS_GET_IID(nsIDOMDOMImplementation),
(void**) aImplementation);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrivateDOMImplementation> impl = do_QueryInterface(*aImplementation, &rv); nsCOMPtr<nsIPrivateDOMImplementation> impl = do_QueryInterface(*aImplementation, &rv);
@ -2833,17 +2794,15 @@ nsXULDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetDocumentElement(nsIDOMElement** aDocumentElement) nsXULDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
{ {
NS_PRECONDITION(aDocumentElement != nsnull, "null ptr"); NS_ENSURE_ARG_POINTER(aDocumentElement);
if (! aDocumentElement)
return NS_ERROR_NULL_POINTER;
if (mRootContent) { if (mRootContent) {
return mRootContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aDocumentElement); return CallQueryInterface(mRootContent, aDocumentElement);
}
else {
*aDocumentElement = nsnull;
return NS_OK;
} }
*aDocumentElement = nsnull;
return NS_OK;
} }
@ -2860,7 +2819,7 @@ nsXULDocument::CreateElement(const nsAString& aTagName,
nsCOMPtr<nsIAtom> name, prefix; nsCOMPtr<nsIAtom> name, prefix;
name = dont_AddRef(NS_NewAtom(aTagName)); name = do_GetAtom(aTagName);
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
#ifdef PR_LOGGING #ifdef PR_LOGGING
@ -2887,7 +2846,7 @@ nsXULDocument::CreateElement(const nsAString& aTagName,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// get the DOM interface // get the DOM interface
rv = result->QueryInterface(NS_GET_IID(nsIDOMElement), (void**) aReturn); rv = CallQueryInterface(result, aReturn);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element"); NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -2913,14 +2872,13 @@ nsXULDocument::CreateTextNode(const nsAString& aData,
nsresult rv; nsresult rv;
nsCOMPtr<nsITextContent> text; nsCOMPtr<nsITextContent> text = do_CreateInstance(kTextNodeCID, &rv);
rv = nsComponentManager::CreateInstance(kTextNodeCID, nsnull, NS_GET_IID(nsITextContent), getter_AddRefs(text));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = text->SetText(aData, PR_FALSE); rv = text->SetText(aData, PR_FALSE);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = text->QueryInterface(NS_GET_IID(nsIDOMText), (void**) aReturn); rv = CallQueryInterface(text, aReturn);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOMText"); NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOMText");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -2936,8 +2894,7 @@ nsXULDocument::CreateComment(const nsAString& aData,
nsresult rv = NS_NewCommentNode(getter_AddRefs(comment)); nsresult rv = NS_NewCommentNode(getter_AddRefs(comment));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
rv = comment->QueryInterface(NS_GET_IID(nsIDOMComment), rv = CallQueryInterface(comment, aReturn);
(void**)aReturn);
(*aReturn)->AppendData(aData); (*aReturn)->AppendData(aData);
} }
@ -3030,21 +2987,19 @@ nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute,
return rv; return rv;
} }
nsIContent* root = nsnull; nsCOMPtr<nsIContent> root;
GetRootContent(&root); GetRootContent(getter_AddRefs(root));
NS_ASSERTION(root != nsnull, "no doc root");
if (root != nsnull) { nsCOMPtr<nsIDOMNode> domRoot = do_QueryInterface(root);
nsIDOMNode* domRoot; NS_ASSERTION(domRoot, "no doc root");
if (NS_SUCCEEDED(rv = root->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) &domRoot))) {
rv = GetElementsByAttribute(domRoot, aAttribute, aValue, elements); if (domRoot) {
NS_RELEASE(domRoot); rv = GetElementsByAttribute(domRoot, aAttribute, aValue, elements);
}
NS_RELEASE(root);
} }
*aReturn = elements; *aReturn = elements;
return NS_OK;
return rv;
} }
@ -3207,9 +3162,7 @@ nsXULDocument::GetCharacterSet(nsAString& aCharacterSet)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::CreateRange(nsIDOMRange** aRange) nsXULDocument::CreateRange(nsIDOMRange** aRange)
{ {
return nsComponentManager::CreateInstance(kRangeCID, nsnull, return CallCreateInstance(kRangeCID, aRange);
NS_GET_IID(nsIDOMRange),
(void **)aRange);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -3260,17 +3213,10 @@ nsXULDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
rv = ctx->GetContainer(getter_AddRefs(container)); rv = ctx->GetContainer(getter_AddRefs(container));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv);
nsCOMPtr<nsIInterfaceRequestor> ifrq(do_QueryInterface(container)); nsCOMPtr<nsIDOMWindowInternal> window = do_GetInterface(container);
NS_ENSURE_TRUE(ifrq, NS_OK);
nsCOMPtr<nsIDOMWindowInternal> window;
ifrq->GetInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_OK); NS_ENSURE_TRUE(window, NS_OK);
window->QueryInterface(NS_GET_IID(nsIDOMAbstractView), return CallQueryInterface(window, aDefaultView);
(void **)aDefaultView);
return NS_OK;
} }
nsresult nsresult
@ -3300,8 +3246,7 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell,
if (view) { if (view) {
nsIScrollableView* scrollableView; nsIScrollableView* scrollableView;
if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), if (NS_SUCCEEDED(CallQueryInterface(view, &scrollableView))) {
(void**)&scrollableView))) {
scrollableView->GetScrolledView(view); scrollableView->GetScrolledView(view);
} }
@ -3456,7 +3401,7 @@ GetElementByAttribute(nsIContent* aContent,
nsresult rv = aContent->GetAttr(kNameSpaceID_None, aAttrName, value); nsresult rv = aContent->GetAttr(kNameSpaceID_None, aAttrName, value);
if (rv == NS_CONTENT_ATTR_HAS_VALUE) { if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
if (aUniversalMatch || value.Equals(aAttrValue)) if (aUniversalMatch || value.Equals(aAttrValue))
return aContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aResult); return CallQueryInterface(aContent, aResult);
} }
@ -3491,7 +3436,7 @@ nsXULDocument::GetAnonymousElementByAttribute(nsIDOMElement* aElement,
if (!nodeList) if (!nodeList)
return NS_OK; return NS_OK;
nsCOMPtr<nsIAtom> attribute = getter_AddRefs(NS_NewAtom(aAttrName)); nsCOMPtr<nsIAtom> attribute = do_GetAtom(aAttrName);
PRUint32 length; PRUint32 length;
nodeList->GetLength(&length); nodeList->GetLength(&length);
@ -3718,7 +3663,7 @@ nsXULDocument::CreateElementNS(const nsAString& aNamespaceURI,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// get the DOM interface // get the DOM interface
rv = result->QueryInterface(NS_GET_IID(nsIDOMElement), (void**) aReturn); rv = CallQueryInterface(result, aReturn);
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element"); NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -3752,10 +3697,7 @@ nsXULDocument::GetElementById(const nsAString& aId,
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (element) { if (element) {
rv = element->QueryInterface(NS_GET_IID(nsIDOMElement), (void**) aReturn); rv = CallQueryInterface(element, aReturn);
}
else {
rv = NS_OK;
} }
return rv; return rv;
@ -4119,13 +4061,11 @@ nsXULDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
rv = nsRDFDOMNodeList::Create(&children); rv = nsRDFDOMNodeList::Create(&children);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsIDOMNode* domNode = nsnull; nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(mRootContent);
rv = mRootContent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&domNode); NS_ASSERTION(domNode, "root content is not a DOM node");
NS_ASSERTION(NS_SUCCEEDED(rv), "root content is not a DOM node");
if (NS_SUCCEEDED(rv)) { if (domNode) {
rv = children->AppendNode(domNode); rv = children->AppendNode(domNode);
NS_RELEASE(domNode);
*aChildNodes = children; *aChildNodes = children;
return NS_OK; return NS_OK;
@ -4136,10 +4076,10 @@ nsXULDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
NS_RELEASE(children); NS_RELEASE(children);
return rv; return rv;
} }
else {
*aChildNodes = nsnull; *aChildNodes = nsnull;
return NS_OK;
} return NS_OK;
} }
@ -4174,34 +4114,30 @@ nsXULDocument::HasAttributes(PRBool* aHasAttributes)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetFirstChild(nsIDOMNode** aFirstChild) nsXULDocument::GetFirstChild(nsIDOMNode** aFirstChild)
{ {
NS_PRECONDITION(aFirstChild != nsnull, "null ptr"); NS_ENSURE_ARG_POINTER(aFirstChild);
if (! aFirstChild)
return NS_ERROR_NULL_POINTER;
if (mRootContent) { if (mRootContent) {
return mRootContent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aFirstChild); return CallQueryInterface(mRootContent, aFirstChild);
}
else {
*aFirstChild = nsnull;
return NS_OK;
} }
*aFirstChild = nsnull;
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetLastChild(nsIDOMNode** aLastChild) nsXULDocument::GetLastChild(nsIDOMNode** aLastChild)
{ {
NS_PRECONDITION(aLastChild != nsnull, "null ptr"); NS_ENSURE_ARG_POINTER(aLastChild);
if (! aLastChild)
return NS_ERROR_NULL_POINTER;
if (mRootContent) { if (mRootContent) {
return mRootContent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aLastChild); return CallQueryInterface(mRootContent, aLastChild);
}
else {
*aLastChild = nsnull;
return NS_OK;
} }
*aLastChild = nsnull;
return NS_OK;
} }
@ -4404,17 +4340,15 @@ nsXULDocument::LookupNamespaceURI(const nsAString& aNamespacePrefix,
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult) nsXULDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
{ {
NS_PRECONDITION(nsnull != aResult, "null ptr"); NS_ENSURE_ARG_POINTER(aResult);
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mAttrStyleSheet; *aResult = mAttrStyleSheet;
if (! mAttrStyleSheet) { if (!mAttrStyleSheet) {
return NS_ERROR_NOT_AVAILABLE; // probably not the right error... return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
} }
else {
NS_ADDREF(*aResult); NS_ADDREF(*aResult);
}
return NS_OK; return NS_OK;
} }
@ -4448,11 +4382,7 @@ nsXULDocument::Init()
rv = NS_NewHeapArena(getter_AddRefs(mArena), nsnull); rv = NS_NewHeapArena(getter_AddRefs(mArena), nsnull);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(NS_NODEINFOMANAGER_CONTRACTID, mNodeInfoManager = do_CreateInstance(NS_NODEINFOMANAGER_CONTRACTID, &rv);
nsnull,
NS_GET_IID(nsINodeInfoManager),
getter_AddRefs(mNodeInfoManager));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
mNodeInfoManager->Init(this); mNodeInfoManager->Init(this);
@ -4462,21 +4392,10 @@ nsXULDocument::Init()
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// Get the local store. Yeah, I know. I wish GetService() used a
// 'void**', too.
nsIRDFDataSource* localstore;
rv = nsServiceManager::GetService(kLocalStoreCID,
NS_GET_IID(nsIRDFDataSource),
(nsISupports**) &localstore);
// this _could_ fail; e.g., if we've tried to grab the local store // this _could_ fail; e.g., if we've tried to grab the local store
// before profiles have initialized. If so, no big deal; nothing // before profiles have initialized. If so, no big deal; nothing
// will persist. // will persist.
mLocalStore = do_GetService(kLocalStoreCID);
if (NS_SUCCEEDED(rv)) {
mLocalStore = localstore;
NS_IF_RELEASE(localstore);
}
// Create a new nsISupportsArray for dealing with overlay references // Create a new nsISupportsArray for dealing with overlay references
rv = NS_NewISupportsArray(getter_AddRefs(mUnloadedOverlays)); rv = NS_NewISupportsArray(getter_AddRefs(mUnloadedOverlays));
@ -4489,23 +4408,10 @@ nsXULDocument::Init()
rv = NS_NewISupportsArray(getter_AddRefs(mPrototypes)); rv = NS_NewISupportsArray(getter_AddRefs(mPrototypes));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
#if 0
// construct a selection object
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,
nsnull,
kIDOMSelectionIID,
(void**) &mSelection))) {
NS_ERROR("unable to create DOM selection");
}
#endif
if (gRefCnt++ == 0) { if (gRefCnt++ == 0) {
// Keep the RDF service cached in a member variable to make using // Keep the RDF service cached in a member variable to make using
// it a bit less painful // it a bit less painful
rv = nsServiceManager::GetService(kRDFServiceCID, rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF Service"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF Service");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -4513,24 +4419,15 @@ nsXULDocument::Init()
gRDFService->GetResource(NC_NAMESPACE_URI "attribute", &kNC_attribute); gRDFService->GetResource(NC_NAMESPACE_URI "attribute", &kNC_attribute);
gRDFService->GetResource(NC_NAMESPACE_URI "value", &kNC_value); gRDFService->GetResource(NC_NAMESPACE_URI "value", &kNC_value);
rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID, rv = CallCreateInstance(kHTMLElementFactoryCID, &gHTMLElementFactory);
nsnull,
NS_GET_IID(nsIElementFactory),
(void**) &gHTMLElementFactory);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get HTML element factory"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get HTML element factory");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kXMLElementFactoryCID, rv = CallCreateInstance(kXMLElementFactoryCID, &gXMLElementFactory);
nsnull,
NS_GET_IID(nsIElementFactory),
(void**) &gXMLElementFactory);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get XML element factory"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get XML element factory");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kXULPrototypeCacheCID, rv = CallGetService(kXULPrototypeCacheCID, &gXULCache);
NS_GET_IID(nsIXULPrototypeCache),
(nsISupports**) &gXULCache);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
@ -4910,13 +4807,9 @@ nsXULDocument::CreateEventGroup(nsIDOMEventGroup **_retval)
NS_IMETHODIMP NS_IMETHODIMP
nsXULDocument::GetListenerManager(nsIEventListenerManager** aResult) nsXULDocument::GetListenerManager(nsIEventListenerManager** aResult)
{ {
if (! mListenerManager) { if (!mListenerManager) {
nsresult rv; nsresult rv;
rv = nsComponentManager::CreateInstance(kEventListenerManagerCID, mListenerManager = do_CreateInstance(kEventListenerManagerCID, &rv);
nsnull,
NS_GET_IID(nsIEventListenerManager),
getter_AddRefs(mListenerManager));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIDocument*,this)); mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIDocument*,this));
@ -5023,11 +4916,8 @@ nsXULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
// Create a XUL content sink, a parser, and kick off a load for // Create a XUL content sink, a parser, and kick off a load for
// the overlay. // the overlay.
nsCOMPtr<nsIXULContentSink> sink; nsCOMPtr<nsIXULContentSink> sink = do_CreateInstance(kXULContentSinkCID,
rv = nsComponentManager::CreateInstance(kXULContentSinkCID, &rv);
nsnull,
NS_GET_IID(nsIXULContentSink),
getter_AddRefs(sink));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create XUL content sink"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create XUL content sink");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -5035,11 +4925,7 @@ nsXULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to initialize datasource sink"); NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to initialize datasource sink");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIParser> parser; nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
rv = nsComponentManager::CreateInstance(kParserCID,
nsnull,
kIParserIID,
getter_AddRefs(parser));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create parser"); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create parser");
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -5151,7 +5037,7 @@ nsXULDocument::ApplyPersistentAttributesToElements(nsIRDFResource* aResource, ns
rv = property->GetValueConst(&attrname); rv = property->GetValueConst(&attrname);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIAtom> attr = dont_AddRef(NS_NewAtom(attrname)); nsCOMPtr<nsIAtom> attr = do_GetAtom(attrname);
if (! attr) if (! attr)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -5595,11 +5481,8 @@ nsXULDocument::ResumeWalk()
// and attach them to the parent node. // and attach them to the parent node.
NS_ASSERTION(element != nsnull, "no element on context stack"); NS_ASSERTION(element != nsnull, "no element on context stack");
nsCOMPtr<nsITextContent> text; nsCOMPtr<nsITextContent> text =
rv = nsComponentManager::CreateInstance(kTextNodeCID, do_CreateInstance(kTextNodeCID, &rv);
nsnull,
NS_GET_IID(nsITextContent),
getter_AddRefs(text));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsXULPrototypeText* textproto = nsXULPrototypeText* textproto =
NS_REINTERPRET_CAST(nsXULPrototypeText*, childproto); NS_REINTERPRET_CAST(nsXULPrototypeText*, childproto);

View File

@ -144,12 +144,9 @@ value_to_isupports(const nsIID& aIID, const Value& aValue)
// Need to const_cast aValue because QI() & Release() are not const // Need to const_cast aValue because QI() & Release() are not const
nsISupports* isupports = NS_STATIC_CAST(nsISupports*, NS_CONST_CAST(Value&, aValue)); nsISupports* isupports = NS_STATIC_CAST(nsISupports*, NS_CONST_CAST(Value&, aValue));
if (isupports) { if (isupports) {
nsISupports* dummy; nsCOMPtr<nsISupports> dummy;
rv = isupports->QueryInterface(aIID, (void**) &dummy); rv = isupports->QueryInterface(aIID, getter_AddRefs(dummy));
if (NS_SUCCEEDED(rv)) { if (NS_FAILED(rv)) {
NS_RELEASE(dummy);
}
else {
NS_ERROR("value does not support expected interface"); NS_ERROR("value does not support expected interface");
} }
} }

View File

@ -339,11 +339,7 @@ nsXULContentBuilder::nsXULContentBuilder()
nsXULContentBuilder::~nsXULContentBuilder() nsXULContentBuilder::~nsXULContentBuilder()
{ {
if (--gRefCnt == 0) { if (--gRefCnt == 0) {
if (gXULSortService) { NS_IF_RELEASE(gXULSortService);
nsServiceManager::ReleaseService(kXULSortServiceCID, gXULSortService);
gXULSortService = nsnull;
}
NS_IF_RELEASE(gHTMLElementFactory); NS_IF_RELEASE(gHTMLElementFactory);
NS_IF_RELEASE(gXMLElementFactory); NS_IF_RELEASE(gXMLElementFactory);
} }
@ -353,24 +349,17 @@ nsresult
nsXULContentBuilder::Init() nsXULContentBuilder::Init()
{ {
if (gRefCnt++ == 0) { if (gRefCnt++ == 0) {
nsresult rv; nsresult rv = CallGetService(kXULSortServiceCID, &gXULSortService);
if (NS_FAILED(rv))
return rv;
rv = nsServiceManager::GetService(kXULSortServiceCID, rv = CallGetService(kHTMLElementFactoryCID, &gHTMLElementFactory);
NS_GET_IID(nsIXULSortService), if (NS_FAILED(rv))
(nsISupports**) &gXULSortService); return rv;
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID, rv = CallGetService(kXMLElementFactoryCID, &gXMLElementFactory);
nsnull, if (NS_FAILED(rv))
NS_GET_IID(nsIElementFactory), return rv;
(void**) &gHTMLElementFactory);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kXMLElementFactoryCID,
nsnull,
NS_GET_IID(nsIElementFactory),
(void**) &gXMLElementFactory);
if (NS_FAILED(rv)) return rv;
} }
return nsXULTemplateBuilder::Init(); return nsXULTemplateBuilder::Init();
@ -709,11 +698,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
rv = SubstituteText(*aMatch, attrValue, value); rv = SubstituteText(*aMatch, attrValue, value);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITextContent> content; nsCOMPtr<nsITextContent> content =
rv = nsComponentManager::CreateInstance(kTextNodeCID, do_CreateInstance(kTextNodeCID, &rv);
nsnull,
NS_GET_IID(nsITextContent),
getter_AddRefs(content));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = content->SetText(value.get(), value.Length(), PR_FALSE); rv = content->SetText(value.get(), value.Length(), PR_FALSE);
@ -2160,7 +2146,7 @@ nsXULContentBuilder::CompileContentCondition(nsTemplateRule* aRule,
aCondition->GetAttr(kNameSpaceID_None, nsXULAtoms::tag, tagstr); aCondition->GetAttr(kNameSpaceID_None, nsXULAtoms::tag, tagstr);
if (!tagstr.IsEmpty()) { if (!tagstr.IsEmpty()) {
tag = dont_AddRef(NS_NewAtom(tagstr)); tag = do_GetAtom(tagstr);
} }
nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIDocument> doc;
@ -2206,7 +2192,7 @@ nsXULContentBuilder::CompileSimpleAttributeCondition(PRInt32 aNameSpaceID,
// the previous node, because it'll cause an unconstrained // the previous node, because it'll cause an unconstrained
// search if we ever came "up" through this path. Need a // search if we ever came "up" through this path. Need a
// JoinNode in here somewhere. // JoinNode in here somewhere.
nsCOMPtr<nsIAtom> tag = dont_AddRef(NS_NewAtom(aValue)); nsCOMPtr<nsIAtom> tag = do_GetAtom(aValue);
*aResult = new nsContentTagTestNode(aParentNode, mConflictSet, mContentVar, tag); *aResult = new nsContentTagTestNode(aParentNode, mConflictSet, mContentVar, tag);
if (*aResult) if (*aResult)

View File

@ -95,11 +95,10 @@ nsresult
nsXULContentUtils::Init() nsXULContentUtils::Init()
{ {
if (gRefCnt++ == 0) { if (gRefCnt++ == 0) {
nsresult rv; nsresult rv = CallGetService(kRDFServiceCID, &gRDF);
rv = nsServiceManager::GetService(kRDFServiceCID, if (NS_FAILED(rv)) {
NS_GET_IID(nsIRDFService), return rv;
(nsISupports**) &gRDF); }
if (NS_FAILED(rv)) return rv;
#define XUL_RESOURCE(ident, uri) \ #define XUL_RESOURCE(ident, uri) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \
@ -117,14 +116,13 @@ nsXULContentUtils::Init()
#undef XUL_RESOURCE #undef XUL_RESOURCE
#undef XUL_LITERAL #undef XUL_LITERAL
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, rv = CallCreateInstance(kDateTimeFormatCID, &gFormat);
nsnull, if (NS_FAILED(rv)) {
NS_GET_IID(nsIDateTimeFormat), return rv;
(void**) &gFormat); }
if (NS_FAILED(rv)) return rv;
} }
// XXX HUH?
return gRefCnt; return gRefCnt;
} }
@ -133,10 +131,7 @@ nsresult
nsXULContentUtils::Finish() nsXULContentUtils::Finish()
{ {
if (--gRefCnt == 0) { if (--gRefCnt == 0) {
if (gRDF) { NS_IF_RELEASE(gRDF);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDF);
gRDF = nsnull;
}
#define XUL_RESOURCE(ident, uri) NS_IF_RELEASE(ident) #define XUL_RESOURCE(ident, uri) NS_IF_RELEASE(ident)
#define XUL_LITERAL(ident, val) NS_IF_RELEASE(ident) #define XUL_LITERAL(ident, val) NS_IF_RELEASE(ident)

View File

@ -227,15 +227,11 @@ XULSortServiceImpl::XULSortServiceImpl(void)
kAscendingStr = new nsString(NS_LITERAL_STRING("ascending")); kAscendingStr = new nsString(NS_LITERAL_STRING("ascending"));
kDescendingStr = new nsString(NS_LITERAL_STRING("descending")); kDescendingStr = new nsString(NS_LITERAL_STRING("descending"));
nsresult rv = nsServiceManager::GetService(kRDFServiceCID, nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
NS_ERROR("couldn't create rdf service"); NS_ERROR("couldn't create rdf service");
rv = nsServiceManager::GetService(kRDFContainerUtilsCID, rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
NS_GET_IID(nsIRDFContainerUtils),
(nsISupports**) &gRDFC);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
NS_ERROR("couldn't create rdf container utils"); NS_ERROR("couldn't create rdf container utils");
@ -286,12 +282,8 @@ XULSortServiceImpl::~XULSortServiceImpl(void) {
NS_IF_RELEASE(gCollation); NS_IF_RELEASE(gCollation);
if (gRDFService) { NS_IF_RELEASE(gRDFService);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService); NS_IF_RELEASE(gRDFC);
gRDFService = nsnull;
}
if (gRDFC)
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFC);
} }
} }

View File

@ -163,22 +163,10 @@ nsXULTemplateBuilder::nsXULTemplateBuilder(void)
nsXULTemplateBuilder::~nsXULTemplateBuilder(void) nsXULTemplateBuilder::~nsXULTemplateBuilder(void)
{ {
if (--gRefCnt == 0) { if (--gRefCnt == 0) {
if (gRDFService) { NS_IF_RELEASE(gRDFService);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService); NS_IF_RELEASE(gRDFContainerUtils);
gRDFService = nsnull;
}
if (gRDFContainerUtils) {
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
gRDFContainerUtils = nsnull;
}
NS_IF_RELEASE(gSystemPrincipal); NS_IF_RELEASE(gSystemPrincipal);
NS_IF_RELEASE(gScriptSecurityManager);
if (gScriptSecurityManager) {
nsServiceManager::ReleaseService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, gScriptSecurityManager);
gScriptSecurityManager = nsnull;
}
} }
} }
@ -191,23 +179,22 @@ nsXULTemplateBuilder::Init()
// Initialize the global shared reference to the service // Initialize the global shared reference to the service
// manager and get some shared resource objects. // manager and get some shared resource objects.
rv = nsServiceManager::GetService(kRDFServiceCID, rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_GET_IID(nsIRDFService), if (NS_FAILED(rv))
(nsISupports**) &gRDFService); return rv;
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(kRDFContainerUtilsCID, rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
NS_GET_IID(nsIRDFContainerUtils), if (NS_FAILED(rv))
(nsISupports**) &gRDFContainerUtils); return rv;
if (NS_FAILED(rv)) return rv;
rv = nsServiceManager::GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID,
NS_GET_IID(nsIScriptSecurityManager), &gScriptSecurityManager);
(nsISupports**) &gScriptSecurityManager); if (NS_FAILED(rv))
if (NS_FAILED(rv)) return rv; return rv;
rv = gScriptSecurityManager->GetSystemPrincipal(&gSystemPrincipal); rv = gScriptSecurityManager->GetSystemPrincipal(&gSystemPrincipal);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv))
return rv;
} }
#ifdef PR_LOGGING #ifdef PR_LOGGING

View File

@ -1543,7 +1543,7 @@ nsXULTreeBuilder::TokenizeProperties(const nsAString& aString,
if (iter == first) if (iter == first)
break; break;
nsCOMPtr<nsIAtom> atom = dont_AddRef(NS_NewAtom(Substring(first, iter))); nsCOMPtr<nsIAtom> atom = do_GetAtom(Substring(first, iter));
aProperties->AppendElement(atom); aProperties->AppendElement(atom);
} while (iter != end); } while (iter != end);

View File

@ -1785,7 +1785,7 @@ DocumentViewerImpl::FindFrameSetWithIID(nsIContent * aParentContent,
// do a breadth search across all siblings // do a breadth search across all siblings
PRInt32 inx; PRInt32 inx;
for (inx=0;inx<numChildren;inx++) { for (inx = 0; inx < numChildren; ++inx) {
nsCOMPtr<nsIContent> child; nsCOMPtr<nsIContent> child;
if (NS_SUCCEEDED(aParentContent->ChildAt(inx, *getter_AddRefs(child))) && child) { if (NS_SUCCEEDED(aParentContent->ChildAt(inx, *getter_AddRefs(child))) && child) {
nsCOMPtr<nsISupports> temp; nsCOMPtr<nsISupports> temp;
@ -1869,7 +1869,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
nsISupports* data = (nsISupports*)clientData; nsISupports* data = (nsISupports*)clientData;
if (data) { if (data) {
data->QueryInterface(NS_GET_IID(nsIView), (void **)&containerView); CallQueryInterface(data, &containerView);
} }
} }

View File

@ -146,7 +146,8 @@ NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult)
if (!it) { if (!it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsIDocumentLoaderFactory), (void**)aResult);
return CallQueryInterface(it, aResult);
} }
nsContentDLF::nsContentDLF() nsContentDLF::nsContentDLF()
@ -415,9 +416,7 @@ nsContentDLF::CreateDocument(const char* aCommand,
nsCOMPtr<nsIDocumentViewer> docv; nsCOMPtr<nsIDocumentViewer> docv;
do { do {
// Create the document // Create the document
rv = nsComponentManager::CreateInstance(aDocumentCID, nsnull, doc = do_CreateInstance(aDocumentCID, &rv);
NS_GET_IID(nsIDocument),
getter_AddRefs(doc));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
break; break;
@ -482,9 +481,7 @@ nsContentDLF::CreateRDFDocument(nsISupports* aExtraInfo,
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
// Create the XUL document // Create the XUL document
rv = nsComponentManager::CreateInstance(kXULDocumentCID, nsnull, *doc = do_CreateInstance(kXULDocumentCID, &rv);
NS_GET_IID(nsIDocument),
getter_AddRefs(*doc));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// Create the image content viewer... // Create the image content viewer...

View File

@ -101,11 +101,12 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
#include "nsIEventQueue.h" #include "nsIEventQueue.h"
#include "nsIEventQueueService.h" #include "nsIEventQueueService.h"
//nodtifications // notifications
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsISelectionController.h"//for the enums #include "nsISelectionController.h"//for the enums
#include "nsHTMLAtoms.h"
#define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;} #define STATUS_CHECK_RETURN_MACRO() {if (!mTracker) return NS_ERROR_FAILURE;}
@ -532,12 +533,6 @@ private:
PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened
PRPackedBool mDesiredXSet; PRPackedBool mDesiredXSet;
short mReason; //reason for notifications of selection changing short mReason; //reason for notifications of selection changing
public:
static nsIAtom *sTableAtom;
static nsIAtom *sRowAtom;
static nsIAtom *sCellAtom;
static nsIAtom *sTbodyAtom;
static PRInt32 sInstanceCount;
}; };
class nsSelectionIterator : public nsIBidirectionalEnumerator class nsSelectionIterator : public nsIBidirectionalEnumerator
@ -715,13 +710,6 @@ nsresult NS_NewDomSelection(nsISelection **aDomSelection)
return NS_OK; return NS_OK;
} }
//Horrible statics but no choice
nsIAtom *nsSelection::sTableAtom = 0;
nsIAtom *nsSelection::sRowAtom = 0;
nsIAtom *nsSelection::sCellAtom = 0;
nsIAtom *nsSelection::sTbodyAtom = 0;
PRInt32 nsSelection::sInstanceCount = 0;
static PRInt8 static PRInt8
GetIndexFromSelectionType(SelectionType aType) GetIndexFromSelectionType(SelectionType aType)
{ {
@ -978,15 +966,7 @@ nsSelection::nsSelection()
mMouseDoubleDownState = PR_FALSE; mMouseDoubleDownState = PR_FALSE;
if (sInstanceCount <= 0)
{
sTableAtom = NS_NewAtom("table");
sRowAtom = NS_NewAtom("tr");
sCellAtom = NS_NewAtom("td");
sTbodyAtom = NS_NewAtom("tbody");
}
mHint = HINTLEFT; mHint = HINTLEFT;
sInstanceCount ++;
mDragSelectingCells = PR_FALSE; mDragSelectingCells = PR_FALSE;
mSelectingTableCellMode = 0; mSelectingTableCellMode = 0;
mSelectedCellIndex = 0; mSelectedCellIndex = 0;
@ -1024,19 +1004,11 @@ nsSelection::nsSelection()
nsSelection::~nsSelection() nsSelection::~nsSelection()
{ {
if (sInstanceCount <= 1)
{
NS_IF_RELEASE(sTableAtom);
NS_IF_RELEASE(sRowAtom);
NS_IF_RELEASE(sCellAtom);
NS_IF_RELEASE(sTbodyAtom);
}
PRInt32 i; PRInt32 i;
for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){ for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){
if (mDomSelections[i]) if (mDomSelections[i])
NS_IF_RELEASE(mDomSelections[i]); NS_IF_RELEASE(mDomSelections[i]);
} }
sInstanceCount--;
} }
@ -1445,8 +1417,7 @@ ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
if (!aNode || !aParent || !aChildOffset) if (!aNode || !aParent || !aChildOffset)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsresult result = NS_OK; nsresult result = NS_OK;
nsCOMPtr<nsIContent> content; nsCOMPtr<nsIContent> content = do_QueryInterface(aNode, &result);
result = aNode->QueryInterface(NS_GET_IID(nsIContent),getter_AddRefs(content));
if (NS_SUCCEEDED(result) && content) if (NS_SUCCEEDED(result) && content)
{ {
nsCOMPtr<nsIContent> parent; nsCOMPtr<nsIContent> parent;
@ -1454,8 +1425,9 @@ ParentOffset(nsIDOMNode *aNode, nsIDOMNode **aParent, PRInt32 *aChildOffset)
if (NS_SUCCEEDED(result) && parent) if (NS_SUCCEEDED(result) && parent)
{ {
result = parent->IndexOf(content, *aChildOffset); result = parent->IndexOf(content, *aChildOffset);
if (NS_SUCCEEDED(result)) if (NS_SUCCEEDED(result)) {
result = parent->QueryInterface(NS_GET_IID(nsIDOMNode),(void **)aParent); result = CallQueryInterface(parent, aParent);
}
} }
} }
return result; return result;
@ -1474,7 +1446,7 @@ GetCellParent(nsIDOMNode *aDomNode)
while(current) while(current)
{ {
tag = GetTag(current); tag = GetTag(current);
if (tag == nsSelection::sCellAtom) if (tag == nsHTMLAtoms::td)
return current; return current;
if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent) if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent)
return 0; return 0;
@ -1892,11 +1864,12 @@ nsresult FindLineContaining(nsIFrame* aFrame, nsIFrame** aBlock, PRInt32* aLine)
{ {
thisBlock = blockFrame; thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame); result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame){ if (NS_SUCCEEDED(result) && blockFrame) {
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIteratorNavigator),getter_AddRefs(it)); it = do_QueryInterface(blockFrame, &result);
} }
else else {
blockFrame = nsnull; blockFrame = nsnull;
}
} }
if (!blockFrame || !it) if (!blockFrame || !it)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -2345,11 +2318,12 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext,
{ {
thisBlock = blockFrame; thisBlock = blockFrame;
result = blockFrame->GetParent(&blockFrame); result = blockFrame->GetParent(&blockFrame);
if (NS_SUCCEEDED(result) && blockFrame){ if (NS_SUCCEEDED(result) && blockFrame) {
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIteratorNavigator),getter_AddRefs(it)); it = do_QueryInterface(blockFrame, &result);
} }
else else {
blockFrame = nsnull; blockFrame = nsnull;
}
} }
if (!blockFrame || !it) if (!blockFrame || !it)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -3416,19 +3390,21 @@ static PRBool IsCell(nsIContent *aContent)
{ {
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag;
aContent->GetTag(*getter_AddRefs(tag)); aContent->GetTag(*getter_AddRefs(tag));
return (tag != 0 && tag.get() == nsSelection::sCellAtom); return (tag == nsHTMLAtoms::td);
} }
nsITableCellLayout* nsITableCellLayout*
nsSelection::GetCellLayout(nsIContent *aCellContent) nsSelection::GetCellLayout(nsIContent *aCellContent)
{ {
// Get frame for cell // Get frame for cell
nsIFrame *cellFrame = nsnull; nsIFrame *cellFrame = nsnull;
nsresult result = GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame); GetTracker()->GetPrimaryFrameFor(aCellContent, &cellFrame);
if (!cellFrame) return nsnull; if (!cellFrame)
return nsnull;
nsITableCellLayout *cellLayoutObject = nsnull; nsITableCellLayout *cellLayoutObject = nsnull;
result = cellFrame->QueryInterface(NS_GET_IID(nsITableCellLayout), (void**)(&cellLayoutObject)); CallQueryInterface(cellFrame, &cellLayoutObject);
if (NS_FAILED(result)) return nsnull;
return cellLayoutObject; return cellLayoutObject;
} }
@ -3436,12 +3412,14 @@ nsITableLayout*
nsSelection::GetTableLayout(nsIContent *aTableContent) nsSelection::GetTableLayout(nsIContent *aTableContent)
{ {
// Get frame for table // Get frame for table
nsIFrame *tableFrame = nsnull; nsIFrame *tableFrame = nsnull;
nsresult result = GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame); GetTracker()->GetPrimaryFrameFor(aTableContent, &tableFrame);
if (!tableFrame) return nsnull; if (!tableFrame)
return nsnull;
nsITableLayout *tableLayoutObject = nsnull; nsITableLayout *tableLayoutObject = nsnull;
result = tableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void**)(&tableLayoutObject)); CallQueryInterface(tableFrame, &tableLayoutObject);
if (NS_FAILED(result)) return nsnull;
return tableLayoutObject; return tableLayoutObject;
} }
@ -4180,7 +4158,7 @@ nsSelection::GetParentTable(nsIContent *aCell, nsIContent **aTable)
{ {
nsIAtom *tag; nsIAtom *tag;
parent->GetTag(tag); parent->GetTag(tag);
if (tag && tag == nsSelection::sTableAtom) if (tag == nsHTMLAtoms::table)
{ {
*aTable = parent; *aTable = parent;
NS_ADDREF(*aTable); NS_ADDREF(*aTable);
@ -4381,7 +4359,7 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
content->GetTag(*getter_AddRefs(atom)); content->GetTag(*getter_AddRefs(atom));
if (!atom) return NS_ERROR_FAILURE; if (!atom) return NS_ERROR_FAILURE;
if (atom.get() == nsSelection::sRowAtom) if (atom == nsHTMLAtoms::tr)
{ {
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL;
} }
@ -4395,9 +4373,9 @@ nsTypedSelection::GetTableSelectionType(nsIDOMRange* aRange, PRInt32* aTableSele
child->GetTag(*getter_AddRefs(atom)); child->GetTag(*getter_AddRefs(atom));
if (!atom) return NS_ERROR_FAILURE; if (!atom) return NS_ERROR_FAILURE;
if (atom.get() == nsSelection::sTableAtom) if (atom == nsHTMLAtoms::table)
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
else if (atom.get() == nsSelection::sRowAtom) else if (atom == nsHTMLAtoms::tr)
*aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW; *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW;
} }
return result; return result;
@ -5119,8 +5097,9 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext,
mFrameSelection->GetTableCellSelection(&tablesel); mFrameSelection->GetTableCellSelection(&tablesel);
if (tablesel) if (tablesel)
{ {
nsITableCellLayout *tcl; nsITableCellLayout *tcl = nsnull;
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITableCellLayout),(void **)&tcl)) && tcl) CallQueryInterface(frame, &tcl);
if (tcl)
{ {
return NS_OK; return NS_OK;
} }
@ -5181,28 +5160,25 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange
return NS_OK;//nothing to do return NS_OK;//nothing to do
if (!aRange || !aPresContext) if (!aRange || !aPresContext)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContentIterator> iter;
nsCOMPtr<nsIContentIterator> inneriter; nsresult result;
nsresult result = nsComponentManager::CreateInstance( nsCOMPtr<nsIContentIterator> iter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
kCGenSubtreeIteratorCID, kCGenSubtreeIteratorCID,
#else #else
kCSubtreeIteratorCID, kCSubtreeIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
nsnull, &result);
NS_GET_IID(nsIContentIterator),
getter_AddRefs(iter));
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
result = nsComponentManager::CreateInstance(
nsCOMPtr<nsIContentIterator> inneriter = do_CreateInstance(
#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
kCGenContentIteratorCID, kCGenContentIteratorCID,
#else #else
kCContentIteratorCID, kCContentIteratorCID,
#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE #endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE
nsnull, &result);
NS_GET_IID(nsIContentIterator),
getter_AddRefs(inneriter));
if ((NS_SUCCEEDED(result)) && iter && inneriter) if ((NS_SUCCEEDED(result)) && iter && inneriter)
{ {
@ -5504,11 +5480,10 @@ nsTypedSelection::GetClosestScrollableView(nsIView *aView, nsIScrollableView **a
while (!*aScrollableView && aView) while (!*aScrollableView && aView)
{ {
nsresult result = aView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)aScrollableView); CallQueryInterface(aView, aScrollableView);
if (!*aScrollableView) if (!*aScrollableView)
{ {
result = aView->GetParent(aView); nsresult result = aView->GetParent(aView);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
@ -5759,7 +5734,7 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
nsIView *scrolledView = 0; nsIView *scrolledView = 0;
nsIView *view = 0; nsIView *view = 0;
result = scrollableView->QueryInterface(NS_GET_IID(nsIView), (void**)&view); CallQueryInterface(scrollableView, &view);
if (view) if (view)
{ {
@ -5819,13 +5794,11 @@ nsTypedSelection::ScrollPointIntoView(nsIPresContext *aPresContext, nsIView *aVi
// //
view = 0; view = 0;
result = scrollableView->QueryInterface(NS_GET_IID(nsIView), (void**)&view); result = CallQueryInterface(scrollableView, &view);
if (!view)
if (NS_FAILED(result))
return result; return result;
if (view) view->GetParent(view);
view->GetParent(view);
} }
} }
} }
@ -6290,7 +6263,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
// if end node is a tbody then all bets are off we cannot select "rows" // if end node is a tbody then all bets are off we cannot select "rows"
nsCOMPtr<nsIAtom> atom; nsCOMPtr<nsIAtom> atom;
atom = GetTag(endNode); atom = GetTag(endNode);
if (atom.get() == nsSelection::sTbodyAtom) if (atom == nsHTMLAtoms::tbody)
return NS_ERROR_FAILURE; //cannot select INTO row node ony cells return NS_ERROR_FAILURE; //cannot select INTO row node ony cells
//get common parent //get common parent
@ -6336,7 +6309,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
while (tempNode != parent) while (tempNode != parent)
{ {
atom = GetTag(tempNode); atom = GetTag(tempNode);
if (atom.get() == nsSelection::sTableAtom) //select whole table if in cell mode, wait for cell if (atom == nsHTMLAtoms::table) //select whole table if in cell mode, wait for cell
{ {
result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset);
if (NS_FAILED(result)) if (NS_FAILED(result))
@ -6346,7 +6319,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
dirtystart = PR_TRUE; dirtystart = PR_TRUE;
cellMode = PR_FALSE; cellMode = PR_FALSE;
} }
else if (atom.get() == nsSelection::sCellAtom) //you are in "cell" mode put selection to end of cell else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell
{ {
cellMode = PR_TRUE; cellMode = PR_TRUE;
result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset);
@ -6373,7 +6346,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
while (tempNode != parent) while (tempNode != parent)
{ {
atom = GetTag(tempNode); atom = GetTag(tempNode);
if (atom.get() == nsSelection::sTableAtom) //select whole table if in cell mode, wait for cell if (atom == nsHTMLAtoms::table) //select whole table if in cell mode, wait for cell
{ {
if (!cellMode) if (!cellMode)
{ {
@ -6387,7 +6360,7 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir,
else else
found = PR_FALSE; //didnt find the right cell yet found = PR_FALSE; //didnt find the right cell yet
} }
else if (atom.get() == nsSelection::sCellAtom) //you are in "cell" mode put selection to end of cell else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell
{ {
result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset); result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset);
if (NS_FAILED(result)) if (NS_FAILED(result))
@ -7141,7 +7114,7 @@ nsTypedSelection::GetFrameToScrolledViewOffsets(nsIScrollableView *aScrollableVi
// XXX Deal with the case where there is a scrolled element, e.g., a // XXX Deal with the case where there is a scrolled element, e.g., a
// DIV in the middle... // DIV in the middle...
while ((closestView != nsnull) && (closestView != scrolledView)) { while (closestView && closestView != scrolledView) {
nscoord dx, dy; nscoord dx, dy;
// Update the offset // Update the offset
@ -7610,14 +7583,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// //
nsIView *view = 0; nsIView *view = 0;
rv = CallQueryInterface(aScrollableView, &view);
rv = aScrollableView->QueryInterface(NS_GET_IID(nsIView), (void **)&view);
if (NS_FAILED(rv))
return rv;
if (!view) if (!view)
return NS_ERROR_FAILURE; return rv;
rv = view->GetParent(view); rv = view->GetParent(view);

View File

@ -4788,19 +4788,18 @@ int RemoveFilesInDir(const char * aDir)
*/ */
static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
{ {
if((nsnull == aPresContext) || (nsnull == out)) if (!aPresContext || !out)
return; return;
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell)); aPresContext->GetShell(getter_AddRefs(shell));
if (nsnull != shell) { if (shell) {
nsIFrame* frame; nsIFrame* frame;
shell->GetRootFrame(&frame); shell->GetRootFrame(&frame);
if(nsnull != frame) { if (frame) {
nsIFrameDebug* debugFrame; nsIFrameDebug* debugFrame;
nsresult rv; nsresult rv = CallQueryInterface(frame, &debugFrame);
rv = frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&debugFrame); if (NS_SUCCEEDED(rv))
if(NS_SUCCEEDED(rv))
debugFrame->List(aPresContext, out, aIndent); debugFrame->List(aPresContext, out, aIndent);
} }
} }

View File

@ -6117,8 +6117,7 @@ void nsCSSDeclaration::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSDeclaration");
tag = getter_AddRefs(NS_NewAtom("nsCSSDeclaration"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);

View File

@ -1097,9 +1097,8 @@ PRBool CSSParserImpl::GatherMedia(PRInt32& aErrorCode, nsString& aMedia,
} }
ToLowerCase(mToken.mIdent); // case insensitive from CSS - must be lower cased ToLowerCase(mToken.mIdent); // case insensitive from CSS - must be lower cased
if (aMediaAtoms) { if (aMediaAtoms) {
nsIAtom* medium = NS_NewAtom(mToken.mIdent); nsCOMPtr<nsIAtom> medium = do_GetAtom(mToken.mIdent);
aMediaAtoms->AppendElement(medium); aMediaAtoms->AppendElement(medium);
NS_RELEASE(medium);
} }
aMedia.Append(mToken.mIdent); aMedia.Append(mToken.mIdent);
first = PR_FALSE; first = PR_FALSE;
@ -1323,7 +1322,7 @@ PRBool CSSParserImpl::ProcessNameSpace(PRInt32& aErrorCode, const nsString& aPre
nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> prefix;
if (!aPrefix.IsEmpty()) { if (!aPrefix.IsEmpty()) {
prefix = dont_AddRef(NS_NewAtom(aPrefix)); prefix = do_GetAtom(aPrefix);
} }
NS_NewCSSNameSpaceRule(getter_AddRefs(rule), prefix, aURLSpec); NS_NewCSSNameSpaceRule(getter_AddRefs(rule), prefix, aURLSpec);
@ -1838,12 +1837,10 @@ void CSSParserImpl::ParseTypeOrUniversalSelector(PRInt32& aDataMask,
aDataMask |= SEL_MASK_NSPACE; aDataMask |= SEL_MASK_NSPACE;
PRInt32 nameSpaceID = kNameSpaceID_Unknown; PRInt32 nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(buffer); // always case insensitive, since stays within CSS ToLowerCase(buffer); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(buffer); nsCOMPtr<nsIAtom> prefix = do_GetAtom(buffer);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") + REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +
buffer + NS_LITERAL_STRING("'.")); buffer + NS_LITERAL_STRING("'."));
@ -2027,12 +2024,10 @@ void CSSParserImpl::ParseAttributeSelector(PRInt32& aDataMask,
if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // was a namespace if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // was a namespace
nameSpaceID = kNameSpaceID_Unknown; nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(attr); // always case insensitive, since stays within CSS ToLowerCase(attr); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(attr); nsCOMPtr<nsIAtom> prefix = do_GetAtom(attr);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") + REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +
attr + NS_LITERAL_STRING("'.")); attr + NS_LITERAL_STRING("'."));
@ -2690,7 +2685,7 @@ PRBool CSSParserImpl::ParseTreePseudoElement(PRInt32& aErrorCode,
return PR_FALSE; return PR_FALSE;
} }
else if (eCSSToken_Ident == mToken.mType) { else if (eCSSToken_Ident == mToken.mType) {
nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_NewAtom(mToken.mIdent)); nsCOMPtr<nsIAtom> pseudo = do_GetAtom(mToken.mIdent);
aSelector.AddPseudoClass(pseudo); aSelector.AddPseudoClass(pseudo);
} }
else if (eCSSToken_Symbol == mToken.mType) { else if (eCSSToken_Symbol == mToken.mType) {
@ -3252,12 +3247,10 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // namespace if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) { // namespace
PRInt32 nameSpaceID = kNameSpaceID_Unknown; PRInt32 nameSpaceID = kNameSpaceID_Unknown;
if (mNameSpace) { if (mNameSpace) {
nsIAtom* prefix;
ToLowerCase(holdIdent); // always case insensitive, since stays within CSS ToLowerCase(holdIdent); // always case insensitive, since stays within CSS
prefix = NS_NewAtom(holdIdent); nsCOMPtr<nsIAtom> prefix = do_GetAtom(holdIdent);
mNameSpace->FindNameSpaceID(prefix, nameSpaceID); mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
NS_IF_RELEASE(prefix); } // else, no declared namespaces
} // else, no delcared namespaces
if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it if (kNameSpaceID_Unknown == nameSpaceID) { // unknown prefix, dump it
return PR_FALSE; return PR_FALSE;
} }

View File

@ -271,8 +271,7 @@ void CSSCharsetRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSCharsetRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSCharsetRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
// add the string for encoding value // add the string for encoding value
@ -295,7 +294,7 @@ CSSCharsetRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSCharsetRuleImpl* clone = new CSSCharsetRuleImpl(*this); CSSCharsetRuleImpl* clone = new CSSCharsetRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -520,8 +519,7 @@ void CSSImportRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSImportRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSImportRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -546,7 +544,7 @@ CSSImportRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSImportRuleImpl* clone = new CSSImportRuleImpl(*this); CSSImportRuleImpl* clone = new CSSImportRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -935,8 +933,7 @@ void CSSMediaRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSMediaRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSMediaRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -981,7 +978,7 @@ CSSMediaRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSMediaRuleImpl* clone = new CSSMediaRuleImpl(*this); CSSMediaRuleImpl* clone = new CSSMediaRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -1380,8 +1377,7 @@ void CSSNameSpaceRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aS
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSNameSpaceRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSNameSpaceRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -1410,7 +1406,7 @@ CSSNameSpaceRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSNameSpaceRuleImpl* clone = new CSSNameSpaceRuleImpl(*this); CSSNameSpaceRuleImpl* clone = new CSSNameSpaceRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;

View File

@ -6117,8 +6117,7 @@ void nsCSSDeclaration::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSDeclaration");
tag = getter_AddRefs(NS_NewAtom("nsCSSDeclaration"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);

View File

@ -336,8 +336,7 @@ void nsAttrSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsAttrSelector");
tag = getter_AddRefs(NS_NewAtom("nsAttrSelector"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -655,8 +654,7 @@ void nsCSSSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("nsCSSSelector");
tag = getter_AddRefs(NS_NewAtom("nsCSSSelector"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
@ -1071,8 +1069,7 @@ void CSSImportantRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSImportantRule");
tag = getter_AddRefs(NS_NewAtom("CSSImportantRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSImportantRule); aSize = sizeof(CSSImportantRule);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -1377,13 +1374,14 @@ DOMCSSDeclarationImpl::ParseDeclaration(const nsAString& aDecl,
nsresult nsresult
DOMCSSDeclarationImpl::GetParent(nsISupports **aParent) DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
{ {
if (nsnull != mRule) { NS_ENSURE_ARG_POINTER(aParent);
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
} else { if (mRule) {
NS_ENSURE_ARG_POINTER(aParent); return CallQueryInterface(mRule, aParent);
*aParent = nsnull;
} }
*aParent = nsnull;
return NS_OK; return NS_OK;
} }
@ -1698,7 +1696,7 @@ CSSStyleRuleImpl::Clone(nsICSSRule*& aClone) const
{ {
CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this); CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this);
if (clone) { if (clone) {
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone); return CallQueryInterface(clone, &aClone);
} }
aClone = nsnull; aClone = nsnull;
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2446,8 +2444,7 @@ void CSSStyleRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleRuleImpl");
tag = getter_AddRefs(NS_NewAtom("CSSStyleRuleImpl"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
// remove the sizeof the mSelector's class since we count it seperately below // remove the sizeof the mSelector's class since we count it seperately below
@ -2509,8 +2506,8 @@ CSSStyleRuleImpl::SetCssText(const nsAString& aCssText)
NS_IMETHODIMP NS_IMETHODIMP
CSSStyleRuleImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet) CSSStyleRuleImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
{ {
if (nsnull != mSheet) { if (mSheet) {
return mSheet->QueryInterface(NS_GET_IID(nsIDOMCSSStyleSheet), (void**)aSheet); return CallQueryInterface(mSheet, aSheet);
} }
*aSheet = nsnull; *aSheet = nsnull;
return NS_OK; return NS_OK;
@ -2566,10 +2563,10 @@ NS_EXPORT nsresult
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector); CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector);
if (!it) {
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
return it->QueryInterface(NS_GET_IID(nsICSSStyleRule), (void **) aInstancePtrResult);
return CallQueryInterface(it, aInstancePtrResult);
} }

View File

@ -1317,7 +1317,7 @@ DOMMediaListImpl::Delete(const nsAString& aOldMedium)
if (aOldMedium.IsEmpty()) if (aOldMedium.IsEmpty())
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
nsCOMPtr<nsIAtom> old(dont_AddRef(NS_NewAtom(aOldMedium))); nsCOMPtr<nsIAtom> old = do_GetAtom(aOldMedium);
NS_ENSURE_TRUE(old, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(old, NS_ERROR_OUT_OF_MEMORY);
PRInt32 indx = IndexOf(old); PRInt32 indx = IndexOf(old);
@ -1337,7 +1337,7 @@ DOMMediaListImpl::Append(const nsAString& aNewMedium)
if (aNewMedium.IsEmpty()) if (aNewMedium.IsEmpty())
return NS_ERROR_DOM_NOT_FOUND_ERR; return NS_ERROR_DOM_NOT_FOUND_ERR;
nsCOMPtr<nsIAtom> media(dont_AddRef(NS_NewAtom(aNewMedium))); nsCOMPtr<nsIAtom> media = do_GetAtom(aNewMedium);
NS_ENSURE_TRUE(media, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(media, NS_ERROR_OUT_OF_MEMORY);
PRInt32 indx = IndexOf(media); PRInt32 indx = IndexOf(media);
@ -1453,14 +1453,14 @@ CSSImportsCollectionImpl::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn)
nsresult result = NS_OK; nsresult result = NS_OK;
*aReturn = nsnull; *aReturn = nsnull;
if (nsnull != mStyleSheet) {
nsICSSStyleSheet *sheet;
result = mStyleSheet->GetStyleSheetAt(aIndex, sheet); if (mStyleSheet) {
if (NS_OK == result) { nsCOMPtr<nsICSSStyleSheet> sheet;
result = sheet->QueryInterface(NS_GET_IID(nsIDOMStyleSheet), (void **)aReturn);
result = mStyleSheet->GetStyleSheetAt(aIndex, *getter_AddRefs(sheet));
if (NS_SUCCEEDED(result)) {
result = CallQueryInterface(sheet, aReturn);
} }
NS_RELEASE(sheet);
} }
return result; return result;
@ -1667,8 +1667,7 @@ void CSSStyleSheetInner::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSiz
PRBool rulesCounted=PR_FALSE; PRBool rulesCounted=PR_FALSE;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleSheetInner");
tag = getter_AddRefs(NS_NewAtom("CSSStyleSheetInner"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSStyleSheetInner); aSize = sizeof(CSSStyleSheetInner);
@ -2588,8 +2587,7 @@ void CSSStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSStyleSheet");
tag = getter_AddRefs(NS_NewAtom("CSSStyleSheet"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSStyleSheetImpl); aSize = sizeof(CSSStyleSheetImpl);
@ -4350,13 +4348,13 @@ void CascadeSizeEnumFunc(RuleCascadeData *cascade, CascadeSizeEnumData *pData)
// next add up the selectors and the weighted rules for the cascade // next add up the selectors and the weighted rules for the cascade
nsCOMPtr<nsIAtom> stateSelectorSizeTag; nsCOMPtr<nsIAtom> stateSelectorSizeTag;
stateSelectorSizeTag = getter_AddRefs(NS_NewAtom("CascadeStateSelectors")); stateSelectorSizeTag = do_GetAtom("CascadeStateSelectors");
CascadeSizeEnumData stateData(pData->handler,pData->uniqueItems,stateSelectorSizeTag); CascadeSizeEnumData stateData(pData->handler,pData->uniqueItems,stateSelectorSizeTag);
cascade->mStateSelectors.EnumerateForwards(StateSelectorsSizeEnumFunc, &stateData); cascade->mStateSelectors.EnumerateForwards(StateSelectorsSizeEnumFunc, &stateData);
if(cascade->mWeightedRules){ if(cascade->mWeightedRules){
nsCOMPtr<nsIAtom> weightedRulesSizeTag; nsCOMPtr<nsIAtom> weightedRulesSizeTag;
weightedRulesSizeTag = getter_AddRefs(NS_NewAtom("CascadeWeightedRules")); weightedRulesSizeTag = do_GetAtom("CascadeWeightedRules");
CascadeSizeEnumData stateData2(pData->handler,pData->uniqueItems,weightedRulesSizeTag); CascadeSizeEnumData stateData2(pData->handler,pData->uniqueItems,weightedRulesSizeTag);
cascade->mWeightedRules->EnumerateForwards(WeightedRulesSizeEnumFunc, &stateData2); cascade->mWeightedRules->EnumerateForwards(WeightedRulesSizeEnumFunc, &stateData2);
} }
@ -4387,8 +4385,7 @@ void CSSRuleProcessor::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("CSSRuleProcessor");
tag = getter_AddRefs(NS_NewAtom("CSSRuleProcessor"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(CSSRuleProcessor); aSize = sizeof(CSSRuleProcessor);
@ -4413,7 +4410,7 @@ void CSSRuleProcessor::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
// and for the medium cascade table we account for the hash table overhead, // and for the medium cascade table we account for the hash table overhead,
// and then compute the sizeof each rule-cascade in the table // and then compute the sizeof each rule-cascade in the table
{ {
nsCOMPtr<nsIAtom> tag2 = getter_AddRefs(NS_NewAtom("RuleCascade")); nsCOMPtr<nsIAtom> tag2 = do_GetAtom("RuleCascade");
CascadeSizeEnumData data(aSizeOfHandler, uniqueItems, tag2); CascadeSizeEnumData data(aSizeOfHandler, uniqueItems, tag2);
for (RuleCascadeData *cascadeData = mRuleCascades; for (RuleCascadeData *cascadeData = mRuleCascades;
cascadeData; cascadeData;

View File

@ -205,7 +205,7 @@ nsComputedDOMStyle::Init(nsIDOMElement *aElement,
} }
if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty()) { if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty()) {
mPseudo = dont_AddRef(NS_NewAtom(aPseudoElt)); mPseudo = do_GetAtom(aPseudoElt);
NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY);
} }

Some files were not shown because too many files have changed in this diff Show More