| 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/FontDataForRangeSet.h" | 8 #include "platform/fonts/FontDataRange.h" | 
| 9 #include "platform/fonts/FontFallbackPriority.h" | 9 #include "platform/fonts/FontFallbackPriority.h" | 
| 10 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" | 
| 11 #include "wtf/PassRefPtr.h" | 11 #include "wtf/PassRefPtr.h" | 
| 12 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" | 
| 13 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" | 
| 14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" | 
| 15 #include "wtf/text/Unicode.h" | 15 #include "wtf/text/Unicode.h" | 
| 16 | 16 | 
| 17 namespace blink { | 17 namespace blink { | 
| 18 | 18 | 
| 19 using namespace WTF; | 19 using namespace WTF; | 
| 20 | 20 | 
| 21 class FontDescription; | 21 class FontDescription; | 
| 22 class FontFallbackList; | 22 class FontFallbackList; | 
| 23 class SimpleFontData; | 23 class SimpleFontData; | 
|  | 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>, | 
| 31         FontFallbackPriority); | 32         FontFallbackPriority); | 
| 32 | 33 | 
| 33     // 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 | 
| 34     // needed.  Needed by the FontfallbackIterator in order to check whether a | 35     // needed.  Needed by the FontfallbackIterator in order to check whether a | 
| 35     // font from a segmented range should be loaded. | 36     // font from a segmented range should be loaded. | 
| 36     bool needsHintList() const; | 37     bool needsHintList() const; | 
| 37 | 38 | 
| 38     bool hasNext() const { return m_fallbackStage != OutOfLuck; }; | 39     bool hasNext() const { return m_fallbackStage != OutOfLuck; }; | 
| 39 | 40 | 
| 40     // Some system fallback APIs (Windows, Android) require a character, or a | 41     // Some system fallback APIs (Windows, Android) require a character, or a | 
| 41     // 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 | 
| 42     // fonts without passing in characters. | 43     // fonts without passing in characters. | 
| 43     const FontDataForRangeSet next(const Vector<UChar32>& hintList); | 44     const FontDataRange next(const Vector<UChar32>& hintList); | 
| 44 | 45 | 
| 45 private: | 46 private: | 
| 46     FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>, | 47     FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>, | 
| 47         FontFallbackPriority); | 48         FontFallbackPriority); | 
| 48     bool rangeSetContributesForHint(const Vector<UChar32> hintList, const FontDa
    taForRangeSet&); | 49     bool rangeContributesForHint(const Vector<UChar32> hintList, const FontDataR
    ange&); | 
| 49     bool alreadyLoadingRangeForHintChar(UChar32 hintChar); | 50     bool alreadyLoadingRangeForHintChar(UChar32 hintChar); | 
| 50     void willUseRange(const AtomicString& family, const FontDataForRangeSet&); | 51     void willUseRange(const AtomicString& family, const FontDataRange&); | 
| 51 | 52 | 
| 52     const PassRefPtr<SimpleFontData> fallbackPriorityFont(UChar32 hint); | 53     const PassRefPtr<SimpleFontData> fallbackPriorityFont(UChar32 hint); | 
| 53     const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint); | 54     const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint); | 
| 54 | 55 | 
| 55     const FontDescription& m_fontDescription; | 56     const FontDescription& m_fontDescription; | 
| 56     RefPtr<FontFallbackList> m_fontFallbackList; | 57     RefPtr<FontFallbackList> m_fontFallbackList; | 
| 57     int m_currentFontDataIndex; | 58     int m_currentFontDataIndex; | 
| 58     unsigned m_segmentedFaceIndex; | 59     unsigned m_segmentedIndex; | 
| 59 | 60 | 
| 60     enum FallbackStage { | 61     enum FallbackStage { | 
| 61         FallbackPriorityFonts, | 62         FallbackPriorityFonts, | 
| 62         FontGroupFonts, | 63         FontGroupFonts, | 
| 63         SegmentedFace, | 64         SegmentedFace, | 
| 64         PreferencesFonts, | 65         PreferencesFonts, | 
| 65         SystemFonts, | 66         SystemFonts, | 
| 66         OutOfLuck | 67         OutOfLuck | 
| 67     }; | 68     }; | 
| 68 | 69 | 
| 69     FallbackStage m_fallbackStage; | 70     FallbackStage m_fallbackStage; | 
| 70     HashMap<UChar32, RefPtr<SimpleFontData>> m_visitedSystemFonts; | 71     HashMap<UChar32, RefPtr<SimpleFontData>> m_visitedSystemFonts; | 
| 71     Vector<FontDataForRangeSet> m_trackedLoadingRangeSets; | 72     Vector<FontDataRange> m_loadingCustomFontForRanges; | 
| 72     FontFallbackPriority m_fontFallbackPriority; | 73     FontFallbackPriority m_fontFallbackPriority; | 
| 73 }; | 74 }; | 
| 74 | 75 | 
| 75 } // namespace blink | 76 } // namespace blink | 
| 76 | 77 | 
| 77 #endif | 78 #endif | 
| OLD | NEW | 
|---|