Bug 1095098 - move do_QueryObject templates into their own header; r=froydnj

This commit is contained in:
Denis Volk 2015-04-15 12:47:03 -04:00
parent b7d011cb44
commit cd6346cce0
67 changed files with 172 additions and 88 deletions

View File

@ -11,6 +11,7 @@
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::a11y;

View File

@ -17,6 +17,7 @@
#include "Role.h"
#include "States.h"
#include "XULTreeGridAccessible.h"
#include "nsQueryObject.h"
#include "nsComponentManagerUtils.h"
#include "nsIAccessibleRelation.h"

View File

@ -13,6 +13,7 @@
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "nsQueryObject.h"
#include "nsIBoxObject.h"
#include "nsIMutableArray.h"

View File

@ -15,6 +15,7 @@
#include "nsEscape.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "nsQueryObject.h"
#include "mozilla/CSSStyleSheet.h"
#include "mozilla/dom/URL.h"

View File

@ -14,6 +14,7 @@
#include "nsIDOMWindow.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsQueryObject.h"
#include "nsIHttpChannel.h"
#include "nsIScriptSecurityManager.h"
#include "nsError.h"

View File

@ -59,6 +59,7 @@
#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
#include "nsISeekableStream.h"
#include "nsAutoPtr.h"
#include "nsQueryObject.h"
#include "nsIWritablePropertyBag2.h"
#include "nsIAppShell.h"
#include "nsWidgetsCID.h"

View File

@ -24,6 +24,7 @@
#include "nsFrame.h"
#include "mozilla/layers/ShadowLayers.h"
#include "ClientLayerManager.h"
#include "nsQueryObject.h"
#include "nsIScrollableFrame.h"

View File

@ -35,6 +35,7 @@
#include "nsDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsCOMArray.h"
#include "nsQueryObject.h"
#include "nsDOMClassInfo.h"
#include "mozilla/Services.h"

View File

@ -44,6 +44,7 @@
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "nsPrintfCString.h"
#include "nsXULAppAPI.h"
#include "nsQueryObject.h"
#include <algorithm>
#ifdef ANDROID

View File

@ -120,6 +120,7 @@
#include "nsIControllerContext.h"
#include "nsGlobalWindowCommands.h"
#include "nsAutoPtr.h"
#include "nsQueryObject.h"
#include "nsContentUtils.h"
#include "nsCSSProps.h"
#include "nsIDOMFileList.h"

View File

@ -30,6 +30,7 @@
#include "nsUnicharInputStream.h"
#include "nsContentUtils.h"
#include "nsStyleUtil.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -23,6 +23,7 @@
#include "nsContentUtils.h"
#include "nsIParserUtils.h"
#include "nsIDocument.h"
#include "nsQueryObject.h"
using namespace mozilla;

View File

@ -14,6 +14,7 @@
#include "nsITelephonyService.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsQueryObject.h"
USING_BLUETOOTH_NAMESPACE

View File

@ -13,6 +13,7 @@
#include "nsITelephonyService.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsQueryObject.h"
USING_BLUETOOTH_NAMESPACE

View File

@ -23,6 +23,7 @@
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsQueryObject.h"
#include "nsStreamUtils.h"
#include "nsString.h"
#include "nsURLParsers.h"

View File

@ -9,6 +9,7 @@
#include "CameraPreviewMediaStream.h"
#include "mozilla/dom/CameraManagerBinding.h"
#include "mozilla/dom/File.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -19,6 +19,7 @@
#include "CameraPreferences.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -17,6 +17,7 @@
#include "nsIRunnable.h"
#include "nsISeekableStream.h"
#include "nsThreadUtils.h"
#include "nsQueryObject.h"
#ifdef DEBUG
#include "nsXULAppAPI.h"

View File

@ -9,6 +9,7 @@
#include "mozilla/dom/HTMLFieldSetElement.h"
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
#include "nsContentList.h"
#include "nsQueryObject.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)

View File

@ -30,6 +30,7 @@
#include "nsIMutableArray.h"
#include "nsIFormAutofillContentService.h"
#include "mozilla/BinarySearch.h"
#include "nsQueryObject.h"
// form submission
#include "mozilla/Telemetry.h"

View File

