Commit 7ca31dfd authored by levin@chromium.org's avatar levin@chromium.org

[windows] Convert usages of GetDC to HWndDC Part 1.

https://bugs.webkit.org/show_bug.cgi?id=76744

Reviewed by Adam Roben.

Source/WebCore:

No new functionality so no new tests.

* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::getFontDataForCharacters): Changed GetDC to HWndDC
and removed ReleaseDC.
(WebCore::createGDIFont): Ditto.
(WebCore::FontCache::getTraitsInFamily): Ditto.
* platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Ditto.
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::SimpleFontData::platformInit): Ditto.
* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::SimpleFontData::initGDIFont): Ditto.
(WebCore::SimpleFontData::containsCharacters): Ditto.
(WebCore::SimpleFontData::determinePitch): Ditto.
(WebCore::SimpleFontData::boundsForGDIGlyph): Ditto.
(WebCore::SimpleFontData::widthForGDIGlyph): Ditto.
(WebCore::SimpleFontData::scriptFontProperties): Ditto.
* platform/win/CursorWin.cpp:
(WebCore::createSharedCursor): Ditto.
* platform/win/DragImageCGWin.cpp:
(WebCore::scaleDragImage): Ditto.
(WebCore::createDragImageFromImage): Ditto.
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink): Ditto.
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::writeImage): Ditto.

Source/WebKit/win:

* WebIconDatabase.cpp:
(createDIB): Changed GetDC to HWndDC and removed ReleaseDC.

Source/WebKit2:

