Skip to content

Commit a03893d

Browse files
committed
servo: Merge #6593 - compositing: Make the constellation messages serializable (from pcwalton:constellation-ipc); r=jdm
Same idea as before. This depends on: * servo/euclid#94 * hyperium/hyper#603 r? jdm Source-Repo: https://github.com/servo/servo Source-Revision: 2f4bdc6ad631dc56b64622e3390943b59270b3ae UltraBlame original commit: 2564d34df7d27ad820f50ea42fdbb4667faab300
1 parent 22e546a commit a03893d

File tree

31 files changed

+316
-226
lines changed

31 files changed

+316
-226
lines changed

servo/components/compositing/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ git = "https://github.com/servo/rust-layers"
4848

4949
[dependencies.png]
5050
git = "https://github.com/servo/rust-png"
51+
features = [ "serde-serialization" ]
5152

5253
[dependencies.clipboard]
5354
git = "https://github.com/aweinstock314/rust-clipboard"
@@ -58,7 +59,7 @@ git = "https://github.com/pcwalton/ipc-channel"
5859
[dependencies]
5960
log = "*"
6061
num = "0.1.24"
61-
url = "0.2.35"
62+
url = "0.2.36"
6263
time = "0.1.17"
6364
libc = "*"
6465
gleam = "0.1"

servo/components/compositing/compositor_task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use windowing::{WindowEvent, WindowMethods};
1313

1414
use euclid::point::Point2D;
1515
use euclid::rect::Rect;
16-
use ipc_channel::ipc::IpcReceiver;
16+
use ipc_channel::ipc::{IpcReceiver, IpcSender};
1717
use layers::platform::surface::NativeDisplay;
1818
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
1919
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, FrameTreeId};
@@ -183,7 +183,7 @@ pub enum Msg {
183183

184184
SetCursor(Cursor),
185185

186-
CreatePng(Sender<Option<png::Image>>),
186+
CreatePng(IpcSender<Option<png::Image>>),
187187

188188
PaintTaskExited(PipelineId),
189189

servo/components/compositing/constellation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use euclid::rect::{Rect, TypedRect};
1919
use euclid::size::Size2D;
2020
use euclid::scale_factor::ScaleFactor;
2121
use gfx::font_cache_task::FontCacheTask;
22-
use ipc_channel::ipc;
22+
use ipc_channel::ipc::{self, IpcSender};
2323
use layout_traits::{LayoutControlChan, LayoutTaskFactory};
2424
use libc;
2525
use msg::compositor_msg::{Epoch, LayerId};
@@ -44,7 +44,7 @@ use std::collections::HashMap;
4444
use std::io::{self, Write};
4545
use std::marker::PhantomData;
4646
use std::mem::replace;
47-
use std::sync::mpsc::{Sender, Receiver, channel};
47+
use std::sync::mpsc::{Receiver, channel};
4848
use style::viewport::ViewportConstraints;
4949
use url::Url;
5050
use util::cursor::Cursor;
@@ -191,7 +191,7 @@ pub struct SendableFrameTree {
191191
}
192192

193193
struct WebDriverData {
194-
load_channel: Option<(PipelineId, Sender<webdriver_msg::LoadStatus>)>
194+
load_channel: Option<(PipelineId, IpcSender<webdriver_msg::LoadStatus>)>
195195
}
196196

197197
impl WebDriverData {
@@ -849,7 +849,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
849849
}
850850

851851
fn handle_get_pipeline(&mut self, frame_id: Option<FrameId>,
852-
resp_chan: Sender<Option<PipelineId>>) {
852+
resp_chan: IpcSender<Option<PipelineId>>) {
853853
let current_pipeline_id = frame_id.or(self.root_frame_id).map(|frame_id| {
854854
let frame = self.frames.get(&frame_id).unwrap();
855855
frame.current
@@ -863,7 +863,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
863863
fn handle_get_frame(&mut self,
864864
containing_pipeline_id: PipelineId,
865865
subpage_id: SubpageId,
866-
resp_chan: Sender<Option<FrameId>>) {
866+
resp_chan: IpcSender<Option<FrameId>>) {
867867
let frame_id = self.subpage_map.get(&(containing_pipeline_id, subpage_id)).and_then(
868868
|x| self.pipeline_to_frame_map.get(&x)).map(|x| *x);
869869
resp_chan.send(frame_id).unwrap();

servo/components/devtools/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ authors = ["The Servo Project Developers"]
77
name = "devtools"
88
path = "lib.rs"
99

10+
[dependencies.hyper]
11+
version = "0.6"
12+
features = [ "serde-serialization" ]
13+
1014
[dependencies.devtools_traits]
1115
path = "../devtools_traits"
1216

@@ -20,5 +24,4 @@ path = "../util"
2024
log = "*"
2125
time = "*"
2226
rustc-serialize = "0.3"
23-
url = "*"
24-
hyper = "0.6"
27+
url = "0.2"

servo/components/devtools_traits/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ authors = ["The Servo Project Developers"]
77
name = "devtools_traits"
88
path = "lib.rs"
99

10+
[dependencies.hyper]
11+
version = "0.6"
12+
features = [ "serde-serialization" ]
13+
1014
[dependencies.msg]
1115
path = "../msg"
1216

@@ -16,6 +20,5 @@ path = "../util"
1620
[dependencies]
1721
time = "*"
1822
rustc-serialize = "0.3"
19-
url = "*"
20-
hyper = "0.6"
23+
url = "0.2"
2124
bitflags = "*"

servo/components/gfx/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ path = "../script_traits"
4747
[dependencies]
4848
log = "*"
4949
fnv = "1.0"
50-
url = "0.2.35"
50+
url = "0.2.36"
5151
time = "0.1.12"
5252
bitflags = "*"
5353
rustc-serialize = "0.3"

servo/components/layout/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ git = "https://github.com/pcwalton/ipc-channel"
6262
log = "*"
6363
encoding = "0.2"
6464
fnv = "1.0"
65-
url = "0.2.35"
65+
url = "0.2.36"
6666
bitflags = "*"
6767
rustc-serialize = "0.3"
6868
libc = "*"

servo/components/layout_traits/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ path = "../util"
2929
git = "https://github.com/pcwalton/ipc-channel"
3030

3131
[dependencies]
32-
url = "0.2.35"
32+
url = "0.2.36"
3333
euclid = "0.1"
3434
serde = "*"
3535
serde_macros = "*"

servo/components/msg/Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ git = "https://github.com/servo/rust-layers"
2121

2222
[dependencies.png]
2323
git = "https://github.com/servo/rust-png"
24+
features = [ "serde-serialization" ]
25+
26+
[dependencies.hyper]
27+
version = "0.6"
28+
features = [ "serde-serialization" ]
29+
30+
[dependencies.url]
31+
version = "0.2.36"
32+
features = [ "serde_serialization" ]
2433

2534
[dependencies.ipc-channel]
2635
git = "https://github.com/pcwalton/ipc-channel"
2736

2837
[dependencies]
29-
url = "0.2.35"
3038
bitflags = "*"
31-
hyper = "0.6"
3239
rustc-serialize = "0.3.4"
3340
euclid = "0.1"
3441
serde = "*"

servo/components/msg/constellation_msg.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77

88
use compositor_msg::Epoch;
9+
910
use euclid::rect::Rect;
1011
use euclid::size::TypedSize2D;
1112
use euclid::scale_factor::ScaleFactor;
1213
use hyper::header::Headers;
1314
use hyper::method::Method;
15+
use ipc_channel::ipc::IpcSender;
1416
use layers::geometry::DevicePixel;
15-
use png;
17+
use png::Image;
1618
use util::cursor::Cursor;
1719
use util::geometry::{PagePx, ViewportPx};
1820
use std::collections::HashMap;
@@ -31,20 +33,20 @@ impl ConstellationChan {
3133
}
3234
}
3335

34-
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
36+
#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)]
3537
pub enum IFrameSandboxState {
3638
IFrameSandboxed,
3739
IFrameUnsandboxed
3840
}
3941

4042

41-
#[derive(Clone, Copy)]
43+
#[derive(Clone, Copy, Deserialize, Serialize)]
4244
pub struct Failure {
4345
pub pipeline_id: PipelineId,
4446
pub parent_info: Option<(PipelineId, SubpageId)>,
4547
}
4648

47-
#[derive(Copy, Clone)]
49+
#[derive(Copy, Clone, Deserialize, Serialize)]
4850
pub struct WindowSizeData {
4951

5052

@@ -209,6 +211,7 @@ pub enum FocusType {
209211
}
210212

211213

214+
#[derive(Deserialize, Serialize)]
212215
pub enum Msg {
213216
Exit,
214217
Failure(Failure),
@@ -234,14 +237,14 @@ pub enum Msg {
234237
TickAnimation(PipelineId),
235238

236239

237-
GetPipeline(Option<FrameId>, Sender<Option<PipelineId>>),
240+
GetPipeline(Option<FrameId>, IpcSender<Option<PipelineId>>),
238241

239242

240-
GetFrame(PipelineId, SubpageId, Sender<Option<FrameId>>),
243+
GetFrame(PipelineId, SubpageId, IpcSender<Option<FrameId>>),
241244

242245
Focus(PipelineId),
243246

244-
GetClipboardContents(Sender<String>),
247+
GetClipboardContents(IpcSender<String>),
245248

246249
WebDriverCommand(WebDriverCommandMsg),
247250

@@ -256,7 +259,7 @@ pub enum Msg {
256259
HeadParsed,
257260
}
258261

259-
#[derive(Clone, Eq, PartialEq)]
262+
#[derive(Clone, Eq, PartialEq, Deserialize, Serialize)]
260263
pub enum AnimationState {
261264
AnimationsPresent,
262265
AnimationCallbacksPresent,
@@ -265,6 +268,7 @@ pub enum AnimationState {
265268
}
266269

267270

271+
#[derive(Deserialize, Serialize)]
268272
pub enum MozBrowserEvent {
269273

270274
AsyncScroll,
@@ -329,16 +333,17 @@ impl MozBrowserEvent {
329333
}
330334
}
331335

336+
#[derive(Deserialize, Serialize)]
332337
pub enum WebDriverCommandMsg {
333-
LoadUrl(PipelineId, LoadData, Sender<LoadStatus>),
338+
LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
334339
ScriptCommand(PipelineId, WebDriverScriptCommand),
335-
TakeScreenshot(PipelineId, Sender<Option<png::Image>>)
340+
TakeScreenshot(PipelineId, IpcSender<Option<Image>>)
336341
}
337342

338343

339344

340345

341-
#[derive(Clone)]
346+
#[derive(Clone, Deserialize, Serialize)]
342347
pub struct LoadData {
343348
pub url: Url,
344349
pub method: Method,
@@ -357,16 +362,16 @@ impl LoadData {
357362
}
358363
}
359364

360-
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
365+
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
361366
pub enum NavigationDirection {
362367
Forward,
363368
Back,
364369
}
365370

366-
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
371+
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
367372
pub struct FrameId(pub u32);
368373

369-
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
374+
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
370375
pub struct WorkerId(pub u32);
371376

372377
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]

servo/components/msg/webdriver_msg.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22

33

44

5-
use rustc_serialize::json::{Json, ToJson};
65
use constellation_msg::{PipelineId, SubpageId};
76

8-
use std::sync::mpsc::Sender;
7+
use ipc_channel::ipc::IpcSender;
8+
use rustc_serialize::json::{Json, ToJson};
99

10+
#[derive(Deserialize, Serialize)]
1011
pub enum WebDriverScriptCommand {
11-
ExecuteScript(String, Sender<WebDriverJSResult>),
12-
ExecuteAsyncScript(String, Sender<WebDriverJSResult>),
13-
FindElementCSS(String, Sender<Result<Option<String>, ()>>),
14-
FindElementsCSS(String, Sender<Result<Vec<String>, ()>>),
15-
GetActiveElement(Sender<Option<String>>),
16-
GetElementTagName(String, Sender<Result<String, ()>>),
17-
GetElementText(String, Sender<Result<String, ()>>),
18-
GetFrameId(WebDriverFrameId, Sender<Result<Option<(PipelineId, SubpageId)>, ()>>),
19-
GetTitle(Sender<String>)
12+
ExecuteScript(String, IpcSender<WebDriverJSResult>),
13+
ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>),
14+
FindElementCSS(String, IpcSender<Result<Option<String>, ()>>),
15+
FindElementsCSS(String, IpcSender<Result<Vec<String>, ()>>),
16+
GetActiveElement(IpcSender<Option<String>>),
17+
GetElementTagName(String, IpcSender<Result<String, ()>>),
18+
GetElementText(String, IpcSender<Result<String, ()>>),
19+
GetFrameId(WebDriverFrameId, IpcSender<Result<Option<(PipelineId, SubpageId)>, ()>>),
20+
GetTitle(IpcSender<String>)
2021
}
2122

23+
#[derive(Deserialize, Serialize)]
2224
pub enum WebDriverJSValue {
2325
Undefined,
2426
Null,
@@ -28,13 +30,15 @@ pub enum WebDriverJSValue {
2830

2931
}
3032

33+
#[derive(Deserialize, Serialize)]
3134
pub enum WebDriverJSError {
3235
Timeout,
3336
UnknownType
3437
}
3538

3639
pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>;
3740

41+
#[derive(Deserialize, Serialize)]
3842
pub enum WebDriverFrameId {
3943
Short(u16),
4044
Element(String),
@@ -53,6 +57,7 @@ impl ToJson for WebDriverJSValue {
5357
}
5458
}
5559

60+
#[derive(Deserialize, Serialize)]
5661
pub enum LoadStatus {
5762
LoadComplete,
5863
LoadTimeout

servo/components/net/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@ path = "../devtools_traits"
1818

1919
[dependencies.png]
2020
git = "https://github.com/servo/rust-png"
21+
features = [ "serde-serialization" ]
22+
23+
[dependencies.hyper]
24+
version = "0.6"
25+
features = [ "serde-serialization" ]
2126

2227
[dependencies]
2328
log = "*"
24-
url = "0.2.35"
29+
url = "0.2.36"
2530
time = "0.1.17"
2631
openssl="0.6.1"
2732
rustc-serialize = "0.3"
2833
cookie="*"
2934
regex = "0.1.14"
3035
regex_macros = "0.1.8"
31-
hyper = "0.6"
3236
flate2 = "0.2.0"
3337
uuid = "0.1.16"
3438
euclid = "0.1"

0 commit comments

Comments
 (0)