mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
parent
6ff3a5a3c1
commit
0fbfb8cffc
4 changed files with 13 additions and 17 deletions
|
@ -6,7 +6,6 @@ use pipeline::{Pipeline, CompositionPipeline};
|
||||||
|
|
||||||
use compositor_task::CompositorProxy;
|
use compositor_task::CompositorProxy;
|
||||||
use compositor_task::Msg as CompositorMsg;
|
use compositor_task::Msg as CompositorMsg;
|
||||||
use devtools_traits;
|
|
||||||
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg};
|
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg};
|
||||||
use geom::rect::{Rect, TypedRect};
|
use geom::rect::{Rect, TypedRect};
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
use actor::{Actor, ActorRegistry};
|
use actor::{Actor, ActorRegistry};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
|
|
||||||
use devtools_traits::{NullValue, VoidValue, NumberValue, StringValue, BooleanValue};
|
use devtools_traits;
|
||||||
use devtools_traits::{ActorValue, DevtoolScriptControlMsg};
|
use devtools_traits::{DevtoolScriptControlMsg};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
|
@ -226,18 +226,18 @@ impl Actor for ConsoleActor {
|
||||||
|
|
||||||
//TODO: extract conversion into protocol module or some other useful place
|
//TODO: extract conversion into protocol module or some other useful place
|
||||||
let result = match try!(port.recv().map_err(|_| ())) {
|
let result = match try!(port.recv().map_err(|_| ())) {
|
||||||
VoidValue => {
|
devtools_traits::EvaluateJSReply::VoidValue => {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_string(), "undefined".to_string().to_json());
|
m.insert("type".to_string(), "undefined".to_string().to_json());
|
||||||
Json::Object(m)
|
Json::Object(m)
|
||||||
}
|
}
|
||||||
NullValue => {
|
devtools_traits::EvaluateJSReply::NullValue => {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_string(), "null".to_string().to_json());
|
m.insert("type".to_string(), "null".to_string().to_json());
|
||||||
Json::Object(m)
|
Json::Object(m)
|
||||||
}
|
}
|
||||||
BooleanValue(val) => val.to_json(),
|
devtools_traits::EvaluateJSReply::BooleanValue(val) => val.to_json(),
|
||||||
NumberValue(val) => {
|
devtools_traits::EvaluateJSReply::NumberValue(val) => {
|
||||||
if val.is_nan() {
|
if val.is_nan() {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_string(), "NaN".to_string().to_json());
|
m.insert("type".to_string(), "NaN".to_string().to_json());
|
||||||
|
@ -258,8 +258,8 @@ impl Actor for ConsoleActor {
|
||||||
val.to_json()
|
val.to_json()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringValue(s) => s.to_json(),
|
devtools_traits::EvaluateJSReply::StringValue(s) => s.to_json(),
|
||||||
ActorValue(s) => {
|
devtools_traits::EvaluateJSReply::ActorValue(s) => {
|
||||||
//TODO: make initial ActorValue message include these properties.
|
//TODO: make initial ActorValue message include these properties.
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_string(), "object".to_string().to_json());
|
m.insert("type".to_string(), "object".to_string().to_json());
|
||||||
|
|
|
@ -20,8 +20,6 @@ extern crate "serialize" as rustc_serialize;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
extern crate util;
|
extern crate util;
|
||||||
|
|
||||||
pub use self::EvaluateJSReply::*;
|
|
||||||
|
|
||||||
use rustc_serialize::{Decodable, Decoder};
|
use rustc_serialize::{Decodable, Decoder};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use devtools_traits;
|
|
||||||
use devtools_traits::{EvaluateJSReply, NodeInfo, Modification};
|
use devtools_traits::{EvaluateJSReply, NodeInfo, Modification};
|
||||||
use dom::bindings::conversions::FromJSValConvertible;
|
use dom::bindings::conversions::FromJSValConvertible;
|
||||||
use dom::bindings::conversions::StringificationBehavior;
|
use dom::bindings::conversions::StringificationBehavior;
|
||||||
|
@ -31,16 +30,16 @@ pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, r
|
||||||
let rval = window.r().evaluate_js_on_global_with_result(eval.as_slice());
|
let rval = window.r().evaluate_js_on_global_with_result(eval.as_slice());
|
||||||
|
|
||||||
reply.send(if rval.is_undefined() {
|
reply.send(if rval.is_undefined() {
|
||||||
devtools_traits::VoidValue
|
EvaluateJSReply::VoidValue
|
||||||
} else if rval.is_boolean() {
|
} else if rval.is_boolean() {
|
||||||
devtools_traits::BooleanValue(rval.to_boolean())
|
EvaluateJSReply::BooleanValue(rval.to_boolean())
|
||||||
} else if rval.is_double() {
|
} else if rval.is_double() {
|
||||||
devtools_traits::NumberValue(FromJSValConvertible::from_jsval(cx, rval, ()).unwrap())
|
EvaluateJSReply::NumberValue(FromJSValConvertible::from_jsval(cx, rval, ()).unwrap())
|
||||||
} else if rval.is_string() {
|
} else if rval.is_string() {
|
||||||
//FIXME: use jsstring_to_str when jsval grows to_jsstring
|
//FIXME: use jsstring_to_str when jsval grows to_jsstring
|
||||||
devtools_traits::StringValue(FromJSValConvertible::from_jsval(cx, rval, StringificationBehavior::Default).unwrap())
|
EvaluateJSReply::StringValue(FromJSValConvertible::from_jsval(cx, rval, StringificationBehavior::Default).unwrap())
|
||||||
} else if rval.is_null() {
|
} else if rval.is_null() {
|
||||||
devtools_traits::NullValue
|
EvaluateJSReply::NullValue
|
||||||
} else {
|
} else {
|
||||||
//FIXME: jsvals don't have an is_int32/is_number yet
|
//FIXME: jsvals don't have an is_int32/is_number yet
|
||||||
assert!(rval.is_object());
|
assert!(rval.is_object());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue