diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/platform/graphics/win | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/platform/graphics/win')
15 files changed, 114 insertions, 210 deletions
diff --git a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp index e800245..5382ef7 100644 --- a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp @@ -584,7 +584,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD #if PLATFORM(CG) bool fontCreationFailed = !result->cgFont(); #elif PLATFORM(CAIRO) - bool fontCreationFailed = !result->fontFace(); + bool fontCreationFailed = !result->scaledFont(); #endif if (fontCreationFailed) { diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp index 4aee6cd..8348acb 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp @@ -59,7 +59,7 @@ FontCustomPlatformData::~FontCustomPlatformData() } } -FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode) +FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode renderingMode) { ASSERT(m_fontReference); ASSERT(T2embedLibrary()); diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h index abdb356..65388d8 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h @@ -25,6 +25,7 @@ #include "FontRenderingMode.h" #include "FontWidthVariant.h" #include "PlatformString.h" +#include "TextOrientation.h" #include <wtf/Forward.h> #include <wtf/Noncopyable.h> @@ -46,7 +47,8 @@ public: ~FontCustomPlatformData(); - FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); + FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, + FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); static bool supportsFormat(const String&); diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp index fd30a6d..6f9bbf0 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp @@ -23,8 +23,11 @@ #include "SharedBuffer.h" #include "FontPlatformData.h" + +#include <cairo-win32.h> #include <wtf/RetainPtr.h> + namespace WebCore { FontCustomPlatformData::~FontCustomPlatformData() @@ -32,7 +35,7 @@ FontCustomPlatformData::~FontCustomPlatformData() cairo_font_face_destroy(m_fontFace); } -FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant) +FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant) { return FontPlatformData(m_fontFace, size, bold, italic); } diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h index ea3ae38..bd90f18 100644 --- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h +++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h @@ -42,7 +42,7 @@ public: } ~FontCustomPlatformData(); - FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth); + FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth); static bool supportsFormat(const String&); diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp index 9234229..287121b 100644 --- a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp @@ -115,11 +115,15 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* } FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI) - : m_font(RefCountedGDIHandle<HFONT>::create(hfont)) + : m_syntheticBold(bold) + , m_syntheticOblique(oblique) + , m_orientation(Horizontal) + , m_textOrientation(TextOrientationVerticalRight) , m_size(size) + , m_widthVariant(RegularWidth) + , m_font(RefCountedGDIHandle<HFONT>::create(hfont)) , m_cgFont(font) - , m_syntheticBold(bold) - , m_syntheticOblique(oblique) + , m_isColorBitmapFont(false) , m_useGDI(useGDI) { } @@ -128,4 +132,27 @@ FontPlatformData::~FontPlatformData() { } +void FontPlatformData::platformDataInit(const FontPlatformData& source) +{ + m_font = source.m_font; + m_cgFont = source.m_cgFont; + m_useGDI = source.m_useGDI; +} + +const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other) +{ + m_font = other.m_font; + m_cgFont = other.m_cgFont; + m_useGDI = other.m_useGDI; + + return *this; +} + +bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const +{ + return m_font == other.m_font + && m_cgFont == other.m_cgFont + && m_useGDI == other.m_useGDI; +} + } diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp index 0f5c365..e60b69b 100644 --- a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2006, 2007, 2008 Apple Inc. * Copyright (C) 2007 Alp Toker - * Copyright (C) 2008, 2010 Brent Fulgham + * Copyright (C) 2008, 2010, 2011 Brent Fulgham * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -40,7 +40,7 @@ namespace WebCore { void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName) { - m_fontFace = cairo_win32_font_face_create_for_hfont(font); + cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(font); cairo_matrix_t sizeMatrix, ctm; cairo_matrix_init_identity(&ctm); @@ -52,14 +52,18 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_SUBPIXEL); } - m_scaledFont = cairo_scaled_font_create(m_fontFace, &sizeMatrix, &ctm, fontOptions); + m_scaledFont = cairo_scaled_font_create(fontFace, &sizeMatrix, &ctm, fontOptions); + cairo_font_face_destroy(fontFace); } FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique) : m_font(0) , m_size(size) - , m_fontFace(fontFace) + , m_orientation(Horizontal) + , m_textOrientation(TextOrientationVerticalRight) + , m_widthVariant(RegularWidth) , m_scaledFont(0) + , m_isColorBitmapFont(false) , m_syntheticBold(bold) , m_syntheticOblique(oblique) , m_useGDI(false) @@ -79,64 +83,39 @@ FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool cairo_font_options_destroy(options); } -FontPlatformData::FontPlatformData(const FontPlatformData& source) - : m_font(source.m_font) - , m_size(source.m_size) - , m_fontFace(0) - , m_scaledFont(0) - , m_syntheticBold(source.m_syntheticBold) - , m_syntheticOblique(source.m_syntheticOblique) - , m_useGDI(source.m_useGDI) +FontPlatformData::~FontPlatformData() { - if (source.m_fontFace) - m_fontFace = cairo_font_face_reference(source.m_fontFace); - - if (source.m_scaledFont) - m_scaledFont = cairo_scaled_font_reference(source.m_scaledFont); + if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue()) + cairo_scaled_font_destroy(m_scaledFont); } - -FontPlatformData::~FontPlatformData() +void FontPlatformData::platformDataInit(const FontPlatformData& source) { - cairo_scaled_font_destroy(m_scaledFont); - cairo_font_face_destroy(m_fontFace); + m_font = source.m_font; + m_useGDI = source.m_useGDI; + m_scaledFont = 0; + + if (source.m_scaledFont) + m_scaledFont = cairo_scaled_font_reference(source.m_scaledFont); } -FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other) +const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other) { - // Check for self-assignment. - if (this == &other) - return *this; - m_font = other.m_font; - m_size = other.m_size; - m_syntheticBold = other.m_syntheticBold; - m_syntheticOblique = other.m_syntheticOblique; m_useGDI = other.m_useGDI; - if (other.m_fontFace) - cairo_font_face_reference(other.m_fontFace); - if (m_fontFace) - cairo_font_face_destroy(m_fontFace); - m_fontFace = other.m_fontFace; - - if (other.m_scaledFont) - cairo_scaled_font_reference(other.m_scaledFont); - if (m_scaledFont) + if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue()) cairo_scaled_font_destroy(m_scaledFont); - m_scaledFont = other.m_scaledFont; + + m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont); return *this; } -bool FontPlatformData::operator==(const FontPlatformData& other) const -{ +bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const +{ return m_font == other.m_font - && m_fontFace == other.m_fontFace && m_scaledFont == other.m_scaledFont - && m_size == other.m_size - && m_syntheticBold == other.m_syntheticBold - && m_syntheticOblique == other.m_syntheticOblique && m_useGDI == other.m_useGDI; } diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp index 09ed4a6..301198d 100644 --- a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp @@ -38,12 +38,15 @@ namespace WebCore { FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI) : m_font(RefCountedGDIHandle<HFONT>::create(font)) , m_size(size) + , m_orientation(Horizontal) + , m_textOrientation(TextOrientationVerticalRight) + , m_widthVariant(RegularWidth) #if PLATFORM(CG) , m_cgFont(0) #elif PLATFORM(CAIRO) - , m_fontFace(0) , m_scaledFont(0) #endif + , m_isColorBitmapFont(false) , m_syntheticBold(bold) , m_syntheticOblique(oblique) , m_useGDI(useGDI) @@ -71,20 +74,6 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq ReleaseDC(0, hdc); } -FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) - : m_size(size) -#if PLATFORM(CG) - , m_cgFont(0) -#elif PLATFORM(CAIRO) - , m_fontFace(0) - , m_scaledFont(0) -#endif - , m_syntheticBold(bold) - , m_syntheticOblique(oblique) - , m_useGDI(false) -{ -} - #ifndef NDEBUG String FontPlatformData::description() const { diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp index 47c44bc..9e31f56 100644 --- a/Source/WebCore/platform/graphics/win/FontWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontWin.cpp @@ -127,8 +127,8 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon UniscribeController controller(this, run, fallbackFonts); controller.advance(run.length()); if (glyphOverflow) { - glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - fontMetrics().ascent()); - glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - fontMetrics().descent()); + glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent())); + glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent())); glyphOverflow->left = max<int>(0, ceilf(-controller.minGlyphBoundingBoxX())); glyphOverflow->right = max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.runWidthSoFar())); } diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp index b2c702f..7ce7ee9 100644 --- a/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp +++ b/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp @@ -72,18 +72,15 @@ GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha) void GraphicsContext::platformInit(HDC dc, bool hasAlpha) { - m_data = new GraphicsContextPlatformPrivate; - - if (dc) { - m_data->cr = createCairoContextWithHDC(dc, hasAlpha); - m_data->m_hdc = dc; - } else { + cairo_t* cr = 0; + if (dc) + cr = createCairoContextWithHDC(dc, hasAlpha); + else setPaintingDisabled(true); - m_data->cr = 0; - m_data->m_hdc = 0; - } - if (m_data->cr) { + m_data = new GraphicsContextPlatformPrivateTopLevel(new PlatformContextCairo(cr)); + m_data->m_hdc = dc; + if (platformContext()->cr()) { // Make sure the context starts in sync with our state. setPlatformFillColor(fillColor(), fillColorSpace()); setPlatformStrokeColor(strokeColor(), strokeColorSpace()); @@ -131,24 +128,25 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo // Scale the target surface to the new image size, and flip it // so that when we set the srcImage as the surface it will draw // right-side-up. - cairo_save(m_data->cr); - cairo_translate(m_data->cr, dstRect.x(), dstRect.height() + dstRect.y()); - cairo_scale(m_data->cr, 1.0, -1.0); - cairo_set_source_surface(m_data->cr, image, 0, 0); + cairo_t* cr = platformContext()->cr(); + cairo_save(cr); + cairo_translate(cr, dstRect.x(), dstRect.height() + dstRect.y()); + cairo_scale(cr, 1, -1); + cairo_set_source_surface(cr, image, 0, 0); if (m_data->layers.size()) - cairo_paint_with_alpha(m_data->cr, m_data->layers.last()); + cairo_paint_with_alpha(cr, m_data->layers.last()); else - cairo_paint(m_data->cr); + cairo_paint(cr); // Delete all our junk. cairo_surface_destroy(image); ::DeleteDC(hdc); ::DeleteObject(bitmap); - cairo_restore(m_data->cr); + cairo_restore(cr); } -void GraphicsContextPlatformPrivate::syncContext(PlatformGraphicsContext* cr) +void GraphicsContextPlatformPrivate::syncContext(cairo_t* cr) { if (!cr) return; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp index 40fe1d1..bac85f7 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp @@ -28,8 +28,11 @@ #if ENABLE(VIDEO) #include "MediaPlayerPrivateQuickTimeVisualContext.h" +#include "ApplicationCacheHost.h" +#include "ApplicationCacheResource.h" #include "Cookie.h" #include "CookieJar.h" +#include "DocumentLoader.h" #include "Frame.h" #include "FrameView.h" #include "GraphicsContext.h" @@ -369,7 +372,16 @@ void MediaPlayerPrivateQuickTimeVisualContext::loadInternal(const String& url) setUpCookiesForQuickTime(url); m_movie = adoptRef(new QTMovie(m_movieClient.get())); - m_movie->load(url.characters(), url.length(), m_player->preservesPitch()); + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0; + ApplicationCacheHost* cacheHost = frame ? frame->loader()->documentLoader()->applicationCacheHost() : 0; + ApplicationCacheResource* resource = 0; + if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource) && resource && !resource->path().isEmpty()) + m_movie->load(resource->path().characters(), resource->path().length(), m_player->preservesPitch()); + else +#endif + m_movie->load(url.characters(), url.length(), m_player->preservesPitch()); m_movie->setVolume(m_player->volume()); } diff --git a/Source/WebCore/platform/graphics/win/QTMovie.cpp b/Source/WebCore/platform/graphics/win/QTMovie.cpp index 05fbb86..6f9c668 100644 --- a/Source/WebCore/platform/graphics/win/QTMovie.cpp +++ b/Source/WebCore/platform/graphics/win/QTMovie.cpp @@ -442,6 +442,17 @@ void QTMovie::getNaturalSize(int& width, int& height) height = (rect.bottom - rect.top) * m_private->m_heightScaleFactor; } +void QTMovie::loadPath(const UChar* url, int len, bool preservesPitch) +{ + CFStringRef urlStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(url), len); + CFURLRef cfURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, urlStringRef, kCFURLWindowsPathStyle, false); + + load(cfURL, preservesPitch); + + CFRelease(cfURL); + CFRelease(urlStringRef); +} + void QTMovie::load(const UChar* url, int len, bool preservesPitch) { CFStringRef urlStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(url), len); diff --git a/Source/WebCore/platform/graphics/win/QTMovie.h b/Source/WebCore/platform/graphics/win/QTMovie.h index e97d16d..38b3473 100644 --- a/Source/WebCore/platform/graphics/win/QTMovie.h +++ b/Source/WebCore/platform/graphics/win/QTMovie.h @@ -70,6 +70,7 @@ public: void addClient(QTMovieClient*); void removeClient(QTMovieClient*); + void loadPath(const UChar* url, int len, bool preservesPitch); void load(const UChar* url, int len, bool preservesPitch); void load(CFURLRef, bool preservesPitch); diff --git a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp index 30a931e..12f1127 100644 --- a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp +++ b/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp @@ -97,18 +97,14 @@ void SimpleFontData::platformInit() m_fontMetrics.setLineGap(fLineGap); m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap)); - // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font. - // Unfortunately, NSFont will round this for us so we don't quite get the right value. GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); Glyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0; if (xGlyph) { + // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the + // reported x-height to only include the portion of the glyph that is above the baseline. CGRect xBox; CGFontGetGlyphBBoxes(font, &xGlyph, 1, &xBox); - // Use the maximum of either width or height because "x" is nearly square - // and web pages that foolishly use this metric for width will be laid out - // poorly if we return an accurate height. Classic case is Times 13 point, - // which has an "x" that is 7x6 pixels. - m_fontMetrics.setXHeight(scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), unitsPerEm) * pointSize); + m_fontMetrics.setXHeight(scaleEmToUnits(CGRectGetMaxY(xBox), unitsPerEm) * pointSize); } else { int iXHeight = CGFontGetXHeight(font); m_fontMetrics.setXHeight(scaleEmToUnits(iXHeight, unitsPerEm) * pointSize); diff --git a/Source/WebCore/platform/graphics/win/cairo/FontPlatformData.h b/Source/WebCore/platform/graphics/win/cairo/FontPlatformData.h deleted file mode 100644 index d8f538a..0000000 --- a/Source/WebCore/platform/graphics/win/cairo/FontPlatformData.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com - * Copyright (C) 2007 Holger Hans Peter Freyther - * Copyright (C) 2007 Pioneer Research Center USA, Inc. - * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org> - * All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef FontPlatformDataCairoWin_h -#define FontPlatformDataCairoWin_h - -#include "FontOrientation.h" -#include "GlyphBuffer.h" -#include "RefCountedGDIHandle.h" -#include "StringImpl.h" -#include <cairo-win32.h> -#include <cairo.h> -#include <wtf/Forward.h> - -typedef struct HFONT__* HFONT; - -namespace WebCore { - -class FontDescription; - -class FontPlatformData { -public: - FontPlatformData(WTF::HashTableDeletedValueType) - : m_fontFace(0) - , m_useGDI(false) - , m_font(WTF::HashTableDeletedValue) - , m_size(0) - , m_syntheticBold(false) - , m_syntheticOblique(false) - , m_scaledFont(0) - { } - - FontPlatformData() - : m_fontFace(0) - , m_useGDI(false) - , m_size(0) - , m_syntheticBold(false) - , m_syntheticOblique(false) - , m_scaledFont(0) - { } - - FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI); - FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic); - FontPlatformData(float size, bool bold, bool italic); - FontPlatformData(const FontPlatformData&); - ~FontPlatformData(); - - HFONT hfont() const { return m_font->handle(); } - bool useGDI() const { return m_useGDI; } - cairo_font_face_t* fontFace() const { return m_fontFace; } - - bool isFixedPitch(); - float size() const { return m_size; } - void setSize(float size) { m_size = size; } - bool syntheticBold() const { return m_syntheticBold; } - bool syntheticOblique() const { return m_syntheticOblique; } - - FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. - - cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } - - unsigned hash() const - { - return m_font->hash(); - } - - bool operator==(const FontPlatformData&) const; - FontPlatformData& operator=(const FontPlatformData&); - bool isHashTableDeletedValue() const - { - return m_font.isHashTableDeletedValue(); - } - -#ifndef NDEBUG - String description() const; -#endif - -private: - void platformDataInit(HFONT, float size, HDC, WCHAR* faceName); - - RefPtr<RefCountedGDIHandle<HFONT> > m_font; - cairo_font_face_t* m_fontFace; - bool m_useGDI; - float m_size; - bool m_syntheticBold; - bool m_syntheticOblique; - cairo_scaled_font_t* m_scaledFont; -}; - -} - -#endif // FontPlatformDataCairoWin_h |