| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "DocumentStatisticsCollector.h" | 5 #include "DocumentStatisticsCollector.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/InputTypeNames.h" | 8 #include "core/InputTypeNames.h" |
| 9 #include "core/dom/ElementTraversal.h" | 9 #include "core/dom/ElementTraversal.h" |
| 10 #include "core/dom/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 WebDistillabilityFeatures DocumentStatisticsCollector::collectStatistics(Documen
t& document) | 216 WebDistillabilityFeatures DocumentStatisticsCollector::collectStatistics(Documen
t& document) |
| 217 { | 217 { |
| 218 TRACE_EVENT0("blink", "DocumentStatisticsCollector::collectStatistics"); | 218 TRACE_EVENT0("blink", "DocumentStatisticsCollector::collectStatistics"); |
| 219 | 219 |
| 220 WebDistillabilityFeatures features = WebDistillabilityFeatures(); | 220 WebDistillabilityFeatures features = WebDistillabilityFeatures(); |
| 221 | 221 |
| 222 if (!document.frame() || !document.frame()->isMainFrame()) | 222 if (!document.frame() || !document.frame()->isMainFrame()) |
| 223 return features; | 223 return features; |
| 224 | 224 |
| 225 ASSERT(document.hasFinishedParsing()); | 225 DCHECK(document.hasFinishedParsing()); |
| 226 | 226 |
| 227 HTMLElement* body = document.body(); | 227 HTMLElement* body = document.body(); |
| 228 HTMLElement* head = document.head(); | 228 HTMLElement* head = document.head(); |
| 229 | 229 |
| 230 if (!body || !head) | 230 if (!body || !head) |
| 231 return features; | 231 return features; |
| 232 | 232 |
| 233 features.isMobileFriendly = isMobileFriendly(document); | 233 features.isMobileFriendly = isMobileFriendly(document); |
| 234 | 234 |
| 235 double startTime = monotonicallyIncreasingTime(); | 235 double startTime = monotonicallyIncreasingTime(); |
| 236 | 236 |
| 237 // This should be cheap since collectStatistics is only called right after l
ayout. | 237 // This should be cheap since collectStatistics is only called right after l
ayout. |
| 238 document.updateLayoutTree(); | 238 document.updateLayoutTree(); |
| 239 | 239 |
| 240 // Traverse the DOM tree and collect statistics. | 240 // Traverse the DOM tree and collect statistics. |
| 241 collectFeatures(*body, features); | 241 collectFeatures(*body, features); |
| 242 features.openGraph = hasOpenGraphArticle(*head); | 242 features.openGraph = hasOpenGraphArticle(*head); |
| 243 | 243 |
| 244 double elapsedTime = monotonicallyIncreasingTime() - startTime; | 244 double elapsedTime = monotonicallyIncreasingTime() - startTime; |
| 245 | 245 |
| 246 DEFINE_STATIC_LOCAL(CustomCountHistogram, distillabilityHistogram, ("WebCore
.DistillabilityUs", 1, 1000000, 50)); | 246 DEFINE_STATIC_LOCAL(CustomCountHistogram, distillabilityHistogram, ("WebCore
.DistillabilityUs", 1, 1000000, 50)); |
| 247 distillabilityHistogram.count(static_cast<int>(1e6 * elapsedTime)); | 247 distillabilityHistogram.count(static_cast<int>(1e6 * elapsedTime)); |
| 248 | 248 |
| 249 return features; | 249 return features; |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace blink | 252 } // namespace blink |
| OLD | NEW |