Bug 859817 - Remove implicit conversions from raw pointer to already_AddRefed; r=Ms2ger

This commit is contained in:
Aryeh Gregor 2013-04-22 14:15:59 +03:00
parent e0a4cd5848
commit 659b807986
107 changed files with 399 additions and 561 deletions

View File

@ -303,11 +303,10 @@ nsAccessibilityService::CreatePluginAccessible(nsObjectFrame* aFrame,
nsresult rv = pluginInstance->GetValueFromPlugin(
NPPVpluginNativeAccessibleAtkPlugId, &plugId);
if (NS_SUCCEEDED(rv) && !plugId.IsEmpty()) {
AtkSocketAccessible* socketAccessible =
nsRefPtr<AtkSocketAccessible> socketAccessible =
new AtkSocketAccessible(aContent, aContext->Document(), plugId);
NS_ADDREF(socketAccessible);
return socketAccessible;
return socketAccessible.forget();
}
#endif
}
@ -1132,12 +1131,11 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
return nullptr;
if (type == nsIAccessibleProvider::OuterDoc) {
Accessible* accessible = new OuterDocAccessible(aContent, aDoc);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible = new OuterDocAccessible(aContent, aDoc);
return accessible.forget();
}
Accessible* accessible = nullptr;
nsRefPtr<Accessible> accessible;
switch (type)
{
#ifdef MOZ_XUL
@ -1322,8 +1320,7 @@ nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
return nullptr;
}
NS_IF_ADDREF(accessible);
return accessible;
return accessible.forget();
}
already_AddRefed<Accessible>
@ -1335,10 +1332,9 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
if (aContext->IsTableRow()) {
if (nsCoreUtils::IsHTMLTableHeader(aContent) &&
aContext->GetContent() == aContent->GetParent()) {
Accessible* accessible = new HTMLTableHeaderCellAccessibleWrap(aContent,
document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLTableHeaderCellAccessibleWrap(aContent, document);
return accessible.forget();
}
return nullptr;
@ -1347,41 +1343,40 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
// This method assumes we're in an HTML namespace.
nsIAtom* tag = aContent->Tag();
if (tag == nsGkAtoms::figcaption) {
Accessible* accessible = new HTMLFigcaptionAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLFigcaptionAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::figure) {
Accessible* accessible = new HTMLFigureAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLFigureAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::legend) {
Accessible* accessible = new HTMLLegendAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLLegendAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::option) {
Accessible* accessible = new HTMLSelectOptionAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLSelectOptionAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::optgroup) {
Accessible* accessible =
nsRefPtr<Accessible> accessible =
new HTMLSelectOptGroupAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
return accessible.forget();
}
if (tag == nsGkAtoms::ul || tag == nsGkAtoms::ol ||
tag == nsGkAtoms::dl) {
Accessible* accessible = new HTMLListAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLListAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::a) {
@ -1390,14 +1385,14 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aContent);
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::LINK) {
Accessible* accessible = new HyperTextAccessibleWrap(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HyperTextAccessibleWrap(aContent, document);
return accessible.forget();
}
Accessible* accessible = new HTMLLinkAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLLinkAccessible(aContent, document);
return accessible.forget();
}
if (aContext->IsList()) {
@ -1406,15 +1401,15 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
// accessible for other elements styled as list items.
if (aContext->GetContent() == aContent->GetParent()) {
if (tag == nsGkAtoms::dt || tag == nsGkAtoms::li) {
Accessible* accessible = new HTMLLIAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLLIAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::dd) {
Accessible* accessible = new HyperTextAccessibleWrap(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HyperTextAccessibleWrap(aContent, document);
return accessible.forget();
}
}
@ -1432,22 +1427,21 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
tag == nsGkAtoms::h5 ||
tag == nsGkAtoms::h6 ||
tag == nsGkAtoms::q) {
Accessible* accessible = new HyperTextAccessibleWrap(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HyperTextAccessibleWrap(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::output) {
Accessible* accessible = new HTMLOutputAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new HTMLOutputAccessible(aContent, document);
return accessible.forget();
}
if (tag == nsGkAtoms::progress) {
Accessible* accessible =
nsRefPtr<Accessible> accessible =
new HTMLProgressMeterAccessible(aContent, document);
NS_ADDREF(accessible);
return accessible;
return accessible.forget();
}
return nullptr;
@ -1663,15 +1657,15 @@ nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent,
// Outline of list accessible.
if (count == 1) {
Accessible* accessible = new XULTreeAccessible(aContent, aDoc, treeFrame);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new XULTreeAccessible(aContent, aDoc, treeFrame);
return accessible.forget();
}
// Table or tree table accessible.
Accessible* accessible = new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame);
NS_ADDREF(accessible);
return accessible;
nsRefPtr<Accessible> accessible =
new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame);
return accessible.forget();
}
#endif

View File

@ -517,9 +517,9 @@ nsCoreUtils::GetTreeBodyBoxObject(nsITreeBoxObject *aTreeBoxObj)
if (!tcXULElm)
return nullptr;
nsIBoxObject *boxObj = nullptr;
tcXULElm->GetBoxObject(&boxObj);
return boxObj;
nsCOMPtr<nsIBoxObject> boxObj;
tcXULElm->GetBoxObject(getter_AddRefs(boxObj));
return boxObj.forget();
}
already_AddRefed<nsITreeBoxObject>

View File

@ -2847,9 +2847,7 @@ Accessible::SelectedItems()
while ((selected = iter.Next()))
selectedItems->AppendElement(selected, false);
nsIMutableArray* items = nullptr;
selectedItems.forget(&items);
return items;
return selectedItems.forget();
}
uint32_t

View File

@ -150,10 +150,8 @@ public:
*/
inline already_AddRefed<nsIDOMNode> DOMNode() const
{
nsIDOMNode *DOMNode = nullptr;
if (GetNode())
CallQueryInterface(GetNode(), &DOMNode);
return DOMNode;
nsCOMPtr<nsIDOMNode> DOMNode = do_QueryInterface(GetNode());
return DOMNode.forget();
}
/**

View File

@ -300,10 +300,10 @@ XULLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
nsIDocument* document = mContent->OwnerDoc();
nsIURI* anchorURI = nullptr;
NS_NewURI(&anchorURI, href,
nsCOMPtr<nsIURI> anchorURI;
NS_NewURI(getter_AddRefs(anchorURI), href,
document->GetDocumentCharacterSet().get(),
baseURI);
return anchorURI;
return anchorURI.forget();
}

View File

@ -864,9 +864,6 @@ XULTextFieldAccessible::GetInputField() const
NS_ASSERTION(inputFieldDOMNode, "No input field for XULTextFieldAccessible");
nsIContent* inputField = nullptr;
if (inputFieldDOMNode)
CallQueryInterface(inputFieldDOMNode, &inputField);
return inputField;
nsCOMPtr<nsIContent> inputField = do_QueryInterface(inputFieldDOMNode);
return inputField.forget();
}

View File

@ -83,9 +83,7 @@ XULSelectControlAccessible::SelectedItems()
}
}
nsIMutableArray* items = nullptr;
selectedItems.forget(&items);
return items;
return selectedItems.forget();
}
Accessible*

View File

@ -275,9 +275,7 @@ XULTreeAccessible::SelectedItems()
}
}
nsIMutableArray* items = nullptr;
selectedItems.forget(&items);
return items;
return selectedItems.forget();
}
uint32_t

View File

@ -133,8 +133,8 @@ nsChromeRegistry::GetService()
if (!gChromeRegistry)
return nullptr;
}
NS_ADDREF(gChromeRegistry);
return gChromeRegistry;
nsCOMPtr<nsIChromeRegistry> registry = gChromeRegistry;
return registry.forget();
}
nsresult
@ -632,8 +632,8 @@ already_AddRefed<nsChromeRegistry>
nsChromeRegistry::GetSingleton()
{
if (gChromeRegistry) {
NS_ADDREF(gChromeRegistry);
return gChromeRegistry;
nsRefPtr<nsChromeRegistry> registry = gChromeRegistry;
return registry.forget();
}
nsRefPtr<nsChromeRegistry> cr;

View File

@ -247,11 +247,8 @@ public:
*/
already_AddRefed<nsILoadGroup> GetDocumentLoadGroup() const
{
nsILoadGroup *group = nullptr;
if (mDocumentLoadGroup)
CallQueryReferent(mDocumentLoadGroup.get(), &group);
return group;
nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
return group.forget();
}
/**
@ -1080,11 +1077,8 @@ public:
*/
already_AddRefed<nsISupports> GetContainer() const
{
nsISupports* container = nullptr;
if (mDocumentContainer)
CallQueryReferent(mDocumentContainer.get(), &container);
return container;
nsCOMPtr<nsISupports> container = do_QueryReferent(mDocumentContainer);
return container.forget();
}
/**

View File

@ -133,7 +133,6 @@ Attr::GetName(nsAString& aName)
already_AddRefed<nsIAtom>
Attr::GetNameAtom(nsIContent* aContent)
{
nsIAtom* result = nullptr;
if (!mNsAware &&
mNodeInfo->NamespaceID() == kNameSpaceID_None &&
aContent->IsInHTMLDocument() &&
@ -142,13 +141,10 @@ Attr::GetNameAtom(nsIContent* aContent)
mNodeInfo->GetName(name);
nsAutoString lowercaseName;
nsContentUtils::ASCIIToLower(name, lowercaseName);
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(lowercaseName);
nameAtom.swap(result);
} else {
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
nameAtom.swap(result);
return do_GetAtom(lowercaseName);
}
return result;
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
return nameAtom.forget();
}
NS_IMETHODIMP

View File

@ -1443,17 +1443,17 @@ Element::GetExistingAttrNameFromQName(const nsAString& aStr) const
return nullptr;
}
nsINodeInfo* nodeInfo;
nsCOMPtr<nsINodeInfo> nodeInfo;
if (name->IsAtom()) {
nodeInfo = mNodeInfo->NodeInfoManager()->
GetNodeInfo(name->Atom(), nullptr, kNameSpaceID_None,
nsIDOMNode::ATTRIBUTE_NODE).get();
nsIDOMNode::ATTRIBUTE_NODE);
}
else {
NS_ADDREF(nodeInfo = name->NodeInfo());
nodeInfo = name->NodeInfo();
}
return nodeInfo;
return nodeInfo.forget();
}
// static

View File

@ -691,9 +691,7 @@ FragmentOrElement::GetChildren(uint32_t aFilter)
}
}
nsINodeList* returnList = nullptr;
list.forget(&returnList);
return returnList;
return list.forget();
}
static nsIContent*

View File

@ -209,7 +209,7 @@ nsAttrAndChildArray::TakeChildAt(uint32_t aPos)
memmove(pos, pos + 1, (childCount - aPos - 1) * sizeof(nsIContent*));
SetChildCount(childCount - 1);
return child;
return dont_AddRef(child);
}
int32_t

View File

@ -739,9 +739,8 @@ nsAttrValue::GetAsAtom() const
case eAtom:
{
nsIAtom* atom = GetAtomValue();
NS_ADDREF(atom);
return atom;
nsCOMPtr<nsIAtom> atom = GetAtomValue();
return atom.forget();
}
default:

View File

@ -274,8 +274,8 @@ DragDataProducer::FindParentLinkNode(nsIContent* inNode)
for (; content; content = content->GetParent()) {
if (nsContentUtils::IsDraggableLink(content)) {
NS_ADDREF(content);
return content;
nsCOMPtr<nsIContent> ret = content;
return ret.forget();
}
}

View File

@ -196,7 +196,7 @@ NS_GetContentList(nsINode* aRootNode,
{
NS_ASSERTION(aRootNode, "content list has to have a root");
nsContentList* list = nullptr;
nsRefPtr<nsContentList> list;
static PLDHashTableOps hash_table_ops =
{
@ -255,9 +255,7 @@ NS_GetContentList(nsINode* aRootNode,
}
}
NS_ADDREF(list);
return list;
return list.forget();
}
#ifdef DEBUG
@ -319,7 +317,7 @@ GetFuncStringContentList(nsINode* aRootNode,
{
NS_ASSERTION(aRootNode, "content list has to have a root");
nsCacheableFuncStringContentList* list = nullptr;
nsRefPtr<nsCacheableFuncStringContentList> list;
static PLDHashTableOps hash_table_ops =
{
@ -373,11 +371,9 @@ GetFuncStringContentList(nsINode* aRootNode,
}
}
NS_ADDREF(list);
// Don't cache these lists globally
return list;
return list.forget();
}
already_AddRefed<nsContentList>

View File

@ -5261,12 +5261,12 @@ nsContentUtils::HidePopupsInDocument(nsIDocument* aDocument)
already_AddRefed<nsIDragSession>
nsContentUtils::GetDragSession()
{
nsIDragSession* dragSession = nullptr;
nsCOMPtr<nsIDragSession> dragSession;
nsCOMPtr<nsIDragService> dragService =
do_GetService("@mozilla.org/widget/dragservice;1");
if (dragService)
dragService->GetCurrentSession(&dragSession);
return dragSession;
dragService->GetCurrentSession(getter_AddRefs(dragSession));
return dragSession.forget();
}
/* static */
@ -5836,15 +5836,13 @@ nsContentUtils::GetDocumentFromScriptContext(nsIScriptContext *aScriptContext)
nsCOMPtr<nsIDOMWindow> window =
do_QueryInterface(aScriptContext->GetGlobalObject());
nsIDocument *doc = nullptr;
nsCOMPtr<nsIDocument> doc;
if (window) {
nsCOMPtr<nsIDOMDocument> domdoc;
window->GetDocument(getter_AddRefs(domdoc));
if (domdoc) {
CallQueryInterface(domdoc, &doc);
}
doc = do_QueryInterface(domdoc);
}
return doc;
return doc.forget();
}
/* static */

View File

@ -7664,17 +7664,17 @@ nsDocument::RemovedFromDocShell()
already_AddRefed<nsILayoutHistoryState>
nsDocument::GetLayoutHistoryState() const
{
nsILayoutHistoryState* state = nullptr;
nsCOMPtr<nsILayoutHistoryState> state;
if (!mScriptGlobalObject) {
NS_IF_ADDREF(state = mLayoutHistoryState);
state = mLayoutHistoryState;
} else {
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocumentContainer));
if (docShell) {
docShell->GetLayoutHistoryState(&state);
docShell->GetLayoutHistoryState(getter_AddRefs(state));
}
}
return state;
return state.forget();
}
void

View File

@ -242,11 +242,9 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
if (node) {
nsINodeInfo* nodeInfo = static_cast<nsINodeInfo *>(node);
nsCOMPtr<nsINodeInfo> nodeInfo = static_cast<nsINodeInfo*>(node);
NS_ADDREF(nodeInfo);
return nodeInfo;
return nodeInfo.forget();
}
nsRefPtr<nsNodeInfo> newNodeInfo =
@ -263,10 +261,7 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
NS_IF_ADDREF(mDocument);
}
nsNodeInfo *nodeInfo = nullptr;
newNodeInfo.swap(nodeInfo);
return nodeInfo;
return newNodeInfo.forget();
}

View File

@ -986,9 +986,8 @@ nsObjectLoadingContent::GetFrameLoader(nsIFrameLoader** aFrameLoader)
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
nsObjectLoadingContent::GetFrameLoader()
{
nsFrameLoader* loader = mFrameLoader;
NS_IF_ADDREF(loader);
return loader;
nsRefPtr<nsFrameLoader> loader = mFrameLoader;
return loader.forget();
}
NS_IMETHODIMP

View File

@ -1533,22 +1533,17 @@ RangeSubtreeIterator::Init(nsIDOMRange *aRange)
already_AddRefed<nsIDOMNode>
RangeSubtreeIterator::GetCurrentNode()
{
nsIDOMNode *node = nullptr;
nsCOMPtr<nsIDOMNode> node;
if (mIterState == eUseStart && mStart) {
NS_ADDREF(node = mStart);
} else if (mIterState == eUseEnd && mEnd)
NS_ADDREF(node = mEnd);
else if (mIterState == eUseIterator && mIter)
{
nsINode* n = mIter->GetCurrentNode();
if (n) {
CallQueryInterface(n, &node);
}
node = mStart;
} else if (mIterState == eUseEnd && mEnd) {
node = mEnd;
} else if (mIterState == eUseIterator && mIter) {
node = do_QueryInterface(mIter->GetCurrentNode());
}
return node;
return node.forget();
}
void

View File

@ -3715,8 +3715,8 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
static_cast<CanvasRenderingContext2DUserData*>(
aOldLayer->GetUserData(&g2DContextLayerUserData));
if (userData && userData->IsForContext(this)) {
NS_ADDREF(aOldLayer);
return aOldLayer;
nsRefPtr<CanvasLayer> ret = aOldLayer;
return ret.forget();
}
}

View File

@ -837,8 +837,8 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
if (!mResetLayer && aOldLayer &&
aOldLayer->HasUserData(&gWebGLLayerUserData)) {
NS_ADDREF(aOldLayer);
return aOldLayer;
nsRefPtr<layers::CanvasLayer> ret = aOldLayer;
return ret.forget();
}
nsRefPtr<CanvasLayer> canvasLayer = aManager->CreateCanvasLayer();
@ -880,7 +880,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
mResetLayer = false;
return canvasLayer.forget().get();
return canvasLayer.forget();
}
void

View File

@ -2816,16 +2816,15 @@ WebGLContext::GetUniformLocation(WebGLProgram *prog, const nsAString& name)
MakeContextCurrent();
GLint intlocation = gl->fGetUniformLocation(progname, mappedName.get());
WebGLUniformLocation *loc = nullptr;
nsRefPtr<WebGLUniformLocation> loc;
if (intlocation >= 0) {
WebGLUniformInfo info = prog->GetUniformInfoForMappedIdentifier(mappedName);
loc = new WebGLUniformLocation(this,
prog,
intlocation,
info);
NS_ADDREF(loc);
}
return loc;
return loc.forget();
}
JS::Value
@ -4674,10 +4673,9 @@ WebGLContext::GetShaderPrecisionFormat(WebGLenum shadertype, WebGLenum precision
GLint range[2], precision;
gl->fGetShaderPrecisionFormat(shadertype, precisiontype, range, &precision);
WebGLShaderPrecisionFormat *retShaderPrecisionFormat
nsRefPtr<WebGLShaderPrecisionFormat> retShaderPrecisionFormat
= new WebGLShaderPrecisionFormat(this, range[0], range[1], precision);
NS_ADDREF(retShaderPrecisionFormat);
return retShaderPrecisionFormat;
return retShaderPrecisionFormat.forget();
}
void

View File

@ -67,9 +67,7 @@ NS_METHOD_(already_AddRefed<nsIPrivateTextRangeList>) nsDOMTextEvent::GetInputRa
{
if (mEvent->message == NS_TEXT_TEXT) {
nsRefPtr<nsPrivateTextRangeList> textRange = mTextRange;
nsPrivateTextRangeList *textRangePtr = nullptr;
textRange.swap(textRangePtr);
return textRangePtr;
return textRange.forget();
}
return nullptr;
}

View File

@ -274,7 +274,7 @@ nsDOMUIEvent::GetRangeParent()
!nsContentUtils::CanAccessNativeAnon()) {
return nullptr;
}
return parent.forget().get();
return parent.forget();
}
}

View File

@ -4616,20 +4616,20 @@ nsEventStateManager::GetEventTargetContent(nsEvent* aEvent)
return content.forget();
}
nsIContent *content = nullptr;
nsCOMPtr<nsIContent> content;
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
content = presShell->GetEventTargetContent(aEvent).get();
content = presShell->GetEventTargetContent(aEvent);
}
// Some events here may set mCurrentTarget but not set the corresponding
// event target in the PresShell.
if (!content && mCurrentTarget) {
mCurrentTarget->GetContentForEvent(aEvent, &content);
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(content));
}
return content;
return content.forget();
}
static Element*

View File

@ -60,11 +60,6 @@ NS_METHOD_(uint16_t) nsPrivateTextRangeList::GetLength()
NS_METHOD_(already_AddRefed<nsIPrivateTextRange>) nsPrivateTextRangeList::Item(uint16_t aIndex)
{
nsRefPtr<nsPrivateTextRange> ret = mList.ElementAt(aIndex);
if (ret) {
nsPrivateTextRange *retPtr = nullptr;
ret.swap(retPtr);
return retPtr;
}
return nullptr;
return ret.forget();
}

View File

@ -339,10 +339,9 @@ HTMLAnchorElement::GetLinkState() const
already_AddRefed<nsIURI>
HTMLAnchorElement::GetHrefURI() const
{
nsIURI* uri = Link::GetCachedURI();
nsCOMPtr<nsIURI> uri = Link::GetCachedURI();
if (uri) {
NS_ADDREF(uri);
return uri;
return uri.forget();
}
return GetHrefURIForAnchors();

View File

@ -1388,9 +1388,9 @@ already_AddRefed<nsISupports>
nsHTMLFormElement::DoResolveName(const nsAString& aName,
bool aFlushContent)
{
nsISupports *result;
NS_IF_ADDREF(result = mControls->NamedItemInternal(aName, aFlushContent));
return result;
nsCOMPtr<nsISupports> result =
mControls->NamedItemInternal(aName, aFlushContent);
return result.forget();
}
void

View File

@ -495,10 +495,9 @@ CreateHTMLElement(uint32_t aNodeType, already_AddRefed<nsINodeInfo> aNodeInfo,
NS_ASSERTION(cb != NS_NewHTMLNOTUSEDElement,
"Don't know how to construct tag element!");
nsGenericHTMLElement* result = cb(aNodeInfo, aFromParser);
NS_IF_ADDREF(result);
nsRefPtr<nsGenericHTMLElement> result = cb(aNodeInfo, aFromParser);
return result;
return result.forget();
}
//----------------------------------------------------------------------

View File

@ -1470,35 +1470,35 @@ nsHTMLDocument::Open(JSContext* cx,
// Note that aborting a parser leaves the parser "active" with its
// insertion point "not undefined". We track this using mParserAborted,
// because aborting a parser nulls out mParser.
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
// No calling document.open() without a script global object
if (!mScriptGlobalObject) {
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
nsPIDOMWindow* outer = GetWindow();
if (!outer || (GetInnerWindow() != outer->GetCurrentInnerWindow())) {
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
// check whether we're in the middle of unload. If so, ignore this call.
nsCOMPtr<nsIDocShell> shell = do_QueryReferent(mDocumentContainer);
if (!shell) {
// We won't be able to create a parser anyway.
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
bool inUnload;
shell->GetIsInUnload(&inUnload);
if (inUnload) {
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
// Note: We want to use GetDocumentFromContext here because this document
@ -1563,8 +1563,8 @@ nsHTMLDocument::Open(JSContext* cx,
if (NS_SUCCEEDED(cv->PermitUnload(false, &okToUnload)) && !okToUnload) {
// We don't want to unload, so stop here, but don't throw an
// exception.
NS_ADDREF_THIS();
return this;
nsCOMPtr<nsIDocument> ret = this;
return ret.forget();
}
}

View File

@ -71,10 +71,10 @@ SpeechSynthesisUtterance::Constructor(GlobalObject& aGlobal,
}
MOZ_ASSERT(win->IsInnerWindow());
SpeechSynthesisUtterance* object = new SpeechSynthesisUtterance(aText);
NS_ADDREF(object);
nsRefPtr<SpeechSynthesisUtterance> object =
new SpeechSynthesisUtterance(aText);
object->BindToOwner(win);
return object;
return object.forget();
}
void

View File

@ -516,11 +516,11 @@ nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
aUtterance.mVoice->GetVoiceURI(uri);
}
nsSpeechTask* task;
nsRefPtr<nsSpeechTask> task;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
task = new SpeechTaskChild(&aUtterance);
SpeechSynthesisRequestChild* actor =
new SpeechSynthesisRequestChild(static_cast<SpeechTaskChild*>(task));
new SpeechSynthesisRequestChild(static_cast<SpeechTaskChild*>(task.get()));
mSpeechSynthChild->SendPSpeechSynthesisRequestConstructor(actor,
aUtterance.mText,
lang,
@ -534,8 +534,7 @@ nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
aUtterance.Rate(), aUtterance.Pitch(), task);
}
NS_IF_ADDREF(task);
return task;
return task.forget();
}
void

View File

@ -34,7 +34,7 @@ SVGTests::RequiredFeatures()
nsCOMPtr<nsIDOMSVGElement> elem = do_QueryInterface(this);
nsSVGElement* element = static_cast<nsSVGElement*>(elem.get());
return DOMSVGStringList::GetDOMWrapper(
&mStringListAttributes[FEATURES], element, true, FEATURES).get();
&mStringListAttributes[FEATURES], element, true, FEATURES);
}
already_AddRefed<DOMSVGStringList>
@ -43,7 +43,7 @@ SVGTests::RequiredExtensions()
nsCOMPtr<nsIDOMSVGElement> elem = do_QueryInterface(this);
nsSVGElement* element = static_cast<nsSVGElement*>(elem.get());
return DOMSVGStringList::GetDOMWrapper(
&mStringListAttributes[EXTENSIONS], element, true, EXTENSIONS).get();
&mStringListAttributes[EXTENSIONS], element, true, EXTENSIONS);
}
already_AddRefed<DOMSVGStringList>
@ -52,7 +52,7 @@ SVGTests::SystemLanguage()
nsCOMPtr<nsIDOMSVGElement> elem = do_QueryInterface(this);
nsSVGElement* element = static_cast<nsSVGElement*>(elem.get());
return DOMSVGStringList::GetDOMWrapper(
&mStringListAttributes[LANGUAGE], element, true, LANGUAGE).get();
&mStringListAttributes[LANGUAGE], element, true, LANGUAGE);
}
bool

View File

@ -24,7 +24,7 @@ SVGTransformableElement::Transform()
// We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
// to allocate the SVGAnimatedTransformList if it hasn't already done so:
return SVGAnimatedTransformList::GetDOMWrapper(
GetAnimatedTransformList(DO_ALLOCATE), this).get();
GetAnimatedTransformList(DO_ALLOCATE), this);
}

View File

@ -317,9 +317,8 @@ nsXBLPrototypeBinding::SetBasePrototype(nsXBLPrototypeBinding* aBinding)
already_AddRefed<nsIContent>
nsXBLPrototypeBinding::GetBindingElement()
{
nsIContent* result = mBinding;
NS_IF_ADDREF(result);
return result;
nsCOMPtr<nsIContent> result = mBinding;
return result.forget();
}
void

View File

@ -138,9 +138,7 @@ nsXBLPrototypeHandler::GetHandlerElement()
{
if (mType & NS_HANDLER_TYPE_XUL) {
nsCOMPtr<nsIContent> element = do_QueryReferent(mHandlerElement);
nsIContent* el = nullptr;
element.swap(el);
return el;
return element.forget();
}
return nullptr;
@ -574,9 +572,8 @@ nsXBLPrototypeHandler::DispatchXULKeyCommand(nsIDOMEvent* aEvent)
already_AddRefed<nsIAtom>
nsXBLPrototypeHandler::GetEventName()
{
nsIAtom* eventName = mEventName;
NS_IF_ADDREF(eventName);
return eventName;
nsCOMPtr<nsIAtom> eventName = mEventName;
return eventName.forget();
}
already_AddRefed<nsIController>
@ -611,13 +608,12 @@ nsXBLPrototypeHandler::GetController(EventTarget* aTarget)
// Return the first controller.
// XXX This code should be checking the command name and using supportscommand and
// iscommandenabled.
nsIController* controller;
nsCOMPtr<nsIController> controller;
if (controllers) {
controllers->GetControllerAt(0, &controller); // return reference
controllers->GetControllerAt(0, getter_AddRefs(controller));
}
else controller = nullptr;
return controller;
return controller.forget();
}
bool

