Allow delayed DC allocation in HWndDC.
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 00:35:29 +0000 (00:35 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 00:35:29 +0000 (00:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76737

Reviewed by Adam Roben.

No new functionality exposed so no new tests.

* platform/win/HWndDC.h: Changed this slightly to allow
for allocating a window DC after the initial creation since
this pattern occurrs in several places so this makes it easy to
replace them in an upcoming change.
(WebCore::HWndDC::HWndDC):
(WebCore::HWndDC::~HWndDC):
(WebCore::HWndDC::setHWnd):
(WebCore::HWndDC::clear):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105656 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/win/HWndDC.h

index 4618ea0..82cbb1b 100644 (file)
@@ -1,3 +1,21 @@
+2012-01-18  David Levin  <levin@chromium.org>
+
+        Allow delayed DC allocation in HWndDC.
+        https://bugs.webkit.org/show_bug.cgi?id=76737
+
+        Reviewed by Adam Roben.
+
+        No new functionality exposed so no new tests.
+
+        * platform/win/HWndDC.h: Changed this slightly to allow
+        for allocating a window DC after the initial creation since
+        this pattern occurrs in several places so this makes it easy to
+        replace them in an upcoming change.
+        (WebCore::HWndDC::HWndDC):
+        (WebCore::HWndDC::~HWndDC):
+        (WebCore::HWndDC::setHWnd):
+        (WebCore::HWndDC::clear):
+
 2012-01-23  Arko Saha  <nghq36@motorola.com>
 
         MicroData: Compilation error while building Webkit with --microdata.
index 11dc332..2eaecad 100644 (file)
@@ -34,6 +34,12 @@ namespace WebCore {
 class HWndDC {
     WTF_MAKE_NONCOPYABLE(HWndDC);
 public:
+    HWndDC()
+        : m_hwnd(0)
+        , m_hdc(0)
+    {
+    }
+
     explicit HWndDC(HWND hwnd)
         : m_hwnd(hwnd)
         , m_hdc(::GetDC(hwnd))
@@ -48,8 +54,24 @@ public:
 
     ~HWndDC()
     {
-        if (m_hdc)
-            ::ReleaseDC(m_hwnd, m_hdc);
+        clear();
+    }
+
+    HDC setHWnd(HWND hwnd)
+    {
+        clear();
+        m_hwnd = hwnd;
+        m_hdc = ::GetDC(hwnd);
+        return m_hdc;
+    }
+
+    void clear()
+    {
+        if (!m_hdc)
+            return;
+        ::ReleaseDC(m_hwnd, m_hdc);
+        m_hwnd = 0;
+        m_hdc = 0;
     }
 
     operator HDC()