From 40f8d29adc9f3ad4c0a435328d9b3a11b43e0de5 Mon Sep 17 00:00:00 2001 From: "levin@chromium.org" Date: Tue, 24 Jan 2012 00:35:29 +0000 Subject: [PATCH] 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105656 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 ++++++++++++++++++ Source/WebCore/platform/win/HWndDC.h | 26 ++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 4618ea0..82cbb1b 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2012-01-18 David Levin + + 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 MicroData: Compilation error while building Webkit with --microdata. diff --git a/Source/WebCore/platform/win/HWndDC.h b/Source/WebCore/platform/win/HWndDC.h index 11dc332..2eaecad 100644 --- a/Source/WebCore/platform/win/HWndDC.h +++ b/Source/WebCore/platform/win/HWndDC.h @@ -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() -- 2.7.4