* UIProcess/win/WebView.cpp:
(WebKit::WebView::flashBackingStoreUpdates): Typical conversion.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0823eec7
2012-01-23 David Levin <levin@chromium.org>
[windows] Convert usages of GetDC to HWndDC Part 1.
https://bugs.webkit.org/show_bug.cgi?id=76744
Reviewed by Adam Roben.
No new functionality so no new tests.
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::getFontDataForCharacters): Changed GetDC to HWndDC
and removed ReleaseDC.
(WebCore::createGDIFont): Ditto.
(WebCore::FontCache::getTraitsInFamily): Ditto.
* platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Ditto.
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::SimpleFontData::platformInit): Ditto.
* platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::SimpleFontData::initGDIFont): Ditto.
(WebCore::SimpleFontData::containsCharacters): Ditto.
(WebCore::SimpleFontData::determinePitch): Ditto.
(WebCore::SimpleFontData::boundsForGDIGlyph): Ditto.
(WebCore::SimpleFontData::widthForGDIGlyph): Ditto.
(WebCore::SimpleFontData::scriptFontProperties): Ditto.
* platform/win/CursorWin.cpp:
(WebCore::createSharedCursor): Ditto.
* platform/win/DragImageCGWin.cpp:
(WebCore::scaleDragImage): Ditto.
(WebCore::createDragImageFromImage): Ditto.
* platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink): Ditto.
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::writeImage): Ditto.
2012-01-23 Martin Robinson <mrobinson@igalia.com>
[GTK] Scrollbars do not respect the has-backward-stepper and has-forward-stepper properties
......@@ -30,6 +30,7 @@
#include <winsock2.h>
#include "FontCache.h"
#include "Font.h"
#include "HWndDC.h"
#include "SimpleFontData.h"
#include "UnicodeRange.h"
#include <mlang.h>
......@@ -189,7 +190,7 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, cons
{
UChar character = characters[0];
SimpleFontData* fontData = 0;
HDC hdc = GetDC(0);
HWndDC hdc(0);
HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont();
HGDIOBJ oldFont = SelectObject(hdc, primaryFont);
HFONT hfont = 0;
......@@ -292,7 +293,6 @@ const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, cons
DeleteObject(hfont);
}
ReleaseDC(0, hdc);
return fontData;
}
......@@ -447,7 +447,7 @@ static int CALLBACK matchImprovingEnumProc(CONST LOGFONT* candidate, CONST TEXTM
static HFONT createGDIFont(const AtomicString& family, LONG desiredWeight, bool desiredItalic, int size, bool synthesizeItalic)
{
HDC hdc = GetDC(0);
HWndDC hdc(0);
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
......@@ -459,8 +459,6 @@ static HFONT createGDIFont(const AtomicString& family, LONG desiredWeight, bool
MatchImprovingProcData matchData(desiredWeight, desiredItalic);
EnumFontFamiliesEx(hdc, &logFont, matchImprovingEnumProc, reinterpret_cast<LPARAM>(&matchData), 0);
ReleaseDC(0, hdc);
if (!matchData.m_hasMatched)
return 0;
......@@ -486,13 +484,12 @@ static HFONT createGDIFont(const AtomicString& family, LONG desiredWeight, bool
if (!result)
return 0;
HDC dc = GetDC(0);
HWndDC dc(0);
SaveDC(dc);
SelectObject(dc, result);
WCHAR actualName[LF_FACESIZE];
GetTextFace(dc, LF_FACESIZE, actualName);
RestoreDC(dc, -1);
ReleaseDC(0, dc);
if (wcsicmp(matchData.m_chosen.lfFaceName, actualName)) {
DeleteObject(result);
......@@ -534,7 +531,7 @@ static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMET
}
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
{
HDC hdc = GetDC(0);
HWndDC hdc(0);
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
......@@ -546,8 +543,6 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne
TraitsInFamilyProcData procData(familyName);
EnumFontFamiliesEx(hdc, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
copyToVector(procData.m_traitsMasks, traitsMasks);
ReleaseDC(0, hdc);
}
FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
......
......@@ -25,6 +25,7 @@
#include "config.h"
#include "FontPlatformData.h"
#include "HWndDC.h"
#include "PlatformString.h"
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
......@@ -51,7 +52,7 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq
, m_syntheticOblique(oblique)
, m_useGDI(useGDI)
{
HDC hdc = GetDC(0);
HWndDC hdc(0);
SaveDC(hdc);
SelectObject(hdc, font);
......@@ -71,7 +72,6 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq
}
RestoreDC(hdc, -1);
ReleaseDC(0, hdc);
}
#ifndef NDEBUG
......
......@@ -33,6 +33,7 @@
#include "FontCache.h"
#include "FloatRect.h"
#include "FontDescription.h"
#include "HWndDC.h"
#include "PlatformString.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
......@@ -55,7 +56,7 @@ void SimpleFontData::platformInit()
m_isSystemFont = false;
if (m_platformData.useGDI())
return initGDIFont();
return initGDIFont();
CGFontRef font = m_platformData.cgFont();
int iAscent = CGFontGetAscent(font);
......@@ -68,14 +69,13 @@ void SimpleFontData::platformInit()
float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
if (!isCustomFont()) {
HDC dc = GetDC(0);
HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
int faceLength = GetTextFace(dc, 0, 0);
Vector<WCHAR> faceName(faceLength);
GetTextFace(dc, faceLength, faceName.data());
m_isSystemFont = !wcscmp(faceName.data(), L"Lucida Grande");
SelectObject(dc, oldFont);
ReleaseDC(0, dc);
fAscent = ascentConsideringMacAscentHack(faceName.data(), fAscent, fDescent);
}
......
......@@ -33,6 +33,7 @@
#include "FontCache.h"
#include "FloatRect.h"
#include "FontDescription.h"
#include "HWndDC.h"
#include <mlang.h>
#include <unicode/uchar.h>
#include <unicode/unorm.h>
......@@ -89,7 +90,7 @@ void SimpleFontData::initGDIFont()
return;
}
HDC hdc = GetDC(0);
HWndDC hdc(0);
HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
OUTLINETEXTMETRIC metrics;
GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
......@@ -115,9 +116,6 @@ void SimpleFontData::initGDIFont()
m_fontMetrics.setUnitsPerEm(metrics.otmEMSquare);
SelectObject(hdc, oldFont);
ReleaseDC(0, hdc);
return;
}
void SimpleFontData::platformCharWidthInit()
......@@ -185,8 +183,8 @@ bool SimpleFontData::containsCharacters(const UChar* characters, int length) con
if (!langFontLink)
return false;
HDC dc = GetDC(0);
HWndDC dc(0);
DWORD acpCodePages;
langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages);
......@@ -203,8 +201,6 @@ bool SimpleFontData::containsCharacters(const UChar* characters, int length) con
offset += numCharactersProcessed;
}
ReleaseDC(0, dc);
return true;
}
......@@ -216,7 +212,7 @@ void SimpleFontData::determinePitch()
}
// TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
HDC dc = GetDC(0);
HWndDC dc(0);
SaveDC(dc);
SelectObject(dc, m_platformData.hfont());
......@@ -227,12 +223,11 @@ void SimpleFontData::determinePitch()
m_treatAsFixedPitch = ((tm.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
RestoreDC(dc, -1);
ReleaseDC(0, dc);
}
FloatRect SimpleFontData::boundsForGDIGlyph(Glyph glyph) const
{
HDC hdc = GetDC(0);
HWndDC hdc(0);
SetGraphicsMode(hdc, GM_ADVANCED);
HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
......@@ -241,7 +236,6 @@ FloatRect SimpleFontData::boundsForGDIGlyph(Glyph glyph) const
GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
SelectObject(hdc, oldFont);
ReleaseDC(0, hdc);
return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY);
......@@ -249,7 +243,7 @@ FloatRect SimpleFontData::boundsForGDIGlyph(Glyph glyph) const
float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
{
HDC hdc = GetDC(0);
HWndDC hdc(0);
SetGraphicsMode(hdc, GM_ADVANCED);
HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
......@@ -258,7 +252,6 @@ float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
SelectObject(hdc, oldFont);
ReleaseDC(0, hdc);
return gdiMetrics.gmCellIncX + m_syntheticBoldOffset;
}
......@@ -271,12 +264,11 @@ SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
m_scriptFontProperties->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
HRESULT result = ScriptGetFontProperties(0, scriptCache(), m_scriptFontProperties);
if (result == E_PENDING) {
HDC dc = GetDC(0);
HWndDC dc(0);
SaveDC(dc);
SelectObject(dc, m_platformData.hfont());
ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties);
RestoreDC(dc, -1);
ReleaseDC(0, dc);
}
}
return m_scriptFontProperties;
......
......@@ -28,6 +28,7 @@
#include "Cursor.h"
#include "BitmapInfo.h"
#include "HWndDC.h"
#include "Image.h"
#include "IntPoint.h"
#include "SystemInfo.h"
......@@ -49,7 +50,7 @@ static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& h
static bool doAlpha = windowsVersion() >= WindowsXP;
BitmapInfo cursorImage = BitmapInfo::create(IntSize(img->width(), img->height()));
HDC dc = GetDC(0);
HWndDC dc(0);
HDC workingDC = CreateCompatibleDC(dc);
if (doAlpha) {
OwnPtr<HBITMAP> hCursor = adoptPtr(CreateDIBSection(dc, (BITMAPINFO *)&cursorImage, DIB_RGB_COLORS, 0, 0, 0));
......@@ -112,7 +113,6 @@ static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& h
DeleteDC(andMaskDC);
}
DeleteDC(workingDC);
ReleaseDC(0, dc);
return impl.release();
}
......
......@@ -29,6 +29,7 @@
#include "BitmapInfo.h"
#include "CachedImage.h"
#include "GraphicsContextCG.h"
#include "HWndDC.h"
#include "Image.h"
#include "RetainPtr.h"
......@@ -89,7 +90,7 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
IntSize srcSize = dragImageSize(image);
IntSize dstSize(static_cast<int>(srcSize.width() * scale.width()), static_cast<int>(srcSize.height() * scale.height()));
HBITMAP hbmp = 0;
HDC dc = GetDC(0);
HWndDC dc(0);
HDC dstDC = CreateCompatibleDC(dc);
if (!dstDC)
goto exit;
......@@ -116,14 +117,13 @@ exit:
hbmp = image;
if (dstDC)
DeleteDC(dstDC);
ReleaseDC(0, dc);
return hbmp;
}
DragImageRef createDragImageFromImage(Image* img)
{
HBITMAP hbmp = 0;
HDC dc = GetDC(0);
HWndDC dc(0);
HDC workingDC = CreateCompatibleDC(dc);
CGContextRef drawContext = 0;
if (!workingDC)
......@@ -155,7 +155,6 @@ DragImageRef createDragImageFromImage(Image* img)
exit:
if (workingDC)
DeleteDC(workingDC);
ReleaseDC(0, dc);
return hbmp;
}
......
......@@ -33,6 +33,7 @@
#include "FontSelector.h"
#include "Frame.h"
#include "GraphicsContext.h"
#include "HWndDC.h"
#include "Image.h"
#include "RetainPtr.h"
#include "Settings.h"
......@@ -183,18 +184,15 @@ DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* fra
// We now know how big the image needs to be, so we create and
// fill the background
HBITMAP image = 0;
HDC dc = GetDC(0);
HWndDC dc(0);
HDC workingDC = CreateCompatibleDC(dc);
if (!workingDC) {
ReleaseDC(0, dc);
if (!workingDC)
return 0;
}
PlatformGraphicsContext* contextRef;
image = allocImage(workingDC, imageSize, &contextRef);
if (!image) {
DeleteDC(workingDC);
ReleaseDC(0, dc);
return 0;
}
......@@ -225,7 +223,6 @@ DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* fra
deallocContext(contextRef);
DeleteDC(workingDC);
ReleaseDC(0, dc);
return image;
}
......
......@@ -32,6 +32,7 @@
#include "DocumentFragment.h"
#include "Element.h"
#include "Frame.h"
#include "HWndDC.h"
#include "HitTestResult.h"
#include "Image.h"
#include "KURL.h"
......@@ -223,7 +224,7 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
clear();
HDC dc = GetDC(0);
HWndDC dc(0);
HDC compatibleDC = CreateCompatibleDC(0);
HDC sourceDC = CreateCompatibleDC(0);
OwnPtr<HBITMAP> resultBitmap = adoptPtr(CreateCompatibleBitmap(dc, image->width(), image->height()));
......@@ -243,7 +244,6 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
SelectObject(compatibleDC, oldBitmap);
DeleteDC(sourceDC);
DeleteDC(compatibleDC);
ReleaseDC(0, dc);
if (::OpenClipboard(m_owner)) {
::SetClipboardData(CF_BITMAP, resultBitmap.leakPtr());
......
2012-01-23 David Levin <levin@chromium.org>
[windows] Convert usages of GetDC to HWndDC Part 1.
https://bugs.webkit.org/show_bug.cgi?id=76744
Reviewed by Adam Roben.
* WebIconDatabase.cpp:
(createDIB): Changed GetDC to HWndDC and removed ReleaseDC.
2012-01-07 Andreas Kling <awesomekling@apple.com>
Windows build fix.
......
......@@ -34,6 +34,7 @@
#include <WebCore/BString.h>
#include <WebCore/COMPtr.h>
#include <WebCore/FileSystem.h>
#include <WebCore/HWndDC.h>
#include <WebCore/IconDatabase.h>
#include <WebCore/Image.h>
#include <WebCore/PlatformString.h>
......@@ -284,11 +285,8 @@ HBITMAP createDIB(LPSIZE size)
{
BitmapInfo bmInfo = BitmapInfo::create(IntSize(*size));
HDC dc = GetDC(0);
HBITMAP result = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0);
ReleaseDC(0, dc);
return result;
HWndDC dc(0);
return CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0);
}
HBITMAP WebIconDatabase::getOrCreateSharedBitmap(LPSIZE size)
......
2012-01-23 David Levin <levin@chromium.org>
[windows] Convert usages of GetDC to HWndDC Part 1.
https://bugs.webkit.org/show_bug.cgi?id=76744
Reviewed by Adam Roben.
* UIProcess/win/WebView.cpp:
(WebKit::WebView::flashBackingStoreUpdates): Typical conversion.
2012-01-21 Timothy Hatcher <timothy@apple.com>
Make WebKit2 remember the height of the Web Inspector when it is docked.
......@@ -46,6 +46,7 @@
#include <WebCore/Editor.h>
#include <WebCore/FileSystem.h>
#include <WebCore/FloatRect.h>
#include <WebCore/HWndDC.h>
#include <WebCore/IntRect.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/Region.h>
......@@ -959,9 +960,8 @@ void WebView::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
void WebView::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
{
static HBRUSH brush = createBrush(WebPageProxy::backingStoreUpdatesFlashColor().rgb()).leakPtr();
HDC dc = ::GetDC(m_window);
HWndDC dc(m_window);
flashRects(dc, updateRects.data(), updateRects.size(), brush);
::ReleaseDC(m_window, dc);
}
WebCore::IntSize WebView::viewSize()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment