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

Side by Side Diff: Source/core/css/CSSFontFaceSource.h

Issue 23446007: Use unicode-range to prevent unnecessary @font-face donwnloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class SVGFontFaceElement; 44 class SVGFontFaceElement;
45 #endif 45 #endif
46 46
47 47
48 class CSSFontFaceSource : public FontResourceClient { 48 class CSSFontFaceSource : public FontResourceClient {
49 public: 49 public:
50 CSSFontFaceSource(const String&, FontResource* = 0); 50 CSSFontFaceSource(const String&, FontResource* = 0);
51 virtual ~CSSFontFaceSource(); 51 virtual ~CSSFontFaceSource();
52 52
53 bool isLocal() const; 53 bool isLocal() const;
54 bool isLoading() const;
54 bool isLoaded() const; 55 bool isLoaded() const;
55 bool isValid() const; 56 bool isValid() const;
56 57
57 const AtomicString& string() const { return m_string; } 58 const AtomicString& string() const { return m_string; }
58 59
59 void setFontFace(CSSFontFace* face) { m_face = face; } 60 void setFontFace(CSSFontFace* face) { m_face = face; }
60 61
61 virtual void didStartFontLoad(FontResource*) OVERRIDE; 62 virtual void didStartFontLoad(FontResource*) OVERRIDE;
62 virtual void fontLoaded(FontResource*); 63 virtual void fontLoaded(FontResource*);
63 64
64 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheti cBold, bool syntheticItalic, CSSFontSelector*); 65 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheti cBold, bool syntheticItalic, CSSFontSelector*);
65 66
66 void pruneTable(); 67 void pruneTable();
67 68
68 #if ENABLE(SVG_FONTS) 69 #if ENABLE(SVG_FONTS)
69 SVGFontFaceElement* svgFontFaceElement() const; 70 SVGFontFaceElement* svgFontFaceElement() const;
70 void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement>); 71 void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement>);
71 bool isSVGFontFaceSource() const; 72 bool isSVGFontFaceSource() const;
72 void setHasExternalSVGFont(bool value) { m_hasExternalSVGFont = value; } 73 void setHasExternalSVGFont(bool value) { m_hasExternalSVGFont = value; }
73 #endif 74 #endif
74 75
75 bool isDecodeError() const; 76 bool isDecodeError() const;
76 bool ensureFontData(); 77 bool ensureFontData();
77 bool isLocalFontAvailable(const FontDescription&); 78 bool isLocalFontAvailable(const FontDescription&);
78 void willUseFontData(); 79 void willUseFontData();
80 void beginLoadingFontSoon();
79 81
80 private: 82 private:
83 typedef HashMap<unsigned, RefPtr<SimpleFontData> > FontDataTable;
84
81 class FontLoadHistograms { 85 class FontLoadHistograms {
82 public: 86 public:
83 enum UsageType { 87 enum UsageType {
84 StyledAndUsed, 88 StyledAndUsed,
85 StyledButNotUsed, 89 StyledButNotUsed,
86 NotStyledButUsed, 90 NotStyledButUsed,
87 UsageTypeMax 91 UsageTypeMax
88 }; 92 };
89 FontLoadHistograms() : m_styledTime(0), m_loadStartTime(0) { } 93 FontLoadHistograms() : m_styledTime(0), m_loadStartTime(0) { }
90 ~FontLoadHistograms(); 94 ~FontLoadHistograms();
91 void willUseFontData(); 95 void willUseFontData();
92 void loadStarted(); 96 void loadStarted();
93 void recordLocalFont(bool loadSuccess); 97 void recordLocalFont(bool loadSuccess);
94 void recordRemoteFont(const FontResource*); 98 void recordRemoteFont(const FontResource*);
95 private: 99 private:
96 const char* histogramName(const FontResource*); 100 const char* histogramName(const FontResource*);
97 double m_styledTime; 101 double m_styledTime;
98 double m_loadStartTime; 102 double m_loadStartTime;
99 }; 103 };
100 104
101 void startLoadingTimerFired(Timer<CSSFontFaceSource>*); 105 void startLoadingTimerFired(Timer<CSSFontFaceSource>*);
102 106
103 AtomicString m_string; // URI for remote, built-in font name for local. 107 AtomicString m_string; // URI for remote, built-in font name for local.
104 ResourcePtr<FontResource> m_font; // For remote fonts, a pointer to our cach ed resource. 108 ResourcePtr<FontResource> m_font; // For remote fonts, a pointer to our cach ed resource.
105 CSSFontFace* m_face; // Our owning font face. 109 CSSFontFace* m_face; // Our owning font face.
106 HashMap<unsigned, RefPtr<SimpleFontData> > m_fontDataTable; // The hash key is composed of size synthetic styles. 110 FontDataTable m_fontDataTable; // The hash key is composed of size synthetic styles.
dglazkov 2013/09/10 15:26:41 Should the comment go with the typedef?
Kunihiko Sakamoto 2013/09/11 13:28:09 Done.
107 FontLoadHistograms m_histograms; 111 FontLoadHistograms m_histograms;
108 112
109 #if ENABLE(SVG_FONTS) 113 #if ENABLE(SVG_FONTS)
110 RefPtr<SVGFontFaceElement> m_svgFontFaceElement; 114 RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
111 RefPtr<SVGFontElement> m_externalSVGFontElement; 115 RefPtr<SVGFontElement> m_externalSVGFontElement;
112 bool m_hasExternalSVGFont; 116 bool m_hasExternalSVGFont;
113 #endif 117 #endif
114 }; 118 };
115 119
116 } 120 }
117 121
118 #endif 122 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698