| OLD | NEW | 
|   1 // Copyright 2015 The Chromium Authors. All rights reserved. |   1 // Copyright 2015 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 #ifndef FontFallbackIterator_h |   5 #ifndef FontFallbackIterator_h | 
|   6 #define FontFallbackIterator_h |   6 #define FontFallbackIterator_h | 
|   7  |   7  | 
|   8 #include "platform/fonts/FontDataRange.h" |   8 #include "platform/fonts/FontDataRange.h" | 
 |   9 #include "platform/fonts/FontFallbackPriority.h" | 
|   9 #include "wtf/HashMap.h" |  10 #include "wtf/HashMap.h" | 
|  10 #include "wtf/PassRefPtr.h" |  11 #include "wtf/PassRefPtr.h" | 
|  11 #include "wtf/RefCounted.h" |  12 #include "wtf/RefCounted.h" | 
|  12 #include "wtf/RefPtr.h" |  13 #include "wtf/RefPtr.h" | 
|  13 #include "wtf/Vector.h" |  14 #include "wtf/Vector.h" | 
|  14 #include "wtf/text/Unicode.h" |  15 #include "wtf/text/Unicode.h" | 
|  15  |  16  | 
|  16 namespace blink { |  17 namespace blink { | 
|  17  |  18  | 
|  18 using namespace WTF; |  19 using namespace WTF; | 
|  19  |  20  | 
|  20 class FontDescription; |  21 class FontDescription; | 
|  21 class FontFallbackList; |  22 class FontFallbackList; | 
|  22 class SimpleFontData; |  23 class SimpleFontData; | 
|  23 struct FontDataRange; |  24 struct FontDataRange; | 
|  24 class FontFamily; |  25 class FontFamily; | 
|  25  |  26  | 
|  26 class FontFallbackIterator : public RefCounted<FontFallbackIterator> { |  27 class FontFallbackIterator : public RefCounted<FontFallbackIterator> { | 
|  27     WTF_MAKE_NONCOPYABLE(FontFallbackIterator); |  28     WTF_MAKE_NONCOPYABLE(FontFallbackIterator); | 
|  28  |  29  | 
|  29 public: |  30 public: | 
|  30     static PassRefPtr<FontFallbackIterator> create(const FontDescription&, PassR
    efPtr<FontFallbackList>); |  31     static PassRefPtr<FontFallbackIterator> create(const FontDescription&, PassR
    efPtr<FontFallbackList>, | 
 |  32         FontFallbackPriority); | 
|  31  |  33  | 
|  32     // Returns whether a list of all remaining characters to be shaped is |  34     // Returns whether a list of all remaining characters to be shaped is | 
|  33     // needed.  Needed by the FontfallbackIterator in order to check whether a |  35     // needed.  Needed by the FontfallbackIterator in order to check whether a | 
|  34     // font from a segmented range should be loaded. |  36     // font from a segmented range should be loaded. | 
|  35     bool needsHintList() const; |  37     bool needsHintList() const; | 
|  36  |  38  | 
|  37     bool hasNext() const { return m_fallbackStage != OutOfLuck; }; |  39     bool hasNext() const { return m_fallbackStage != OutOfLuck; }; | 
|  38  |  40  | 
|  39     // Some system fallback APIs (Windows, Android) require a character, or a |  41     // Some system fallback APIs (Windows, Android) require a character, or a | 
|  40     // portion of the string to be passed.  On Mac and Linux, we get a list of |  42     // portion of the string to be passed.  On Mac and Linux, we get a list of | 
|  41     // fonts without passing in characters. |  43     // fonts without passing in characters. | 
|  42     const FontDataRange next(const Vector<UChar32>& hintList); |  44     const FontDataRange next(const Vector<UChar32>& hintList); | 
|  43  |  45  | 
|  44 private: |  46 private: | 
|  45     FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>); |  47     FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>, | 
 |  48         FontFallbackPriority); | 
|  46     bool rangeContributesForHint(const Vector<UChar32> hintList, const FontDataR
    ange&); |  49     bool rangeContributesForHint(const Vector<UChar32> hintList, const FontDataR
    ange&); | 
|  47     bool alreadyLoadingRangeForHintChar(UChar32 hintChar); |  50     bool alreadyLoadingRangeForHintChar(UChar32 hintChar); | 
|  48     void willUseRange(const AtomicString& family, const FontDataRange&); |  51     void willUseRange(const AtomicString& family, const FontDataRange&); | 
|  49  |  52  | 
 |  53     const PassRefPtr<SimpleFontData> fallbackPriorityFont(UChar32 hint); | 
|  50     const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint); |  54     const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint); | 
|  51  |  55  | 
|  52     const FontDescription& m_fontDescription; |  56     const FontDescription& m_fontDescription; | 
|  53     RefPtr<FontFallbackList> m_fontFallbackList; |  57     RefPtr<FontFallbackList> m_fontFallbackList; | 
|  54     int m_currentFontDataIndex; |  58     int m_currentFontDataIndex; | 
|  55     unsigned m_segmentedIndex; |  59     unsigned m_segmentedIndex; | 
|  56  |  60  | 
|  57     enum FallbackStage { |  61     enum FallbackStage { | 
 |  62         FallbackPriorityFonts, | 
|  58         FontGroupFonts, |  63         FontGroupFonts, | 
|  59         SegmentedFace, |  64         SegmentedFace, | 
|  60         PreferencesFonts, |  65         PreferencesFonts, | 
|  61         SystemFonts, |  66         SystemFonts, | 
|  62         OutOfLuck |  67         OutOfLuck | 
|  63     }; |  68     }; | 
|  64  |  69  | 
|  65     FallbackStage m_fallbackStage; |  70     FallbackStage m_fallbackStage; | 
|  66     HashMap<UChar32, RefPtr<SimpleFontData>> m_visitedSystemFonts; |  71     HashMap<UChar32, RefPtr<SimpleFontData>> m_visitedSystemFonts; | 
|  67     Vector<FontDataRange> m_loadingCustomFontForRanges; |  72     Vector<FontDataRange> m_loadingCustomFontForRanges; | 
 |  73     FontFallbackPriority m_fontFallbackPriority; | 
|  68 }; |  74 }; | 
|  69  |  75  | 
|  70 } // namespace blink |  76 } // namespace blink | 
|  71  |  77  | 
|  72 #endif |  78 #endif | 
| OLD | NEW |