aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/msg/constellation_msg.rs
blob: 51bcbb08c467c5972ce41a932ec7b1ca02b6445e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* This Source Code Form is subject to the terms of the Mozilla Public
 * 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/. */

//! The high-level interface from script to constellation. Using this abstract interface helps reduce
/// coupling between these two components

use std::comm::{Chan, SharedChan};
use extra::url::Url;
use extra::future::Future;
use geom::size::Size2D;
use geom::rect::Rect;

#[deriving(Clone)]
pub struct ConstellationChan {
    chan: SharedChan<Msg>,
}

impl ConstellationChan {
    pub fn new(chan: Chan<Msg>) -> ConstellationChan {
        ConstellationChan {
            chan: SharedChan::new(chan),
        }
    }
    pub fn send(&self, msg: Msg) {
        self.chan.send(msg);
    }
}

pub enum Msg {
    ExitMsg(Chan<()>),
    InitLoadUrlMsg(Url),
    FrameRectMsg(PipelineId, SubpageId, Rect<f32>),
    LoadUrlMsg(PipelineId, Url, Future<Size2D<uint>>),
    LoadIframeUrlMsg(Url, PipelineId, SubpageId, Future<Size2D<uint>>),
    NavigateMsg(NavigationDirection),
    RendererReadyMsg(PipelineId),
    ResizedWindowMsg(Size2D<uint>),
}

/// Represents the two different ways to which a page can be navigated
#[deriving(Clone, Eq, IterBytes)]
enum NavigationType {
    Load,               // entered or clicked on a url
    Navigate,           // browser forward/back buttons
}

#[deriving(Clone, Eq, IterBytes)]
pub enum NavigationDirection {
    Forward,
    Back,
}

#[deriving(Clone, Eq, IterBytes)]
pub struct PipelineId(uint);
#[deriving(Clone, Eq, IterBytes)]
pub struct SubpageId(uint);