View File

@ -346,10 +346,8 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
if (aNode.isContent()) {
if (aNode.mNode->IsElement()) {
nsIAtom* localName = aNode.Content()->Tag();
NS_ADDREF(localName);
return localName;
nsCOMPtr<nsIAtom> localName = aNode.Content()->Tag();
return localName.forget();
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
@ -363,11 +361,10 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
return nullptr;
}
nsIAtom* localName = aNode.Content()->
nsCOMPtr<nsIAtom> localName = aNode.Content()->
GetAttrNameAt(aNode.mIndex)->LocalName();
NS_ADDREF(localName);
return localName;
return localName.forget();
}
nsIAtom*

View File

@ -225,10 +225,8 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsINodeInfo *aNodeInfo,
bool aIsScriptable, bool aIsRoot)
{
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
nsXULElement *element = new nsXULElement(ni.forget());
nsRefPtr<nsXULElement> element = new nsXULElement(ni.forget());
if (element) {
NS_ADDREF(element);
if (aPrototype->mHasIdAttribute) {
element->SetHasID();
}
@ -259,7 +257,7 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsINodeInfo *aNodeInfo,
}
}
return element;
return element.forget();
}
nsresult
@ -1474,9 +1472,8 @@ nsXULElement::GetFrameLoader()
if (!slots)
return nullptr;
nsFrameLoader* loader = slots->mFrameLoader;
NS_IF_ADDREF(loader);
return loader;
nsRefPtr<nsFrameLoader> loader = slots->mFrameLoader;
return loader.forget();
}
nsresult

View File

@ -300,8 +300,8 @@ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag)
child;
child = child->GetNextSibling()) {
if (child->Tag() == aTag) {
NS_ADDREF(child);
return child;
nsCOMPtr<nsIContent> ret = child;
return ret.forget();
}
}

View File

@ -1249,7 +1249,7 @@ XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
{
nsCOMPtr<nsIAtom> attrAtom(do_GetAtom(aAttribute));
void* attrValue = new nsString(aValue);
nsContentList *list = new nsContentList(this,
nsRefPtr<nsContentList> list = new nsContentList(this,
MatchAttribute,
nsContentUtils::DestroyMatchString,
attrValue,
@ -1257,8 +1257,7 @@ XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
attrAtom,
kNameSpaceID_Unknown);
NS_ADDREF(list);
return list;
return list.forget();
}
NS_IMETHODIMP
@ -1293,15 +1292,14 @@ XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
}
}
nsContentList *list = new nsContentList(this,
nsRefPtr<nsContentList> list = new nsContentList(this,
MatchAttribute,
nsContentUtils::DestroyMatchString,
attrValue,
true,
attrAtom,
nameSpaceId);
NS_ADDREF(list);
return list;
return list.forget();
}
NS_IMETHODIMP

View File

@ -4828,18 +4828,16 @@ static already_AddRefed<nsIDocShellTreeItem>
GetCallerDocShellTreeItem()
{
JSContext *cx = nsContentUtils::GetCurrentJSContext();
nsIDocShellTreeItem *callerItem = nullptr;
nsCOMPtr<nsIDocShellTreeItem> callerItem;
if (cx) {
nsCOMPtr<nsIWebNavigation> callerWebNav =
do_GetInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
if (callerWebNav) {
CallQueryInterface(callerWebNav, &callerItem);
}
callerItem = do_QueryInterface(callerWebNav);
}
return callerItem;
return callerItem.forget();
}
bool
@ -4869,13 +4867,13 @@ nsGlobalWindow::GetMainWidget()
{
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
nsIWidget *widget = nullptr;
nsCOMPtr<nsIWidget> widget;
if (treeOwnerAsWin) {
treeOwnerAsWin->GetMainWidget(&widget);
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
}
return widget;
return widget.forget();
}
nsIWidget*

View File

@ -679,13 +679,9 @@ GetPromptFromContext(nsJSContext* ctx)
nsIDocShell *docShell = win->GetDocShell();
NS_ENSURE_TRUE(docShell, nullptr);
nsCOMPtr<nsIInterfaceRequestor> ireq(do_QueryInterface(docShell));
NS_ENSURE_TRUE(ireq, nullptr);
// Get the nsIPrompt interface from the docshell
nsIPrompt* prompt;
ireq->GetInterface(NS_GET_IID(nsIPrompt), (void**)&prompt);
return prompt;
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(docShell);
return prompt.forget();
}
JSBool

View File

@ -354,10 +354,9 @@ nsNPAPIPluginInstance::GetDOMWindow()
if (!doc)
return nullptr;
nsPIDOMWindow *window = doc->GetWindow();
NS_IF_ADDREF(window);
nsRefPtr<nsPIDOMWindow> window = doc->GetWindow();
return window;
return window.forget();
}
nsresult

View File

@ -336,8 +336,8 @@ nsPluginHost::GetInst()
NS_ADDREF(sInst);
}
NS_ADDREF(sInst);
return sInst;
nsRefPtr<nsPluginHost> inst = sInst;
return inst.forget();
}
bool nsPluginHost::IsRunningPlugin(nsPluginTag * aPluginTag)

View File

@ -362,9 +362,7 @@ nsComposerCommandsUpdater::GetCommandUpdater()
NS_ENSURE_TRUE(docShell, nullptr);
nsCOMPtr<nsICommandManager> manager = do_GetInterface(docShell);
nsCOMPtr<nsPICommandUpdater> updater = do_QueryInterface(manager);
nsPICommandUpdater* retVal = nullptr;
updater.swap(retVal);
return retVal;
return updater.forget();
}
#if 0

View File

@ -57,24 +57,23 @@ nsTransactionStack::PopBottom()
already_AddRefed<nsTransactionItem>
nsTransactionStack::Peek()
{
nsTransactionItem* transaction = nullptr;
nsRefPtr<nsTransactionItem> transaction;
if (mQue.GetSize()) {
NS_IF_ADDREF(transaction = static_cast<nsTransactionItem*>(mQue.Last()));
transaction = static_cast<nsTransactionItem*>(mQue.Last());
}
return transaction;
return transaction.forget();
}
already_AddRefed<nsTransactionItem>
nsTransactionStack::GetItem(int32_t aIndex)
{
nsTransactionItem* transaction = nullptr;
nsRefPtr<nsTransactionItem> transaction;
if (aIndex >= 0 && aIndex < mQue.GetSize()) {
NS_IF_ADDREF(transaction =
static_cast<nsTransactionItem*>(mQue.ObjectAt(aIndex)));
transaction = static_cast<nsTransactionItem*>(mQue.ObjectAt(aIndex));
}
return transaction;
return transaction.forget();
}
void

View File

@ -1718,22 +1718,20 @@ already_AddRefed<nsIDocShellTreeItem>
nsWindowWatcher::GetCallerTreeItem(nsIDocShellTreeItem* aParentItem)
{
JSContext *cx = nsContentUtils::GetCurrentJSContext();
nsIDocShellTreeItem* callerItem = nullptr;
nsCOMPtr<nsIDocShellTreeItem> callerItem;
if (cx) {
nsCOMPtr<nsIWebNavigation> callerWebNav =
do_GetInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
if (callerWebNav) {
CallQueryInterface(callerWebNav, &callerItem);
}
callerItem = do_QueryInterface(callerWebNav);
}
if (!callerItem) {
NS_IF_ADDREF(callerItem = aParentItem);
callerItem = aParentItem;
}
return callerItem;
return callerItem.forget();
}
nsresult

View File

@ -530,7 +530,7 @@ PlanarYCbCrImage::GetAsSurface()
mSurface = imageSurface;
return imageSurface.forget().get();
return imageSurface.forget();
}
already_AddRefed<gfxASurface>

View File

@ -97,10 +97,9 @@ GLTexture::Release()
mContext->MakeCurrent();
mContext->fDeleteTextures(1, &mTexture);
} else {
nsCOMPtr<nsIRunnable> runnable =
new TextureDeleter(mContext.get(), mTexture);
mContext->DispatchToOwningThread(runnable);
mContext.forget();
already_AddRefed<GLContext> context = mContext.forget();
nsCOMPtr<nsIRunnable> runnable = new TextureDeleter(context, mTexture);
context.get()->DispatchToOwningThread(runnable);
}
mTexture = 0;

View File

@ -126,14 +126,13 @@ gfxASurface::SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf)
already_AddRefed<gfxASurface>
gfxASurface::Wrap (cairo_surface_t *csurf)
{
gfxASurface *result;
nsRefPtr<gfxASurface> result;
/* Do we already have a wrapper for this surface? */
result = GetSurfaceWrapper(csurf);
if (result) {
// fprintf(stderr, "Existing wrapper for %p -> %p\n", csurf, result);
NS_ADDREF(result);
return result;
return result.forget();
}
/* No wrapper; figure out the surface type and create it */
@ -177,8 +176,7 @@ gfxASurface::Wrap (cairo_surface_t *csurf)
// fprintf(stderr, "New wrapper for %p -> %p\n", csurf, result);
NS_ADDREF(result);
return result;
return result.forget();
}
void

View File

