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

This commit is contained in:
Denis Volk 2014-11-20 12:20:10 +01:00
parent 974a3b93f8
commit c3639f1324
58 changed files with 163 additions and 92 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

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

View File

@ -57,6 +57,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

@ -224,6 +224,7 @@
#include "nsLocation.h"
#include "mozilla/dom/FontFaceSet.h"
#include "mozilla/dom/BoxObject.h"
#include "nsQueryObject.h"
#ifdef MOZ_MEDIA_NAVIGATOR
#include "mozilla/MediaManager.h"

View File

@ -42,6 +42,7 @@
#include "mozilla/dom/DOMStringList.h"
#include "nsPrintfCString.h"
#include "nsXULAppAPI.h"
#include "nsQueryObject.h"
#include <algorithm>
#ifdef ANDROID

View File

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

View File

@ -58,6 +58,7 @@
#include "nsUnicharUtils.h"
#include "mozilla/Preferences.h"
#include "nsSandboxFlags.h"
#include "nsQueryObject.h"
// Concrete classes
#include "nsFrameLoader.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 "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsQueryObject.h"
USING_BLUETOOTH_NAMESPACE

View File

@ -14,6 +14,7 @@
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsQueryObject.h"
USING_BLUETOOTH_NAMESPACE

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

@ -31,6 +31,7 @@
#include "nsIMutableArray.h"
#include "nsIFormAutofillContentService.h"
#include "mozilla/BinarySearch.h"
#include "nsQueryObject.h"
// form submission
#include "nsIFormSubmitObserver.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

@ -49,6 +49,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

@ -10,6 +10,7 @@
#include "nsIEventTarget.h"
#include "nsIScriptGlobalObject.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

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

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

@ -53,6 +53,7 @@
#include "mozilla/dom/SVGElementBinding.h"
#include "mozilla/unused.h"
#include "RestyleManager.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

View File

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

View File

@ -29,6 +29,7 @@
#include "nsIURL.h"
#include "nsIWorkerDebugger.h"
#include "nsIXPConnect.h"
#include "nsQueryObject.h"
#include <algorithm>
#include "jsfriendapi.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

@ -11,6 +11,7 @@
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsError.h"
#include "nsQueryObject.h"
#include "nsHTMLEditUtils.h"
#include "nsHTMLEditor.h"
#include "nsIDOMElement.h"

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

@ -43,6 +43,7 @@
#include "mozilla/Likely.h"
#include "mozilla/dom/CSSStyleSheetBinding.h"
#include "nsComponentManagerUtils.h"
#include "nsQueryObject.h"
using namespace mozilla;
using namespace mozilla::dom;

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"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -17,6 +17,7 @@
#include "nspr.h"
#include "nss.h"
#include "pk11pub.h"
#include "nsQueryObject.h"
#include "nsNetCID.h"
#include "nsIProperty.h"

View File

@ -31,7 +31,7 @@
#include "mozilla/ipc/BackgroundUtils.h"
#include "nsIOService.h"
#include "nsICachingChannel.h"
#include "nsQueryObject.h"
using namespace mozilla::dom;
using namespace mozilla::ipc;

View File

@ -71,6 +71,7 @@
#include "nsIHttpPushListener.h"
#include "nsIX509Cert.h"
#include "ScopedNSSTypes.h"
#include "nsQueryObject.h"
namespace mozilla { namespace net {

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

@ -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

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

View File

@ -758,95 +758,4 @@ operator!=(NSCAP_Zero* aLhs, const nsAutoArrayPtr<T>& aRhs)
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
}
/*****************************************************************************/
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(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

@ -50,6 +50,7 @@
#include "nsContentUtils.h"
#include "nsWebShellWindow.h" // get rid of this one, too...
#include "nsGlobalWindow.h"
#include "nsQueryObject.h"
#include "prenv.h"
#include "mozilla/AutoRestore.h"