| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 : m_version(0) | 46 : m_version(0) |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void CSSSegmentedFontFaceCache::add(CSSFontSelector* cssFontSelector, const Styl
eRuleFontFace* fontFaceRule, PassRefPtr<CSSFontFace> prpCssFontFace) | 50 void CSSSegmentedFontFaceCache::add(CSSFontSelector* cssFontSelector, const Styl
eRuleFontFace* fontFaceRule, PassRefPtr<CSSFontFace> prpCssFontFace) |
| 51 { | 51 { |
| 52 RefPtr<CSSFontFace> cssFontFace = prpCssFontFace; | 52 RefPtr<CSSFontFace> cssFontFace = prpCssFontFace; |
| 53 | 53 |
| 54 if (!m_styleRuleToFontFace.add(fontFaceRule, cssFontFace).isNewEntry) | 54 if (!m_styleRuleToFontFace.add(fontFaceRule, cssFontFace).isNewEntry) |
| 55 return; | 55 return; |
| 56 m_fontFaceList.add(cssFontFace); |
| 56 | 57 |
| 57 FontFace* fontFace = cssFontFace->fontFace(); | 58 FontFace* fontFace = cssFontFace->fontFace(); |
| 58 | 59 |
| 59 OwnPtr<TraitsMap>& familyFontFaces = m_fontFaces.add(fontFace->family(), nul
lptr).iterator->value; | 60 OwnPtr<TraitsMap>& familyFontFaces = m_fontFaces.add(fontFace->family(), nul
lptr).iterator->value; |
| 60 if (!familyFontFaces) | 61 if (!familyFontFaces) |
| 61 familyFontFaces = adoptPtr(new TraitsMap); | 62 familyFontFaces = adoptPtr(new TraitsMap); |
| 62 | 63 |
| 63 RefPtr<CSSSegmentedFontFace>& segmentedFontFace = familyFontFaces->add(fontF
ace->traitsMask(), 0).iterator->value; | 64 RefPtr<CSSSegmentedFontFace>& segmentedFontFace = familyFontFaces->add(fontF
ace->traitsMask(), 0).iterator->value; |
| 64 if (!segmentedFontFace) | 65 if (!segmentedFontFace) |
| 65 segmentedFontFace = CSSSegmentedFontFace::create(cssFontSelector, static
_cast<FontTraitsMask>(fontFace->traitsMask())); | 66 segmentedFontFace = CSSSegmentedFontFace::create(cssFontSelector, static
_cast<FontTraitsMask>(fontFace->traitsMask())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 if (familyFontFacesIter == familyFontFaces->end()) | 86 if (familyFontFacesIter == familyFontFaces->end()) |
| 86 return; | 87 return; |
| 87 RefPtr<CSSSegmentedFontFace> segmentedFontFace = familyFontFacesIter->value; | 88 RefPtr<CSSSegmentedFontFace> segmentedFontFace = familyFontFacesIter->value; |
| 88 | 89 |
| 89 segmentedFontFace->removeFontFace(cssFontFace); | 90 segmentedFontFace->removeFontFace(cssFontFace); |
| 90 if (segmentedFontFace->isEmpty()) { | 91 if (segmentedFontFace->isEmpty()) { |
| 91 familyFontFaces->remove(familyFontFacesIter); | 92 familyFontFaces->remove(familyFontFacesIter); |
| 92 if (familyFontFaces->isEmpty()) | 93 if (familyFontFaces->isEmpty()) |
| 93 m_fontFaces.remove(fontFacesIter); | 94 m_fontFaces.remove(fontFacesIter); |
| 94 } | 95 } |
| 96 m_fontFaceList.remove(styleRuleToFontFaceIter->value); |
| 95 m_styleRuleToFontFace.remove(styleRuleToFontFaceIter); | 97 m_styleRuleToFontFace.remove(styleRuleToFontFaceIter); |
| 96 m_fonts.clear(); | 98 m_fonts.clear(); |
| 97 ++m_version; | 99 ++m_version; |
| 98 } | 100 } |
| 99 | 101 |
| 100 static inline bool compareFontFaces(CSSSegmentedFontFace* first, CSSSegmentedFon
tFace* second, FontTraitsMask desiredTraitsMask) | 102 static inline bool compareFontFaces(CSSSegmentedFontFace* first, CSSSegmentedFon
tFace* second, FontTraitsMask desiredTraitsMask) |
| 101 { | 103 { |
| 102 FontTraitsMask firstTraitsMask = first->traitsMask(); | 104 FontTraitsMask firstTraitsMask = first->traitsMask(); |
| 103 FontTraitsMask secondTraitsMask = second->traitsMask(); | 105 FontTraitsMask secondTraitsMask = second->traitsMask(); |
| 104 | 106 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask &
FontVariantNormalMask)) | 201 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask &
FontVariantNormalMask)) |
| 200 continue; | 202 continue; |
| 201 if (!face || compareFontFaces(candidate, face.get(), traitsMask)) | 203 if (!face || compareFontFaces(candidate, face.get(), traitsMask)) |
| 202 face = candidate; | 204 face = candidate; |
| 203 } | 205 } |
| 204 } | 206 } |
| 205 return face.get(); | 207 return face.get(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 } | 210 } |
| OLD | NEW |