mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #7132 - jdm:docenum, r=ms2ger
Document the use and meaning of the devtools control messages. Fixes … …#6922. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7132) <!-- Reviewable:end -->
This commit is contained in:
commit
f3b7c5cb4b
10 changed files with 80 additions and 96 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use devtools_traits::{CachedConsoleMessage, CachedConsoleMessageTypes, PAGE_ERROR, CONSOLE_API};
|
||||
use devtools_traits::{EvaluateJSReply, NodeInfo, Modification, TimelineMarker, TimelineMarkerType};
|
||||
use devtools_traits::{ConsoleAPI, PageError};
|
||||
use devtools_traits::{ConsoleAPI, PageError, ScriptToDevtoolsControlMsg, ComputedNodeLayout};
|
||||
use dom::bindings::conversions::jsstring_to_str;
|
||||
use dom::bindings::conversions::FromJSValConvertible;
|
||||
use dom::bindings::js::Root;
|
||||
|
@ -97,13 +97,16 @@ pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: Strin
|
|||
reply.send(children).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: IpcSender<(f32, f32)>) {
|
||||
pub fn handle_get_layout(page: &Rc<Page>,
|
||||
pipeline: PipelineId,
|
||||
node_id: String,
|
||||
reply: IpcSender<ComputedNodeLayout>) {
|
||||
let node = find_node_by_unique_id(&*page, pipeline, node_id);
|
||||
let elem = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
|
||||
let rect = elem.GetBoundingClientRect();
|
||||
let width = *rect.r().Width();
|
||||
let height = *rect.r().Height();
|
||||
reply.send((width, height)).unwrap();
|
||||
reply.send(ComputedNodeLayout { width: width, height: height }).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_cached_messages(_pipeline_id: PipelineId,
|
||||
|
@ -202,10 +205,12 @@ pub fn handle_drop_timeline_markers(page: &Rc<Page>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, callback: IpcSender<f64>) {
|
||||
pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, actor_name: String) {
|
||||
let page = page.find(id).expect("There is no such page");
|
||||
let doc = page.document();
|
||||
let devtools_sender = page.window().devtools_chan().unwrap();
|
||||
doc.r().request_animation_frame(box move |time| {
|
||||
callback.send(time).unwrap()
|
||||
let msg = ScriptToDevtoolsControlMsg::FramerateTick(actor_name, time);
|
||||
devtools_sender.send(msg).unwrap();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ use net_traits::image::base::Image;
|
|||
use profile_traits::mem::ProfilerChan;
|
||||
use util::str::{LengthOrPercentageOrAuto};
|
||||
use selectors::parser::PseudoElement;
|
||||
use std::boxed::FnBox;
|
||||
use std::cell::{Cell, UnsafeCell, RefCell};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::hash_state::HashState;
|
||||
|
@ -313,7 +314,7 @@ impl JSTraceable for Box<ScriptChan+Send> {
|
|||
}
|
||||
}
|
||||
|
||||
impl JSTraceable for Box<Fn(f64, )> {
|
||||
impl JSTraceable for Box<FnBox(f64, )> {
|
||||
#[inline]
|
||||
fn trace(&self, _trc: *mut JSTracer) {
|
||||
// Do nothing
|
||||
|
|
|
@ -94,6 +94,7 @@ use js::jsapi::{JSContext, JSObject, JSRuntime};
|
|||
use num::ToPrimitive;
|
||||
use std::iter::FromIterator;
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::FnBox;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::ascii::AsciiExt;
|
||||
|
@ -148,7 +149,7 @@ pub struct Document {
|
|||
/// https://html.spec.whatwg.org/multipage/#list-of-animation-frame-callbacks
|
||||
/// List of animation frame callbacks
|
||||
#[ignore_heap_size_of = "closures are hard"]
|
||||
animation_frame_list: RefCell<HashMap<i32, Box<Fn(f64)>>>,
|
||||
animation_frame_list: RefCell<HashMap<i32, Box<FnBox(f64)>>>,
|
||||
/// Tracks all outstanding loads related to this document.
|
||||
loader: DOMRefCell<DocumentLoader>,
|
||||
/// The current active HTML parser, to allow resuming after interruptions.
|
||||
|
@ -292,7 +293,7 @@ pub trait DocumentHelpers<'a> {
|
|||
fn set_current_script(self, script: Option<&HTMLScriptElement>);
|
||||
fn trigger_mozbrowser_event(self, event: MozBrowserEvent);
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||
fn request_animation_frame(self, callback: Box<Fn(f64, )>) -> i32;
|
||||
fn request_animation_frame(self, callback: Box<FnBox(f64, )>) -> i32;
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||
fn cancel_animation_frame(self, ident: i32);
|
||||
/// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
|
||||
|
@ -949,7 +950,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||
fn request_animation_frame(self, callback: Box<Fn(f64, )>) -> i32 {
|
||||
fn request_animation_frame(self, callback: Box<FnBox(f64)>) -> i32 {
|
||||
let window = self.window.root();
|
||||
let window = window.r();
|
||||
let ident = self.animation_frame_ident.get() + 1;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#![feature(custom_attribute)]
|
||||
#![feature(custom_derive)]
|
||||
#![feature(drain)]
|
||||
#![feature(fnbox)]
|
||||
#![feature(hashmap_hasher)]
|
||||
#![feature(mpsc_select)]
|
||||
#![feature(nonzero)]
|
||||
|
|
|
@ -909,8 +909,8 @@ impl ScriptTask {
|
|||
devtools::handle_set_timeline_markers(&page, self, marker_types, reply),
|
||||
DevtoolScriptControlMsg::DropTimelineMarkers(_pipeline_id, marker_types) =>
|
||||
devtools::handle_drop_timeline_markers(&page, self, marker_types),
|
||||
DevtoolScriptControlMsg::RequestAnimationFrame(pipeline_id, callback) =>
|
||||
devtools::handle_request_animation_frame(&page, pipeline_id, callback),
|
||||
DevtoolScriptControlMsg::RequestAnimationFrame(pipeline_id, name) =>
|
||||
devtools::handle_request_animation_frame(&page, pipeline_id, name),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue