| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 RefPtr<ComputedStyle> fontStyle = ComputedStyle::clone(*m_defaultFontStyle.g
et()); | 75 RefPtr<ComputedStyle> fontStyle = ComputedStyle::clone(*m_defaultFontStyle.g
et()); |
| 76 m_document->ensureStyleResolver().computeFont(fontStyle.get(), *parsedStyle)
; | 76 m_document->ensureStyleResolver().computeFont(fontStyle.get(), *parsedStyle)
; |
| 77 m_fontsResolvedUsingDefaultStyle.add(fontString, fontStyle->font()); | 77 m_fontsResolvedUsingDefaultStyle.add(fontString, fontStyle->font()); |
| 78 resolvedFont = m_fontsResolvedUsingDefaultStyle.find(fontString)->value; | 78 resolvedFont = m_fontsResolvedUsingDefaultStyle.find(fontString)->value; |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 MutableStylePropertySet* CanvasFontCache::parseFont(const String& fontString) | 82 MutableStylePropertySet* CanvasFontCache::parseFont(const String& fontString) |
| 83 { | 83 { |
| 84 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle; | 84 RawPtr<MutableStylePropertySet> parsedStyle; |
| 85 MutableStylePropertyMap::iterator i = m_fetchedFonts.find(fontString); | 85 MutableStylePropertyMap::iterator i = m_fetchedFonts.find(fontString); |
| 86 if (i != m_fetchedFonts.end()) { | 86 if (i != m_fetchedFonts.end()) { |
| 87 ASSERT(m_fontLRUList.contains(fontString)); | 87 ASSERT(m_fontLRUList.contains(fontString)); |
| 88 parsedStyle = i->value; | 88 parsedStyle = i->value; |
| 89 m_fontLRUList.remove(fontString); | 89 m_fontLRUList.remove(fontString); |
| 90 m_fontLRUList.add(fontString); | 90 m_fontLRUList.add(fontString); |
| 91 } else { | 91 } else { |
| 92 parsedStyle = MutableStylePropertySet::create(HTMLStandardMode); | 92 parsedStyle = MutableStylePropertySet::create(HTMLStandardMode); |
| 93 CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, tr
ue, 0); | 93 CSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, tr
ue, 0); |
| 94 if (parsedStyle->isEmpty()) | 94 if (parsedStyle->isEmpty()) |
| 95 return nullptr; | 95 return nullptr; |
| 96 // According to http://lists.w3.org/Archives/Public/public-html/2009Jul/
0947.html, | 96 // According to http://lists.w3.org/Archives/Public/public-html/2009Jul/
0947.html, |
| 97 // the "inherit" and "initial" values must be ignored. | 97 // the "inherit" and "initial" values must be ignored. |
| 98 RefPtrWillBeRawPtr<CSSValue> fontValue = parsedStyle->getPropertyCSSValu
e(CSSPropertyFontSize); | 98 RawPtr<CSSValue> fontValue = parsedStyle->getPropertyCSSValue(CSSPropert
yFontSize); |
| 99 if (fontValue && (fontValue->isInitialValue() || fontValue->isInheritedV
alue())) | 99 if (fontValue && (fontValue->isInitialValue() || fontValue->isInheritedV
alue())) |
| 100 return nullptr; | 100 return nullptr; |
| 101 m_fetchedFonts.add(fontString, parsedStyle); | 101 m_fetchedFonts.add(fontString, parsedStyle); |
| 102 m_fontLRUList.add(fontString); | 102 m_fontLRUList.add(fontString); |
| 103 // Hard limit is applied here, on the fly, while the soft limit is | 103 // Hard limit is applied here, on the fly, while the soft limit is |
| 104 // applied at the end of the task. | 104 // applied at the end of the task. |
| 105 if (m_fetchedFonts.size() > hardMaxFonts()) { | 105 if (m_fetchedFonts.size() > hardMaxFonts()) { |
| 106 ASSERT(m_fetchedFonts.size() == hardMaxFonts() + 1); | 106 ASSERT(m_fetchedFonts.size() == hardMaxFonts() + 1); |
| 107 ASSERT(m_fontLRUList.size() == hardMaxFonts() + 1); | 107 ASSERT(m_fontLRUList.size() == hardMaxFonts() + 1); |
| 108 m_fetchedFonts.remove(m_fontLRUList.first()); | 108 m_fetchedFonts.remove(m_fontLRUList.first()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 DEFINE_TRACE(CanvasFontCache) | 154 DEFINE_TRACE(CanvasFontCache) |
| 155 { | 155 { |
| 156 #if ENABLE(OILPAN) | 156 #if ENABLE(OILPAN) |
| 157 visitor->trace(m_fetchedFonts); | 157 visitor->trace(m_fetchedFonts); |
| 158 visitor->trace(m_document); | 158 visitor->trace(m_document); |
| 159 #endif | 159 #endif |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |