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

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

Issue 2066253002: Fix Refcount in FontDataCache for objects from FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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) 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 bool haveGlyphs; 241 bool haveGlyphs;
242 if (!fontData->isSegmented()) { 242 if (!fontData->isSegmented()) {
243 m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontD ata)); 243 m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontD ata));
244 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength , toSimpleFontData(fontData)); 244 haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength , toSimpleFontData(fontData));
245 } else { 245 } else {
246 m_page = GlyphPage::createForMixedFontData(this); 246 m_page = GlyphPage::createForMixedFontData(this);
247 haveGlyphs = false; 247 haveGlyphs = false;
248 248
249 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontDat a); 249 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontDat a);
250 for (int i = segmentedFontData->numFaces() - 1; i >= 0; i--) { 250 for (int i = segmentedFontData->numFaces() - 1; i >= 0; i--) {
251 const FontDataForRangeSet& fontDataForRangeSet = segmentedFontData-> faceAt(i); 251 RefPtr<FontDataForRangeSet> fontDataForRangeSet = segmentedFontData- >faceAt(i);
252 RefPtr<UnicodeRangeSet> ranges = fontDataForRangeSet.ranges(); 252 RefPtr<UnicodeRangeSet> ranges = fontDataForRangeSet->ranges();
253 // If there are no ranges, that means this font should be used for 253 // If there are no ranges, that means this font should be used for
254 // the full codepoint range, thus running the loop once over a 254 // the full codepoint range, thus running the loop once over a
255 // synthetic full UnicodeRange object. Otherwise we use the ranges 255 // synthetic full UnicodeRange object. Otherwise we use the ranges
256 // that come from the segmented font. This needs a locally 256 // that come from the segmented font. This needs a locally
257 // initialized size_t variable (or a cast alternatively) as a 257 // initialized size_t variable (or a cast alternatively) as a
258 // compile fix for Android since size_t differs between platforms. 258 // compile fix for Android since size_t differs between platforms.
259 const size_t oneRoundForZeroRanges = 1u; 259 const size_t oneRoundForZeroRanges = 1u;
260 for (size_t i = 0; i < max(ranges->size(), oneRoundForZeroRanges); + +i) { 260 for (size_t i = 0; i < max(ranges->size(), oneRoundForZeroRanges); + +i) {
261 UnicodeRange range(0, kMaxCodepoint); 261 UnicodeRange range(0, kMaxCodepoint);
262 if (ranges->size()) { 262 if (ranges->size()) {
263 range = ranges->rangeAt(i); 263 range = ranges->rangeAt(i);
264 } 264 }
265 // all this casting is to ensure all the parameters to min and m ax have the same type, 265 // all this casting is to ensure all the parameters to min and m ax have the same type,
266 // to avoid ambiguous template parameter errors on Windows 266 // to avoid ambiguous template parameter errors on Windows
267 int from = max(0, static_cast<int>(range.from()) - static_cast<i nt>(start)); 267 int from = max(0, static_cast<int>(range.from()) - static_cast<i nt>(start));
268 int to = 1 + min(static_cast<int>(range.to()) - static_cast<int> (start), static_cast<int>(GlyphPage::size) - 1); 268 int to = 1 + min(static_cast<int>(range.to()) - static_cast<int> (start), static_cast<int>(GlyphPage::size) - 1);
269 if (from >= static_cast<int>(GlyphPage::size) || to <= 0) 269 if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
270 continue; 270 continue;
271 271
272 // If this is a custom font needs to be loaded, do not fill 272 // If this is a custom font needs to be loaded, do not fill
273 // the page so that font fallback is used while loading. 273 // the page so that font fallback is used while loading.
274 RefPtr<CustomFontData> customData = fontDataForRangeSet.fontData ()->customFontData(); 274 RefPtr<CustomFontData> customData = fontDataForRangeSet->fontDat a()->customFontData();
275 if (customData && customData->isLoadingFallback()) { 275 if (customData && customData->isLoadingFallback()) {
276 for (int j = from; j < to; j++) { 276 for (int j = from; j < to; j++) {
277 m_page->setCustomFontToLoad(j, customData.get()); 277 m_page->setCustomFontToLoad(j, customData.get());
278 haveGlyphs = true; 278 haveGlyphs = true;
279 } 279 }
280 continue; 280 continue;
281 } 281 }
282 282
283 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), fontDataFo rRangeSet.fontData()); 283 haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), fontDataFo rRangeSet->fontData());
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288 if (!haveGlyphs) 288 if (!haveGlyphs)
289 m_page = nullptr; 289 m_page = nullptr;
290 } 290 }
291 291
292 void GlyphPageTreeNode::initializeOverridePage(const FontData* fontData, unsigne d pageNumber) 292 void GlyphPageTreeNode::initializeOverridePage(const FontData* fontData, unsigne d pageNumber)
293 { 293 {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // entries may use different fonts depending on character. If the Font 453 // entries may use different fonts depending on character. If the Font
454 // ever finds it needs a glyph out of the system fallback page, it will 454 // ever finds it needs a glyph out of the system fallback page, it will
455 // ask the system for the best font to use and fill that glyph in for us. 455 // ask the system for the best font to use and fill that glyph in for us.
456 if (GlyphPage* parentPage = m_parent->page()) 456 if (GlyphPage* parentPage = m_parent->page())
457 return parentPage->createCopiedSystemFallbackPage(this); 457 return parentPage->createCopiedSystemFallbackPage(this);
458 return GlyphPage::createForMixedFontData(this); 458 return GlyphPage::createForMixedFontData(this);
459 } 459 }
460 460
461 } // namespace blink 461 } // namespace blink
462 462
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698