@ -148,9 +148,8 @@ gfxContext::CurrentSurface(gfxFloat *dx, gfxFloat *dy)
if (s == mSurface->CairoSurface()) {
if (dx && dy)
cairo_surface_get_device_offset(s, dx, dy);
gfxASurface *ret = mSurface;
NS_ADDREF(ret);
return ret;
nsRefPtr<gfxASurface> ret = mSurface;
return ret.forget();
}
if (dx && dy)
@ -1374,14 +1373,13 @@ gfxContext::GetPattern()
cairo_pattern_t *pat = cairo_get_source(mCairo);
NS_ASSERTION(pat, "I was told this couldn't be null");
gfxPattern *wrapper = nullptr;
nsRefPtr<gfxPattern> wrapper;
if (pat)
wrapper = new gfxPattern(pat);
else
wrapper = new gfxPattern(gfxRGBA(0,0,0,0));
NS_IF_ADDREF(wrapper);
return wrapper;
return wrapper.forget();
} else {
nsRefPtr<gfxPattern> pat;
@ -1557,10 +1555,9 @@ gfxContext::PopGroup()
{
if (mCairo) {
cairo_pattern_t *pat = cairo_pop_group(mCairo);
gfxPattern *wrapper = new gfxPattern(pat);
nsRefPtr<gfxPattern> wrapper = new gfxPattern(pat);
cairo_pattern_destroy(pat);
NS_IF_ADDREF(wrapper);
return wrapper;
return wrapper.forget();
} else {
RefPtr<SourceSurface> src = mDT->Snapshot();
Point deviceOffset = CurrentState().deviceOffset;
@ -1664,10 +1661,9 @@ already_AddRefed<gfxFlattenedPath>
gfxContext::GetFlattenedPath()
{
if (mCairo) {
gfxFlattenedPath *path =
nsRefPtr<gfxFlattenedPath> path =
new gfxFlattenedPath(cairo_copy_path_flat(mCairo));
NS_IF_ADDREF(path);
return path;
return path.forget();
} else {
// XXX - Used by SVG, needs fixing.
return NULL;

View File

@ -202,9 +202,7 @@ gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle, bool aNeedsBold)
font = newFont;
gfxFontCache::GetCache()->AddNew(font);
}
gfxFont *f = nullptr;
font.swap(f);
return f;
return font.forget();
}
bool
@ -1255,9 +1253,8 @@ gfxFontCache::Lookup(const gfxFontEntry *aFontEntry,
if (!entry)
return nullptr;
gfxFont *font = entry->mFont;
NS_ADDREF(font);
return font;
nsRefPtr<gfxFont> font = entry->mFont;
return font.forget();
}
void
@ -4395,11 +4392,10 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
bool isVarSelector = gfxFontUtils::IsVarSelector(aCh);
if (!isJoinControl && !wasJoinCauser && !isVarSelector) {
gfxFont *firstFont = mFonts[0].Font();
nsRefPtr<gfxFont> firstFont = mFonts[0].Font();
if (firstFont->HasCharacter(aCh)) {
*aMatchType = gfxTextRange::kFontGroup;
firstFont->AddRef();
return firstFont;
return firstFont.forget();
}
// It's possible that another font in the family (e.g. regular face,
// where the requested style was italic) will support the character
@ -4418,16 +4414,16 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
// actually be rendered (see bug 716229)
uint8_t category = GetGeneralCategory(aCh);
if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) {
aPrevMatchedFont->AddRef();
return aPrevMatchedFont;
nsRefPtr<gfxFont> ret = aPrevMatchedFont;
return ret.forget();
}
// if this character is a join-control or the previous is a join-causer,
// use the same font as the previous range if we can
if (isJoinControl || wasJoinCauser) {
if (aPrevMatchedFont->HasCharacter(aCh)) {
aPrevMatchedFont->AddRef();
return aPrevMatchedFont;
nsRefPtr<gfxFont> ret = aPrevMatchedFont;
return ret.forget();
}
}
}
@ -4437,8 +4433,8 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
// otherwise the text run will be divided.
if (isVarSelector) {
if (aPrevMatchedFont) {
aPrevMatchedFont->AddRef();
return aPrevMatchedFont;
nsRefPtr<gfxFont> ret = aPrevMatchedFont;
return ret.forget();
}
// VS alone. it's meaningless to search different fonts
return nullptr;
@ -4475,8 +4471,8 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
// -- before searching for something else check the font used for the previous character
if (aPrevMatchedFont && aPrevMatchedFont->HasCharacter(aCh)) {
*aMatchType = gfxTextRange::kSystemFallback;
aPrevMatchedFont->AddRef();
return aPrevMatchedFont;
nsRefPtr<gfxFont> ret = aPrevMatchedFont;
return ret.forget();
}
// never fall back for characters from unknown scripts
@ -4637,7 +4633,7 @@ struct PrefFontCallbackData {
already_AddRefed<gfxFont>
gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
{
gfxFont *font;
nsRefPtr<gfxFont> font;
// get the pref font list if it hasn't been set up already
uint32_t unicodeRange = FindCharUnicodeRange(aCh);
@ -4647,8 +4643,7 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
if (mLastPrefFont && charLang == mLastPrefLang &&
mLastPrefFirstFont && mLastPrefFont->HasCharacter(aCh)) {
font = mLastPrefFont;
NS_ADDREF(font);
return font;
return font.forget();
}
// based on char lang and page lang, set up list of pref lang fonts to check
@ -4686,8 +4681,7 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
// pref font lookups
if (family == mLastPrefFamily && mLastPrefFont->HasCharacter(aCh)) {
font = mLastPrefFont;
NS_ADDREF(font);
return font;
return font.forget();
}
bool needsBold;

View File

@ -283,7 +283,7 @@ gfxImageSurface::GetSubimage(const gfxRect& aRect)
new gfxSubimageSurface(this, subData,
gfxIntSize((int)r.Width(), (int)r.Height()));
return image.forget().get();
return image.forget();
}
gfxSubimageSurface::gfxSubimageSurface(gfxImageSurface* aParent,

View File

@ -513,9 +513,7 @@ gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
tmpCtx.SetSource(aSurface);
tmpCtx.Paint();
gfxASurface *ret = optSurface;
NS_ADDREF(ret);
return ret;
return optSurface.forget();
}
cairo_user_data_key_t kDrawTarget;

View File

@ -611,9 +611,7 @@ already_AddRefed<imgCacheEntry> imgCacheQueue::Pop()
mQueue.pop_back();
mSize -= entry->GetDataSize();
imgCacheEntry *ret = entry;
NS_ADDREF(ret);
return ret;
return entry.forget();
}
void imgCacheQueue::Refresh()

View File

@ -103,9 +103,8 @@ public:
already_AddRefed<imgRequest> GetRequest() const
{
imgRequest *req = mRequest;
NS_ADDREF(req);
return req;
nsRefPtr<imgRequest> req = mRequest;
return req.forget();
}
bool Evicted() const

View File

@ -68,14 +68,10 @@ nsLanguageAtomService::LookupCharSet(const char *aCharSet, nsresult *aError)
return nullptr;
}
// transfer reference to raw pointer
nsIAtom *raw = nullptr;
langGroup.swap(raw);
if (aError)
*aError = NS_OK;
return raw;
return langGroup.forget();
}
nsIAtom*

View File

@ -151,8 +151,8 @@ jsds_FindEphemeral (LiveEphemeral **listHead, void *key)
{
if (lv_record->key == key)
{
NS_IF_ADDREF(lv_record->value);
return lv_record->value;
nsCOMPtr<jsdIEphemeral> ret = lv_record->value;
return ret.forget();
}
lv_record = reinterpret_cast<LiveEphemeral *>
(PR_NEXT_LINK(&lv_record->links));

View File

@ -4145,14 +4145,14 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState,
// we used the style that was passed in. So resolve another one.
nsStyleSet *styleSet = mPresShell->StyleSet();
nsStyleContext* aScrolledChildStyle =
styleSet->ResolveAnonymousBoxStyle(aScrolledPseudo, contentStyle).get();
nsRefPtr<nsStyleContext> scrolledChildStyle =
styleSet->ResolveAnonymousBoxStyle(aScrolledPseudo, contentStyle);
if (gfxScrollFrame) {
gfxScrollFrame->SetInitialChildList(kPrincipalList, anonymousItems);
}
return aScrolledChildStyle;
return scrolledChildStyle.forget();
}
void

View File

@ -1460,11 +1460,8 @@ nsPresContext::SetContainer(nsISupports* aHandler)
already_AddRefed<nsISupports>
nsPresContext::GetContainerInternal() const
{
nsISupports *result = nullptr;
if (mContainer)
CallQueryReferent(mContainer.get(), &result);
return result;
nsCOMPtr<nsISupports> result = do_QueryReferent(mContainer);
return result.forget();
}
already_AddRefed<nsISupports>

View File

@ -678,8 +678,8 @@ nsIPresShell::RemoveWeakFrameInternal(nsWeakFrame* aWeakFrame)
already_AddRefed<nsFrameSelection>
nsIPresShell::FrameSelection()
{
NS_IF_ADDREF(mSelection);
return mSelection;
nsRefPtr<nsFrameSelection> ret = mSelection;
return ret.forget();
}
//----------------------------------------------------------------------
@ -2024,9 +2024,8 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
already_AddRefed<nsCaret> PresShell::GetCaret() const
{
nsCaret* caret = mCaret;
NS_IF_ADDREF(caret);
return caret;
nsRefPtr<nsCaret> caret = mCaret;
return caret.forget();
}
void PresShell::MaybeInvalidateCaretPosition()
@ -4711,11 +4710,10 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
aScreenRect->width = pixelArea.width;
aScreenRect->height = pixelArea.height;
gfxImageSurface* surface =
nsRefPtr<gfxImageSurface> surface =
new gfxImageSurface(gfxIntSize(pixelArea.width, pixelArea.height),
gfxImageSurface::ImageFormatARGB32);
if (surface->CairoStatus()) {
delete surface;
return nullptr;
}
@ -4774,8 +4772,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
// restore the old selection display state
frameSelection->SetDisplaySelection(oldDisplaySelection);
NS_ADDREF(surface);
return surface;
return surface.forget();
}
already_AddRefed<gfxASurface>
@ -5673,20 +5670,16 @@ PresShell::GetEventTargetFrame()
already_AddRefed<nsIContent>
PresShell::GetEventTargetContent(nsEvent* aEvent)
{
nsIContent* content = GetCurrentEventContent();
if (content) {
NS_ADDREF(content);
} else {
nsCOMPtr<nsIContent> content = GetCurrentEventContent();
if (!content) {
nsIFrame* currentEventFrame = GetCurrentEventFrame();
if (currentEventFrame) {
currentEventFrame->GetContentForEvent(aEvent, &content);
currentEventFrame->GetContentForEvent(aEvent, getter_AddRefs(content));
NS_ASSERTION(!content || content->GetCurrentDoc() == mDocument,
"handing out content from a different doc");
} else {
content = nullptr;
}
}
return content;
return content.forget();
}
void
@ -5802,9 +5795,10 @@ PresShell::GetFocusedDOMWindowInOurWindow()
{
nsCOMPtr<nsPIDOMWindow> rootWindow = GetRootWindow();
NS_ENSURE_TRUE(rootWindow, nullptr);
nsPIDOMWindow* focusedWindow;
nsFocusManager::GetFocusedDescendant(rootWindow, true, &focusedWindow);
return focusedWindow;
nsCOMPtr<nsPIDOMWindow> focusedWindow;
nsFocusManager::GetFocusedDescendant(rootWindow, true,
getter_AddRefs(focusedWindow));
return focusedWindow.forget();
}
void

View File

@ -1018,17 +1018,13 @@ nsListControlFrame::Init(nsIContent* aContent,
already_AddRefed<nsIContent>
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection, int32_t aIndex)
{
nsIContent * content = nullptr;
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = GetOption(aCollection,
aIndex);
NS_ASSERTION(optionElement != nullptr, "could not get option element by index!");
if (optionElement) {
CallQueryInterface(optionElement, &content);
}
return content;
nsCOMPtr<nsIContent> content = do_QueryInterface(optionElement);
return content.forget();
}
already_AddRefed<nsIContent>
@ -1047,13 +1043,13 @@ nsListControlFrame::GetOptionContent(int32_t aIndex) const
already_AddRefed<nsIDOMHTMLOptionsCollection>
nsListControlFrame::GetOptions(nsIContent * aContent)
{
nsIDOMHTMLOptionsCollection* options = nullptr;
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = do_QueryInterface(aContent);
if (selectElement) {
selectElement->GetOptions(&options); // AddRefs (1)
selectElement->GetOptions(getter_AddRefs(options));
}
return options;
return options.forget();
}
already_AddRefed<nsIDOMHTMLOptionElement>
@ -1065,10 +1061,9 @@ nsListControlFrame::GetOption(nsIDOMHTMLOptionsCollection* aCollection,
NS_ASSERTION(node,
"Item was successful, but node from collection was null!");
if (node) {
nsIDOMHTMLOptionElement* option = nullptr;
CallQueryInterface(node, &option);
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
return option;
return option.forget();
}
} else {
NS_ERROR("Couldn't get option by index from collection!");

View File

@ -5485,10 +5485,9 @@ nsFrame::GetSelectionController(nsPresContext *aPresContext, nsISelectionControl
already_AddRefed<nsFrameSelection>
nsIFrame::GetFrameSelection()
{
nsFrameSelection* fs =
nsRefPtr<nsFrameSelection> fs =
const_cast<nsFrameSelection*>(GetConstFrameSelection());
NS_IF_ADDREF(fs);
return fs;
return fs.forget();
}
const nsFrameSelection*

View File

@ -1706,9 +1706,8 @@ GetReferenceRenderingContext(nsTextFrame* aTextFrame, nsRenderingContext* aRC)
return nullptr;
}
gfxContext* ctx = tmp->ThebesContext();
NS_ADDREF(ctx);
return ctx;
nsRefPtr<gfxContext> ctx = tmp->ThebesContext();
return ctx.forget();
}
/**

View File

@ -3115,15 +3115,15 @@ nsPrintEngine::FindFocusedDOMWindow()
nsCOMPtr<nsPIDOMWindow> rootWindow = window->GetPrivateRoot();
NS_ENSURE_TRUE(rootWindow, nullptr);
nsPIDOMWindow* focusedWindow;
nsFocusManager::GetFocusedDescendant(rootWindow, true, &focusedWindow);
nsCOMPtr<nsPIDOMWindow> focusedWindow;
nsFocusManager::GetFocusedDescendant(rootWindow, true,
getter_AddRefs(focusedWindow));
NS_ENSURE_TRUE(focusedWindow, nullptr);
if (IsWindowsInOurSubTree(focusedWindow)) {
return focusedWindow;
return focusedWindow.forget();
}
NS_IF_RELEASE(focusedWindow);
return nullptr;
}

View File

@ -1408,12 +1408,7 @@ StyleRule::GetExistingDOMRule()
StyleRule::DeclarationChanged(Declaration* aDecl,
bool aHandleContainer)
{
StyleRule* clone = new StyleRule(*this, aDecl);
if (!clone) {
return nullptr;
}
NS_ADDREF(clone); // for return
nsRefPtr<StyleRule> clone = new StyleRule(*this, aDecl);
if (aHandleContainer) {
nsCSSStyleSheet* sheet = GetStyleSheet();
@ -1428,7 +1423,7 @@ StyleRule::DeclarationChanged(Declaration* aDecl,
}
}
return clone;
return clone.forget();
}
/* virtual */ void

View File

@ -1573,13 +1573,12 @@ nsCSSStyleSheet::Clone(nsCSSStyleSheet* aCloneParent,
nsIDocument* aCloneDocument,
nsINode* aCloneOwningNode) const
{
nsCSSStyleSheet* clone = new nsCSSStyleSheet(*this,
aCloneParent,
aCloneOwnerRule,
aCloneDocument,
aCloneOwningNode);
NS_IF_ADDREF(clone);
return clone;
nsRefPtr<nsCSSStyleSheet> clone = new nsCSSStyleSheet(*this,
aCloneParent,
aCloneOwnerRule,
aCloneDocument,
aCloneOwningNode);
return clone.forget();
}
#ifdef DEBUG

View File

@ -316,8 +316,8 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement,
// for this element.
if (!result->HasPseudoElementData()) {
// this function returns an addrefed style context
result->AddRef();
return result;
nsRefPtr<nsStyleContext> ret = result;
return ret.forget();
}
}
}

View File

@ -455,8 +455,8 @@ nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped)
// We added a new entry to the hashtable, so we have a new unique set.
entry->mAttributes = aMapped;
}
NS_ADDREF(entry->mAttributes); // for caller
return entry->mAttributes;
nsRefPtr<nsMappedAttributes> ret = entry->mAttributes;
return ret.forget();
}
void

View File

@ -3616,7 +3616,8 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList,
NS_ABORT_IF_FALSE(arrayLength > 0,
"Non-null text-shadow list, yet we counted 0 items.");
nsCSSShadowArray* shadowList = new(arrayLength) nsCSSShadowArray(arrayLength);
nsRefPtr<nsCSSShadowArray> shadowList =
new(arrayLength) nsCSSShadowArray(arrayLength);
if (!shadowList)
return nullptr;
@ -3682,8 +3683,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList,
}
}
NS_ADDREF(shadowList);
return shadowList;
return shadowList.forget();
}
const void*

View File

@ -156,7 +156,7 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
uint32_t threshold = 10; // The # of siblings we're willing to examine
// before just giving this whole thing up.
nsStyleContext* result = nullptr;
nsRefPtr<nsStyleContext> result;
nsStyleContext *list = aRuleNode->IsRoot() ? mEmptyChild : mChild;
if (list) {
@ -191,12 +191,9 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
RemoveChild(result);
AddChild(result);
}
// Add reference for the caller.
result->AddRef();
}
return result;
return result.forget();
}
const void* nsStyleContext::GetCachedStyleData(nsStyleStructID aSID)
@ -720,12 +717,11 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
nsRuleNode* aRuleNode,
bool aSkipFlexItemStyleFixup)
{
nsStyleContext* context =
nsRefPtr<nsStyleContext> context =
new (aRuleNode->PresContext())
nsStyleContext(aParentContext, aPseudoTag, aPseudoType, aRuleNode,
aSkipFlexItemStyleFixup);
context->AddRef();
return context;
return context.forget();
}
static inline void

View File

@ -1664,8 +1664,8 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
// This short-circuit is OK because we don't call TryStartingTransition
// during style reresolution if the style context pointer hasn't changed.
if (aStyleContext->GetParent() == aNewParentContext) {
aStyleContext->AddRef();
return aStyleContext;
nsRefPtr<nsStyleContext> ret = aStyleContext;
return ret.forget();
}
nsIAtom* pseudoTag = aStyleContext->GetPseudo();

View File

@ -76,9 +76,7 @@ nsSVGFilterInstance::CreateImage()
surface->SetDeviceOffset(gfxPoint(-mSurfaceRect.x, -mSurfaceRect.y));
gfxImageSurface *retval = nullptr;
surface.swap(retval);
return retval;
return surface.forget();
}
gfxRect

View File

@ -523,9 +523,8 @@ nsSVGLinearGradientFrame::CreateGradient()
x2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_X2);
y2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y2);
gfxPattern *pattern = new gfxPattern(x1, y1, x2, y2);
NS_IF_ADDREF(pattern);
return pattern;
nsRefPtr<gfxPattern> pattern = new gfxPattern(x1, y1, x2, y2);
return pattern.forget();
}
// -------------------------------------------------------------------------
@ -672,9 +671,8 @@ nsSVGRadialGradientFrame::CreateGradient()
}
}
gfxPattern *pattern = new gfxPattern(fx, fy, 0, cx, cy, r);
NS_IF_ADDREF(pattern);
return pattern;
nsRefPtr<gfxPattern> pattern = new gfxPattern(fx, fy, 0, cx, cy, r);
return pattern.forget();
}
// -------------------------------------------------------------------------

View File

@ -126,10 +126,9 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsRenderingContext *aContext,
nsSVGUtils::ComputeAlphaMask(data, stride, rect, aOpacity);
}
gfxPattern *retval = new gfxPattern(image);
nsRefPtr<gfxPattern> retval = new gfxPattern(image);
retval->SetMatrix(matrix);
NS_IF_ADDREF(retval);
return retval;
return retval.forget();
}
/* virtual */ void

View File

@ -37,9 +37,9 @@ doc_viewer(nsIDocShell *aDocShell)
{
if (!aDocShell)
return nullptr;
nsIContentViewer *result = nullptr;
aDocShell->GetContentViewer(&result);
return result;
nsCOMPtr<nsIContentViewer> result;
aDocShell->GetContentViewer(getter_AddRefs(result));
return result.forget();
}
static already_AddRefed<nsIPresShell>
@ -73,9 +73,8 @@ document(nsIDocShell *aDocShell)
cv->GetDOMDocument(getter_AddRefs(domDoc));
if (!domDoc)
return nullptr;
nsIDocument *result = nullptr;
CallQueryInterface(domDoc, &result);
return result;
nsCOMPtr<nsIDocument> result = do_QueryInterface(domDoc);
return result.forget();
}
#endif

View File

@ -207,7 +207,6 @@ nsListBoxLayout::LayoutInternal(nsIFrame* aBox, nsBoxLayoutState& aState)
already_AddRefed<nsBoxLayout> NS_NewListBoxLayout()
{
nsBoxLayout* layout = new nsListBoxLayout();
NS_IF_ADDREF(layout);
return layout;
nsRefPtr<nsBoxLayout> layout = new nsListBoxLayout();
return layout.forget();
}

View File

@ -49,9 +49,8 @@ int32_t nsSliderFrame::gSnapMultiplier;
static already_AddRefed<nsIContent>
GetContentOfBox(nsIFrame *aBox)
{
nsIContent* content = aBox->GetContent();
NS_IF_ADDREF(content);
return content;
nsCOMPtr<nsIContent> content = aBox->GetContent();
return content.forget();
}
nsIFrame*

View File

@ -25,9 +25,8 @@
already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout()
{
nsBoxLayout* layout = new nsGridRowGroupLayout();
NS_IF_ADDREF(layout);
return layout;
nsRefPtr<nsBoxLayout> layout = new nsGridRowGroupLayout();
return layout.forget();
}
nsGridRowGroupLayout::nsGridRowGroupLayout():nsGridRowLayout(), mRowCount(0)

View File

@ -22,9 +22,8 @@
already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout()
{
nsBoxLayout* layout = new nsGridRowLeafLayout();
NS_IF_ADDREF(layout);
return layout;
nsRefPtr<nsBoxLayout> layout = new nsGridRowLeafLayout();
return layout.forget();
}
nsGridRowLeafLayout::nsGridRowLeafLayout():nsGridRowLayout()

View File

@ -402,9 +402,8 @@ public:
if (!aUnknownCol)
return nullptr;
nsTreeColumn* col;
aUnknownCol->QueryInterface(NS_GET_IID(nsTreeColumn), (void**)&col);
return col;
nsCOMPtr<nsTreeColumn> col = do_QueryInterface(aUnknownCol);
return col.forget();
}
/**

View File

@ -198,11 +198,10 @@ public:
CreateSourceStream(nsIDOMWindow* aWindow, uint32_t aHintContents) {
Fake_SourceMediaStream *source = new Fake_SourceMediaStream();
Fake_DOMMediaStream *ds = new Fake_DOMMediaStream(source);
nsRefPtr<Fake_DOMMediaStream> ds = new Fake_DOMMediaStream(source);
ds->SetHintContents(aHintContents);
ds->AddRef();
return ds;
return ds.forget();
}
Fake_MediaStream *GetStream() { return mMediaStream; }

View File

@ -1089,8 +1089,8 @@ NS_BufferOutputStream(nsIOutputStream *aOutputStream,
if (NS_SUCCEEDED(rv))
return bos.forget();
NS_ADDREF(aOutputStream);
return aOutputStream;
bos = aOutputStream;
return bos.forget();
}
// returns an input stream compatible with nsIUploadChannel::SetUploadStream()
@ -1626,21 +1626,21 @@ NS_TryToMakeImmutable(nsIURI* uri,
nsresult rv;
nsCOMPtr<nsINetUtil> util = do_GetNetUtil(&rv);
nsIURI* result = nullptr;
nsCOMPtr<nsIURI> result;
if (NS_SUCCEEDED(rv)) {
NS_ASSERTION(util, "do_GetNetUtil lied");
rv = util->ToImmutableURI(uri, &result);
rv = util->ToImmutableURI(uri, getter_AddRefs(result));
}
if (NS_FAILED(rv)) {
NS_IF_ADDREF(result = uri);
result = uri;
}
if (outRv) {
*outRv = rv;
}
return result;
return result.forget();
}
/**
@ -1664,22 +1664,23 @@ NS_URIChainHasFlags(nsIURI *uri,
* value could be just the object passed in if it's not a nested URI.
*/
inline already_AddRefed<nsIURI>
NS_GetInnermostURI(nsIURI *uri)
NS_GetInnermostURI(nsIURI* aURI)
{
NS_PRECONDITION(uri, "Must have URI");
NS_PRECONDITION(aURI, "Must have URI");
nsCOMPtr<nsIURI> uri = aURI;
nsCOMPtr<nsINestedURI> nestedURI(do_QueryInterface(uri));
if (!nestedURI) {
NS_ADDREF(uri);
return uri;
return uri.forget();
}
nsresult rv = nestedURI->GetInnermostURI(&uri);
nsresult rv = nestedURI->GetInnermostURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) {
return nullptr;
}
return uri;
return uri.forget();
}
/**

View File

@ -101,9 +101,8 @@ already_AddRefed<nsIThread>
nsSocketTransportService::GetThreadSafely()
{
MutexAutoLock lock(mLock);
nsIThread* result = mThread;
NS_IF_ADDREF(result);
return result;
nsCOMPtr<nsIThread> result = mThread;
return result.forget();
}
NS_IMETHODIMP

View File

@ -72,9 +72,8 @@ already_AddRefed<nsIParser>
nsHtml5Module::NewHtml5Parser()
{
NS_ABORT_IF_FALSE(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
nsIParser* rv = static_cast<nsIParser*> (new nsHtml5Parser());
NS_ADDREF(rv);
return rv;
nsCOMPtr<nsIParser> rv = new nsHtml5Parser();
return rv.forget();
}
// static

View File

@ -200,9 +200,7 @@ nsRDFXMLSerializer::EnsureNewPrefix()
++iter;
}
} while (!isNewPrefix);
nsIAtom* outPrefix = nullptr;
prefix.swap(outPrefix);
return outPrefix;
return prefix.forget();
}
// This converts a property resource (like

View File

@ -245,18 +245,18 @@ nsSecureBrowserUIImpl::GetState(uint32_t* aState)
already_AddRefed<nsISupports>
nsSecureBrowserUIImpl::ExtractSecurityInfo(nsIRequest* aRequest)
{
nsISupports *retval = nullptr;
nsCOMPtr<nsISupports> retval;
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel)
channel->GetSecurityInfo(&retval);
channel->GetSecurityInfo(getter_AddRefs(retval));
if (!retval) {
nsCOMPtr<nsISecurityInfoProvider> provider(do_QueryInterface(aRequest));
if (provider)
provider->GetSecurityInfo(&retval);
provider->GetSecurityInfo(getter_AddRefs(retval));
}
return retval;
return retval.forget();
}
nsresult

View File

@ -284,14 +284,13 @@ nsCertTree::GetCertAtIndex(int32_t index, int32_t *outAbsoluteCertOffset)
if (!certdi)
return nullptr;
nsIX509Cert *rawPtr = nullptr;
nsCOMPtr<nsIX509Cert> ret;
if (certdi->mCert) {
rawPtr = certdi->mCert;
ret = certdi->mCert;
} else if (certdi->mAddonInfo) {
rawPtr = certdi->mAddonInfo->mCert;
ret = certdi->mAddonInfo->mCert;
}
NS_IF_ADDREF(rawPtr);
return rawPtr;
return ret.forget();
}
// If the row at index is a cert, return that cert. Otherwise, return null.

View File

@ -240,10 +240,10 @@ do_get_db()
nsCOMPtr<nsPIPlacesDatabase> database = do_QueryInterface(history);
do_check_true(database);
mozIStorageConnection* dbConn;
nsresult rv = database->GetDBConnection(&dbConn);
nsCOMPtr<mozIStorageConnection> dbConn;
nsresult rv = database->GetDBConnection(getter_AddRefs(dbConn));
do_check_success(rv);
return dbConn;
return dbConn.forget();
}
/**

View File

@ -1863,8 +1863,8 @@ TelemetryImpl::CreateTelemetryInstance()
// AddRef for the local reference
NS_ADDREF(sTelemetry);
// AddRef for the caller
NS_ADDREF(sTelemetry);
return sTelemetry;
nsCOMPtr<nsITelemetry> ret = sTelemetry;
return ret.forget();
}
void

View File

@ -1219,14 +1219,13 @@ nsTypeAheadFind::GetPresShell()
if (!mPresShell)
return nullptr;
nsIPresShell *shell = nullptr;
CallQueryReferent(mPresShell.get(), &shell);
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
if (shell) {
nsPresContext *pc = shell->GetPresContext();
if (!pc || !nsCOMPtr<nsISupports>(pc->GetContainer())) {
NS_RELEASE(shell);
return nullptr;
}
}
return shell;
return shell.forget();
}

View File

@ -7,6 +7,7 @@
#include "nsDBusService.h"
#include "nsComponentManagerUtils.h"
#include "nsAutoPtr.h"
#include <glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@ -36,8 +37,8 @@ nsDBusService::Get() {
if (!gSingleton) {
gSingleton = new nsDBusService();
}
NS_IF_ADDREF(gSingleton);
return gSingleton;
nsRefPtr<nsDBusService> ret = gSingleton;
return ret.forget();
}
nsresult

View File

@ -292,7 +292,7 @@ static already_AddRefed<nsIFile>
GetFileFromEnv(const char *name)
{
nsresult rv;
nsIFile *file = nullptr;
nsCOMPtr<nsIFile> file;
#ifdef XP_WIN
WCHAR path[_MAX_PATH];
@ -300,21 +300,22 @@ GetFileFromEnv(const char *name)
path, _MAX_PATH))
return nullptr;
rv = NS_NewLocalFile(nsDependentString(path), true, &file);
rv = NS_NewLocalFile(nsDependentString(path), true, getter_AddRefs(file));
if (NS_FAILED(rv))
return nullptr;
return file;
return file.forget();
#else
const char *arg = PR_GetEnv(name);
if (!arg || !*arg)
return nullptr;
rv = NS_NewNativeLocalFile(nsDependentCString(arg), true, &file);
rv = NS_NewNativeLocalFile(nsDependentCString(arg), true,
getter_AddRefs(file));
if (NS_FAILED(rv))
return nullptr;
return file;
return file.forget();
#endif
}

View File

@ -235,13 +235,8 @@ NS_IMETHODIMP nsDocLoader::GetInterface(const nsIID& aIID, void** aSink)
already_AddRefed<nsDocLoader>
nsDocLoader::GetAsDocLoader(nsISupports* aSupports)
{
if (!aSupports) {
return nullptr;
}
nsDocLoader* ptr;
CallQueryInterface(aSupports, &ptr);
return ptr;
nsRefPtr<nsDocLoader> ret = do_QueryObject(aSupports);
return ret.forget();
}
/* static */

