| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/css/FontLoader.h" | 6 #include "core/css/FontLoader.h" |
| 7 | 7 |
| 8 #include "core/css/CSSFontSelector.h" |
| 8 #include "core/fetch/FontResource.h" | 9 #include "core/fetch/FontResource.h" |
| 9 #include "core/fetch/ResourceFetcher.h" | 10 #include "core/fetch/ResourceFetcher.h" |
| 10 | 11 |
| 11 namespace WebCore { | 12 namespace WebCore { |
| 12 | 13 |
| 13 FontLoader::FontLoader(ResourceFetcher* resourceFetcher) | 14 FontLoader::FontLoader(CSSFontSelector* fontSelector, ResourceFetcher* resourceF
etcher) |
| 14 : m_beginLoadingTimer(this, &FontLoader::beginLoadTimerFired) | 15 : m_beginLoadingTimer(this, &FontLoader::beginLoadTimerFired) |
| 16 , m_fontSelector(fontSelector) |
| 15 , m_resourceFetcher(resourceFetcher) | 17 , m_resourceFetcher(resourceFetcher) |
| 16 { | 18 { |
| 17 } | 19 } |
| 18 | 20 |
| 19 FontLoader::~FontLoader() | 21 FontLoader::~FontLoader() |
| 20 { | 22 { |
| 21 #if ENABLE(OILPAN) | 23 #if ENABLE(OILPAN) |
| 22 if (!m_resourceFetcher) { | 24 if (!m_resourceFetcher) { |
| 23 ASSERT(m_fontsToBeginLoading.isEmpty()); | 25 ASSERT(m_fontsToBeginLoading.isEmpty()); |
| 24 return; | 26 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 for (FontsToLoadVector::iterator it = fontsToBeginLoading.begin(); it != fon
tsToBeginLoading.end(); ++it) { | 58 for (FontsToLoadVector::iterator it = fontsToBeginLoading.begin(); it != fon
tsToBeginLoading.end(); ++it) { |
| 57 FontResource* fontResource = it->first.get(); | 59 FontResource* fontResource = it->first.get(); |
| 58 fontResource->beginLoadIfNeeded(m_resourceFetcher); | 60 fontResource->beginLoadIfNeeded(m_resourceFetcher); |
| 59 } | 61 } |
| 60 | 62 |
| 61 // When the local fontsToBeginLoading vector goes out of scope it will | 63 // When the local fontsToBeginLoading vector goes out of scope it will |
| 62 // decrement the request counts on the ResourceFetcher for all the fonts | 64 // decrement the request counts on the ResourceFetcher for all the fonts |
| 63 // that were just loaded. | 65 // that were just loaded. |
| 64 } | 66 } |
| 65 | 67 |
| 68 void FontLoader::fontFaceInvalidated() |
| 69 { |
| 70 if (m_fontSelector) |
| 71 m_fontSelector->fontFaceInvalidated(); |
| 72 } |
| 73 |
| 66 #if !ENABLE(OILPAN) | 74 #if !ENABLE(OILPAN) |
| 67 void FontLoader::clearResourceFetcher() | 75 void FontLoader::clearResourceFetcherAndFontSelector() |
| 68 { | 76 { |
| 69 if (!m_resourceFetcher) { | 77 if (!m_resourceFetcher) { |
| 70 ASSERT(m_fontsToBeginLoading.isEmpty()); | 78 ASSERT(m_fontsToBeginLoading.isEmpty()); |
| 71 return; | 79 return; |
| 72 } | 80 } |
| 73 | 81 |
| 74 m_beginLoadingTimer.stop(); | 82 m_beginLoadingTimer.stop(); |
| 75 m_fontsToBeginLoading.clear(); | 83 m_fontsToBeginLoading.clear(); |
| 76 m_resourceFetcher = nullptr; | 84 m_resourceFetcher = nullptr; |
| 85 m_fontSelector = nullptr; |
| 77 } | 86 } |
| 78 #endif | 87 #endif |
| 79 | 88 |
| 80 void FontLoader::trace(Visitor* visitor) | 89 void FontLoader::trace(Visitor* visitor) |
| 81 { | 90 { |
| 82 visitor->trace(m_resourceFetcher); | 91 visitor->trace(m_resourceFetcher); |
| 92 visitor->trace(m_fontSelector); |
| 83 } | 93 } |
| 84 | 94 |
| 85 } // namespace WebCore | 95 } // namespace WebCore |
| OLD | NEW |