• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the internal font implementation.  It should not be included by anyone other than
3  * FontMac.cpp, FontWin.cpp and Font.cpp.
4  *
5  * Copyright (C) 2006 Apple Computer, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 // This file has no guards on purpose in order to detect redundant includes. This is a private header
25 // and so this may catch someone trying to include this file in public cpp files.
26 
27 #include "FontSelector.h"
28 #include "SimpleFontData.h"
29 #include <wtf/Forward.h>
30 
31 namespace WebCore {
32 
33 class Font;
34 class GlyphPageTreeNode;
35 class GraphicsContext;
36 class IntRect;
37 class FontDescription;
38 class FontPlatformData;
39 class FontSelector;
40 
41 const int cAllFamiliesScanned = -1;
42 
43 class FontFallbackList : public RefCounted<FontFallbackList> {
44 public:
create()45     static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
46 
~FontFallbackList()47     ~FontFallbackList() { releaseFontData(); }
48     void invalidate(PassRefPtr<FontSelector>);
49 
isFixedPitch(const Font * f)50     bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
51     void determinePitch(const Font*) const;
52 
loadingCustomFonts()53     bool loadingCustomFonts() const { return m_loadingCustomFonts; }
54 
fontSelector()55     FontSelector* fontSelector() const { return m_fontSelector.get(); }
generation()56     unsigned generation() const { return m_generation; }
57 
58 private:
59     FontFallbackList();
60 
primarySimpleFontData(const Font * f)61     const SimpleFontData* primarySimpleFontData(const Font* f)
62     {
63         ASSERT(isMainThread());
64         if (!m_cachedPrimarySimpleFontData)
65             m_cachedPrimarySimpleFontData = primaryFontData(f)->fontDataForCharacter(' ');
66         return m_cachedPrimarySimpleFontData;
67     }
68 
primaryFontData(const Font * f)69     const FontData* primaryFontData(const Font* f) const { return fontDataAt(f, 0); }
70     const FontData* fontDataAt(const Font*, unsigned index) const;
71     const FontData* fontDataForCharacters(const Font*, const UChar*, int length) const;
72 
73     void setPlatformFont(const FontPlatformData&);
74 
75     void releaseFontData();
76 
77     mutable Vector<pair<const FontData*, bool>, 1> m_fontList;
78     mutable HashMap<int, GlyphPageTreeNode*> m_pages;
79     mutable GlyphPageTreeNode* m_pageZero;
80     mutable const SimpleFontData* m_cachedPrimarySimpleFontData;
81     RefPtr<FontSelector> m_fontSelector;
82     mutable int m_familyIndex;
83     mutable Pitch m_pitch;
84     mutable bool m_loadingCustomFonts;
85     unsigned m_generation;
86 
87     friend class Font;
88 };
89 
90 }
91 
92