servo: Merge #19569 - Add a topLevelDomComplete metric (from asajeffrey:script-perf-measure-topLevelDomComplete); r=jdm

<!-- Please describe your changes on the following line: -->

Measure DOM completion without iframes. This is in support of measuring when the main document is loaded, ignoring secondary content, e.g. ads.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #19561
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: d832e1b8f843612b4cb124d8c4eb9dce94e92d50

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 377138e2fc2d7d65866ba238978ba0e30ae910b0
This commit is contained in:
Alan Jeffrey 2017-12-14 17:02:44 -06:00
Родитель 5d284a763f
Коммит 832283ef24
4 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -141,6 +141,13 @@ impl DocumentLoader {
!self.blocking_loads.is_empty()
}
pub fn is_only_blocked_by_iframes(&self) -> bool {
self.blocking_loads.iter().all(|load| match *load {
LoadType::Subframe(_) => true,
_ => false
})
}
pub fn inhibit_events(&mut self) {
self.events_inhibited = true;
}

Просмотреть файл

@ -322,6 +322,7 @@ pub struct Document {
dom_content_loaded_event_start: Cell<u64>,
dom_content_loaded_event_end: Cell<u64>,
dom_complete: Cell<u64>,
top_level_dom_complete: Cell<u64>,
load_event_start: Cell<u64>,
load_event_end: Cell<u64>,
/// <https://html.spec.whatwg.org/multipage/#concept-document-https-state>
@ -1627,6 +1628,12 @@ impl Document {
// asap_in_order_script_loaded.
let loader = self.loader.borrow();
// Servo measures when the top-level content (not iframes) is loaded.
if (self.top_level_dom_complete.get() == 0) && loader.is_only_blocked_by_iframes() {
update_with_current_time_ms(&self.top_level_dom_complete);
}
if loader.is_blocked() || loader.events_inhibited() {
// Step 6.
return;
@ -1951,6 +1958,10 @@ impl Document {
self.dom_complete.get()
}
pub fn get_top_level_dom_complete(&self) -> u64 {
self.top_level_dom_complete.get()
}
pub fn get_load_event_start(&self) -> u64 {
self.load_event_start.get()
}
@ -2265,6 +2276,7 @@ impl Document {
dom_content_loaded_event_start: Cell::new(Default::default()),
dom_content_loaded_event_end: Cell::new(Default::default()),
dom_complete: Cell::new(Default::default()),
top_level_dom_complete: Cell::new(Default::default()),
load_event_start: Cell::new(Default::default()),
load_event_end: Cell::new(Default::default()),
https_state: Cell::new(HttpsState::None),

Просмотреть файл

@ -86,6 +86,12 @@ impl PerformanceTimingMethods for PerformanceTiming {
fn LoadEventEnd(&self) -> u64 {
self.document.get_load_event_end()
}
// check-tidy: no specs after this line
// Servo-only timing for when top-level content (not iframes) is complete
fn TopLevelDomComplete(&self) -> u64 {
self.document.get_top_level_dom_complete()
}
}

Просмотреть файл

@ -29,4 +29,7 @@ interface PerformanceTiming {
readonly attribute unsigned long long domComplete;
readonly attribute unsigned long long loadEventStart;
readonly attribute unsigned long long loadEventEnd;
/* Servo-onnly attribute for measuring when the top-level document (not iframes) is complete. */
[Pref="dom.testperf.enabled"]
readonly attribute unsigned long long topLevelDomComplete;
};