Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/core/css/FontFaceCache.cpp

Issue 2653773006: Make FontFaceCache::version return unique number across all instances (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/FontFaceCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 #include "core/css/FontStyleMatcher.h" 33 #include "core/css/FontStyleMatcher.h"
34 #include "core/css/StyleRule.h" 34 #include "core/css/StyleRule.h"
35 #include "core/fetch/ResourceFetcher.h" 35 #include "core/fetch/ResourceFetcher.h"
36 #include "core/loader/resource/FontResource.h" 36 #include "core/loader/resource/FontResource.h"
37 #include "platform/FontFamilyNames.h" 37 #include "platform/FontFamilyNames.h"
38 #include "platform/fonts/FontDescription.h" 38 #include "platform/fonts/FontDescription.h"
39 #include "wtf/text/AtomicString.h" 39 #include "wtf/text/AtomicString.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 static unsigned s_version = 0;
44
43 FontFaceCache::FontFaceCache() : m_version(0) {} 45 FontFaceCache::FontFaceCache() : m_version(0) {}
44 46
45 void FontFaceCache::add(CSSFontSelector* cssFontSelector, 47 void FontFaceCache::add(CSSFontSelector* cssFontSelector,
46 const StyleRuleFontFace* fontFaceRule, 48 const StyleRuleFontFace* fontFaceRule,
47 FontFace* fontFace) { 49 FontFace* fontFace) {
48 if (!m_styleRuleToFontFace.add(fontFaceRule, fontFace).isNewEntry) 50 if (!m_styleRuleToFontFace.add(fontFaceRule, fontFace).isNewEntry)
49 return; 51 return;
50 addFontFace(cssFontSelector, fontFace, true); 52 addFontFace(cssFontSelector, fontFace, true);
51 } 53 }
52 54
(...skipping 11 matching lines...) Expand all
64 if (!segmentedFontFaceResult.storedValue->value) 66 if (!segmentedFontFaceResult.storedValue->value)
65 segmentedFontFaceResult.storedValue->value = 67 segmentedFontFaceResult.storedValue->value =
66 CSSSegmentedFontFace::create(cssFontSelector, fontFace->traits()); 68 CSSSegmentedFontFace::create(cssFontSelector, fontFace->traits());
67 69
68 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace, 70 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace,
69 cssConnected); 71 cssConnected);
70 if (cssConnected) 72 if (cssConnected)
71 m_cssConnectedFontFaces.add(fontFace); 73 m_cssConnectedFontFaces.add(fontFace);
72 74
73 m_fonts.remove(fontFace->family()); 75 m_fonts.remove(fontFace->family());
74 ++m_version; 76 incrementVersion();
75 } 77 }
76 78
77 void FontFaceCache::remove(const StyleRuleFontFace* fontFaceRule) { 79 void FontFaceCache::remove(const StyleRuleFontFace* fontFaceRule) {
78 StyleRuleToFontFace::iterator it = m_styleRuleToFontFace.find(fontFaceRule); 80 StyleRuleToFontFace::iterator it = m_styleRuleToFontFace.find(fontFaceRule);
79 if (it != m_styleRuleToFontFace.end()) { 81 if (it != m_styleRuleToFontFace.end()) {
80 removeFontFace(it->value.get(), true); 82 removeFontFace(it->value.get(), true);
81 m_styleRuleToFontFace.remove(it); 83 m_styleRuleToFontFace.remove(it);
82 } 84 }
83 } 85 }
84 86
(...skipping 13 matching lines...) Expand all
98 segmentedFontFace->removeFontFace(fontFace); 100 segmentedFontFace->removeFontFace(fontFace);
99 if (segmentedFontFace->isEmpty()) { 101 if (segmentedFontFace->isEmpty()) {
100 familyFontFaces->remove(familyFontFacesIter); 102 familyFontFaces->remove(familyFontFacesIter);
101 if (familyFontFaces->isEmpty()) 103 if (familyFontFaces->isEmpty())
102 m_fontFaces.remove(fontFacesIter); 104 m_fontFaces.remove(fontFacesIter);
103 } 105 }
104 m_fonts.remove(fontFace->family()); 106 m_fonts.remove(fontFace->family());
105 if (cssConnected) 107 if (cssConnected)
106 m_cssConnectedFontFaces.remove(fontFace); 108 m_cssConnectedFontFaces.remove(fontFace);
107 109
108 ++m_version; 110 incrementVersion();
109 } 111 }
110 112
111 void FontFaceCache::clearCSSConnected() { 113 void FontFaceCache::clearCSSConnected() {
112 for (const auto& item : m_styleRuleToFontFace) 114 for (const auto& item : m_styleRuleToFontFace)
113 removeFontFace(item.value.get(), true); 115 removeFontFace(item.value.get(), true);
114 m_styleRuleToFontFace.clear(); 116 m_styleRuleToFontFace.clear();
115 } 117 }
116 118
117 void FontFaceCache::clearAll() { 119 void FontFaceCache::clearAll() {
118 if (m_fontFaces.isEmpty()) 120 if (m_fontFaces.isEmpty())
119 return; 121 return;
120 122
121 m_fontFaces.clear(); 123 m_fontFaces.clear();
122 m_fonts.clear(); 124 m_fonts.clear();
123 m_styleRuleToFontFace.clear(); 125 m_styleRuleToFontFace.clear();
124 m_cssConnectedFontFaces.clear(); 126 m_cssConnectedFontFaces.clear();
125 ++m_version; 127 incrementVersion();
128 }
129
130 void FontFaceCache::incrementVersion() {
131 m_version = ++s_version;
drott 2017/01/24 12:16:20 I assume multiple documents in the same renderer w
126 } 132 }
127 133
128 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription, 134 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription,
129 const AtomicString& family) { 135 const AtomicString& family) {
130 TraitsMap* familyFontFaces = m_fontFaces.get(family); 136 TraitsMap* familyFontFaces = m_fontFaces.get(family);
131 if (!familyFontFaces || familyFontFaces->isEmpty()) 137 if (!familyFontFaces || familyFontFaces->isEmpty())
132 return nullptr; 138 return nullptr;
133 139
134 FamilyToTraitsMap::AddResult traitsResult = m_fonts.add(family, nullptr); 140 FamilyToTraitsMap::AddResult traitsResult = m_fonts.add(family, nullptr);
135 if (!traitsResult.storedValue->value) 141 if (!traitsResult.storedValue->value)
(...skipping 16 matching lines...) Expand all
152 } 158 }
153 159
154 DEFINE_TRACE(FontFaceCache) { 160 DEFINE_TRACE(FontFaceCache) {
155 visitor->trace(m_fontFaces); 161 visitor->trace(m_fontFaces);
156 visitor->trace(m_fonts); 162 visitor->trace(m_fonts);
157 visitor->trace(m_styleRuleToFontFace); 163 visitor->trace(m_styleRuleToFontFace);
158 visitor->trace(m_cssConnectedFontFaces); 164 visitor->trace(m_cssConnectedFontFaces);
159 } 165 }
160 166
161 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/FontFaceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698