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

Side by Side Diff: Source/platform/fonts/GlyphPageTreeNode.cpp

Issue 243453003: Proper unicode-range font loading behavior (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/GlyphPage.h ('k') | Source/platform/fonts/GlyphPageTreeNodeTest.cpp » ('j') | 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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 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 * 7 *
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const SegmentedFontData* segmentedFontData = static_cast<const S egmentedFontData*>(fontData); 216 const SegmentedFontData* segmentedFontData = static_cast<const S egmentedFontData*>(fontData);
217 for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) { 217 for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) {
218 const FontDataRange& range = segmentedFontData->rangeAt(i); 218 const FontDataRange& range = segmentedFontData->rangeAt(i);
219 // all this casting is to ensure all the parameters to min a nd max have the same type, 219 // all this casting is to ensure all the parameters to min a nd max have the same type,
220 // to avoid ambiguous template parameter errors on Windows 220 // to avoid ambiguous template parameter errors on Windows
221 int from = max(0, static_cast<int>(range.from()) - static_ca st<int>(start)); 221 int from = max(0, static_cast<int>(range.from()) - static_ca st<int>(start));
222 int to = 1 + min(static_cast<int>(range.to()) - static_cast< int>(start), static_cast<int>(GlyphPage::size) - 1); 222 int to = 1 + min(static_cast<int>(range.to()) - static_cast< int>(start), static_cast<int>(GlyphPage::size) - 1);
223 if (from >= static_cast<int>(GlyphPage::size) || to <= 0) 223 if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
224 continue; 224 continue;
225 225
226 // If this is a custom font needs to be loaded, kick off 226 // If this is a custom font needs to be loaded, do not fill
227 // the load here, and do not fill the page so that 227 // the page so that font fallback is used while loading.
228 // font fallback is used while loading.
229 RefPtr<CustomFontData> customData = range.fontData()->custom FontData(); 228 RefPtr<CustomFontData> customData = range.fontData()->custom FontData();
230 if (customData && customData->isLoadingFallback()) { 229 if (customData && customData->isLoadingFallback()) {
231 customData->beginLoadIfNeeded(); 230 for (int j = from; j < to; j++) {
eae 2014/04/23 18:38:39 Here and elsewhere shouldn't j (and from) be unsig
Kunihiko Sakamoto 2014/04/24 01:49:24 I'd prefer to keep them int, as calculation of |fr
231 m_page->setCustomFontToLoad(j, customData.get());
232 haveGlyphs = true;
233 }
232 continue; 234 continue;
233 } 235 }
234 236
235 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + f rom * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range. fontData().get()); 237 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + f rom * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range. fontData().get());
236 } 238 }
237 } 239 }
238 240
239 if (!haveGlyphs) 241 if (!haveGlyphs)
240 m_page = nullptr; 242 m_page = nullptr;
241 } else if (parentPage && parentPage->owner() != m_parent) { 243 } else if (parentPage && parentPage->owner() != m_parent) {
(...skipping 23 matching lines...) Expand all
265 // parent page. 267 // parent page.
266 m_page = parentPage; 268 m_page = parentPage;
267 } else { 269 } else {
268 // Combine the parent's glyphs and ours to form a new more compl ete page. 270 // Combine the parent's glyphs and ours to form a new more compl ete page.
269 m_page = GlyphPage::createForMixedFontData(this); 271 m_page = GlyphPage::createForMixedFontData(this);
270 272
271 // Overlay the parent page on the fallback page. Check if the fa llback font 273 // Overlay the parent page on the fallback page. Check if the fa llback font
272 // has added anything. 274 // has added anything.
273 bool newGlyphs = false; 275 bool newGlyphs = false;
274 for (unsigned i = 0; i < GlyphPage::size; i++) { 276 for (unsigned i = 0; i < GlyphPage::size; i++) {
275 if (parentPage->glyphAt(i)) 277 if (parentPage->glyphAt(i)) {
276 m_page->setGlyphDataForIndex(i, parentPage->glyphDataFor Index(i)); 278 m_page->setGlyphDataForIndex(i, parentPage->glyphDataFor Index(i));
277 else if (fallbackPage->glyphAt(i)) { 279 } else if (fallbackPage->glyphAt(i)) {
278 m_page->setGlyphDataForIndex(i, fallbackPage->glyphDataF orIndex(i)); 280 m_page->setGlyphDataForIndex(i, fallbackPage->glyphDataF orIndex(i));
279 newGlyphs = true; 281 newGlyphs = true;
280 } 282 }
283
284 if (parentPage->customFontToLoadAt(i)) {
285 m_page->setCustomFontToLoad(i, parentPage->customFontToL oadAt(i));
286 } else if (fallbackPage->customFontToLoadAt(i) && !parentPag e->glyphAt(i)) {
287 m_page->setCustomFontToLoad(i, fallbackPage->customFontT oLoadAt(i));
288 newGlyphs = true;
289 }
281 } 290 }
282 291
283 if (!newGlyphs) 292 if (!newGlyphs)
284 // We didn't override anything, so our override is just the parent page. 293 // We didn't override anything, so our override is just the parent page.
285 m_page = parentPage; 294 m_page = parentPage;
286 } 295 }
287 } 296 }
288 } else { 297 } else {
289 // System fallback. Initialized with the parent's page here, as individu al 298 // System fallback. Initialized with the parent's page here, as individu al
290 // entries may use different fonts depending on character. If the Font 299 // entries may use different fonts depending on character. If the Font
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 printf("\nPage %d:\n", it->key); 414 printf("\nPage %d:\n", it->key);
406 showGlyphPageTree(it->key); 415 showGlyphPageTree(it->key);
407 } 416 }
408 } 417 }
409 418
410 void showGlyphPageTree(unsigned pageNumber) 419 void showGlyphPageTree(unsigned pageNumber)
411 { 420 {
412 WebCore::GlyphPageTreeNode::getRoot(pageNumber)->showSubtree(); 421 WebCore::GlyphPageTreeNode::getRoot(pageNumber)->showSubtree();
413 } 422 }
414 #endif 423 #endif
OLDNEW
« no previous file with comments | « Source/platform/fonts/GlyphPage.h ('k') | Source/platform/fonts/GlyphPageTreeNodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698