diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 01:35:31 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 01:35:31 +0000 |
commit | f7eafd723ab7640c81ddb2309620bcc7963fe66d (patch) | |
tree | d1653fba75c15d85d3166356b850417037de8b76 | |
parent | fb7f9bef3ceecd5a3efb9252410f6850320462b8 (diff) | |
download | chromium_src-f7eafd723ab7640c81ddb2309620bcc7963fe66d.zip chromium_src-f7eafd723ab7640c81ddb2309620bcc7963fe66d.tar.gz chromium_src-f7eafd723ab7640c81ddb2309620bcc7963fe66d.tar.bz2 |
Stub out Font functions for Linux
Review URL: http://codereview.chromium.org/7842
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3716 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 397 insertions, 128 deletions
diff --git a/webkit/SConscript.port b/webkit/SConscript.port index ae043d0..093ce42 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -180,6 +180,10 @@ if env['PLATFORM'] == 'posix': input_files.extend([ '$PORT_DIR/platform/chromium/FileSystemPosix.cpp', '$PORT_DIR/platform/chromium/SoundPosix.cpp', + '$PORT_DIR/platform/graphics/chromium/FontLinux.cpp', + '$PORT_DIR/platform/graphics/chromium/FontCacheLinux.cpp', + '$PORT_DIR/platform/graphics/chromium/FontPlatformDataLinux.cpp', + '$PORT_DIR/platform/graphics/chromium/SimpleFontDataLinux.cpp', ]) if env['PLATFORM'] == 'darwin': diff --git a/webkit/port/platform/graphics/FontPlatformData.h b/webkit/port/platform/graphics/FontPlatformData.h index 362ed16..0453244 100644 --- a/webkit/port/platform/graphics/FontPlatformData.h +++ b/webkit/port/platform/graphics/FontPlatformData.h @@ -1,134 +1,17 @@ -/* - * This file is part of the internal font implementation. It should not be included by anyone other than - * FontMac.cpp, FontWin.cpp and Font.cpp. - * - * Copyright (C) 2006, 2007 Apple Inc. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. -#ifndef FontPlatformData_H -#define FontPlatformData_H +#ifndef FontPlatformData_h +#define FontPlatformData_h #include "config.h" +#include "build/build_config.h" -#include "StringImpl.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> - -// TODO(tc): Once this file is only included by the ChromiumWin build, we can -// remove the PLATFORM #ifs. -#if PLATFORM(WIN_OS) -#include <usp10.h> -#endif - -typedef struct HFONT__ *HFONT; - -namespace WebCore { - -class FontDescription; - -class FontPlatformData -{ -public: - // Used for deleted values in the font cache's hash tables. The hash table - // will create us with this structure, and it will compare other values - // to this "Deleted" one. It expects the Deleted one to be differentiable - // from the NULL one (created with the empty constructor), so we can't just - // set everything to NULL. - FontPlatformData(WTF::HashTableDeletedValueType); - FontPlatformData(); - FontPlatformData(HFONT hfont, float size, - bool isMLangFont); - FontPlatformData(float size, bool bold, bool oblique); - FontPlatformData(const FontPlatformData& data); - - FontPlatformData& operator=(const FontPlatformData& data); - - bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); } - - ~FontPlatformData(); - - HFONT hfont() const { return m_font ? m_font->hfont() : 0; } - float size() const { return m_size; } - - unsigned hash() const - { - return m_font ? m_font->hash() : NULL; - } - - bool operator==(const FontPlatformData& other) const - { - return m_font == other.m_font && m_size == other.m_size; - } - -#if PLATFORM(WIN_OS) - SCRIPT_FONTPROPERTIES* scriptFontProperties() const; - SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; } +#if defined(OS_WIN) +#include "FontPlatformDataWin.h" +#elif defined(OS_LINUX) +#include "FontPlatformDataLinux.h" #endif -private: - // We refcount the internal HFONT so that FontPlatformData can be - // efficiently copied. WebKit depends on being able to copy it, and we - // don't really want to re-create the HFONT. - class RefCountedHFONT : public RefCounted<RefCountedHFONT> { - public: - static PassRefPtr<RefCountedHFONT> create(HFONT hfont, bool isMLangFont) - { - return adoptRef(new RefCountedHFONT(hfont, isMLangFont)); - } - - ~RefCountedHFONT(); - - HFONT hfont() const { return m_hfont; } - unsigned hash() const - { - return StringImpl::computeHash(reinterpret_cast<const UChar*>(&m_hfont), sizeof(HFONT) / sizeof(UChar)); - } - - bool operator==(const RefCountedHFONT& other) const - { - return m_hfont == other.m_hfont; - } - - private: - // The create() function assumes there is already a refcount of one - // so it can do adoptRef. - RefCountedHFONT(HFONT hfont, bool isMLangFont) - : m_hfont(hfont) - , m_isMLangFont(isMLangFont) - { - } - - HFONT m_hfont; - bool m_isMLangFont; - }; - - static RefCountedHFONT* hashTableDeletedFontValue(); - - RefPtr<RefCountedHFONT> m_font; - float m_size; // Point size of the font in pixels. - -#if PLATFORM(WIN_OS) - mutable SCRIPT_CACHE m_scriptCache; - mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties; -#endif -}; - -} - -#endif +#endif // ifndef FontPlatformData_h diff --git a/webkit/port/platform/graphics/FontPlatformDataWin.h b/webkit/port/platform/graphics/FontPlatformDataWin.h new file mode 100644 index 0000000..7c9ef40 --- /dev/null +++ b/webkit/port/platform/graphics/FontPlatformDataWin.h @@ -0,0 +1,134 @@ +/* + * This file is part of the internal font implementation. It should not be included by anyone other than + * FontMac.cpp, FontWin.cpp and Font.cpp. + * + * Copyright (C) 2006, 2007 Apple Inc. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef FontPlatformDataWin_H +#define FontPlatformDataWin_H + +#include "config.h" + +#include "StringImpl.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +// TODO(tc): Once this file is only included by the ChromiumWin build, we can +// remove the PLATFORM #ifs. +#if PLATFORM(WIN_OS) +#include <usp10.h> +#endif + +typedef struct HFONT__ *HFONT; + +namespace WebCore { + +class FontDescription; + +class FontPlatformData +{ +public: + // Used for deleted values in the font cache's hash tables. The hash table + // will create us with this structure, and it will compare other values + // to this "Deleted" one. It expects the Deleted one to be differentiable + // from the NULL one (created with the empty constructor), so we can't just + // set everything to NULL. + FontPlatformData(WTF::HashTableDeletedValueType); + FontPlatformData(); + FontPlatformData(HFONT hfont, float size, + bool isMLangFont); + FontPlatformData(float size, bool bold, bool oblique); + FontPlatformData(const FontPlatformData& data); + + FontPlatformData& operator=(const FontPlatformData& data); + + bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); } + + ~FontPlatformData(); + + HFONT hfont() const { return m_font ? m_font->hfont() : 0; } + float size() const { return m_size; } + + unsigned hash() const + { + return m_font ? m_font->hash() : NULL; + } + + bool operator==(const FontPlatformData& other) const + { + return m_font == other.m_font && m_size == other.m_size; + } + +#if PLATFORM(WIN_OS) + SCRIPT_FONTPROPERTIES* scriptFontProperties() const; + SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; } +#endif + +private: + // We refcount the internal HFONT so that FontPlatformData can be + // efficiently copied. WebKit depends on being able to copy it, and we + // don't really want to re-create the HFONT. + class RefCountedHFONT : public RefCounted<RefCountedHFONT> { + public: + static PassRefPtr<RefCountedHFONT> create(HFONT hfont, bool isMLangFont) + { + return adoptRef(new RefCountedHFONT(hfont, isMLangFont)); + } + + ~RefCountedHFONT(); + + HFONT hfont() const { return m_hfont; } + unsigned hash() const + { + return StringImpl::computeHash(reinterpret_cast<const UChar*>(&m_hfont), sizeof(HFONT) / sizeof(UChar)); + } + + bool operator==(const RefCountedHFONT& other) const + { + return m_hfont == other.m_hfont; + } + + private: + // The create() function assumes there is already a refcount of one + // so it can do adoptRef. + RefCountedHFONT(HFONT hfont, bool isMLangFont) + : m_hfont(hfont) + , m_isMLangFont(isMLangFont) + { + } + + HFONT m_hfont; + bool m_isMLangFont; + }; + + static RefCountedHFONT* hashTableDeletedFontValue(); + + RefPtr<RefCountedHFONT> m_font; + float m_size; // Point size of the font in pixels. + +#if PLATFORM(WIN_OS) + mutable SCRIPT_CACHE m_scriptCache; + mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties; +#endif +}; + +} + +#endif diff --git a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp new file mode 100644 index 0000000..6630f670 --- /dev/null +++ b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp @@ -0,0 +1,67 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "FontCache.h" +#include "AtomicString.h" + +#include "NotImplemented.h" + +namespace WebCore { + +// TODO(agl): stubs only + + +void FontCache::platformInit() { } + +const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, + const UChar* characters, + int length) +{ + notImplemented(); + return NULL; +} + +const AtomicString& FontCache::alternateFamilyName(const AtomicString& familyName) +{ + notImplemented(); + + // This is just to stop GCC emitting a warning about returning a reference + // to a temporary variable + static AtomicString a; + return a; +} + +FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) +{ + return 0; +} + +FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description) +{ + notImplemented(); + return 0; +} + +void FontCache::getTraitsInFamily(const AtomicString& familyName, + Vector<unsigned>& traitsMasks) +{ + notImplemented(); +} + +FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, + const AtomicString& family) +{ + notImplemented(); + return 0; +} + +AtomicString FontCache::getGenericFontForScript(UScriptCode script, + const FontDescription&) +{ + notImplemented(); + return AtomicString(); +} + +} // namespace WebCore diff --git a/webkit/port/platform/graphics/chromium/FontLinux.cpp b/webkit/port/platform/graphics/chromium/FontLinux.cpp new file mode 100644 index 0000000..9ee965f --- /dev/null +++ b/webkit/port/platform/graphics/chromium/FontLinux.cpp @@ -0,0 +1,49 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "Font.h" + +#include "FloatRect.h" +#include "NotImplemented.h" + +namespace WebCore { + +// TODO(agl): stubs only + +void Font::drawGlyphs(GraphicsContext*, const SimpleFontData*, + const GlyphBuffer&, int from, int to, + const FloatPoint&) const +{ + notImplemented(); +} + +void Font::drawComplexText(GraphicsContext* context, const TextRun& run, + const FloatPoint& point, int from, int to) const +{ + notImplemented(); +} + +float Font::floatWidthForComplexText(const TextRun& run) const +{ + notImplemented(); + return 0; +} + +int Font::offsetForPositionForComplexText(const TextRun& run, int x, + bool includePartialGlyphs) const +{ + notImplemented(); + return 0; +} + +FloatRect Font::selectionRectForComplexText(const TextRun& run, + const IntPoint& point, int h, + int from, int to) const +{ + notImplemented(); + return FloatRect(); +} + +} // namespace WebCore diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp new file mode 100644 index 0000000..814ca82 --- /dev/null +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -0,0 +1,51 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "FontPlatformData.h" + +#include "NotImplemented.h" + +namespace WebCore { + +// TODO(agl): stubs only + +FontPlatformData::FontPlatformData() { + notImplemented(); +} + +FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) { + notImplemented(); +} + +FontPlatformData::FontPlatformData(const FontDescription& fontDescription, + const AtomicString& familyName) { + notImplemented(); +} + +FontPlatformData::~FontPlatformData() { + notImplemented(); +} + +bool FontPlatformData::isHashTableDeletedValue() const { + notImplemented(); + return false; +} + +unsigned FontPlatformData::hash() const { + notImplemented(); + return 0; +} + +bool FontPlatformData::operator==(const FontPlatformData &other) const { + notImplemented(); + return false; +} + +float FontPlatformData::size() const { + notImplemented(); + return 0; +} + +} // namespace WebCore diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h new file mode 100644 index 0000000..33ce2bb --- /dev/null +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h @@ -0,0 +1,36 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FontPlatformDataLinux_h +#define FontPlatformDataLinux_h + +#include "config.h" +#include "build/build_config.h" + +#include "StringImpl.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class FontDescription; + +// TODO(agl): stubs only + +class FontPlatformData { +public: + FontPlatformData(); + FontPlatformData(WTF::HashTableDeletedValueType); + FontPlatformData(const FontDescription&, const AtomicString& family); + ~FontPlatformData(); + + bool isHashTableDeletedValue() const; + unsigned hash() const; + bool operator==(const FontPlatformData& other) const; + float size() const; +}; + +} // namespace WebCore + +#endif // ifdef FontPlatformData_h diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp new file mode 100644 index 0000000..4525bd3 --- /dev/null +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -0,0 +1,45 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" +#include "Font.h" +#include "FontCache.h" +#include "SimpleFontData.h" +#include "FloatRect.h" +#include "FontDescription.h" +#include "NotImplemented.h" + +namespace WebCore { + +// TODO(agl): only stubs + +void SimpleFontData::platformInit() { } + +void SimpleFontData::platformDestroy() { } + +SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const +{ + notImplemented(); + return NULL; +} + +bool SimpleFontData::containsCharacters(const UChar* characters, + int length) const +{ + notImplemented(); + return false; +} + +void SimpleFontData::determinePitch() +{ + notImplemented(); +} + +float SimpleFontData::platformWidthForGlyph(Glyph glyph) const +{ + notImplemented(); + return 0; +} + +} // namespace WebCore |