@ -12,6 +12,7 @@
#include "mozilla/dom/HTMLLabelElementBinding.h"
#include "nsFocusManager.h"
#include "nsIDOMMouseEvent.h"
#include "nsQueryObject.h"
// construction, destruction

View File

@ -38,6 +38,7 @@
#include "nsIThreadInternal.h"
#include "nsContentUtils.h"
#include "nsIRequest.h"
#include "nsQueryObject.h"
#include "nsIScriptSecurityManager.h"
#include "nsIXPConnect.h"

View File

@ -17,6 +17,7 @@
#include "nsAttrValueInlines.h"
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "nsQueryObject.h"
#include "nsIContentInlines.h"
#include "nsIContentViewer.h"
#include "mozilla/css/StyleRule.h"

View File

@ -50,6 +50,7 @@
#include "nsThreadUtils.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "nsQueryObject.h"
// Include this last to avoid path problems on Windows.
#include "ActorsChild.h"

View File

@ -41,6 +41,7 @@
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "WorkerPrivate.h"

View File

@ -11,6 +11,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsIPermissionManager.h"
#include "nsPIDOMWindow.h"
#include "nsQueryObject.h"
namespace mozilla {
namespace dom {

View File

@ -12,6 +12,7 @@
#include "nsIStringEnumerator.h"
#include "nsISupportsArray.h"
#include "nsJSUtils.h"
#include "nsQueryObject.h"
#include "nsPIDOMWindow.h"
#include "nsTArray.h"
#include "GetUserMediaRequest.h"

View File

@ -11,6 +11,7 @@
#include "nsGlobalWindow.h"
#include "mozilla/MediaManager.h"
#include "prlog.h"
#include "nsQueryObject.h"
#undef LOG
#if defined(PR_LOGGING)

View File

@ -21,6 +21,7 @@
#include "mozilla/dom/SpeechRecognitionEvent.h"
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "nsQueryObject.h"
#include <algorithm>

View File

@ -72,6 +72,7 @@
#include "prprf.h"
#include "nsThreadUtils.h"
#include "nsIInputStreamTee.h"
#include "nsQueryObject.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"

View File

@ -10,6 +10,7 @@
#include "nsError.h"
#include "nsCOMPtr.h"
#include "nsSVGAttrTearoffTable.h"
#include "nsQueryObject.h"
#include <algorithm>
// See the architecture comment in this file's header.

View File

@ -45,6 +45,7 @@
#include "SVGAnimatedPathSegList.h"
#include "SVGContentUtils.h"
#include "nsIFrame.h"
#include "nsQueryObject.h"
#include <stdarg.h>
#include "nsSMILMappedAttribute.h"
#include "SVGMotionSMILAttr.h"

View File

@ -16,6 +16,7 @@
#include "nsStreamUtils.h"
#include "nsNetCID.h"
#include "nsSerializationHelper.h"
#include "nsQueryObject.h"
#include "mozilla/dom/FetchEventBinding.h"
#include "mozilla/dom/PromiseNativeHandler.h"

View File

@ -40,6 +40,7 @@
#include "nsGlobalWindow.h"
#include "nsNetUtil.h"
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "nsTArray.h"
#include "RuntimeService.h"

View File

@ -81,6 +81,7 @@
#include "nsNetUtil.h"
#include "nsPrintfCString.h"
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "nsSandboxFlags.h"
#include "prthread.h"
#include "xpcpublic.h"

View File

@ -6,6 +6,7 @@
#include "mozilla/ArrayUtils.h"
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#include "nsXBLPrototypeHandler.h"
#include "nsXBLPrototypeBinding.h"
#include "nsContentUtils.h"

View File

@ -93,6 +93,7 @@
#include "nsAttrValueInlines.h"
#include "mozilla/Attributes.h"
#include "nsIController.h"
#include "nsQueryObject.h"
#include <algorithm>
// The XUL doc interface

View File

@ -13,6 +13,7 @@
#include "nsError.h" // for NS_SUCCEEDED, NS_FAILED, etc
#include "nsIPresShell.h" // nsISelectionController constants
#include "nsRange.h" // local var
#include "nsQueryObject.h" // for do_QueryObject
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -11,6 +11,7 @@
#include "nsDebug.h" // for NS_ASSERTION, etc
#include "nsEditor.h" // mEditor
#include "nsError.h" // for NS_OK, etc
#include "nsQueryObject.h" // for do_QueryObject
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -8,6 +8,7 @@
#include "IMETextTxn.h"
#include "nsGkAtoms.h"
#include "mozilla/dom/Selection.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -53,6 +53,7 @@
#include "nsRange.h"
#include "nsServiceManagerUtils.h" // for do_GetService
#include "nsString.h" // for nsAutoString
#include "nsQueryObject.h" // for do_QueryObject
#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
#include "nsContentUtils.h" // for nsContentUtils, etc
#include "nsIBidiKeyboard.h" // for nsIBidiKeyboard

View File

@ -24,6 +24,7 @@
#include "nsIHTMLObjectResizer.h"
#include "nsISupportsImpl.h"
#include "nsLiteralString.h"
#include "nsQueryObject.h"
#include "nsRange.h"
using namespace mozilla;

View File

@ -176,6 +176,7 @@
#include "nsIFrameInlines.h"
#include "mozilla/gfx/2D.h"
#include "nsSubDocumentFrame.h"
#include "nsQueryObject.h"
#ifdef ANDROID
#include "nsIDocShellTreeOwner.h"

View File

@ -45,6 +45,7 @@
#include "nsColor.h"
#include "nsStyleSet.h"
#include "nsStyleUtil.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::css;

View File

@ -21,6 +21,7 @@
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsQueryObject.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsIDOMCSSStyleSheet.h"

View File

@ -18,6 +18,7 @@
#include "nsIURI.h"
#include "mozilla/dom/BindingUtils.h"
#include "nsContentUtils.h"
#include "nsQueryObject.h"
using namespace mozilla;

View File

@ -14,6 +14,7 @@
#include "nsRuleNode.h"
#include "nsIStyleRule.h"
#include "StyleRule.h"
#include "nsQueryObject.h"
class nsRuleWalker {
public:

View File

@ -38,6 +38,7 @@
#include "nsPrintfCString.h"
#include "nsIFrame.h"
#include "RestyleManager.h"
#include "nsQueryObject.h"
#include <inttypes.h>

View File

@ -30,6 +30,7 @@
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "prtime.h"
#include "AudioConduit.h"

View File

@ -32,6 +32,7 @@
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIDNSService.h"
#include "nsQueryObject.h"
#include "nsWeakReference.h"
#include "nricectx.h"
#include "rlogringbuffer.h"

View File

@ -33,6 +33,7 @@
#include "nsICachingChannel.h"
#include "mozilla/LoadInfo.h"
#include "nsIHttpHeaderVisitor.h"
#include "nsQueryObject.h"
using namespace mozilla::dom;
using namespace mozilla::ipc;

View File

@ -13,6 +13,7 @@
#include "nsHttpRequestHead.h"
#include "nsIHttpActivityObserver.h"
#include "NullHttpChannel.h"
#include "nsQueryObject.h"
namespace mozilla {
namespace net {

View File

@ -37,6 +37,7 @@
#include "nsError.h"
#include "nsPrintfCString.h"
#include "nsAlgorithm.h"
#include "nsQueryObject.h"
#include "GeckoProfiler.h"
#include "nsIConsoleService.h"
#include "mozilla/Attributes.h"

View File

@ -6,6 +6,7 @@
#include "nsProfileStringTypes.h"
#include "nsProfileLock.h"
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#if defined(XP_WIN)
#include "mozilla/ProfileUnlockerWin.h"

View File

@ -13,6 +13,7 @@
#include "nsError.h"
#include "mozilla/Mutex.h"
#include "mozilla/CondVar.h"
#include "nsQueryObject.h"
#include "nsThreadUtils.h"
#include "nsJSUtils.h"

View File

@ -18,6 +18,7 @@
#include "nsUnicharUtils.h"
#include "prtime.h"
#include "prprf.h"
#include "nsQueryObject.h"
#include "nsCycleCollectionParticipant.h"

View File

@ -20,6 +20,7 @@
#include "nscore.h"
#include "nsWeakPtr.h"
#include "nsAutoPtr.h"
#include "nsQueryObject.h"
#include "nsIDOMWindow.h"

View File

@ -9,6 +9,7 @@
#include <unistd.h>
#include "nsAutoPtr.h"
#include "nsQueryObject.h"
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsPrintSettingsX.h"

View File

@ -17,6 +17,7 @@
#include "nsIDOMDocument.h"
#include "nsIDOMXULCommandEvent.h"
#include "nsPIDOMWindow.h"
#include "nsQueryObject.h"
using namespace mozilla;

View File

@ -9,6 +9,7 @@
#include "nsIPrintSettings.h"
#include "nsPrintSettingsX.h"
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#include "nsServiceManagerUtils.h"
#include "nsIWebProgressListener.h"
#include "nsIStringBundle.h"

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#include "nsIServiceManager.h"
#include "nsPrintOptionsX.h"
#include "nsPrintSettingsX.h"

View File

@ -15,6 +15,7 @@
#include "nsISupportsImpl.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsQueryObject.h"
#include <windows.h>
#include <ws2spi.h>

View File

@ -56,6 +56,7 @@ EXPORTS += [
'nsISizeOf.h',
'nsISupportsBase.h',
'nsObjCExceptions.h',
'nsQueryObject.h',
'nsRefPtr.h',
'nsStackWalk.h',
'nsTraceRefcnt.h',

View File

@ -759,94 +759,6 @@ operator!=(NSCAP_Zero* aLhs, const nsAutoArrayPtr<T>& aRhs)
}
/*****************************************************************************/
template<class T>
class MOZ_STACK_CLASS nsQueryObject : public nsCOMPtr_helper
{
public:
explicit nsQueryObject(T* aRawPtr)
: mRawPtr(aRawPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const override
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
return status;
}
private:
T* MOZ_NON_OWNING_REF mRawPtr;
};
template<class T>
class MOZ_STACK_CLASS nsQueryObjectWithError : public nsCOMPtr_helper
{
public:
nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr)
: mRawPtr(aRawPtr), mErrorPtr(aErrorPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
if (mErrorPtr) {
*mErrorPtr = status;
}
return status;
}
private:
T* MOZ_NON_OWNING_REF mRawPtr;
nsresult* mErrorPtr;
};
template<class T>
inline nsQueryObject<T>
do_QueryObject(T* aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsRefPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(T* aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsRefPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
/*****************************************************************************/
#endif // !defined(nsAutoPtr_h)

107
xpcom/base/nsQueryObject.h Normal file
View File

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsQueryObject_h
#define nsQueryObject_h
#include "nsCOMPtr.h"
#include "nsRefPtr.h"
/*****************************************************************************/
template<class T>
class nsQueryObject : public nsCOMPtr_helper
{
public:
explicit nsQueryObject(T* aRawPtr)
: mRawPtr(aRawPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
return status;
}
private:
T* mRawPtr;
};
template<class T>
class nsQueryObjectWithError : public nsCOMPtr_helper
{
public:
nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr)
: mRawPtr(aRawPtr), mErrorPtr(aErrorPtr)
{
}
virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
void** aResult) const
{
nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
: NS_ERROR_NULL_POINTER;
if (mErrorPtr) {
*mErrorPtr = status;
}
return status;
}
private:
T* mRawPtr;
nsresult* mErrorPtr;
};
/*****************************************************************************/
/*****************************************************************************/
template<class T>
inline nsQueryObject<T>
do_QueryObject(T* aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObject<T>
do_QueryObject(nsRefPtr<T>& aRawPtr)
{
return nsQueryObject<T>(aRawPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(T* aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsCOMPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
template<class T>
inline nsQueryObjectWithError<T>
do_QueryObject(nsRefPtr<T>& aRawPtr, nsresult* aErrorPtr)
{
return nsQueryObjectWithError<T>(aRawPtr, aErrorPtr);
}
/*****************************************************************************/
#endif // !defined(nsQueryObject_h)

View File

@ -8,6 +8,7 @@
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsISupports.h"
#include "nsQueryObject.h"
#define NS_FOO_IID \
{ 0x6f7652e0, 0xee43, 0x11d1, \

View File

@ -17,6 +17,7 @@
#include "prprf.h"
#include "nsThreadUtils.h"
#include "nsNetCID.h"
#include "nsQueryObject.h"
//Interfaces needed to be included
#include "nsIAppShell.h"