Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: Source/platform/fonts/CustomFontData.h

Issue 171823002: Make text visible when font loading takes longer than 3 seconds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/FontResource.cpp ('k') | Source/platform/fonts/Font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. 2 * Copyright (C) 2013 Google, Inc.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 19 matching lines...) Expand all
30 namespace WebCore { 30 namespace WebCore {
31 31
32 class CSSFontFaceSource; 32 class CSSFontFaceSource;
33 struct GlyphData; 33 struct GlyphData;
34 class GlyphPage; 34 class GlyphPage;
35 class SimpleFontData; 35 class SimpleFontData;
36 struct WidthIterator; 36 struct WidthIterator;
37 37
38 class PLATFORM_EXPORT CustomFontData : public RefCounted<CustomFontData> { 38 class PLATFORM_EXPORT CustomFontData : public RefCounted<CustomFontData> {
39 public: 39 public:
40 static PassRefPtr<CustomFontData> create(bool isLoadingFallback = false) 40 enum FallbackVisibility { InvisibleFallback, VisibleFallback };
41 static PassRefPtr<CustomFontData> create(bool isLoadingFallback = false, Fal lbackVisibility visibility = VisibleFallback)
41 { 42 {
42 return adoptRef(new CustomFontData(isLoadingFallback)); 43 return adoptRef(new CustomFontData(isLoadingFallback, visibility));
43 } 44 }
44 45
45 virtual ~CustomFontData() { } 46 virtual ~CustomFontData() { }
46 47
47 virtual void beginLoadIfNeeded() const { }; 48 virtual void beginLoadIfNeeded() const { };
48 bool isLoading() const { return m_isLoadingFallback && m_isUsed; } 49 bool isLoading() const { return m_isLoadingFallback && m_isUsed; }
49 bool isLoadingFallback() const { return m_isLoadingFallback; } 50 bool isLoadingFallback() const { return m_isLoadingFallback; }
51 bool shouldSkipDrawing() const { return m_fallbackVisibility == InvisibleFal lback && m_isUsed; }
50 52
51 virtual bool isSVGFont() const { return false; } 53 virtual bool isSVGFont() const { return false; }
52 virtual void initializeFontData(SimpleFontData*, float) { } 54 virtual void initializeFontData(SimpleFontData*, float) { }
53 virtual float widthForSVGGlyph(Glyph, float) const { return 0.0f; } 55 virtual float widthForSVGGlyph(Glyph, float) const { return 0.0f; }
54 virtual bool fillSVGGlyphPage(GlyphPage*, unsigned, unsigned, UChar*, unsign ed, const SimpleFontData*) const { return false; } 56 virtual bool fillSVGGlyphPage(GlyphPage*, unsigned, unsigned, UChar*, unsign ed, const SimpleFontData*) const { return false; }
55 virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool, int, u nsigned&) const { return false; } 57 virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool, int, u nsigned&) const { return false; }
56 58
57 virtual void setCSSFontFaceSource(CSSFontFaceSource* source) { ASSERT_NOT_RE ACHED(); } 59 virtual void setCSSFontFaceSource(CSSFontFaceSource* source) { ASSERT_NOT_RE ACHED(); }
58 virtual void clearCSSFontFaceSource() { } 60 virtual void clearCSSFontFaceSource() { }
59 61
60 protected: 62 protected:
61 CustomFontData(bool isLoadingFallback) 63 CustomFontData(bool isLoadingFallback, FallbackVisibility visibility = Visib leFallback)
62 : m_isLoadingFallback(isLoadingFallback) 64 : m_isLoadingFallback(isLoadingFallback)
65 , m_fallbackVisibility(visibility)
63 , m_isUsed(false) 66 , m_isUsed(false)
64 { 67 {
65 } 68 }
66 69
67 bool m_isLoadingFallback; // Whether or not this is a temporary font data fo r a custom font which is not yet loaded. 70 bool m_isLoadingFallback;
71 FallbackVisibility m_fallbackVisibility;
68 mutable bool m_isUsed; 72 mutable bool m_isUsed;
69 }; 73 };
70 74
71 } 75 }
72 76
73 #endif // CustomFontData_h 77 #endif // CustomFontData_h
OLDNEW
« no previous file with comments | « Source/core/fetch/FontResource.cpp ('k') | Source/platform/fonts/Font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698