Skip to content

Commit

Permalink
HwndDC is a better name than OwnGetDC.
Browse files Browse the repository at this point in the history
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 95ce9ef
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
21 changes: 21 additions & 0 deletions Source/JavaScriptCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/JavaScriptCore.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -53,4 +53,4 @@ class OwnGetDC {

}

using WTF::OwnGetDC;
using WTF::HwndDC;
10 changes: 10 additions & 0 deletions Source/WebKit/chromium/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "WebScreenInfo.h"

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

#include <windows.h>

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 95ce9ef

Please sign in to comment.