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

Side by Side Diff: Source/core/css/FontFaceSet.cpp

Issue 180273020: UMA histograms to measure whether / how long blank text is rendered for loading web fonts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: early return Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/FontFaceSet.h ('k') | Source/platform/fonts/CustomFontData.h » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 void FontFaceSet::handlePendingEventsAndPromisesSoon() 167 void FontFaceSet::handlePendingEventsAndPromisesSoon()
168 { 168 {
169 // setPendingActivity() is unnecessary because m_asyncRunner will be 169 // setPendingActivity() is unnecessary because m_asyncRunner will be
170 // automatically stopped on destruction. 170 // automatically stopped on destruction.
171 m_asyncRunner.runAsync(); 171 m_asyncRunner.runAsync();
172 } 172 }
173 173
174 void FontFaceSet::didLayout() 174 void FontFaceSet::didLayout()
175 { 175 {
176 if (document()->frame()->isMainFrame()) 176 if (document()->frame()->isMainFrame() && m_loadingFonts.isEmpty())
177 m_histogram.record(); 177 m_histogram.record();
178 if (!RuntimeEnabledFeatures::fontLoadEventsEnabled()) 178 if (!RuntimeEnabledFeatures::fontLoadEventsEnabled())
179 return; 179 return;
180 if (!m_loadingFonts.isEmpty() || (!hasLoadedFonts() && m_readyResolvers.isEm pty())) 180 if (!m_loadingFonts.isEmpty() || (!hasLoadedFonts() && m_readyResolvers.isEm pty()))
181 return; 181 return;
182 handlePendingEventsAndPromisesSoon(); 182 handlePendingEventsAndPromisesSoon();
183 } 183 }
184 184
185 void FontFaceSet::handlePendingEventsAndPromises() 185 void FontFaceSet::handlePendingEventsAndPromises()
186 { 186 {
(...skipping 25 matching lines...) Expand all
212 } 212 }
213 213
214 void FontFaceSet::beginFontLoading(FontFace* fontFace) 214 void FontFaceSet::beginFontLoading(FontFace* fontFace)
215 { 215 {
216 m_histogram.incrementCount(); 216 m_histogram.incrementCount();
217 addToLoadingFonts(fontFace); 217 addToLoadingFonts(fontFace);
218 } 218 }
219 219
220 void FontFaceSet::fontLoaded(FontFace* fontFace) 220 void FontFaceSet::fontLoaded(FontFace* fontFace)
221 { 221 {
222 m_histogram.updateStatus(fontFace);
222 if (RuntimeEnabledFeatures::fontLoadEventsEnabled()) 223 if (RuntimeEnabledFeatures::fontLoadEventsEnabled())
223 m_loadedFonts.append(fontFace); 224 m_loadedFonts.append(fontFace);
224 removeFromLoadingFonts(fontFace); 225 removeFromLoadingFonts(fontFace);
225 } 226 }
226 227
227 void FontFaceSet::loadError(FontFace* fontFace) 228 void FontFaceSet::loadError(FontFace* fontFace)
228 { 229 {
230 m_histogram.updateStatus(fontFace);
229 if (RuntimeEnabledFeatures::fontLoadEventsEnabled()) 231 if (RuntimeEnabledFeatures::fontLoadEventsEnabled())
230 m_failedFonts.append(fontFace); 232 m_failedFonts.append(fontFace);
231 removeFromLoadingFonts(fontFace); 233 removeFromLoadingFonts(fontFace);
232 } 234 }
233 235
234 void FontFaceSet::addToLoadingFonts(PassRefPtr<FontFace> fontFace) 236 void FontFaceSet::addToLoadingFonts(PassRefPtr<FontFace> fontFace)
235 { 237 {
236 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadingFonts.isEmpt y() && !hasLoadedFonts()) { 238 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadingFonts.isEmpt y() && !hasLoadedFonts()) {
237 m_shouldFireLoadingEvent = true; 239 m_shouldFireLoadingEvent = true;
238 handlePendingEventsAndPromisesSoon(); 240 handlePendingEventsAndPromisesSoon();
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 CSSPropertyValue(CSSPropertyLineHeight, *parsedStyle), 504 CSSPropertyValue(CSSPropertyLineHeight, *parsedStyle),
503 }; 505 };
504 StyleResolver& styleResolver = document()->ensureStyleResolver(); 506 StyleResolver& styleResolver = document()->ensureStyleResolver();
505 styleResolver.applyPropertiesToStyle(properties, WTF_ARRAY_LENGTH(properties ), style.get()); 507 styleResolver.applyPropertiesToStyle(properties, WTF_ARRAY_LENGTH(properties ), style.get());
506 508
507 font = style->font(); 509 font = style->font();
508 font.update(document()->styleEngine()->fontSelector()); 510 font.update(document()->styleEngine()->fontSelector());
509 return true; 511 return true;
510 } 512 }
511 513
514 void FontFaceSet::FontLoadHistogram::updateStatus(FontFace* fontFace)
515 {
516 if (m_status == Reported)
517 return;
518 if (fontFace->hadBlankText())
519 m_status = HadBlankText;
520 else if (m_status == NoWebFonts)
521 m_status = DidNotHaveBlankText;
522 }
523
512 void FontFaceSet::FontLoadHistogram::record() 524 void FontFaceSet::FontLoadHistogram::record()
513 { 525 {
514 if (m_recorded) 526 if (!m_recorded) {
515 return; 527 m_recorded = true;
516 m_recorded = true; 528 blink::Platform::current()->histogramCustomCounts("WebFont.WebFontsInPag e", m_count, 1, 100, 50);
517 blink::Platform::current()->histogramCustomCounts("WebFont.WebFontsInPage", m_count, 1, 100, 50); 529 }
530 if (m_status == HadBlankText || m_status == DidNotHaveBlankText) {
531 blink::Platform::current()->histogramEnumeration("WebFont.HadBlankText", m_status == HadBlankText ? 1 : 0, 2);
532 m_status = Reported;
533 }
518 } 534 }
519 535
520 static const char* supplementName() 536 static const char* supplementName()
521 { 537 {
522 return "FontFaceSet"; 538 return "FontFaceSet";
523 } 539 }
524 540
525 PassRefPtr<FontFaceSet> FontFaceSet::from(Document& document) 541 PassRefPtr<FontFaceSet> FontFaceSet::from(Document& document)
526 { 542 {
527 RefPtr<FontFaceSet> fonts = static_cast<FontFaceSet*>(SupplementType::from(d ocument, supplementName())); 543 RefPtr<FontFaceSet> fonts = static_cast<FontFaceSet*>(SupplementType::from(d ocument, supplementName()));
528 if (!fonts) { 544 if (!fonts) {
529 fonts = FontFaceSet::create(document); 545 fonts = FontFaceSet::create(document);
530 SupplementType::provideTo(document, supplementName(), fonts); 546 SupplementType::provideTo(document, supplementName(), fonts);
531 } 547 }
532 548
533 return fonts.release(); 549 return fonts.release();
534 } 550 }
535 551
536 void FontFaceSet::didLayout(Document& document) 552 void FontFaceSet::didLayout(Document& document)
537 { 553 {
538 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName()))) 554 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName())))
539 fonts->didLayout(); 555 fonts->didLayout();
540 } 556 }
541 557
542 558
543 } // namespace WebCore 559 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/FontFaceSet.h ('k') | Source/platform/fonts/CustomFontData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698