mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Stop calling to_string() in devtools.
This commit is contained in:
parent
62a98e4918
commit
1257a33394
9 changed files with 68 additions and 68 deletions
|
@ -133,7 +133,7 @@ impl Actor for ConsoleActor {
|
|||
from: self.name(),
|
||||
nativeConsoleAPI: true,
|
||||
startedListeners:
|
||||
vec!("PageError".to_string(), "ConsoleAPI".to_string()),
|
||||
vec!("PageError".to_owned(), "ConsoleAPI".to_owned()),
|
||||
traits: StartedListenersTraits {
|
||||
customNetworkRequest: true,
|
||||
}
|
||||
|
@ -146,12 +146,12 @@ impl Actor for ConsoleActor {
|
|||
//TODO: actually implement listener filters that support starting/stopping
|
||||
let msg = StopListenersReply {
|
||||
from: self.name(),
|
||||
stoppedListeners: msg.get(&"listeners".to_string())
|
||||
stoppedListeners: msg.get("listeners")
|
||||
.unwrap()
|
||||
.as_array()
|
||||
.unwrap_or(&vec!())
|
||||
.iter()
|
||||
.map(|listener| listener.as_string().unwrap().to_string())
|
||||
.map(|listener| listener.as_string().unwrap().to_owned())
|
||||
.collect(),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
|
@ -164,14 +164,14 @@ impl Actor for ConsoleActor {
|
|||
let msg = AutocompleteReply {
|
||||
from: self.name(),
|
||||
matches: vec!(),
|
||||
matchProp: "".to_string(),
|
||||
matchProp: "".to_owned(),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
}
|
||||
|
||||
"evaluateJS" => {
|
||||
let input = msg.get(&"text".to_string()).unwrap().as_string().unwrap().to_string();
|
||||
let input = msg.get("text").unwrap().as_string().unwrap().to_owned();
|
||||
let (chan, port) = ipc::channel().unwrap();
|
||||
self.script_chan.send(DevtoolScriptControlMsg::EvaluateJS(
|
||||
self.pipeline, input.clone(), chan)).unwrap();
|
||||
|
@ -180,31 +180,31 @@ impl Actor for ConsoleActor {
|
|||
let result = match try!(port.recv().map_err(|_| ())) {
|
||||
VoidValue => {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_string(), "undefined".to_string().to_json());
|
||||
m.insert("type".to_owned(), "undefined".to_owned().to_json());
|
||||
Json::Object(m)
|
||||
}
|
||||
NullValue => {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_string(), "null".to_string().to_json());
|
||||
m.insert("type".to_owned(), "null".to_owned().to_json());
|
||||
Json::Object(m)
|
||||
}
|
||||
BooleanValue(val) => val.to_json(),
|
||||
NumberValue(val) => {
|
||||
if val.is_nan() {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_string(), "NaN".to_string().to_json());
|
||||
m.insert("type".to_owned(), "NaN".to_owned().to_json());
|
||||
Json::Object(m)
|
||||
} else if val.is_infinite() {
|
||||
let mut m = BTreeMap::new();
|
||||
if val < 0. {
|
||||
m.insert("type".to_string(), "-Infinity".to_string().to_json());
|
||||
m.insert("type".to_owned(), "-Infinity".to_owned().to_json());
|
||||
} else {
|
||||
m.insert("type".to_string(), "Infinity".to_string().to_json());
|
||||
m.insert("type".to_owned(), "Infinity".to_owned().to_json());
|
||||
}
|
||||
Json::Object(m)
|
||||
} else if val == 0. && val.is_sign_negative() {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_string(), "-0".to_string().to_json());
|
||||
m.insert("type".to_owned(), "-0".to_owned().to_json());
|
||||
Json::Object(m)
|
||||
} else {
|
||||
val.to_json()
|
||||
|
@ -216,12 +216,12 @@ impl Actor for ConsoleActor {
|
|||
let mut m = BTreeMap::new();
|
||||
let actor = ObjectActor::new(registry, uuid);
|
||||
|
||||
m.insert("type".to_string(), "object".to_string().to_json());
|
||||
m.insert("class".to_string(), class.to_json());
|
||||
m.insert("actor".to_string(), actor.to_json());
|
||||
m.insert("extensible".to_string(), true.to_json());
|
||||
m.insert("frozen".to_string(), false.to_json());
|
||||
m.insert("sealed".to_string(), false.to_json());
|
||||
m.insert("type".to_owned(), "object".to_owned().to_json());
|
||||
m.insert("class".to_owned(), class.to_json());
|
||||
m.insert("actor".to_owned(), actor.to_json());
|
||||
m.insert("extensible".to_owned(), true.to_json());
|
||||
m.insert("frozen".to_owned(), false.to_json());
|
||||
m.insert("sealed".to_owned(), false.to_json());
|
||||
Json::Object(m)
|
||||
}
|
||||
};
|
||||
|
@ -233,7 +233,7 @@ impl Actor for ConsoleActor {
|
|||
result: result,
|
||||
timestamp: 0,
|
||||
exception: Json::Object(BTreeMap::new()),
|
||||
exceptionMessage: "".to_string(),
|
||||
exceptionMessage: "".to_owned(),
|
||||
helperResult: Json::Object(BTreeMap::new()),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
|
|
|
@ -109,14 +109,14 @@ impl Actor for NodeActor {
|
|||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"modifyAttributes" => {
|
||||
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
|
||||
let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap();
|
||||
let target = msg.get("to").unwrap().as_string().unwrap();
|
||||
let mods = msg.get("modifications").unwrap().as_array().unwrap();
|
||||
let modifications = mods.iter().map(|json_mod| {
|
||||
json::decode(&json_mod.to_string()).unwrap()
|
||||
}).collect();
|
||||
|
||||
self.script_chan.send(ModifyAttribute(self.pipeline,
|
||||
registry.actor_to_script(target.to_string()),
|
||||
registry.actor_to_script(target.to_owned()),
|
||||
modifications))
|
||||
.unwrap();
|
||||
let reply = ModifyAttributeReply {
|
||||
|
@ -313,10 +313,10 @@ impl Actor for WalkerActor {
|
|||
}
|
||||
|
||||
"children" => {
|
||||
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
|
||||
let target = msg.get("node").unwrap().as_string().unwrap();
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
self.script_chan.send(GetChildren(self.pipeline,
|
||||
registry.actor_to_script(target.to_string()),
|
||||
registry.actor_to_script(target.to_owned()),
|
||||
tx))
|
||||
.unwrap();
|
||||
let children = rx.recv().unwrap();
|
||||
|
@ -452,15 +452,15 @@ impl Actor for PageStyleActor {
|
|||
|
||||
//TODO: query script for box layout properties of node (msg.node)
|
||||
"getLayout" => {
|
||||
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
|
||||
let target = msg.get("node").unwrap().as_string().unwrap();
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
self.script_chan.send(GetLayout(self.pipeline,
|
||||
registry.actor_to_script(target.to_string()),
|
||||
registry.actor_to_script(target.to_owned()),
|
||||
tx))
|
||||
.unwrap();
|
||||
let ComputedNodeLayout { width, height } = rx.recv().unwrap();
|
||||
|
||||
let auto_margins = msg.get(&"autoMargins".to_string())
|
||||
let auto_margins = msg.get("autoMargins")
|
||||
.and_then(&Json::as_boolean).unwrap_or(false);
|
||||
|
||||
//TODO: the remaining layout properties (margin, border, padding, position)
|
||||
|
@ -473,10 +473,10 @@ impl Actor for PageStyleActor {
|
|||
//TODO: real values like processMargins in
|
||||
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("top".to_string(), "auto".to_string().to_json());
|
||||
m.insert("bottom".to_string(), "auto".to_string().to_json());
|
||||
m.insert("left".to_string(), "auto".to_string().to_json());
|
||||
m.insert("right".to_string(), "auto".to_string().to_json());
|
||||
m.insert("top".to_owned(), "auto".to_owned().to_json());
|
||||
m.insert("bottom".to_owned(), "auto".to_owned().to_json());
|
||||
m.insert("left".to_owned(), "auto".to_owned().to_json());
|
||||
m.insert("right".to_owned(), "auto".to_owned().to_json());
|
||||
Json::Object(m)
|
||||
} else {
|
||||
Json::Null
|
||||
|
|
|
@ -82,7 +82,7 @@ impl Actor for NetworkEventActor {
|
|||
from: self.name(),
|
||||
headers: Vec::new(),
|
||||
headerSize: 10,
|
||||
rawHeaders: "Raw headers".to_string(),
|
||||
rawHeaders: "Raw headers".to_owned(),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -144,7 +144,7 @@ impl NetworkEventActor {
|
|||
actor: self.name(),
|
||||
url: self.request.url.clone(),
|
||||
method: format!("{}", self.request.method),
|
||||
startedDateTime: "2015-04-22T20:47:08.545Z".to_string(),
|
||||
startedDateTime: "2015-04-22T20:47:08.545Z".to_owned(),
|
||||
isXHR: false,
|
||||
private: false,
|
||||
}
|
||||
|
@ -154,11 +154,11 @@ impl NetworkEventActor {
|
|||
// TODO: Send the correct values for all these fields.
|
||||
// This is a fake message.
|
||||
ResponseStartMsg {
|
||||
httpVersion: "HTTP/1.1".to_string(),
|
||||
remoteAddress: "63.245.217.43".to_string(),
|
||||
httpVersion: "HTTP/1.1".to_owned(),
|
||||
remoteAddress: "63.245.217.43".to_owned(),
|
||||
remotePort: 443,
|
||||
status: "200".to_string(),
|
||||
statusText: "OK".to_string(),
|
||||
status: "200".to_owned(),
|
||||
statusText: "OK".to_owned(),
|
||||
headersSize: 337,
|
||||
discardResponseBody: true
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ pub struct RootActor {
|
|||
|
||||
impl Actor for RootActor {
|
||||
fn name(&self) -> String {
|
||||
"root".to_string()
|
||||
"root".to_owned()
|
||||
}
|
||||
|
||||
fn handle_message(&self,
|
||||
|
@ -59,9 +59,9 @@ impl Actor for RootActor {
|
|||
Ok(match msg_type {
|
||||
"listAddons" => {
|
||||
let actor = ErrorReply {
|
||||
from: "root".to_string(),
|
||||
error: "noAddons".to_string(),
|
||||
message: "This root actor has no browser addons.".to_string(),
|
||||
from: "root".to_owned(),
|
||||
error: "noAddons".to_owned(),
|
||||
message: "This root actor has no browser addons.".to_owned(),
|
||||
};
|
||||
stream.write_json_packet(&actor);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -70,7 +70,7 @@ impl Actor for RootActor {
|
|||
//https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs
|
||||
"listTabs" => {
|
||||
let actor = ListTabsReply {
|
||||
from: "root".to_string(),
|
||||
from: "root".to_owned(),
|
||||
selected: 0,
|
||||
tabs: self.tabs.iter().map(|tab| {
|
||||
registry.find::<TabActor>(tab).encodable()
|
||||
|
@ -88,12 +88,12 @@ impl Actor for RootActor {
|
|||
impl RootActor {
|
||||
pub fn encodable(&self) -> RootActorMsg {
|
||||
RootActorMsg {
|
||||
from: "root".to_string(),
|
||||
applicationType: "browser".to_string(),
|
||||
from: "root".to_owned(),
|
||||
applicationType: "browser".to_owned(),
|
||||
traits: ActorTraits {
|
||||
sources: true,
|
||||
highlightable: true,
|
||||
customHighlighters: vec!("BoxModelHighlighter".to_string()),
|
||||
customHighlighters: vec!("BoxModelHighlighter".to_owned()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ impl Actor for TabActor {
|
|||
"attach" => {
|
||||
let msg = TabAttachedReply {
|
||||
from: self.name(),
|
||||
__type__: "tabAttached".to_string(),
|
||||
__type__: "tabAttached".to_owned(),
|
||||
threadActor: self.name(),
|
||||
cacheDisabled: false,
|
||||
javascriptEnabled: true,
|
||||
|
@ -117,7 +117,7 @@ impl Actor for TabActor {
|
|||
"detach" => {
|
||||
let msg = TabDetachedReply {
|
||||
from: self.name(),
|
||||
__type__: "detached".to_string(),
|
||||
__type__: "detached".to_owned(),
|
||||
};
|
||||
let console_actor = registry.find::<ConsoleActor>(&self.console);
|
||||
console_actor.streams.borrow_mut().pop();
|
||||
|
|
|
@ -147,7 +147,7 @@ impl TimelineActor {
|
|||
return;
|
||||
}
|
||||
|
||||
task::spawn_named("PullTimelineMarkers".to_string(), move || {
|
||||
task::spawn_named("PullTimelineMarkers".to_owned(), move || {
|
||||
loop {
|
||||
if !*is_recording.lock().unwrap() {
|
||||
break;
|
||||
|
@ -291,7 +291,7 @@ impl Emitter {
|
|||
fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () {
|
||||
let end_time = PreciseTime::now();
|
||||
let reply = MarkersEmitterReply {
|
||||
__type__: "markers".to_string(),
|
||||
__type__: "markers".to_owned(),
|
||||
markers: markers,
|
||||
from: self.from.clone(),
|
||||
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
|
@ -303,7 +303,7 @@ impl Emitter {
|
|||
let registry = lock.as_mut().unwrap();
|
||||
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
||||
let framerateReply = FramerateEmitterReply {
|
||||
__type__: "framerate".to_string(),
|
||||
__type__: "framerate".to_owned(),
|
||||
from: framerate_actor.name(),
|
||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
timestamps: framerate_actor.take_pending_ticks(),
|
||||
|
@ -315,7 +315,7 @@ impl Emitter {
|
|||
let registry = self.registry.lock().unwrap();
|
||||
let memory_actor = registry.find::<MemoryActor>(actor_name);
|
||||
let memoryReply = MemoryEmitterReply {
|
||||
__type__: "memory".to_string(),
|
||||
__type__: "memory".to_owned(),
|
||||
from: memory_actor.name(),
|
||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
measurement: memory_actor.measure(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue