| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/allocator/Partitions.h" | 40 #include "wtf/allocator/Partitions.h" |
| 41 #include "wtf/text/Unicode.h" | 41 #include "wtf/text/Unicode.h" |
| 42 #include <string.h> | 42 #include <string.h> |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 class SimpleFontData; | 46 class SimpleFontData; |
| 47 class GlyphPageTreeNodeBase; | 47 class GlyphPageTreeNodeBase; |
| 48 | 48 |
| 49 // Holds the glyph index and the corresponding SimpleFontData information for a
given | 49 // Holds the glyph index and the corresponding SimpleFontData information for a |
| 50 // character. | 50 // given character. |
| 51 struct GlyphData { | 51 struct GlyphData { |
| 52 DISALLOW_NEW(); | 52 DISALLOW_NEW(); |
| 53 GlyphData(Glyph g = 0, const SimpleFontData* f = 0) : glyph(g), fontData(f) {} | 53 GlyphData(Glyph g = 0, const SimpleFontData* f = 0) : glyph(g), fontData(f) {} |
| 54 Glyph glyph; | 54 Glyph glyph; |
| 55 const SimpleFontData* fontData; | 55 const SimpleFontData* fontData; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 #if COMPILER(MSVC) | 58 #if COMPILER(MSVC) |
| 59 #pragma warning(push) | 59 #pragma warning(push) |
| 60 #pragma warning( \ | 60 #pragma warning( \ |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void setGlyphDataForIndex(unsigned index, | 140 void setGlyphDataForIndex(unsigned index, |
| 141 Glyph glyph, | 141 Glyph glyph, |
| 142 const SimpleFontData* fontData) { | 142 const SimpleFontData* fontData) { |
| 143 ASSERT_WITH_SECURITY_IMPLICATION(index < size); | 143 ASSERT_WITH_SECURITY_IMPLICATION(index < size); |
| 144 m_glyphs[index] = glyph; | 144 m_glyphs[index] = glyph; |
| 145 setCustomFontToLoad(index, 0); | 145 setCustomFontToLoad(index, 0); |
| 146 | 146 |
| 147 if (hasPerGlyphFontData()) { | 147 if (hasPerGlyphFontData()) { |
| 148 m_perGlyphFontData[index] = fontData; | 148 m_perGlyphFontData[index] = fontData; |
| 149 } else { | 149 } else { |
| 150 // A single-font GlyphPage already assigned m_fontDataForAllGlyphs in the
constructor. | 150 // A single-font GlyphPage already assigned m_fontDataForAllGlyphs in the |
| 151 // constructor. |
| 151 ASSERT(!glyph || fontData == m_fontDataForAllGlyphs); | 152 ASSERT(!glyph || fontData == m_fontDataForAllGlyphs); |
| 152 } | 153 } |
| 153 } | 154 } |
| 154 | 155 |
| 155 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) { | 156 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) { |
| 156 setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData); | 157 setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData); |
| 157 } | 158 } |
| 158 | 159 |
| 159 const CustomFontData* customFontToLoadAt(unsigned index) const { | 160 const CustomFontData* customFontToLoadAt(unsigned index) const { |
| 160 ASSERT_WITH_SECURITY_IMPLICATION(index < size); | 161 ASSERT_WITH_SECURITY_IMPLICATION(index < size); |
| 161 return m_customFontToLoad ? m_customFontToLoad->at(index) : 0; | 162 return m_customFontToLoad ? m_customFontToLoad->at(index) : 0; |
| 162 } | 163 } |
| 163 | 164 |
| 164 void setCustomFontToLoad(unsigned index, | 165 void setCustomFontToLoad(unsigned index, |
| 165 const CustomFontData* customFontToLoad) { | 166 const CustomFontData* customFontToLoad) { |
| 166 if (!m_customFontToLoad) { | 167 if (!m_customFontToLoad) { |
| 167 if (!customFontToLoad) | 168 if (!customFontToLoad) |
| 168 return; | 169 return; |
| 169 m_customFontToLoad = CustomDataPage::create(); | 170 m_customFontToLoad = CustomDataPage::create(); |
| 170 } | 171 } |
| 171 ASSERT_WITH_SECURITY_IMPLICATION(index < size); | 172 ASSERT_WITH_SECURITY_IMPLICATION(index < size); |
| 172 m_customFontToLoad->set(index, customFontToLoad); | 173 m_customFontToLoad->set(index, customFontToLoad); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void removePerGlyphFontData(const SimpleFontData* fontData) { | 176 void removePerGlyphFontData(const SimpleFontData* fontData) { |
| 176 // This method should only be called on the mixed page, which is never singl
e-font. | 177 // This method should only be called on the mixed page, which is never |
| 178 // single-font. |
| 177 ASSERT(hasPerGlyphFontData()); | 179 ASSERT(hasPerGlyphFontData()); |
| 178 for (size_t i = 0; i < size; ++i) { | 180 for (size_t i = 0; i < size; ++i) { |
| 179 if (m_perGlyphFontData[i] == fontData) { | 181 if (m_perGlyphFontData[i] == fontData) { |
| 180 m_glyphs[i] = 0; | 182 m_glyphs[i] = 0; |
| 181 m_perGlyphFontData[i] = 0; | 183 m_perGlyphFontData[i] = 0; |
| 182 } | 184 } |
| 183 } | 185 } |
| 184 } | 186 } |
| 185 | 187 |
| 186 GlyphPageTreeNodeBase* owner() const { return m_owner; } | 188 GlyphPageTreeNodeBase* owner() const { return m_owner; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 209 private: | 211 private: |
| 210 CustomDataPage() { memset(m_customData, 0, sizeof(m_customData)); } | 212 CustomDataPage() { memset(m_customData, 0, sizeof(m_customData)); } |
| 211 const CustomFontData* m_customData[size]; | 213 const CustomFontData* m_customData[size]; |
| 212 }; | 214 }; |
| 213 | 215 |
| 214 const SimpleFontData* m_fontDataForAllGlyphs; | 216 const SimpleFontData* m_fontDataForAllGlyphs; |
| 215 GlyphPageTreeNodeBase* m_owner; | 217 GlyphPageTreeNodeBase* m_owner; |
| 216 RefPtr<CustomDataPage> m_customFontToLoad; | 218 RefPtr<CustomDataPage> m_customFontToLoad; |
| 217 Glyph m_glyphs[size]; | 219 Glyph m_glyphs[size]; |
| 218 | 220 |
| 219 // NOTE: This array has (GlyphPage::size) elements if m_fontDataForAllGlyphs i
s null. | 221 // NOTE: This array has (GlyphPage::size) elements if m_fontDataForAllGlyphs |
| 222 // is null. |
| 220 const SimpleFontData* m_perGlyphFontData[0]; | 223 const SimpleFontData* m_perGlyphFontData[0]; |
| 221 }; | 224 }; |
| 222 | 225 |
| 223 #if COMPILER(MSVC) | 226 #if COMPILER(MSVC) |
| 224 #pragma warning(pop) | 227 #pragma warning(pop) |
| 225 #endif | 228 #endif |
| 226 | 229 |
| 227 } // namespace blink | 230 } // namespace blink |
| 228 | 231 |
| 229 #endif // GlyphPage_h | 232 #endif // GlyphPage_h |
| OLD | NEW |