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 #include "core/html/canvas/CanvasFontCache.h" | 5 #include "core/html/canvas/CanvasFontCache.h" |
6 | 6 |
7 #include "core/css/parser/CSSParser.h" | 7 #include "core/css/parser/CSSParser.h" |
8 #include "core/css/resolver/StyleResolver.h" | 8 #include "core/css/resolver/StyleResolver.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const CSSValue* font_value = | 98 const CSSValue* font_value = |
99 parsed_style->GetPropertyCSSValue(CSSPropertyFontSize); | 99 parsed_style->GetPropertyCSSValue(CSSPropertyFontSize); |
100 if (font_value && | 100 if (font_value && |
101 (font_value->IsInitialValue() || font_value->IsInheritedValue())) | 101 (font_value->IsInitialValue() || font_value->IsInheritedValue())) |
102 return nullptr; | 102 return nullptr; |
103 fetched_fonts_.insert(font_string, parsed_style); | 103 fetched_fonts_.insert(font_string, parsed_style); |
104 font_lru_list_.insert(font_string); | 104 font_lru_list_.insert(font_string); |
105 // Hard limit is applied here, on the fly, while the soft limit is | 105 // Hard limit is applied here, on the fly, while the soft limit is |
106 // applied at the end of the task. | 106 // applied at the end of the task. |
107 if (fetched_fonts_.size() > HardMaxFonts()) { | 107 if (fetched_fonts_.size() > HardMaxFonts()) { |
108 ASSERT(fetched_fonts_.size() == HardMaxFonts() + 1); | 108 DCHECK_EQ(fetched_fonts_.size(), HardMaxFonts() + 1); |
109 ASSERT(font_lru_list_.size() == HardMaxFonts() + 1); | 109 DCHECK_EQ(font_lru_list_.size(), HardMaxFonts() + 1); |
110 fetched_fonts_.erase(font_lru_list_.front()); | 110 fetched_fonts_.erase(font_lru_list_.front()); |
111 fonts_resolved_using_default_style_.erase(font_lru_list_.front()); | 111 fonts_resolved_using_default_style_.erase(font_lru_list_.front()); |
112 font_lru_list_.RemoveFirst(); | 112 font_lru_list_.RemoveFirst(); |
113 } | 113 } |
114 } | 114 } |
115 SchedulePruningIfNeeded(); | 115 SchedulePruningIfNeeded(); |
116 | 116 |
117 return parsed_style; | 117 return parsed_style; |
118 } | 118 } |
119 | 119 |
(...skipping 28 matching lines...) Expand all Loading... |
148 font_lru_list_.clear(); | 148 font_lru_list_.clear(); |
149 fonts_resolved_using_default_style_.clear(); | 149 fonts_resolved_using_default_style_.clear(); |
150 } | 150 } |
151 | 151 |
152 DEFINE_TRACE(CanvasFontCache) { | 152 DEFINE_TRACE(CanvasFontCache) { |
153 visitor->Trace(fetched_fonts_); | 153 visitor->Trace(fetched_fonts_); |
154 visitor->Trace(document_); | 154 visitor->Trace(document_); |
155 } | 155 } |
156 | 156 |
157 } // namespace blink | 157 } // namespace blink |
OLD | NEW |