https://bugs.webkit.org/show_bug.cgi?id=76290
Reviewed by Dmitry Titov.
* platform/graphics/chromium/FontCacheChromiumWin.cpp:
(WebCore::createFontIndirectAndGetWinName):
(WebCore::fontContainsCharacter):
(WebCore::FontCache::getLastResortFallbackFont):
(WebCore::FontCache::getTraitsInFamily):
* platform/graphics/chromium/FontPlatformDataChromiumWin.cpp:
(WebCore::FontPlatformData::scriptFontProperties):
* platform/graphics/chromium/FontUtilsChromiumWin.cpp:
(WebCore::FontMap::getAscent):
(WebCore::FontMap::getSpaceGlyph):
* platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp:
(WebCore::fillBMPGlyphs):
* platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:
(WebCore::SimpleFontData::platformInit):
(WebCore::SimpleFontData::determinePitch):
(WebCore::SimpleFontData::platformWidthForGlyph):
* platform/graphics/chromium/UniscribeHelper.cpp:
(WebCore::UniscribeHelper::EnsureCachedDCCreated):
* rendering/RenderThemeChromiumWin.cpp:
(WebCore::systemFontSize):
(WebCore::pointsToPixels):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105654
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-13 David Levin <levin@chromium.org>
+
+ [chromium] Convert uses of GetDC to HWndDC.
+ https://bugs.webkit.org/show_bug.cgi?id=76290
+
+ Reviewed by Dmitry Titov.
+
+ * platform/graphics/chromium/FontCacheChromiumWin.cpp:
+ (WebCore::createFontIndirectAndGetWinName):
+ (WebCore::fontContainsCharacter):
+ (WebCore::FontCache::getLastResortFallbackFont):
+ (WebCore::FontCache::getTraitsInFamily):
+ * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp:
+ (WebCore::FontPlatformData::scriptFontProperties):
+ * platform/graphics/chromium/FontUtilsChromiumWin.cpp:
+ (WebCore::FontMap::getAscent):
+ (WebCore::FontMap::getSpaceGlyph):
+ * platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp:
+ (WebCore::fillBMPGlyphs):
+ * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:
+ (WebCore::SimpleFontData::platformInit):
+ (WebCore::SimpleFontData::determinePitch):
+ (WebCore::SimpleFontData::platformWidthForGlyph):
+ * platform/graphics/chromium/UniscribeHelper.cpp:
+ (WebCore::UniscribeHelper::EnsureCachedDCCreated):
+ * rendering/RenderThemeChromiumWin.cpp:
+ (WebCore::systemFontSize):
+ (WebCore::pointsToPixels):
+
2012-01-23 Joe Thomas <joethomas@motorola.com>
https://bugs.webkit.org/show_bug.cgi?id=75799
/*
* Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
+ * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include "FontUtilsChromiumWin.h"
#include "HashMap.h"
#include "HashSet.h"
+#include "HWndDC.h"
#include "PlatformSupport.h"
#include "SimpleFontData.h"
#include <unicode/uniset.h>
if (!hfont)
return 0;
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
WCHAR name[LF_FACESIZE];
unsigned resultLength = GetTextFace(dc, LF_FACESIZE, name);
resultLength--; // ignore the null terminator
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
*winName = String(name, resultLength);
return hfont;
}
return it->second->contains(character);
HFONT hfont = fontData->hfont();
- HDC hdc = GetDC(0);
+ HWndDC hdc(0);
HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(hdc, hfont));
int count = GetFontUnicodeRanges(hdc, 0);
if (!count && PlatformSupport::ensureFontLoaded(hfont))
if (!count) {
LOG_ERROR("Unable to get the font unicode range after second attempt");
SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
return true;
}
count = GetFontUnicodeRanges(hdc, glyphset);
ASSERT(count > 0);
SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
// FIXME: consider doing either of the following two:
// 1) port back ICU 4.0's faster look-up code for UnicodeSet
// both GetTextFace() and EnumFontFamilies() return the localized name. So,
// FontCache::createFontPlatformData() does not filter out the fonts
// returned by this EnumFontFamilies() call.
- HDC dc = GetDC(0);
+ HWndDC dc(0);
if (dc) {
GetLastResortFallbackFontProcData procData(this, &description, shouldRetain, fallbackFontName);
EnumFontFamilies(dc, 0, getLastResortFallbackFontProc, reinterpret_cast<LPARAM>(&procData));
- ReleaseDC(0, dc);
if (procData.m_fontData)
return procData.m_fontData;
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
{
- HDC hdc = GetDC(0);
+ HWndDC hdc(0);
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
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)
/*
* Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include <objidl.h>
#include <mlang.h>
+#include "HWndDC.h"
#include "PlatformSupport.h"
#include "SkTypeface_win.h"
#include "SkiaFontWin.h"
HRESULT result = ScriptGetFontProperties(0, scriptCache(),
m_scriptFontProperties);
if (result == E_PENDING) {
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, hfont());
HRESULT hr = ScriptGetFontProperties(dc, scriptCache(),
m_scriptFontProperties);
}
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
}
}
return m_scriptFontProperties;
/*
- * Copyright (c) 2006, 2007, 2008, 2009, 2010, Google Inc. All rights reserved.
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include <limits>
+#include "HWndDC.h"
#include "PlatformString.h"
#include "UniscribeHelper.h"
#include <unicode/locid.h>
fontName);
if (!hfont)
return false;
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
WCHAR actualFontName[LF_FACESIZE];
GetTextFace(dc, LF_FACESIZE, actualFontName);
actualFontName[LF_FACESIZE - 1] = 0;
SelectObject(dc, oldFont);
DeleteObject(hfont);
- ReleaseDC(0, dc);
// We don't have to worry about East Asian fonts with locale-dependent
// names here for now.
return !wcscmp(fontName, actualFontName);
// kUndefinedAscent is returned, instead.
int getAscent(HFONT hfont)
{
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, hfont);
TEXTMETRIC tm;
BOOL gotMetrics = GetTextMetrics(dc, &tm);
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
return gotMetrics ? tm.tmAscent : kUndefinedAscent;
}
WORD getSpaceGlyph(HFONT hfont)
{
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, hfont);
WCHAR space = L' ';
WORD spaceGlyph = 0;
GetGlyphIndices(dc, &space, 1, &spaceGlyph, 0);
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
return spaceGlyph;
}
GlyphPage* page,
const SimpleFontData* fontData)
{
- HWndDC dc((HWND)0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, fontData->platformData().hfont());
TEXTMETRIC tm = {0};
#include "Font.h"
#include "FontCache.h"
#include "FontDescription.h"
+#include "HWndDC.h"
#include "PlatformSupport.h"
#include <wtf/MathExtras.h>
return;
}
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
TEXTMETRIC textMetric = {0};
m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
}
void SimpleFontData::platformCharWidthInit()
void SimpleFontData::determinePitch()
{
// TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
// Yes, this looks backwards, but the fixed pitch bit is actually set if the font
m_treatAsFixedPitch = ((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
}
FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
if (!m_platformData.size())
return 0;
- HDC dc = GetDC(0);
+ HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
int width = 0;
}
SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
return static_cast<float>(width);
}
/*
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include "Font.h"
#include "FontUtilsChromiumWin.h"
+#include "HWndDC.h"
#include "PlatformContextSkia.h"
#include "SkiaFontWin.h"
#include "SkPoint.h"
// Allocate a memory DC that is compatible with the Desktop DC since we don't have any window,
// and we don't want to use the Desktop DC directly since it can have nasty side effects
// as identified in Chrome Issue http://crbug.com/59315.
- HDC screenDC = ::GetDC(0);
+ HWndDC screenDC(0);
m_cachedDC = ::CreateCompatibleDC(screenDC);
ASSERT(m_cachedDC);
-
- int result = ::ReleaseDC(0, screenDC);
- ASSERT(result == 1);
}
+
void UniscribeHelper::fillShapes()
{
m_shapes.resize(m_runs.size());
#include "GraphicsContext.h"
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
+#include "HWndDC.h"
#include "MediaControlElements.h"
#include "PaintInfo.h"
#include "PlatformSupport.h"
if (size < 0) {
HFONT hFont = CreateFontIndirect(&font);
if (hFont) {
- HDC hdc = GetDC(0); // What about printing? Is this the right DC?
+ HWndDC hdc(0); // What about printing? Is this the right DC?
if (hdc) {
HGDIOBJ hObject = SelectObject(hdc, hFont);
TEXTMETRIC tm;
GetTextMetrics(hdc, &tm);
SelectObject(hdc, hObject);
- ReleaseDC(0, hdc);
size = tm.tmAscent;
}
DeleteObject(hFont);
{
static float pixelsPerInch = 0.0f;
if (!pixelsPerInch) {
- HDC hdc = GetDC(0); // What about printing? Is this the right DC?
- if (hdc) { // Can this ever actually be NULL?
+ HWndDC hdc(0); // What about printing? Is this the right DC?
+ if (hdc) // Can this ever actually be NULL?
pixelsPerInch = GetDeviceCaps(hdc, LOGPIXELSY);
- ReleaseDC(0, hdc);
- } else {
+ else
pixelsPerInch = 96.0f;
- }
}
static const float pointsPerInch = 72.0f;