Index: third_party/WebKit/Source/core/frame/UseCounter.cpp |
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.cpp b/third_party/WebKit/Source/core/frame/UseCounter.cpp |
index d6710d285e00caf2c69ea08dfdcbe9ef425102be..23215ef3dcd06182b35c74c431483c7799118c19 100644 |
--- a/third_party/WebKit/Source/core/frame/UseCounter.cpp |
+++ b/third_party/WebKit/Source/core/frame/UseCounter.cpp |
@@ -1101,7 +1101,8 @@ UseCounter::UseCounter(Context context) |
m_disableReporting(false), |
m_context(context), |
m_featuresRecorded(NumberOfFeatures), |
- m_CSSRecorded(numCSSPropertyIDs) {} |
+ m_CSSRecorded(numCSSPropertyIDs), |
+ m_animatedCSSRecorded(numCSSPropertyIDs) {} |
void UseCounter::muteForInspector() { |
m_muteCount++; |
@@ -1166,9 +1167,11 @@ void UseCounter::didCommitLoad(KURL url) { |
m_featuresRecorded.clearAll(); |
m_CSSRecorded.clearAll(); |
+ m_animatedCSSRecorded.clearAll(); |
if (!m_disableReporting && !m_muteCount) { |
featuresHistogram().count(PageVisits); |
cssHistogram().count(totalPagesMeasuredCSSSampleId()); |
+ animatedCSSHistogram().count(totalPagesMeasuredCSSSampleId()); |
} |
} |
@@ -1232,6 +1235,7 @@ void UseCounter::countCrossOriginIframe(const Document& document, |
} |
void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) { |
+ // FIXME(suzyh): Count custom properties as well as named properties |
DCHECK(isCSSPropertyIDWithName(property)); |
if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) |
@@ -1255,6 +1259,48 @@ void UseCounter::count(Feature feature) { |
recordMeasurement(feature); |
} |
+bool UseCounter::isCountedAnimatedCSS(CSSPropertyID unresolvedProperty) { |
+ return m_animatedCSSRecorded.quickGet(unresolvedProperty); |
+} |
+ |
+bool UseCounter::isCountedAnimatedCSS(Document& document, |
+ const String& string) { |
+ Page* page = document.page(); |
+ if (!page) |
+ return false; |
+ |
+ CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string); |
+ if (unresolvedProperty == CSSPropertyInvalid) |
+ return false; |
+ return page->useCounter().isCountedAnimatedCSS(unresolvedProperty); |
+} |
+ |
+void UseCounter::countAnimatedCSS(const Document& document, |
+ CSSPropertyID property) { |
+ Page* page = document.page(); |
+ if (!page) |
+ return; |
+ |
+ page->useCounter().countAnimatedCSS(property); |
+} |
+ |
+void UseCounter::countAnimatedCSS(CSSPropertyID property) { |
+ DCHECK(isCSSPropertyIDWithName(property) || property == CSSPropertyVariable); |
+ |
+ if (m_muteCount) |
+ return; |
+ |
+ if (!m_animatedCSSRecorded.quickGet(property)) { |
+ int sampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(property); |
+ if (!m_disableReporting) { |
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), |
+ "AnimatedCSSFirstUsed", "feature", sampleId); |
+ animatedCSSHistogram().count(sampleId); |
+ } |
+ m_animatedCSSRecorded.quickSet(property); |
+ } |
+} |
+ |
void UseCounter::notifyFeatureCounted(Feature feature) { |
DCHECK(!m_muteCount); |
DCHECK(!m_disableReporting); |
@@ -1293,6 +1339,17 @@ EnumerationHistogram& UseCounter::cssHistogram() const { |
return m_context == SVGImageContext ? svgHistogram : histogram; |
} |
+EnumerationHistogram& UseCounter::animatedCSSHistogram() const { |
+ DEFINE_STATIC_LOCAL( |
+ blink::EnumerationHistogram, histogram, |
+ ("Blink.UseCounter.AnimatedCSSProperties", kMaximumCSSSampleId)); |
+ DEFINE_STATIC_LOCAL( |
+ blink::EnumerationHistogram, svgHistogram, |
+ ("Blink.UseCounter.SVGImage.AnimatedCSSProperties", kMaximumCSSSampleId)); |
+ |
+ return m_context == SVGImageContext ? svgHistogram : histogram; |
+} |
+ |
/* |
* |
* LEGACY metrics support - WebCore.FeatureObserver is to be superceded by |