mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add paint metrics to Performance Timeline API
This commit is contained in:
parent
1c9c0334ba
commit
2d0037f195
15 changed files with 152 additions and 20 deletions
|
@ -401,6 +401,7 @@ pub mod performance;
|
|||
pub mod performanceentry;
|
||||
pub mod performanceobserver;
|
||||
pub mod performanceobserverentrylist;
|
||||
pub mod performancepainttiming;
|
||||
pub mod performancetiming;
|
||||
pub mod permissions;
|
||||
pub mod permissionstatus;
|
||||
|
|
|
@ -21,10 +21,10 @@ pub struct PerformanceEntry {
|
|||
}
|
||||
|
||||
impl PerformanceEntry {
|
||||
fn new_inherited(name: DOMString,
|
||||
entry_type: DOMString,
|
||||
start_time: f64,
|
||||
duration: f64) -> PerformanceEntry {
|
||||
pub fn new_inherited(name: DOMString,
|
||||
entry_type: DOMString,
|
||||
start_time: f64,
|
||||
duration: f64) -> PerformanceEntry {
|
||||
PerformanceEntry {
|
||||
reflector_: Reflector::new(),
|
||||
name,
|
||||
|
|
|
@ -27,7 +27,7 @@ const VALID_ENTRY_TYPES: &'static [&'static str] = &[
|
|||
// "measure", XXX User Timing API
|
||||
// "resource", XXX Resource Timing API
|
||||
// "server", XXX Server Timing API
|
||||
// "paint", XXX Paint Timing API
|
||||
"paint", // Paint Timing API
|
||||
];
|
||||
|
||||
#[dom_struct]
|
||||
|
|
41
components/script/dom/performancepainttiming.rs
Normal file
41
components/script/dom/performancepainttiming.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::PerformancePaintTimingBinding;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::performanceentry::PerformanceEntry;
|
||||
use dom_struct::dom_struct;
|
||||
use script_traits::PaintMetricType;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct PerformancePaintTiming {
|
||||
entry: PerformanceEntry,
|
||||
}
|
||||
|
||||
impl PerformancePaintTiming {
|
||||
fn new_inherited(metric_type: PaintMetricType, start_time: f64)
|
||||
-> PerformancePaintTiming {
|
||||
let name = match metric_type {
|
||||
PaintMetricType::FirstPaint => DOMString::from("first-paint"),
|
||||
PaintMetricType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
|
||||
};
|
||||
PerformancePaintTiming {
|
||||
entry: PerformanceEntry::new_inherited(name,
|
||||
DOMString::from("paint"),
|
||||
start_time,
|
||||
0.)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: &GlobalScope,
|
||||
metric_type: PaintMetricType,
|
||||
start_time: f64) -> Root<PerformancePaintTiming> {
|
||||
let entry = PerformancePaintTiming::new_inherited(metric_type, start_time);
|
||||
reflect_dom_object(box entry, global, PerformancePaintTimingBinding::Wrap)
|
||||
}
|
||||
}
|
11
components/script/dom/webidls/PerformancePaintTiming.webidl
Normal file
11
components/script/dom/webidls/PerformancePaintTiming.webidl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://wicg.github.io/paint-timing/#sec-PerformancePaintTiming
|
||||
*/
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
interface PerformancePaintTiming : PerformanceEntry {
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue