Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History API #11220

Closed
wants to merge 10 commits into from

Added support for mozbrowser/multiple tlbc

rebase and fix bhtml nav issue
  • Loading branch information
cbrewster committed May 28, 2016
commit 24f5fa4f48688a85c4fe16eea07f65e51dab75ee
@@ -1787,7 +1787,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
windowing::WindowNavigateMsg::Forward => NavigationDirection::Forward(1),
windowing::WindowNavigateMsg::Back => NavigationDirection::Back(1),
};
let msg = ConstellationMsg::Navigate(direction);
let msg = ConstellationMsg::Navigate(None, direction);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending navigation to constellation failed ({}).", e);
}
@@ -42,9 +42,7 @@ use euclid::size::TypedSize2D;
use gfx::paint_thread::ChromeToPaintMsg;
use ipc_channel::ipc::IpcSender;
use layout_traits::LayoutControlChan;
use msg::constellation_msg::{FrameId, Key, KeyState, KeyModifiers, LoadData};
use msg::constellation_msg::{NavigationDirection, PipelineId};
use msg::constellation_msg::{WebDriverCommandMsg, WindowSizeData, WindowSizeType};
use msg::constellation_msg::PipelineId;
use script_traits::ConstellationControlMsg;
use std::sync::mpsc::Sender;
use util::geometry::PagePx;
@@ -57,41 +55,6 @@ mod surface_map;
mod touch;
pub mod windowing;

/// Specifies whether the script or layout thread needs to be ticked for animation.
#[derive(Deserialize, Serialize)]
pub enum AnimationTickType {
Script,
Layout,
}

/// Messages from the compositor to the constellation.
#[derive(Deserialize, Serialize)]
pub enum CompositorMsg {
Exit,
FrameSize(PipelineId, Size2D<f32>),
/// Request that the constellation send the FrameId corresponding to the document
/// with the provided pipeline id
GetFrame(PipelineId, IpcSender<Option<FrameId>>),
/// Request that the constellation send the current pipeline id for the provided frame
/// id, or for the root frame if this is None, over a provided channel.
/// Also returns a boolean saying whether the document has finished loading or not.
GetPipeline(Option<FrameId>, IpcSender<Option<(PipelineId, bool)>>),
/// Requests that the constellation inform the compositor of the title of the pipeline
/// immediately.
GetPipelineTitle(PipelineId),
InitLoadUrl(Url),
/// Query the constellation to see if the current compositor output is stable
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
KeyEvent(Key, KeyState, KeyModifiers),
LoadUrl(PipelineId, LoadData),
Navigate(NavigationDirection),
WindowSize(WindowSizeData, WindowSizeType),
/// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId, AnimationTickType),
/// Dispatch a webdriver command
WebDriverCommand(WebDriverCommandMsg),
}

pub struct SendableFrameTree {
pub pipeline: CompositionPipeline,
pub size: Option<TypedSize2D<PagePx, f32>>,

Large diffs are not rendered by default.

@@ -13,6 +13,7 @@ use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descrip
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::WindowProxyHandler;
use dom::bindings::utils::get_array_index_from_id;
@@ -308,23 +309,6 @@ impl BrowsingContext {
state.read(global, state_js.handle_mut());
PopStateEvent::dispatch_jsval(target, global, state_js.handle());
}
}

pub struct PopstateNotificationRunnable {
window: Trusted<Window>,
state: StructuredCloneData,
}

impl Runnable for PopstateNotificationRunnable {
fn handler(self: Box<PopstateNotificationRunnable>) {
let this = *self;
BrowsingContext::handle_popstate(this.window, this.state);
}
}

pub struct ContextIterator {
stack: Vec<Root<BrowsingContext>>,
}

pub fn iter(&self) -> ContextIterator {
ContextIterator {
@@ -344,6 +328,18 @@ pub struct ContextIterator {
}
}

pub struct PopstateNotificationRunnable {
window: Trusted<Window>,
state: StructuredCloneData,
}

impl Runnable for PopstateNotificationRunnable {
fn handler(self: Box<PopstateNotificationRunnable>) {
let this = *self;
BrowsingContext::handle_popstate(this.window, this.state);
}
}

pub struct ContextIterator {
stack: Vec<Root<BrowsingContext>>,
}
@@ -10,14 +10,14 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bindings::structuredclone::StructuredCloneData;
use dom::window::Window;
use ipc_channel::ipc;
use js::jsapi::{HandleValue, JSContext, JSAutoCompartment, RootedValue};
use js::jsval::{JSVal, UndefinedValue};
use msg::constellation_msg::NavigationDirection;
use script_traits::ScriptMsg as ConstellationMsg;
use util::str::DOMString;

// https://html.spec.whatwg.org/multipage/#the-history-interface
#[dom_struct]
@@ -41,7 +41,8 @@ impl History {
}

fn traverse_history(&self, direction: NavigationDirection) {
let msg = ConstellationMsg::Navigate(direction);
let pipeline = self.window.pipeline();
let msg = ConstellationMsg::Navigate(Some(pipeline), direction);
self.window.constellation_chan().send(msg).unwrap();
}

@@ -63,7 +64,8 @@ impl HistoryMethods for History {
fn GetLength(&self) -> Fallible<u32> {
try!(self.is_fully_active());
let (sender, receiver) = ipc::channel::<usize>().expect("Failed to create IPC channel");
let msg = ConstellationMsg::HistoryLength(sender);
let pipeline = self.window.pipeline();
let msg = ConstellationMsg::HistoryLength(pipeline, sender);
self.window.constellation_chan().send(msg).unwrap();
Ok(receiver.recv().unwrap() as u32)
}
@@ -371,7 +371,7 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> E
if iframe.upcast::<Node>().is_in_doc() {
let window = window_from_node(iframe);

let msg = ConstellationMsg::Navigate(direction);
let msg = ConstellationMsg::Navigate(iframe.pipeline_id.get(), direction);
window.constellation_chan().send(msg).unwrap();
}

@@ -493,7 +493,7 @@ pub enum ConstellationMsg {
/// Request to load a page.
LoadUrl(PipelineId, LoadData),
/// Request to navigate a frame.
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
Navigate(Option<PipelineId>, NavigationDirection),
/// Inform the constellation of a window being resized.
WindowSize(WindowSizeData, WindowSizeType),
/// Requests that the constellation instruct layout to begin a new tick of the animation.
@@ -73,10 +73,10 @@ pub enum ScriptMsg {
LoadUrl(PipelineId, LoadData),
/// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode.
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
/// HTMLIFrameElement Forward or Back navigation.
Navigate(NavigationDirection),
/// Pipeline Forward or Back navigation.
Navigate(Option<PipelineId>, NavigationDirection),
/// Returns the session history length.
HistoryLength(IpcSender<usize>),
HistoryLength(PipelineId, IpcSender<usize>),
/// Notifies constellation that a new state was pushed, and the frame needs to be updated
HistoryStatePushed(Option<(PipelineId, SubpageId)>, usize),
/// Favicon detected
@@ -417,12 +417,12 @@ impl Handler {
}

fn handle_go_back(&self) -> WebDriverResult<WebDriverResponse> {
self.constellation_chan.send(ConstellationMsg::Navigate(NavigationDirection::Back(1))).unwrap();
self.constellation_chan.send(ConstellationMsg::Navigate(None, NavigationDirection::Back(1))).unwrap();
Ok(WebDriverResponse::Void)
}

fn handle_go_forward(&self) -> WebDriverResult<WebDriverResponse> {
self.constellation_chan.send(ConstellationMsg::Navigate(NavigationDirection::Forward(1))).unwrap();
self.constellation_chan.send(ConstellationMsg::Navigate(None, NavigationDirection::Forward(1))).unwrap();
Ok(WebDriverResponse::Void)
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.