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

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

Issue 1806363002: Revert of Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
109 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription) 122 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription)
110 { 123 {
111 if (!isValid()) 124 if (!isValid())
112 return nullptr; 125 return nullptr;
113 126
114 FontTraits desiredTraits = fontDescription.traits(); 127 FontTraits desiredTraits = fontDescription.traits();
115 FontCacheKey key = fontDescription.cacheKey(FontFaceCreationParams(), desire dTraits); 128 FontCacheKey key = fontDescription.cacheKey(FontFaceCreationParams(), desire dTraits);
116 129
117 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), nullpt r).storedValue->value; 130 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), nullpt r).storedValue->value;
118 if (fontData && fontData->numFaces()) 131 if (fontData && fontData->numRanges())
119 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has. 132 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has.
120 133
121 if (!fontData) 134 if (!fontData)
122 fontData = SegmentedFontData::create(); 135 fontData = SegmentedFontData::create();
123 136
124 FontDescription requestedFontDescription(fontDescription); 137 FontDescription requestedFontDescription(fontDescription);
125 requestedFontDescription.setTraits(m_traits); 138 requestedFontDescription.setTraits(m_traits);
126 requestedFontDescription.setSyntheticBold(m_traits.weight() < FontWeight600 && desiredTraits.weight() >= FontWeight600); 139 requestedFontDescription.setSyntheticBold(m_traits.weight() < FontWeight600 && desiredTraits.weight() >= FontWeight600);
127 requestedFontDescription.setSyntheticItalic(m_traits.style() == FontStyleNor mal && desiredTraits.style() == FontStyleItalic); 140 requestedFontDescription.setSyntheticItalic(m_traits.style() == FontStyleNor mal && desiredTraits.style() == FontStyleItalic);
128 141
129 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) { 142 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) {
130 if (!(*it)->cssFontFace()->isValid()) 143 if (!(*it)->cssFontFace()->isValid())
131 continue; 144 continue;
132 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD ata(requestedFontDescription)) { 145 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD ata(requestedFontDescription)) {
133 ASSERT(!faceFontData->isSegmented()); 146 ASSERT(!faceFontData->isSegmented());
134 fontData->appendFace(FontDataForRangeSet(faceFontData.release(), (*i t)->cssFontFace()->ranges())); 147 appendFontData(fontData.get(), faceFontData.release(), (*it)->cssFon tFace()->ranges());
135 } 148 }
136 } 149 }
137 if (fontData->numFaces()) 150 if (fontData->numRanges())
138 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has. 151 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has.
139 152
140 return nullptr; 153 return nullptr;
141 } 154 }
142 155
143 void CSSSegmentedFontFace::willUseFontData(const FontDescription& fontDescriptio n, UChar32 character) 156 void CSSSegmentedFontFace::willUseFontData(const FontDescription& fontDescriptio n, UChar32 character)
144 { 157 {
145 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) {
146 if ((*it)->loadStatus() != FontFace::Unloaded) 159 if ((*it)->loadStatus() != FontFace::Unloaded)
147 break; 160 break;
148 if ((*it)->cssFontFace()->maybeScheduleFontLoad(fontDescription, charact er)) 161 if ((*it)->cssFontFace()->maybeScheduleFontLoad(fontDescription, charact er))
149 break; 162 break;
150 } 163 }
151 } 164 }
152 165
153 void CSSSegmentedFontFace::willUseRange(const blink::FontDescription& fontDescri ption, const blink::FontDataForRangeSet& rangeSet) 166 void CSSSegmentedFontFace::willUseRange(const blink::FontDescription& fontDescri ption, const blink::FontDataRange& range)
154 { 167 {
155 // Iterating backwards since later defined unicode-range faces override 168 // Iterating backwards since later defined unicode-range faces override
156 // previously defined ones, according to the CSS3 fonts module. 169 // previously defined ones, according to the CSS3 fonts module.
157 // https://drafts.csswg.org/css-fonts/#composite-fonts 170 // https://drafts.csswg.org/css-fonts/#composite-fonts
158 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) { 171 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF aces.rend(); ++it) {
159 CSSFontFace* cssFontFace = (*it)->cssFontFace(); 172 CSSFontFace* cssFontFace = (*it)->cssFontFace();
160 if (cssFontFace->maybeScheduleFontLoad(fontDescription, rangeSet)) 173 if (cssFontFace->maybeScheduleFontLoad(fontDescription, range))
161 break; 174 break;
162 } 175 }
163 } 176 }
164 177
165 bool CSSSegmentedFontFace::checkFont(const String& text) const 178 bool CSSSegmentedFontFace::checkFont(const String& text) const
166 { 179 {
167 for (const auto& fontFace : m_fontFaces) { 180 for (const auto& fontFace : m_fontFaces) {
168 if (fontFace->loadStatus() != FontFace::Loaded && fontFace->cssFontFace( )->ranges()->intersectsWith(text)) 181 if (fontFace->loadStatus() != FontFace::Loaded && fontFace->cssFontFace( )->ranges().intersectsWith(text))
169 return false; 182 return false;
170 } 183 }
171 return true; 184 return true;
172 } 185 }
173 186
174 void CSSSegmentedFontFace::match(const String& text, WillBeHeapVector<RefPtrWill BeMember<FontFace>>& faces) const 187 void CSSSegmentedFontFace::match(const String& text, WillBeHeapVector<RefPtrWill BeMember<FontFace>>& faces) const
175 { 188 {
176 for (const auto& fontFace : m_fontFaces) { 189 for (const auto& fontFace : m_fontFaces) {
177 if (fontFace->cssFontFace()->ranges()->intersectsWith(text)) 190 if (fontFace->cssFontFace()->ranges().intersectsWith(text))
178 faces.append(fontFace); 191 faces.append(fontFace);
179 } 192 }
180 } 193 }
181 194
182 DEFINE_TRACE(CSSSegmentedFontFace) 195 DEFINE_TRACE(CSSSegmentedFontFace)
183 { 196 {
184 #if ENABLE(OILPAN) 197 #if ENABLE(OILPAN)
185 visitor->trace(m_fontSelector); 198 visitor->trace(m_fontSelector);
186 visitor->trace(m_fontFaces); 199 visitor->trace(m_fontFaces);
187 #endif 200 #endif
188 } 201 }
189 202
190 } // namespace blink 203 } // 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