From 002407fe456424685619a6434cf9728a3dea2d62 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Tue, 1 Mar 2016 12:48:26 -0600 Subject: [PATCH] Bug 1232181 - Add a few win resource helpers. r=aklotz --- xpcom/base/nsWindowsHelpers.h | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/xpcom/base/nsWindowsHelpers.h b/xpcom/base/nsWindowsHelpers.h index 448654440a77..552e74f47401 100644 --- a/xpcom/base/nsWindowsHelpers.h +++ b/xpcom/base/nsWindowsHelpers.h @@ -49,6 +49,78 @@ public: } }; +template<> +class nsAutoRefTraits +{ +public: + typedef HDC RawRef; + static HDC Void() + { + return nullptr; + } + + static void Release(RawRef aFD) + { + if (aFD != Void()) { + ::DeleteDC(aFD); + } + } +}; + +template<> +class nsAutoRefTraits +{ +public: + typedef HBRUSH RawRef; + static HBRUSH Void() + { + return nullptr; + } + + static void Release(RawRef aFD) + { + if (aFD != Void()) { + ::DeleteObject(aFD); + } + } +}; + +template<> +class nsAutoRefTraits +{ +public: + typedef HRGN RawRef; + static HRGN Void() + { + return nullptr; + } + + static void Release(RawRef aFD) + { + if (aFD != Void()) { + ::DeleteObject(aFD); + } + } +}; + +template<> +class nsAutoRefTraits +{ +public: + typedef HBITMAP RawRef; + static HBITMAP Void() + { + return nullptr; + } + + static void Release(RawRef aFD) + { + if (aFD != Void()) { + ::DeleteObject(aFD); + } + } +}; + template<> class nsAutoRefTraits { @@ -140,6 +212,10 @@ public: }; typedef nsAutoRef nsAutoRegKey; +typedef nsAutoRef nsAutoHDC; +typedef nsAutoRef nsAutoBrush; +typedef nsAutoRef nsAutoRegion; +typedef nsAutoRef nsAutoBitmap; typedef nsAutoRef nsAutoServiceHandle; typedef nsAutoRef nsAutoHandle; typedef nsAutoRef nsModuleHandle;