View File

@ -186,7 +186,5 @@ nsGNOMERegistry::GetFromType(const nsACString& aMIMEType)
mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
nsMIMEInfoBase* retval;
NS_ADDREF((retval = mimeInfo));
return retval;
return mimeInfo.forget();
}

View File

@ -1270,10 +1270,11 @@ nsOSHelperAppService::GetFromExtension(const nsCString& aFileExt) {
#ifdef MOZ_WIDGET_GTK2
LOG(("Looking in GNOME registry\n"));
nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromExtension(aFileExt).get();
nsRefPtr<nsMIMEInfoBase> gnomeInfo =
nsGNOMERegistry::GetFromExtension(aFileExt);
if (gnomeInfo) {
LOG(("Got MIMEInfo from GNOME registry\n"));
return gnomeInfo;
return gnomeInfo.forget();
}
#endif
@ -1301,10 +1302,7 @@ nsOSHelperAppService::GetFromExtension(const nsCString& aFileExt) {
}
nsAutoCString mimeType(asciiMajorType + NS_LITERAL_CSTRING("/") + asciiMinorType);
nsMIMEInfoUnix* mimeInfo = new nsMIMEInfoUnix(mimeType);
if (!mimeInfo)
return nullptr;
NS_ADDREF(mimeInfo);
nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix(mimeType);
mimeInfo->AppendExtension(aFileExt);
nsHashtable typeOptions; // empty hash table
@ -1342,7 +1340,7 @@ nsOSHelperAppService::GetFromExtension(const nsCString& aFileExt) {
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
}
return mimeInfo;
return mimeInfo.forget();
}
already_AddRefed<nsMIMEInfoBase>
@ -1389,17 +1387,17 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) {
NS_LossyConvertUTF16toASCII(mailcap_description).get()));
#ifdef MOZ_WIDGET_GTK2
nsMIMEInfoBase *gnomeInfo = nullptr;
nsRefPtr<nsMIMEInfoBase> gnomeInfo;
if (handler.IsEmpty()) {
// No useful data yet. Check the GNOME registry. Unfortunately, newer
// GNOME versions no longer have type-to-extension mappings, so we might
// get back a MIMEInfo without any extensions set. In that case we'll have
// to look in our mime.types files for the extensions.
LOG(("Looking in GNOME registry\n"));
gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType).get();
gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType);
if (gnomeInfo && gnomeInfo->HasExtensions()) {
LOG(("Got MIMEInfo from GNOME registry, and it has extensions set\n"));
return gnomeInfo;
return gnomeInfo.forget();
}
}
#endif
@ -1418,7 +1416,7 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) {
NS_ASSERTION(!gnomeInfo->HasExtensions(), "How'd that happen?");
gnomeInfo->SetFileExtensions(NS_ConvertUTF16toUTF8(extensions));
return gnomeInfo;
return gnomeInfo.forget();
}
#endif
@ -1466,10 +1464,7 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) {
return nullptr;
}
nsMIMEInfoUnix* mimeInfo = new nsMIMEInfoUnix(aMIMEType);
if (!mimeInfo)
return nullptr;
NS_ADDREF(mimeInfo);
nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix(aMIMEType);
mimeInfo->SetFileExtensions(NS_ConvertUTF16toUTF8(extensions));
if (! mime_types_description.IsEmpty()) {
@ -1492,7 +1487,7 @@ nsOSHelperAppService::GetFromType(const nsCString& aMIMEType) {
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
}
return mimeInfo;
return mimeInfo.forget();
}
@ -1501,7 +1496,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
const nsACString& aFileExt,
bool *aFound) {
*aFound = true;
nsMIMEInfoBase* retval = GetFromType(PromiseFlatCString(aType)).get();
nsRefPtr<nsMIMEInfoBase> retval = GetFromType(PromiseFlatCString(aType));
bool hasDefault = false;
if (retval)
retval->GetHasDefaultHandler(&hasDefault);
@ -1509,7 +1504,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
nsRefPtr<nsMIMEInfoBase> miByExt = GetFromExtension(PromiseFlatCString(aFileExt));
// If we had no extension match, but a type match, use that
if (!miByExt && retval)
return retval;
return retval.forget();
// If we had an extension match but no type match, set the mimetype and use
// it
if (!retval && miByExt) {
@ -1517,19 +1512,18 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
miByExt->SetMIMEType(aType);
miByExt.swap(retval);
return retval;
return retval.forget();
}
// If we got nothing, make a new mimeinfo
if (!retval) {
*aFound = false;
retval = new nsMIMEInfoUnix(aType);
if (retval) {
NS_ADDREF(retval);
if (!aFileExt.IsEmpty())
retval->AppendExtension(aFileExt);
}
return retval;
return retval.forget();
}
// Copy the attributes of retval (mimeinfo from type) onto miByExt, to
@ -1542,7 +1536,7 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
miByExt.swap(retval);
}
return retval;
return retval.forget();
}
NS_IMETHODIMP

View File

@ -5940,7 +5940,7 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
Display* xDisplay = DisplayOfScreen(xScreen);
Drawable xDrawable = gdk_x11_drawable_get_xid(aDrawable);
gfxASurface* result = nullptr;
nsRefPtr<gfxASurface> result;
if (visual) {
Visual* xVisual = gdk_x11_visual_get_xvisual(visual);
@ -5967,8 +5967,7 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
gfxIntSize(aSize.width, aSize.height));
}
NS_IF_ADDREF(result);
return result;
return result.forget();
}
#endif

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