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

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

Issue 1806653002: Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update UnicodeRangeSetTests to RefPtrtr, rm copy constructor and test Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return; 99 return;
100 100
101 if (it == m_firstNonCssConnectedFace) 101 if (it == m_firstNonCssConnectedFace)
102 ++m_firstNonCssConnectedFace; 102 ++m_firstNonCssConnectedFace;
103 m_fontFaces.remove(it); 103 m_fontFaces.remove(it);
104 104
105 pruneTable(); 105 pruneTable();
106 fontFace->cssFontFace()->clearSegmentedFontFace(); 106 fontFace->cssFontFace()->clearSegmentedFontFace();
107 } 107 }
108 108
109 static void appendFontData(SegmentedFontData* newFontData, PassRefPtr<SimpleFont Data> prpFaceFontData, const UnicodeRangeSet& ranges)
110 {
111 RefPtr<SimpleFontData> faceFontData = prpFaceFontData;
112 unsigned numRanges = ranges.size();
113 if (!numRanges) {
114 newFontData->appendRange(FontDataRange(0, 0x7FFFFFFF, faceFontData));
115 return;
116 }
117
118 for (unsigned j = 0; j < numRanges; ++j)
119 newFontData->appendRange(FontDataRange(ranges.rangeAt(j).from(), ranges. rangeAt(j).to(), faceFontData));
120 }
121
122 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription) 109 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription)
123 { 110 {
124 if (!isValid()) 111 if (!isValid())
125 return nullptr; 112 return nullptr;
126 113
127 FontTraits desiredTraits = fontDescription.traits(); 114 FontTraits desiredTraits = fontDescription.traits();
128 FontCacheKey key = fontDescription.cacheKey(FontFaceCreationParams(), desire dTraits); 115 FontCacheKey key = fontDescription.cacheKey(FontFaceCreationParams(), desire dTraits);
129 116
130 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), nullpt r).storedValue->value; 117 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), nullpt r).storedValue->value;
131 if (fontData && fontData->numRanges()) 118 if (fontData && fontData->numFaces())
132 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has. 119 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has.
133 120
134 if (!fontData) 121 if (!fontData)
135 fontData = SegmentedFontData::create(); 122 fontData = SegmentedFontData::create();
136 123
137 FontDescription requestedFontDescription(fontDescription); 124 FontDescription requestedFontDescription(fontDescription);
138 requestedFontDescription.setTraits(m_traits); 125 requestedFontDescription.setTraits(m_traits);
139 requestedFontDescription.setSyntheticBold(m_traits.weight() < FontWeight600 && desiredTraits.weight() >= FontWeight600); 126 requestedFontDescription.setSyntheticBold(m_traits.weight() < FontWeight600 && desiredTraits.weight() >= FontWeight600);
140 requestedFontDescription.setSyntheticItalic(m_traits.style() == FontStyleNor mal && desiredTraits.style() == FontStyleItalic); 127 requestedFontDescription.setSyntheticItalic(m_traits.style() == FontStyleNor mal && desiredTraits.style() == FontStyleItalic);
141 128
142 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) { 129 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) {
143 if (!(*it)->cssFontFace()->isValid()) 130 if (!(*it)->cssFontFace()->isValid())
144 continue; 131 continue;
145 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD ata(requestedFontDescription)) { 132 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD ata(requestedFontDescription)) {
146 ASSERT(!faceFontData->isSegmented()); 133 ASSERT(!faceFontData->isSegmented());
147 appendFontData(fontData.get(), faceFontData.release(), (*it)->cssFon tFace()->ranges()); 134 fontData->appendFace(FontDataForRangeSet(faceFontData.release(), (*i t)->cssFontFace()->ranges()));
148 } 135 }
149 } 136 }
150 if (fontData->numRanges()) 137 if (fontData->numFaces())
151 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has. 138 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has.
152 139
153 return nullptr; 140 return nullptr;
154 } 141 }
155 142
156 void CSSSegmentedFontFace::willUseFontData(const FontDescription& fontDescriptio n, UChar32 character) 143 void CSSSegmentedFontFace::willUseFontData(const FontDescription& fontDescriptio n, UChar32 character)
157 { 144 {
158 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) { 145 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) {
159 if ((*it)->loadStatus() != FontFace::Unloaded) 146 if ((*it)->loadStatus() != FontFace::Unloaded)
160 break; 147 break;
161 if ((*it)->cssFontFace()->maybeScheduleFontLoad(fontDescription, charact er)) 148 if ((*it)->cssFontFace()->maybeScheduleFontLoad(fontDescription, charact er))
162 break; 149 break;
163 } 150 }
164 } 151 }
165 152
166 void CSSSegmentedFontFace::willUseRange(const blink::FontDescription& fontDescri ption, const blink::FontDataRange& range) 153 void CSSSegmentedFontFace::willUseRange(const blink::FontDescription& fontDescri ption, const blink::FontDataForRangeSet& rangeSet)
167 { 154 {
168 // Iterating backwards since later defined unicode-range faces override 155 // Iterating backwards since later defined unicode-range faces override
169 // previously defined ones, according to the CSS3 fonts module. 156 // previously defined ones, according to the CSS3 fonts module.
170 // https://drafts.csswg.org/css-fonts/#composite-fonts 157 // https://drafts.csswg.org/css-fonts/#composite-fonts
171 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) { 158 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) {
172 CSSFontFace* cssFontFace = (*it)->cssFontFace(); 159 CSSFontFace* cssFontFace = (*it)->cssFontFace();
173 if (cssFontFace->maybeScheduleFontLoad(fontDescription, range)) 160 if (cssFontFace->maybeScheduleFontLoad(fontDescription, rangeSet))
174 break; 161 break;
175 } 162 }
176 } 163 }
177 164
178 bool CSSSegmentedFontFace::checkFont(const String& text) const 165 bool CSSSegmentedFontFace::checkFont(const String& text) const
179 { 166 {
180 for (const auto& fontFace : m_fontFaces) { 167 for (const auto& fontFace : m_fontFaces) {
181 if (fontFace->loadStatus() != FontFace::Loaded && fontFace->cssFontFace( )->ranges().intersectsWith(text)) 168 if (fontFace->loadStatus() != FontFace::Loaded && fontFace->cssFontFace( )->ranges()->intersectsWith(text))
182 return false; 169 return false;
183 } 170 }
184 return true; 171 return true;
185 } 172 }
186 173
187 void CSSSegmentedFontFace::match(const String& text, WillBeHeapVector<RefPtrWill BeMember<FontFace>>& faces) const 174 void CSSSegmentedFontFace::match(const String& text, WillBeHeapVector<RefPtrWill BeMember<FontFace>>& faces) const
188 { 175 {
189 for (const auto& fontFace : m_fontFaces) { 176 for (const auto& fontFace : m_fontFaces) {
190 if (fontFace->cssFontFace()->ranges().intersectsWith(text)) 177 if (fontFace->cssFontFace()->ranges()->intersectsWith(text))
191 faces.append(fontFace); 178 faces.append(fontFace);
192 } 179 }
193 } 180 }
194 181
195 DEFINE_TRACE(CSSSegmentedFontFace) 182 DEFINE_TRACE(CSSSegmentedFontFace)
196 { 183 {
197 #if ENABLE(OILPAN) 184 #if ENABLE(OILPAN)
198 visitor->trace(m_fontSelector); 185 visitor->trace(m_fontSelector);
199 visitor->trace(m_fontFaces); 186 visitor->trace(m_fontFaces);
200 #endif 187 #endif
201 } 188 }
202 189
203 } // namespace blink 190 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSSegmentedFontFace.h ('k') | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698