зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #7242 - Perf timing dom props (from g-k:perf-timing-dom-props); r=jdm
I think this is closer to what https://github.com/servo/servo/issues/7045 describes, but it panics trying to load a page (trace: https://gist.github.com/g-k/a9911467889cdb6fdbf9) and all reftests fail. Source-Repo: https://github.com/servo/servo Source-Revision: 7de8b0a7ff2038f9fb643141d8759f40fb6ef093
This commit is contained in:
Родитель
d453427bd5
Коммит
c64559414c
|
@ -194,6 +194,13 @@ pub struct Document {
|
||||||
modified_elements: DOMRefCell<HashMap<JS<Element>, ElementSnapshot>>,
|
modified_elements: DOMRefCell<HashMap<JS<Element>, ElementSnapshot>>,
|
||||||
/// http://w3c.github.io/touch-events/#dfn-active-touch-point
|
/// http://w3c.github.io/touch-events/#dfn-active-touch-point
|
||||||
active_touch_points: DOMRefCell<Vec<JS<Touch>>>,
|
active_touch_points: DOMRefCell<Vec<JS<Touch>>>,
|
||||||
|
/// DOM-Related Navigation Timing properties:
|
||||||
|
/// http://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domLoading
|
||||||
|
dom_loading: Cell<u64>,
|
||||||
|
dom_interactive: Cell<u64>,
|
||||||
|
dom_content_loaded_event_start: Cell<u64>,
|
||||||
|
dom_content_loaded_event_end: Cell<u64>,
|
||||||
|
dom_complete: Cell<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for Document {
|
impl PartialEq for Document {
|
||||||
|
@ -507,6 +514,12 @@ impl Document {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
||||||
pub fn set_ready_state(&self, state: DocumentReadyState) {
|
pub fn set_ready_state(&self, state: DocumentReadyState) {
|
||||||
|
match state {
|
||||||
|
DocumentReadyState::Loading => update_with_current_time(&self.dom_loading),
|
||||||
|
DocumentReadyState::Interactive => update_with_current_time(&self.dom_interactive),
|
||||||
|
DocumentReadyState::Complete => update_with_current_time(&self.dom_complete),
|
||||||
|
};
|
||||||
|
|
||||||
self.ready_state.set(state);
|
self.ready_state.set(state);
|
||||||
|
|
||||||
let event = Event::new(GlobalRef::Window(&self.window),
|
let event = Event::new(GlobalRef::Window(&self.window),
|
||||||
|
@ -1226,6 +1239,9 @@ impl Document {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.domcontentloaded_dispatched.set(true);
|
self.domcontentloaded_dispatched.set(true);
|
||||||
|
|
||||||
|
update_with_current_time(&self.dom_content_loaded_event_start);
|
||||||
|
|
||||||
let event = Event::new(GlobalRef::Window(self.window()),
|
let event = Event::new(GlobalRef::Window(self.window()),
|
||||||
DOMString::from("DOMContentLoaded"),
|
DOMString::from("DOMContentLoaded"),
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
|
@ -1233,6 +1249,8 @@ impl Document {
|
||||||
let doctarget = self.upcast::<EventTarget>();
|
let doctarget = self.upcast::<EventTarget>();
|
||||||
let _ = doctarget.DispatchEvent(event.r());
|
let _ = doctarget.DispatchEvent(event.r());
|
||||||
self.window().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::DOMContentLoaded);
|
self.window().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::DOMContentLoaded);
|
||||||
|
|
||||||
|
update_with_current_time(&self.dom_content_loaded_event_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_constellation_load(&self) {
|
pub fn notify_constellation_load(&self) {
|
||||||
|
@ -1258,6 +1276,26 @@ impl Document {
|
||||||
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
.filter_map(Root::downcast::<HTMLIFrameElement>)
|
||||||
.find(|node| node.subpage_id() == Some(subpage_id))
|
.find(|node| node.subpage_id() == Some(subpage_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_dom_loading(&self) -> u64 {
|
||||||
|
self.dom_loading.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_dom_interactive(&self) -> u64 {
|
||||||
|
self.dom_interactive.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_dom_content_loaded_event_start(&self) -> u64 {
|
||||||
|
self.dom_content_loaded_event_start.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_dom_content_loaded_event_end(&self) -> u64 {
|
||||||
|
self.dom_content_loaded_event_end.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_dom_complete(&self) -> u64 {
|
||||||
|
self.dom_complete.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(HeapSizeOf)]
|
#[derive(HeapSizeOf)]
|
||||||
|
@ -1367,6 +1405,11 @@ impl Document {
|
||||||
appropriate_template_contents_owner_document: Default::default(),
|
appropriate_template_contents_owner_document: Default::default(),
|
||||||
modified_elements: DOMRefCell::new(HashMap::new()),
|
modified_elements: DOMRefCell::new(HashMap::new()),
|
||||||
active_touch_points: DOMRefCell::new(Vec::new()),
|
active_touch_points: DOMRefCell::new(Vec::new()),
|
||||||
|
dom_loading: Cell::new(Default::default()),
|
||||||
|
dom_interactive: Cell::new(Default::default()),
|
||||||
|
dom_content_loaded_event_start: Cell::new(Default::default()),
|
||||||
|
dom_content_loaded_event_end: Cell::new(Default::default()),
|
||||||
|
dom_complete: Cell::new(Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,6 +2280,13 @@ fn is_scheme_host_port_tuple(url: &Url) -> bool {
|
||||||
url.host().is_some() && url.port_or_default().is_some()
|
url.host().is_some() && url.port_or_default().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_with_current_time(marker: &Cell<u64>) {
|
||||||
|
if marker.get() == Default::default() {
|
||||||
|
let current_time_ms = time::get_time().sec * 1000;
|
||||||
|
marker.set(current_time_ms as u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DocumentProgressHandler {
|
pub struct DocumentProgressHandler {
|
||||||
addr: Trusted<Document>
|
addr: Trusted<Document>
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::PerformanceTimingBinding;
|
use dom::bindings::codegen::Bindings::PerformanceTimingBinding;
|
||||||
use dom::bindings::codegen::Bindings::PerformanceTimingBinding::PerformanceTimingMethods;
|
use dom::bindings::codegen::Bindings::PerformanceTimingBinding::PerformanceTimingMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
|
use dom::document::Document;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -14,15 +16,19 @@ pub struct PerformanceTiming {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
navigationStart: u64,
|
navigationStart: u64,
|
||||||
navigationStartPrecise: f64,
|
navigationStartPrecise: f64,
|
||||||
|
document: JS<Document>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PerformanceTiming {
|
impl PerformanceTiming {
|
||||||
fn new_inherited(navStart: u64, navStartPrecise: f64)
|
fn new_inherited(navStart: u64,
|
||||||
|
navStartPrecise: f64,
|
||||||
|
document: &Document)
|
||||||
-> PerformanceTiming {
|
-> PerformanceTiming {
|
||||||
PerformanceTiming {
|
PerformanceTiming {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
navigationStart: navStart,
|
navigationStart: navStart,
|
||||||
navigationStartPrecise: navStartPrecise,
|
navigationStartPrecise: navStartPrecise,
|
||||||
|
document: JS::from_ref(document),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,19 +37,45 @@ impl PerformanceTiming {
|
||||||
navigation_start: u64,
|
navigation_start: u64,
|
||||||
navigation_start_precise: f64)
|
navigation_start_precise: f64)
|
||||||
-> Root<PerformanceTiming> {
|
-> Root<PerformanceTiming> {
|
||||||
|
|
||||||
let timing = PerformanceTiming::new_inherited(navigation_start,
|
let timing = PerformanceTiming::new_inherited(navigation_start,
|
||||||
navigation_start_precise);
|
navigation_start_precise,
|
||||||
|
window.Document().r());
|
||||||
reflect_dom_object(box timing, GlobalRef::Window(window),
|
reflect_dom_object(box timing, GlobalRef::Window(window),
|
||||||
PerformanceTimingBinding::Wrap)
|
PerformanceTimingBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PerformanceTimingMethods for PerformanceTiming {
|
impl PerformanceTimingMethods for PerformanceTiming {
|
||||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-navigationStart
|
||||||
// NavigationTiming/Overview.html#dom-performancetiming-navigationstart
|
|
||||||
fn NavigationStart(&self) -> u64 {
|
fn NavigationStart(&self) -> u64 {
|
||||||
self.navigationStart
|
self.navigationStart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domLoading
|
||||||
|
fn DomLoading(&self) -> u64 {
|
||||||
|
self.document.get_dom_loading()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domInteractive
|
||||||
|
fn DomInteractive(&self) -> u64 {
|
||||||
|
self.document.get_dom_interactive()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domContentLoadedEventStart
|
||||||
|
fn DomContentLoadedEventStart(&self) -> u64 {
|
||||||
|
self.document.get_dom_content_loaded_event_start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domContentLoadedEventEnd
|
||||||
|
fn DomContentLoadedEventEnd(&self) -> u64 {
|
||||||
|
self.document.get_dom_content_loaded_event_end()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/navigation-timing/#widl-PerformanceTiming-domComplete
|
||||||
|
fn DomComplete(&self) -> u64 {
|
||||||
|
self.document.get_dom_complete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@ interface PerformanceTiming {
|
||||||
readonly attribute unsigned long long secureConnectionStart;
|
readonly attribute unsigned long long secureConnectionStart;
|
||||||
readonly attribute unsigned long long requestStart;
|
readonly attribute unsigned long long requestStart;
|
||||||
readonly attribute unsigned long long responseStart;
|
readonly attribute unsigned long long responseStart;
|
||||||
readonly attribute unsigned long long responseEnd;
|
readonly attribute unsigned long long responseEnd; */
|
||||||
readonly attribute unsigned long long domLoading;
|
readonly attribute unsigned long long domLoading;
|
||||||
readonly attribute unsigned long long domInteractive;
|
readonly attribute unsigned long long domInteractive;
|
||||||
readonly attribute unsigned long long domContentLoadedEventStart;
|
readonly attribute unsigned long long domContentLoadedEventStart;
|
||||||
readonly attribute unsigned long long domContentLoadedEventEnd;
|
readonly attribute unsigned long long domContentLoadedEventEnd;
|
||||||
readonly attribute unsigned long long domComplete;
|
readonly attribute unsigned long long domComplete;
|
||||||
readonly attribute unsigned long long loadEventStart;
|
/* readonly attribute unsigned long long loadEventStart;
|
||||||
readonly attribute unsigned long long loadEventEnd; */
|
readonly attribute unsigned long long loadEventEnd; */
|
||||||
};
|
};
|
||||||
|
|
|
@ -1642,6 +1642,8 @@ impl ScriptTask {
|
||||||
let frame_element = frame_element.r().map(Castable::upcast);
|
let frame_element = frame_element.r().map(Castable::upcast);
|
||||||
window.init_browsing_context(document.r(), frame_element);
|
window.init_browsing_context(document.r(), frame_element);
|
||||||
|
|
||||||
|
document.set_ready_state(DocumentReadyState::Loading);
|
||||||
|
|
||||||
// Create the root frame
|
// Create the root frame
|
||||||
page.set_frame(Some(Frame {
|
page.set_frame(Some(Frame {
|
||||||
document: JS::from_rooted(&document),
|
document: JS::from_rooted(&document),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче