OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
11 * 1. Redistributions of source code must retain the above copyright | 11 * 1. Redistributions of source code must retain the above copyright |
12 * notice, this list of conditions and the following disclaimer. | 12 * notice, this list of conditions and the following disclaimer. |
13 * 2. Redistributions in binary form must reproduce the above copyright | 13 * 2. Redistributions in binary form must reproduce the above copyright |
14 * notice, this list of conditions and the following disclaimer in the | 14 * notice, this list of conditions and the following disclaimer in the |
15 * documentation and/or other materials provided with the distribution. | 15 * documentation and/or other materials provided with the distribution. |
16 * | 16 * |
17 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 17 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef UniscribeStateTextRun_H | 30 #ifndef UniscribeHelperTextRun_h |
31 #define UniscribeStateTextRun_H | 31 #define UniscribeHelperTextRun_h |
32 | 32 |
33 #include "base/gfx/uniscribe.h" | 33 #include "UniscribeHelper.h" |
34 | 34 |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
37 class Font; | 37 class Font; |
38 class TextRun; | 38 class TextRun; |
39 | 39 |
40 } | 40 // Wrapper around the Uniscribe helper that automatically sets it up with the |
41 | |
42 // Wrapper around the Uniscribe state that automatically sets it up with the | |
43 // WebKit types we supply. | 41 // WebKit types we supply. |
44 class UniscribeStateTextRun : public gfx::UniscribeState { | 42 class UniscribeHelperTextRun : public UniscribeHelper { |
45 public: | 43 public: |
46 // Regular constructor used for WebCore text run processing. | 44 // Regular constructor used for WebCore text run processing. |
47 UniscribeStateTextRun(const WebCore::TextRun& run, | 45 UniscribeHelperTextRun(const WebCore::TextRun& run, |
48 const WebCore::Font& font); | 46 const WebCore::Font& font); |
49 | 47 |
50 // Constructor with the same interface as the gfx::UniscribeState. Using | 48 // Constructor with the same interface as the gfx::UniscribeState. Using |
51 // this constructor will not give you font fallback, but it will provide | 49 // this constructor will not give you font fallback, but it will provide |
52 // the ability to load fonts that may not be in the OS cache | 50 // the ability to load fonts that may not be in the OS cache |
53 // ("TryToPreloadFont") if the caller does not have a TextRun/Font. | 51 // ("TryToPreloadFont") if the caller does not have a TextRun/Font. |
54 UniscribeStateTextRun(const wchar_t* input, | 52 UniscribeHelperTextRun(const wchar_t* input, |
55 int input_length, | 53 int inputLength, |
56 bool is_rtl, | 54 bool isRtl, |
57 HFONT hfont, | 55 HFONT hfont, |
58 SCRIPT_CACHE* script_cache, | 56 SCRIPT_CACHE* scriptCache, |
59 SCRIPT_FONTPROPERTIES* font_properties); | 57 SCRIPT_FONTPROPERTIES* fontProperties); |
60 | 58 |
61 protected: | 59 protected: |
62 virtual void TryToPreloadFont(HFONT font); | 60 virtual void TryToPreloadFont(HFONT font); |
63 | 61 |
64 private: | 62 private: |
65 // This function retrieves the Windows font data (HFONT, etc) | 63 // This function retrieves the Windows font data (HFONT, etc) for the next |
66 // for the next WebKit font in the list. If the font data | 64 // WebKit font in the list. If the font data corresponding to font_index_ |
67 // corresponding to font_index_ has been obtained before, | 65 // has been obtained before, returns the values stored in our internal |
68 // returns the values stored in our internal vectors (hfonts_, etc). | 66 // vectors (hfonts_, etc). Otherwise, it gets next SimpleFontData from |
69 // Otherwise, it gets next SimpleFontData from WebKit and adds them to | 67 // WebKit and adds them to in hfonts_ and friends so that font data can be |
70 // in hfonts_ and friends so that font data can be returned | 68 // returned quickly next time they're requested. |
71 // quickly next time they're requested. | |
72 virtual bool NextWinFontData(HFONT* hfont, | 69 virtual bool NextWinFontData(HFONT* hfont, |
73 SCRIPT_CACHE** script_cache, | 70 SCRIPT_CACHE** scriptCache, |
74 SCRIPT_FONTPROPERTIES** font_properties, | 71 SCRIPT_FONTPROPERTIES** fontProperties, |
75 int* ascent); | 72 int* ascent); |
76 virtual void ResetFontIndex(); | 73 virtual void ResetFontIndex(); |
77 | 74 |
78 // Reference to WebKit::Font that contains all the information | 75 // Reference to WebKit::Font that contains all the information about fonts |
79 // about fonts we can use to render this input run of text. | 76 // we can use to render this input run of text. It is used in |
80 // It is used in NextWinFontData to retrieve Windows font data | 77 // NextWinFontData to retrieve Windows font data for a series of |
81 // for a series of non-primary fonts. | 78 // non-primary fonts. |
82 // | 79 // |
83 // This pointer can be NULL for no font fallback handling. | 80 // This pointer can be NULL for no font fallback handling. |
84 const WebCore::Font* font_; | 81 const Font* m_font; |
85 | 82 |
86 // It's rare that many fonts are listed in stylesheets. | 83 // It's rare that many fonts are listed in stylesheets. |
87 // Four would be large enough in most cases. | 84 // Four would be large enough in most cases. |
88 const static size_t kNumberOfFonts = 4; | 85 const static size_t kNumberOfFonts = 4; |
89 | 86 |
90 // These vectors are used to store Windows font data for | 87 // These vectors are used to store Windows font data for non-primary fonts. |
91 // non-primary fonts. | 88 Vector<HFONT, kNumberOfFonts> m_hfonts; |
92 StackVector<HFONT, kNumberOfFonts> hfonts_; | 89 Vector<SCRIPT_CACHE*, kNumberOfFonts> m_scriptCaches; |
93 StackVector<SCRIPT_CACHE*, kNumberOfFonts> script_caches_; | 90 Vector<SCRIPT_FONTPROPERTIES*, kNumberOfFonts> m_fontProperties; |
94 StackVector<SCRIPT_FONTPROPERTIES*, kNumberOfFonts> font_properties_; | 91 Vector<int, kNumberOfFonts> m_ascents; |
95 StackVector<int, kNumberOfFonts> ascents_; | |
96 | 92 |
97 // | 93 // Index of the fallback font we're currently using for NextWinFontData. |
98 int font_index_; | 94 int m_fontIndex; |
99 }; | 95 }; |
100 | 96 |
101 #endif // UniscribeStateTextRun_H | 97 } // namespace WebCore |
102 | 98 |
| 99 #endif // UniscribeHelperTextRun_h |
OLD | NEW |