OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "wtf/text/Unicode.h" | 36 #include "wtf/text/Unicode.h" |
37 #include <memory> | 37 #include <memory> |
38 #include <string.h> | 38 #include <string.h> |
39 #include <unicode/uscript.h> | 39 #include <unicode/uscript.h> |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 class FontData; | 43 class FontData; |
44 class SimpleFontData; | 44 class SimpleFontData; |
45 | 45 |
46 // The glyph page tree is a data structure that maps (FontData, glyph page numbe
r) | 46 // The glyph page tree is a data structure that maps (FontData, glyph page |
47 // to a GlyphPage. Level 0 (the "root") is special. There is one root | 47 // number) to a GlyphPage. Level 0 (the "root") is special. There is one root |
48 // GlyphPageTreeNode for each glyph page number. The roots do not have a | 48 // GlyphPageTreeNode for each glyph page number. The roots do not have a |
49 // GlyphPage associated with them, and their initializePage() function is never | 49 // GlyphPage associated with them, and their initializePage() function is never |
50 // called to fill the glyphs. | 50 // called to fill the glyphs. |
51 // | 51 // |
52 // Each root node maps a FontData pointer to another GlyphPageTreeNode at | 52 // Each root node maps a FontData pointer to another GlyphPageTreeNode at |
53 // level 1 (the "root child") that stores the actual glyphs for a specific font
data. | 53 // level 1 (the "root child") that stores the actual glyphs for a specific font |
54 // These nodes will only have a GlyphPage if they have glyphs for that range. | 54 // data. These nodes will only have a GlyphPage if they have glyphs for that |
| 55 // range. |
55 // | 56 // |
56 // Levels greater than one correspond to subsequent levels of the fallback list | 57 // Levels greater than one correspond to subsequent levels of the fallback list |
57 // for that font. These levels override their parent's page of glyphs by | 58 // for that font. These levels override their parent's page of glyphs by |
58 // filling in holes with the new font (thus making a more complete page). | 59 // filling in holes with the new font (thus making a more complete page). |
59 // | 60 // |
60 // A SystemFallbackGlyphPageTreeNode is a special leaf node of the glyph tree | 61 // A SystemFallbackGlyphPageTreeNode is a special leaf node of the glyph tree |
61 // which is for tracking the glyph page for a system fallback font. | 62 // which is for tracking the glyph page for a system fallback font. |
62 // The glyph page is tracked separately from the regular pages and overrides | 63 // The glyph page is tracked separately from the regular pages and overrides |
63 // so that the glyph pages do not get polluted with these last-resort glyphs. | 64 // so that the glyph pages do not get polluted with these last-resort glyphs. |
64 // The system fallback page is not populated at construction like the other page
s, | 65 // The system fallback page is not populated at construction like the other |
65 // but on demand for each glyph, because the system may need to use different | 66 // pages, but on demand for each glyph, because the system may need to use |
66 // fallback fonts for each. This lazy population is done by the Font. | 67 // different fallback fonts for each. This lazy population is done by the Font. |
67 | 68 |
68 class GlyphPageTreeNode; | 69 class GlyphPageTreeNode; |
69 class SystemFallbackGlyphPageTreeNode; | 70 class SystemFallbackGlyphPageTreeNode; |
70 | 71 |
71 class PLATFORM_EXPORT GlyphPageTreeNodeBase { | 72 class PLATFORM_EXPORT GlyphPageTreeNodeBase { |
72 USING_FAST_MALLOC(GlyphPageTreeNodeBase); | 73 USING_FAST_MALLOC(GlyphPageTreeNodeBase); |
73 WTF_MAKE_NONCOPYABLE(GlyphPageTreeNodeBase); | 74 WTF_MAKE_NONCOPYABLE(GlyphPageTreeNodeBase); |
74 | 75 |
75 public: | 76 public: |
76 GlyphPageTreeNode* parent() const { return m_parent; } | 77 GlyphPageTreeNode* parent() const { return m_parent; } |
77 | 78 |
78 // Returns the level of this node. See class-level comment. | 79 // Returns the level of this node. See class-level comment. |
79 unsigned level() const { return m_level; } | 80 unsigned level() const { return m_level; } |
80 | 81 |
81 // The system fallback font has special rules (see above). | 82 // The system fallback font has special rules (see above). |
82 bool isSystemFallback() const { return m_isSystemFallback; } | 83 bool isSystemFallback() const { return m_isSystemFallback; } |
83 | 84 |
84 // Returns a page of glyphs (or null if there are no glyphs in this page's cha
racter range). | 85 // Returns a page of glyphs (or null if there are no glyphs in this page's |
| 86 // character range). |
85 virtual GlyphPage* page(UScriptCode = USCRIPT_COMMON) = 0; | 87 virtual GlyphPage* page(UScriptCode = USCRIPT_COMMON) = 0; |
86 | 88 |
87 protected: | 89 protected: |
88 GlyphPageTreeNodeBase(GlyphPageTreeNode* parent, bool isSystemFallback); | 90 GlyphPageTreeNodeBase(GlyphPageTreeNode* parent, bool isSystemFallback); |
89 virtual ~GlyphPageTreeNodeBase() {} | 91 virtual ~GlyphPageTreeNodeBase() {} |
90 | 92 |
91 GlyphPageTreeNode* m_parent; | 93 GlyphPageTreeNode* m_parent; |
92 unsigned m_level : 31; | 94 unsigned m_level : 31; |
93 unsigned m_isSystemFallback : 1; | 95 unsigned m_isSystemFallback : 1; |
94 unsigned m_customFontCount; | 96 unsigned m_customFontCount; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 const FontData* fontData, | 210 const FontData* fontData, |
209 unsigned pageNumber) { | 211 unsigned pageNumber) { |
210 if (fontData) | 212 if (fontData) |
211 return getNormalChild(fontData, pageNumber); | 213 return getNormalChild(fontData, pageNumber); |
212 return getSystemFallbackChild(pageNumber); | 214 return getSystemFallbackChild(pageNumber); |
213 } | 215 } |
214 | 216 |
215 } // namespace blink | 217 } // namespace blink |
216 | 218 |
217 #endif // GlyphPageTreeNode_h | 219 #endif // GlyphPageTreeNode_h |
OLD | NEW |