aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index c591cd955a3..b24af89193e 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -282,35 +282,37 @@ impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> {
/// APIs that need to abstract over multiple kinds of event loops (worker/main thread) with
/// different Receiver interfaces.
pub trait ScriptPort {
- fn recv(&self) -> CommonScriptMsg;
+ fn recv(&self) -> Result<CommonScriptMsg, ()>;
}
impl ScriptPort for Receiver<CommonScriptMsg> {
- fn recv(&self) -> CommonScriptMsg {
- self.recv().unwrap()
+ fn recv(&self) -> Result<CommonScriptMsg, ()> {
+ self.recv().map_err(|_| ())
}
}
impl ScriptPort for Receiver<MainThreadScriptMsg> {
- fn recv(&self) -> CommonScriptMsg {
- match self.recv().unwrap() {
- MainThreadScriptMsg::Common(script_msg) => script_msg,
- _ => panic!("unexpected main thread event message!")
+ fn recv(&self) -> Result<CommonScriptMsg, ()> {
+ match self.recv() {
+ Ok(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg),
+ Ok(_) => panic!("unexpected main thread event message!"),
+ _ => Err(()),
}
}
}
impl ScriptPort for Receiver<(TrustedWorkerAddress, CommonScriptMsg)> {
- fn recv(&self) -> CommonScriptMsg {
- self.recv().unwrap().1
+ fn recv(&self) -> Result<CommonScriptMsg, ()> {
+ self.recv().map(|(_, msg)| msg).map_err(|_| ())
}
}
impl ScriptPort for Receiver<(TrustedWorkerAddress, MainThreadScriptMsg)> {
- fn recv(&self) -> CommonScriptMsg {
- match self.recv().unwrap().1 {
- MainThreadScriptMsg::Common(script_msg) => script_msg,
- _ => panic!("unexpected main thread event message!")
+ fn recv(&self) -> Result<CommonScriptMsg, ()> {
+ match self.recv().map(|(_, msg)| msg) {
+ Ok(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg),
+ Ok(_) => panic!("unexpected main thread event message!"),
+ _ => Err(()),
}
}
}
@@ -1841,7 +1843,7 @@ impl ScriptThread {
// Really what needs to happen is that this needs to go through layout to ask which
// layer the element belongs to, and have it send the scroll message to the
// compositor.
- let rect = element.upcast::<Node>().get_bounding_content_box();
+ let rect = element.upcast::<Node>().bounding_content_box();
// In order to align with element edges, we snap to unscaled pixel boundaries, since the
// paint thread currently does the same for drawing elements. This is important for pages