From: levin@chromium.org Date: Tue, 24 Jan 2012 18:51:50 +0000 (+0000) Subject: [windows] Convert usage of GetDC to HWndDC Part 3. X-Git-Tag: 070512121124~14668 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7ccfdee68fad2006c3a8cba17a9624fd06066de;p=profile%2Fivi%2Fwebkit-efl.git [windows] Convert usage of GetDC to HWndDC Part 3. https://bugs.webkit.org/show_bug.cgi?id=76889 Reviewed by Adam Roben. Source/WebCore: No new functionality so no new tests. * platform/graphics/win/UniscribeController.cpp: (WebCore::UniscribeController::shapeAndPlaceItem): Simple replacement. (WebCore::UniscribeController::shape): Use the delayed allocation. * platform/win/PopupMenuWin.cpp: (WebCore::PopupMenuWin::paint): Fix a dc leak and use the dellayed allocation. Source/WebKit2: * UIProcess/win/WebPopupMenuProxyWin.cpp: (WebKit::WebPopupMenuProxyWin::paint): Fix a dc leak and use the dellayed allocation. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105756 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 94a640e..966c7d8 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2012-01-24 David Levin + + [windows] Convert usage of GetDC to HWndDC Part 3. + https://bugs.webkit.org/show_bug.cgi?id=76889 + + Reviewed by Adam Roben. + + No new functionality so no new tests. + + * platform/graphics/win/UniscribeController.cpp: + (WebCore::UniscribeController::shapeAndPlaceItem): Simple replacement. + (WebCore::UniscribeController::shape): Use the delayed allocation. + * platform/win/PopupMenuWin.cpp: + (WebCore::PopupMenuWin::paint): Fix a dc leak and use the dellayed allocation. + 2012-01-24 Mario Sanchez Prada [GTK] Refactor GTK's accessibilitity code to be more modular diff --git a/Source/WebCore/platform/graphics/win/UniscribeController.cpp b/Source/WebCore/platform/graphics/win/UniscribeController.cpp index 67e34a7..336b4e6 100644 --- a/Source/WebCore/platform/graphics/win/UniscribeController.cpp +++ b/Source/WebCore/platform/graphics/win/UniscribeController.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "UniscribeController.h" #include "Font.h" +#include "HWndDC.h" #include "SimpleFontData.h" #include "TextRun.h" #include @@ -248,13 +249,12 @@ bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const S if (placeResult == E_PENDING) { // The script cache isn't primed with enough info yet. We need to select our HFONT into // a DC and pass the DC in to ScriptPlace. - HDC hdc = GetDC(0); + HWndDC hdc(0); HFONT hfont = fontData->platformData().hfont(); HFONT oldFont = (HFONT)SelectObject(hdc, hfont); placeResult = ScriptPlace(hdc, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(), &item.a, advances.data(), offsets.data(), 0); SelectObject(hdc, oldFont); - ReleaseDC(0, hdc); } if (FAILED(placeResult) || glyphs.isEmpty()) @@ -380,7 +380,7 @@ bool UniscribeController::shape(const UChar* str, int len, SCRIPT_ITEM item, con Vector& glyphs, Vector& clusters, Vector& visualAttributes) { - HDC hdc = 0; + HWndDC hdc; HFONT oldFont = 0; HRESULT shapeResult = E_PENDING; int glyphCount = 0; @@ -391,7 +391,7 @@ bool UniscribeController::shape(const UChar* str, int len, SCRIPT_ITEM item, con // The script cache isn't primed with enough info yet. We need to select our HFONT into // a DC and pass the DC in to ScriptShape. ASSERT(!hdc); - hdc = GetDC(0); + hdc.setHWnd(0); HFONT hfont = fontData->platformData().hfont(); oldFont = (HFONT)SelectObject(hdc, hfont); } else if (shapeResult == E_OUTOFMEMORY) { @@ -401,10 +401,8 @@ bool UniscribeController::shape(const UChar* str, int len, SCRIPT_ITEM item, con } } while (shapeResult == E_PENDING || shapeResult == E_OUTOFMEMORY); - if (hdc) { + if (hdc) SelectObject(hdc, oldFont); - ReleaseDC(0, hdc); - } if (FAILED(shapeResult)) return false; diff --git a/Source/WebCore/platform/win/PopupMenuWin.cpp b/Source/WebCore/platform/win/PopupMenuWin.cpp index 097fc82..d0b3ec9 100644 --- a/Source/WebCore/platform/win/PopupMenuWin.cpp +++ b/Source/WebCore/platform/win/PopupMenuWin.cpp @@ -31,6 +31,7 @@ #include "FrameView.h" #include "GraphicsContext.h" #include "HTMLNames.h" +#include "HWndDC.h" #include "HostWindow.h" #include "Page.h" #include "PlatformMouseEvent.h" @@ -42,6 +43,7 @@ #include "SimpleFontData.h" #include "TextRun.h" #include "WebCoreInstanceHandle.h" + #include #include #if OS(WINCE) @@ -566,7 +568,7 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc) return; if (!m_DC) { - m_DC = ::CreateCompatibleDC(::GetDC(m_popup)); + m_DC = ::CreateCompatibleDC(HWndDC(m_popup)); if (!m_DC) return; } @@ -660,12 +662,10 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc) if (m_scrollbar) m_scrollbar->paint(&context, damageRect); - HDC localDC = hdc ? hdc : ::GetDC(m_popup); + HWndDC hWndDC; + HDC localDC = hdc ? hdc : hWndDC.setHWnd(m_popup); ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY); - - if (!hdc) - ::ReleaseDC(m_popup, localDC); } int PopupMenuWin::scrollSize(ScrollbarOrientation orientation) const diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 8ebfa6e..aa8f07c 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,13 @@ +2012-01-24 David Levin + + [windows] Convert usage of GetDC to HWndDC Part 3. + https://bugs.webkit.org/show_bug.cgi?id=76889 + + Reviewed by Adam Roben. + + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::paint): Fix a dc leak and use the dellayed allocation. + 2012-01-24 Sergio Villar Senin [WK2] [GTK] TestDownloads hitting an assertion in Debug builds diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp index d32e0f8..a040ad4 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -808,7 +809,7 @@ void WebPopupMenuProxyWin::paint(const IntRect& damageRect, HDC hdc) return; if (!m_DC) { - m_DC = ::CreateCompatibleDC(::GetDC(m_popup)); + m_DC = ::CreateCompatibleDC(HWndDC(m_popup)); if (!m_DC) return; } @@ -848,12 +849,11 @@ void WebPopupMenuProxyWin::paint(const IntRect& damageRect, HDC hdc) if (m_scrollbar) m_scrollbar->paint(&context, damageRect); - HDC localDC = hdc ? hdc : ::GetDC(m_popup); - ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY); + HWndDC hWndDC; + HDC localDC = hdc ? hdc : hWndDC.setHWnd(m_popup); - if (!hdc) - ::ReleaseDC(m_popup, localDC); + ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY); } bool WebPopupMenuProxyWin::setFocusedIndex(int i, bool hotTracking)