| OLD | NEW |
| 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 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/css/FontFaceCache.h" | 27 #include "core/css/FontFaceCache.h" |
| 28 | 28 |
| 29 #include "core/css/CSSFontSelector.h" | |
| 30 #include "core/css/CSSSegmentedFontFace.h" | 29 #include "core/css/CSSSegmentedFontFace.h" |
| 31 #include "core/css/CSSValueList.h" | 30 #include "core/css/CSSValueList.h" |
| 32 #include "core/css/FontFace.h" | 31 #include "core/css/FontFace.h" |
| 33 #include "core/css/FontStyleMatcher.h" | 32 #include "core/css/FontStyleMatcher.h" |
| 34 #include "core/css/StyleRule.h" | 33 #include "core/css/StyleRule.h" |
| 35 #include "core/loader/resource/FontResource.h" | 34 #include "core/loader/resource/FontResource.h" |
| 36 #include "platform/FontFamilyNames.h" | 35 #include "platform/FontFamilyNames.h" |
| 37 #include "platform/fonts/FontDescription.h" | 36 #include "platform/fonts/FontDescription.h" |
| 38 #include "platform/loader/fetch/ResourceFetcher.h" | 37 #include "platform/loader/fetch/ResourceFetcher.h" |
| 39 #include "wtf/text/AtomicString.h" | 38 #include "wtf/text/AtomicString.h" |
| 40 | 39 |
| 41 namespace blink { | 40 namespace blink { |
| 42 | 41 |
| 43 static unsigned s_version = 0; | 42 static unsigned s_version = 0; |
| 44 | 43 |
| 45 FontFaceCache::FontFaceCache() : m_version(0) {} | 44 FontFaceCache::FontFaceCache() : m_version(0) {} |
| 46 | 45 |
| 47 void FontFaceCache::add(CSSFontSelector* cssFontSelector, | 46 void FontFaceCache::add(const StyleRuleFontFace* fontFaceRule, |
| 48 const StyleRuleFontFace* fontFaceRule, | |
| 49 FontFace* fontFace) { | 47 FontFace* fontFace) { |
| 50 if (!m_styleRuleToFontFace.insert(fontFaceRule, fontFace).isNewEntry) | 48 if (!m_styleRuleToFontFace.insert(fontFaceRule, fontFace).isNewEntry) |
| 51 return; | 49 return; |
| 52 addFontFace(cssFontSelector, fontFace, true); | 50 addFontFace(fontFace, true); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void FontFaceCache::addFontFace(CSSFontSelector* cssFontSelector, | 53 void FontFaceCache::addFontFace(FontFace* fontFace, bool cssConnected) { |
| 56 FontFace* fontFace, | |
| 57 bool cssConnected) { | |
| 58 FamilyToTraitsMap::AddResult traitsResult = | 54 FamilyToTraitsMap::AddResult traitsResult = |
| 59 m_fontFaces.insert(fontFace->family(), nullptr); | 55 m_fontFaces.insert(fontFace->family(), nullptr); |
| 60 if (!traitsResult.storedValue->value) | 56 if (!traitsResult.storedValue->value) |
| 61 traitsResult.storedValue->value = new TraitsMap; | 57 traitsResult.storedValue->value = new TraitsMap; |
| 62 | 58 |
| 63 TraitsMap::AddResult segmentedFontFaceResult = | 59 TraitsMap::AddResult segmentedFontFaceResult = |
| 64 traitsResult.storedValue->value->insert(fontFace->traits().bitfield(), | 60 traitsResult.storedValue->value->insert(fontFace->traits().bitfield(), |
| 65 nullptr); | 61 nullptr); |
| 66 if (!segmentedFontFaceResult.storedValue->value) | 62 if (!segmentedFontFaceResult.storedValue->value) { |
| 67 segmentedFontFaceResult.storedValue->value = | 63 segmentedFontFaceResult.storedValue->value = |
| 68 CSSSegmentedFontFace::create(cssFontSelector, fontFace->traits()); | 64 CSSSegmentedFontFace::create(fontFace->traits()); |
| 65 } |
| 69 | 66 |
| 70 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace, | 67 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace, |
| 71 cssConnected); | 68 cssConnected); |
| 72 if (cssConnected) | 69 if (cssConnected) |
| 73 m_cssConnectedFontFaces.add(fontFace); | 70 m_cssConnectedFontFaces.add(fontFace); |
| 74 | 71 |
| 75 m_fonts.erase(fontFace->family()); | 72 m_fonts.erase(fontFace->family()); |
| 76 incrementVersion(); | 73 incrementVersion(); |
| 77 } | 74 } |
| 78 | 75 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 155 } |
| 159 | 156 |
| 160 DEFINE_TRACE(FontFaceCache) { | 157 DEFINE_TRACE(FontFaceCache) { |
| 161 visitor->trace(m_fontFaces); | 158 visitor->trace(m_fontFaces); |
| 162 visitor->trace(m_fonts); | 159 visitor->trace(m_fonts); |
| 163 visitor->trace(m_styleRuleToFontFace); | 160 visitor->trace(m_styleRuleToFontFace); |
| 164 visitor->trace(m_cssConnectedFontFaces); | 161 visitor->trace(m_cssConnectedFontFaces); |
| 165 } | 162 } |
| 166 | 163 |
| 167 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |