Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Spidermonkey 39 #6141

Closed
wants to merge 7 commits into from
Closed
@@ -518,6 +518,7 @@ pub struct LayoutElement<'le> {

impl<'le> LayoutElement<'le> {
pub fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
use script::dom::element::ElementHelpers;
let style: &Option<PropertyDeclarationBlock> = unsafe {
&*self.element.style_attribute().borrow_for_layout()
};
@@ -30,8 +30,7 @@ pub struct UnrootedPass;
// TODO (#3874, sort of): unwrap other types like Vec/Option/HashMap/etc
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
match ty.node {
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(..) => {
match cx.tcx.def_map.borrow()[&ty.id] {
def::PathResolution{ base_def: def::DefTy(def_id, _), .. } => {
@@ -42,7 +41,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
_ => (),
}
}
_ => (),
_ => (),
};
}

@@ -23,6 +23,9 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
fn reflector<'a>(&'a self) -> &'a ::dom::bindings::utils::Reflector {
&self.$field_name
}
fn init_reflector(&mut self, obj: *mut ::js::jsapi::JSObject) {
self.$field_name.set_jsobject(obj);
}
}
);
impl_item.map(|it| push(it))
@@ -35,6 +38,9 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
fn reflector<'a>(&'a self) -> &'a ::dom::bindings::utils::Reflector {
self.$field_name.reflector()
}
fn init_reflector(&mut self, obj: *mut ::js::jsapi::JSObject) {
self.$field_name.init_reflector(obj);
}
}
);
impl_item.map(|it| push(it))
@@ -5,71 +5,73 @@
use devtools_traits::{EvaluateJSReply, NodeInfo, Modification, TimelineMarker, TimelineMarkerType};
use dom::bindings::conversions::FromJSValConvertible;
use dom::bindings::conversions::StringificationBehavior;
use dom::bindings::js::{JSRef, OptionalRootable, Rootable, Temporary};
use dom::bindings::js::Root;
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast};
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::DOMRectBinding::{DOMRectMethods};
use dom::bindings::codegen::Bindings::ElementBinding::{ElementMethods};
use dom::node::{Node, NodeHelpers};
use dom::window::{WindowHelpers, ScriptHelpers};
use dom::element::Element;
use dom::document::DocumentHelpers;
use page::{IterablePage, Page};
use msg::constellation_msg::PipelineId;
use script_task::{get_page, ScriptTask};
use js::jsapi::RootedValue;
use js::jsval::UndefinedValue;

use std::sync::mpsc::Sender;
use std::rc::Rc;


pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, reply: Sender<EvaluateJSReply>){
let page = get_page(&*page, pipeline);
let window = page.window().root();
let window = page.window();
let cx = window.r().get_cx();
let rval = window.r().evaluate_js_on_global_with_result(&eval);
let mut rval = RootedValue::new(cx, UndefinedValue());
window.r().evaluate_js_on_global_with_result(&eval, rval.handle_mut());

reply.send(if rval.is_undefined() {
reply.send(if rval.ptr.is_undefined() {
EvaluateJSReply::VoidValue
} else if rval.is_boolean() {
EvaluateJSReply::BooleanValue(rval.to_boolean())
} else if rval.is_double() {
EvaluateJSReply::NumberValue(FromJSValConvertible::from_jsval(cx, rval, ()).unwrap())
} else if rval.is_string() {
} else if rval.ptr.is_boolean() {
EvaluateJSReply::BooleanValue(rval.ptr.to_boolean())
} else if rval.ptr.is_double() {
EvaluateJSReply::NumberValue(FromJSValConvertible::from_jsval(cx, rval.handle(), ()).unwrap())
} else if rval.ptr.is_string() {
//FIXME: use jsstring_to_str when jsval grows to_jsstring
EvaluateJSReply::StringValue(FromJSValConvertible::from_jsval(cx, rval, StringificationBehavior::Default).unwrap())
} else if rval.is_null() {
EvaluateJSReply::StringValue(FromJSValConvertible::from_jsval(cx, rval.handle(), StringificationBehavior::Default).unwrap())
} else if rval.ptr.is_null() {
EvaluateJSReply::NullValue
} else {
//FIXME: jsvals don't have an is_int32/is_number yet
assert!(rval.is_object());
assert!(rval.ptr.is_object());
panic!("object values unimplemented")
}).unwrap();
}

pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
let page = get_page(&*page, pipeline);
let document = page.document().root();
let document = page.document();

let node: JSRef<Node> = NodeCast::from_ref(document.r());
let node = NodeCast::from_ref(document.r());
reply.send(node.summarize()).unwrap();
}

pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
let page = get_page(&*page, pipeline);
let document = page.document().root();
let document_element = document.r().GetDocumentElement().root().unwrap();
let document = page.document();
let document_element = document.r().GetDocumentElement().unwrap();

let node: JSRef<Node> = NodeCast::from_ref(document_element.r());
let node = NodeCast::from_ref(document_element.r());
reply.send(node.summarize()).unwrap();
}

fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Temporary<Node> {
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Root<Node> {
let page = get_page(&*page, pipeline);
let document = page.document().root();
let node: JSRef<Node> = NodeCast::from_ref(document.r());
let document = page.document();
let node = NodeCast::from_ref(document.r());

for candidate in node.traverse_preorder() {
if candidate.root().r().get_unique_id() == node_id {
if candidate.r().get_unique_id() == node_id {
return candidate;
}
}
@@ -78,26 +80,25 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
}

pub fn handle_get_children(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<Vec<NodeInfo>>) {
let parent = find_node_by_unique_id(&*page, pipeline, node_id).root();
let parent = find_node_by_unique_id(&*page, pipeline, node_id);
let children = parent.r().children().map(|child| {
let child = child.root();
child.r().summarize()
}).collect();
reply.send(children).unwrap();
}

pub fn handle_get_layout(page: &Rc<Page>, pipeline: PipelineId, node_id: String, reply: Sender<(f32, f32)>) {
let node = find_node_by_unique_id(&*page, pipeline, node_id).root();
let elem: JSRef<Element> = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
let rect = elem.GetBoundingClientRect().root();
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();
}

pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: String, modifications: Vec<Modification>) {
let node = find_node_by_unique_id(&*page, pipeline, node_id).root();
let elem: JSRef<Element> = ElementCast::to_ref(node.r()).expect("should be getting layout of element");
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");

for modification in modifications.iter(){
match modification.newValue {
@@ -111,7 +112,7 @@ pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: S

pub fn handle_wants_live_notifications(page: &Rc<Page>, pipeline_id: PipelineId, send_notifications: bool) {
let page = get_page(&*page, pipeline_id);
let window = page.window().root();
let window = page.window();
window.r().set_devtools_wants_updates(send_notifications);
}

@@ -122,7 +123,7 @@ pub fn handle_set_timeline_markers(page: &Rc<Page>,
for marker_type in &marker_types {
match *marker_type {
TimelineMarkerType::Reflow => {
let window = page.window().root();
let window = page.window();
window.r().set_devtools_timeline_marker(TimelineMarkerType::Reflow, reply.clone());
}
TimelineMarkerType::DOMEvent => {
@@ -135,7 +136,7 @@ pub fn handle_set_timeline_markers(page: &Rc<Page>,
pub fn handle_drop_timeline_markers(page: &Rc<Page>,
script_task: &ScriptTask,
marker_types: Vec<TimelineMarkerType>) {
let window = page.window().root();
let window = page.window();
for marker_type in &marker_types {
match *marker_type {
TimelineMarkerType::Reflow => {
@@ -150,6 +151,6 @@ pub fn handle_drop_timeline_markers(page: &Rc<Page>,

pub fn handle_request_animation_frame(page: &Rc<Page>, id: PipelineId, callback: Box<Fn(f64, )>) {
let page = page.find(id).expect("There is no such page");
let doc = page.document().root();
let doc = page.document();
doc.r().request_animation_frame(callback);
}
@@ -4,7 +4,6 @@

use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast};
use dom::bindings::js::{JSRef, Temporary, OptionalRootable, Rootable};
use dom::element::{Element, ActivationElementHelpers};
use dom::event::{Event, EventHelpers, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
@@ -15,7 +14,7 @@ use std::borrow::ToOwned;

/// Trait for elements with defined activation behavior
pub trait Activatable {
fn as_element(&self) -> Temporary<Element>;
fn as_element<'a>(&'a self) -> &'a Element;

// Is this particular instance of the element activatable?
fn is_instance_activatable(&self) -> bool;
@@ -27,32 +26,32 @@ pub trait Activatable {
fn canceled_activation(&self);

// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
fn activation_behavior(&self, event: JSRef<Event>, target: JSRef<EventTarget>);
fn activation_behavior(&self, event: &Event, target: &EventTarget);

// https://html.spec.whatwg.org/multipage/#implicit-submission
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool);

// https://html.spec.whatwg.org/multipage/#run-synthetic-click-activation-steps
fn synthetic_click_activation(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
let element = self.as_element().root();
let element = self.as_element();
// Step 1
if element.r().click_in_progress() {
if element.click_in_progress() {
return;
}
// Step 2
element.r().set_click_in_progress(true);
element.set_click_in_progress(true);
// Step 3
self.pre_click_activation();

// Step 4
// https://html.spec.whatwg.org/multipage/#fire-a-synthetic-mouse-event
let win = window_from_node(element.r()).root();
let target: JSRef<EventTarget> = EventTargetCast::from_ref(element.r());
let win = window_from_node(element);
let target = EventTargetCast::from_ref(element);
let mouse = MouseEvent::new(win.r(), "click".to_owned(),
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable, Some(win.r()), 1,
0, 0, 0, 0, ctrlKey, shiftKey, altKey, metaKey,
0, None).root();
let event: JSRef<Event> = EventCast::from_ref(mouse.r());
0, None);
let event = EventCast::from_ref(mouse.r());
event.fire(target);

// Step 5
@@ -64,6 +63,6 @@ pub trait Activatable {
}

// Step 6
element.r().set_click_in_progress(false);
element.set_click_in_progress(false);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.