Skip to content
Permalink
Browse files
HwndDC is a better name than OwnGetDC.
https://bugs.webkit.org/show_bug.cgi?id=76235

Reviewed by Dmitry Titov.

Source/JavaScriptCore:

This is a better name for two reasons:
1. "Own" implies "delete". In this case, the final call is a release (ReleaseDC).
2. "Ref" would be a better name due to the release but the RefPtr (and OwnPtr)
   classes always take something to hold on to. In this case, the object (the DC)
   is created by the class once it is given a Window to ensure that the HDC
   was actually created using GetDC.

* JavaScriptCore.gyp/JavaScriptCore.gyp:
* JavaScriptCore.gypi:
* wtf/win/HwndDCWin.h: Renamed from Source/JavaScriptCore/wtf/win/OwnGetDCWin.h.
(WTF::HwndDC::HwndDC):
(WTF::HwndDC::~HwndDC):
(WTF::HwndDC::operator HDC):

Source/WebKit/chromium:

* src/win/WebScreenInfoFactory.cpp:
(WebKit::WebScreenInfoFactory::screenInfo):


Canonical link: https://commits.webkit.org/93046@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104895 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
David Levin committed Jan 13, 2012
1 parent 2b218c1 commit 95ce9ef19e246f621c97dc3fedf48ffaf12134d1
Showing 6 changed files with 39 additions and 8 deletions.
@@ -1,3 +1,24 @@
2012-01-12 David Levin <levin@chromium.org>

HwndDC is a better name than OwnGetDC.
https://bugs.webkit.org/show_bug.cgi?id=76235

Reviewed by Dmitry Titov.

This is a better name for two reasons:
1. "Own" implies "delete". In this case, the final call is a release (ReleaseDC).
2. "Ref" would be a better name due to the release but the RefPtr (and OwnPtr)
classes always take something to hold on to. In this case, the object (the DC)
is created by the class once it is given a Window to ensure that the HDC
was actually created using GetDC.

* JavaScriptCore.gyp/JavaScriptCore.gyp:
* JavaScriptCore.gypi:
* wtf/win/HwndDCWin.h: Renamed from Source/JavaScriptCore/wtf/win/OwnGetDCWin.h.
(WTF::HwndDC::HwndDC):
(WTF::HwndDC::~HwndDC):
(WTF::HwndDC::operator HDC):

2012-01-12 Gavin Barraclough <barraclough@apple.com>

Clean up putDirect (part 1)
@@ -173,7 +173,7 @@
['include', 'Thread(ing|Specific)Win\\.cpp$'],
['exclude', 'OSAllocatorPosix\\.cpp$'],
['include', 'OSAllocatorWin\\.cpp$'],
['include', 'win/OwnGetDCWin\\.h$'],
['include', 'win/HwndDCWin\\.h$'],
],
'include_dirs!': [
'<(SHARED_INTERMEDIATE_DIR)/webkit',
@@ -648,7 +648,7 @@
'wtf/unicode/wince/UnicodeWinCE.cpp',
'wtf/unicode/wince/UnicodeWinCE.h',
'wtf/win/MainThreadWin.cpp',
'wtf/win/OwnGetDCWin.h',
'wtf/win/HwndDCWin.h',
'wtf/win/OwnPtrWin.cpp',
'wtf/wince/FastMallocWinCE.h',
'wtf/wince/MemoryManager.cpp',
@@ -27,15 +27,15 @@

namespace WTF {

class OwnGetDC {
class HwndDC {
public:
explicit OwnGetDC(HWND hwnd)
explicit HwndDC(HWND hwnd)
: m_hwnd(hwnd)
, m_hdc(::GetDC(hwnd))
{
}

~OwnGetDC()
~HwndDC()
{
if (m_hdc)
::ReleaseDC(m_hwnd, m_hdc);
@@ -53,4 +53,4 @@ class OwnGetDC {

}

using WTF::OwnGetDC;
using WTF::HwndDC;
@@ -1,3 +1,13 @@
2012-01-12 David Levin <levin@chromium.org>

HwndDC is a better name than OwnGetDC.
https://bugs.webkit.org/show_bug.cgi?id=76235

Reviewed by Dmitry Titov.

* src/win/WebScreenInfoFactory.cpp:
(WebKit::WebScreenInfoFactory::screenInfo):

2012-01-12 David Levin <levin@chromium.org>

[chromium] Fix DC leak in WebScreenInfoFactory.
@@ -33,7 +33,7 @@

#include "WebScreenInfo.h"

#include <wtf/win/OwnGetDCWin.h>
#include <wtf/win/HwndDCWin.h>

#include <windows.h>

@@ -62,7 +62,7 @@ WebScreenInfo WebScreenInfoFactory::screenInfo(HWND window)
devMode.dmDriverExtra = 0;
EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);

OwnGetDC hdc(0);
HwndDC hdc(0);
ASSERT(hdc);

WebScreenInfo results;

0 comments on commit 95ce9ef

Please sign in to comment.