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

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

Powered by Google App Engine
This is Rietveld 408576698