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

Side by Side Diff: sky/engine/core/css/FontLoader.cpp

Issue 1223843003: Remove support for loading remote font faces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/engine/core/css/FontLoader.h ('k') | sky/engine/core/css/RemoteFontFaceSource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/engine/core/css/FontLoader.h"
6
7 #include "sky/engine/core/css/CSSFontSelector.h"
8 #include "sky/engine/core/fetch/FontResource.h"
9 #include "sky/engine/core/fetch/ResourceFetcher.h"
10
11 namespace blink {
12
13 FontLoader::FontLoader(CSSFontSelector* fontSelector, ResourceFetcher* resourceF etcher)
14 : m_beginLoadingTimer(this, &FontLoader::beginLoadTimerFired)
15 , m_fontSelector(fontSelector)
16 , m_resourceFetcher(resourceFetcher)
17 {
18 }
19
20 FontLoader::~FontLoader()
21 {
22 #if ENABLE(OILPAN)
23 if (!m_resourceFetcher) {
24 ASSERT(m_fontsToBeginLoading.isEmpty());
25 return;
26 }
27 m_beginLoadingTimer.stop();
28 // This will decrement the request counts on the ResourceFetcher for all the
29 // fonts that were pending at the time the FontLoader dies.
30 clearPendingFonts();
31 #endif
32 }
33
34 void FontLoader::addFontToBeginLoading(FontResource* fontResource)
35 {
36 if (!m_resourceFetcher || !fontResource->stillNeedsLoad() || fontResource->l oadScheduled())
37 return;
38
39 m_fontsToBeginLoading.append(
40 std::make_pair(fontResource, ResourceLoader::RequestCountTracker(m_resou rceFetcher, fontResource)));
41 fontResource->didScheduleLoad();
42 if (!m_beginLoadingTimer.isActive())
43 m_beginLoadingTimer.startOneShot(0, FROM_HERE);
44 }
45
46 void FontLoader::beginLoadTimerFired(Timer<blink::FontLoader>*)
47 {
48 loadPendingFonts();
49 }
50
51 void FontLoader::loadPendingFonts()
52 {
53 ASSERT(m_resourceFetcher);
54
55 FontsToLoadVector fontsToBeginLoading;
56 fontsToBeginLoading.swap(m_fontsToBeginLoading);
57 for (FontsToLoadVector::iterator it = fontsToBeginLoading.begin(); it != fon tsToBeginLoading.end(); ++it) {
58 FontResource* fontResource = it->first.get();
59 fontResource->beginLoadIfNeeded(m_resourceFetcher);
60 }
61
62 // When the local fontsToBeginLoading vector goes out of scope it will
63 // decrement the request counts on the ResourceFetcher for all the fonts
64 // that were just loaded.
65 }
66
67 void FontLoader::fontFaceInvalidated()
68 {
69 if (m_fontSelector)
70 m_fontSelector->fontFaceInvalidated();
71 }
72
73 #if !ENABLE(OILPAN)
74 void FontLoader::clearResourceFetcherAndFontSelector()
75 {
76 if (!m_resourceFetcher) {
77 ASSERT(m_fontsToBeginLoading.isEmpty());
78 return;
79 }
80
81 m_beginLoadingTimer.stop();
82 clearPendingFonts();
83 m_resourceFetcher = nullptr;
84 m_fontSelector = nullptr;
85 }
86 #endif
87
88 void FontLoader::clearPendingFonts()
89 {
90 for (FontsToLoadVector::iterator it = m_fontsToBeginLoading.begin(); it != m _fontsToBeginLoading.end(); ++it)
91 it->first->didUnscheduleLoad();
92 m_fontsToBeginLoading.clear();
93 }
94
95 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/FontLoader.h ('k') | sky/engine/core/css/RemoteFontFaceSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698