Skip to content

Commit

Permalink
Implement beginnings of joint session history
Browse files Browse the repository at this point in the history
Fix backward navigation

make use of history iterator

Add frame iterator
add different back logic

cleanup navigation_info

Add extra explanation for iter logic

Remove forward history on full frame tree

Rename navigation to traversal where appropriate

check full tree for can go back/forward

simplify frame iter logic

remove FrameIterator

cleanup history iter

reduce amount of vec allocations

removed extra parenthesis

Remove history iterator

cleanup after rebasing

avoid recursive vec allocation
remove full_frame_tree
remove_forward_history_in_frame_tree -> clear_joint_session_future
  • Loading branch information
cbrewster committed Jul 22, 2016
1 parent 4ae0897 commit f131818
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 202 deletions.
8 changes: 4 additions & 4 deletions components/compositing/compositor.rs
Expand Up @@ -29,7 +29,7 @@ use layers::rendergl;
use layers::rendergl::RenderContext;
use layers::scene::Scene;
use msg::constellation_msg::{Image, PixelFormat, Key, KeyModifiers, KeyState};
use msg::constellation_msg::{LoadData, NavigationDirection, PipelineId};
use msg::constellation_msg::{LoadData, TraversalDirection, PipelineId};
use msg::constellation_msg::{PipelineIndex, PipelineNamespaceId, WindowSizeType};
use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest};
use profile_traits::time::{self, ProfilerCategory, profile};
Expand Down Expand Up @@ -1862,10 +1862,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {

fn on_navigation_window_event(&self, direction: WindowNavigateMsg) {
let direction = match direction {
windowing::WindowNavigateMsg::Forward => NavigationDirection::Forward(1),
windowing::WindowNavigateMsg::Back => NavigationDirection::Back(1),
windowing::WindowNavigateMsg::Forward => TraversalDirection::Forward(1),
windowing::WindowNavigateMsg::Back => TraversalDirection::Back(1),
};
let msg = ConstellationMsg::Navigate(None, direction);
let msg = ConstellationMsg::TraverseHistory(None, direction);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending navigation to constellation failed ({}).", e);
}
Expand Down
485 changes: 308 additions & 177 deletions components/constellation/constellation.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions components/msg/constellation_msg.rs
Expand Up @@ -212,12 +212,12 @@ impl LoadData {
}

#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
pub enum NavigationDirection {
pub enum TraversalDirection {
Forward(usize),
Back(usize),
}

#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, PartialOrd, Ord)]
pub struct FrameId(pub u32);

/// Each pipeline ID needs to be unique. However, it also needs to be possible to
Expand Down
14 changes: 5 additions & 9 deletions components/script/dom/htmliframeelement.rs
Expand Up @@ -38,7 +38,7 @@ use dom::window::{ReflowReason, Window};
use ipc_channel::ipc;
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue};
use msg::constellation_msg::{FrameType, LoadData, NavigationDirection, PipelineId, SubpageId};
use msg::constellation_msg::{FrameType, LoadData, TraversalDirection, PipelineId, SubpageId};
use net_traits::response::HttpsState;
use script_layout_interface::message::ReflowQueryType;
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
Expand Down Expand Up @@ -419,15 +419,11 @@ unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
}
}


pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> ErrorResult {
pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> ErrorResult {
if iframe.Mozbrowser() {
if iframe.upcast::<Node>().is_in_doc() {
let window = window_from_node(iframe);

let pipeline_info = Some((window.pipeline(),
iframe.subpage_id().unwrap()));
let msg = ConstellationMsg::Navigate(pipeline_info, direction);
let msg = ConstellationMsg::TraverseHistory(iframe.pipeline(), direction);
window.constellation_chan().send(msg).unwrap();
}

Expand Down Expand Up @@ -500,12 +496,12 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
fn GoBack(&self) -> ErrorResult {
Navigate(self, NavigationDirection::Back(1))
Navigate(self, TraversalDirection::Back(1))
}

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
fn GoForward(&self) -> ErrorResult {
Navigate(self, NavigationDirection::Forward(1))
Navigate(self, TraversalDirection::Forward(1))
}

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload
Expand Down
8 changes: 4 additions & 4 deletions components/script_traits/lib.rs
Expand Up @@ -51,8 +51,8 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
use layers::geometry::DevicePixel;
use libc::c_void;
use msg::constellation_msg::{FrameId, FrameType, Image, Key, KeyModifiers, KeyState, LoadData};
use msg::constellation_msg::{NavigationDirection, PipelineId, ReferrerPolicy};
use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeType};
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, ReferrerPolicy};
use msg::constellation_msg::{SubpageId, TraversalDirection, WindowSizeType};
use net_traits::bluetooth_thread::BluetoothMethodMsg;
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::response::HttpsState;
Expand Down Expand Up @@ -621,8 +621,8 @@ pub enum ConstellationMsg {
KeyEvent(Option<char>, Key, KeyState, KeyModifiers),
/// Request to load a page.
LoadUrl(PipelineId, LoadData),
/// Request to navigate a frame.
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
/// Request to traverse the joint session history.
TraverseHistory(Option<PipelineId>, TraversalDirection),
/// 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.
Expand Down
6 changes: 3 additions & 3 deletions components/script_traits/script_msg.rs
Expand Up @@ -17,7 +17,7 @@ use euclid::size::Size2D;
use gfx_traits::LayerId;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
use msg::constellation_msg::{PipelineId, SubpageId, TraversalDirection};
use net_traits::CoreResourceMsg;
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use style_traits::cursor::Cursor;
Expand Down Expand Up @@ -91,8 +91,8 @@ pub enum ScriptMsg {
/// Dispatch a mozbrowser event to a given iframe,
/// or to the window if no subpage id is provided.
MozBrowserEvent(PipelineId, Option<SubpageId>, MozBrowserEvent),
/// HTMLIFrameElement Forward or Back navigation.
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
/// HTMLIFrameElement Forward or Back traversal.
TraverseHistory(Option<PipelineId>, TraversalDirection),
/// Favicon detected
NewFavicon(Url),
/// Status message to be displayed in the chrome, eg. a link URL on mouseover.
Expand Down
6 changes: 3 additions & 3 deletions components/webdriver_server/lib.rs
Expand Up @@ -32,7 +32,7 @@ use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use keys::keycodes_to_keys;
use msg::constellation_msg::{FrameId, LoadData, PipelineId};
use msg::constellation_msg::{NavigationDirection, PixelFormat};
use msg::constellation_msg::{TraversalDirection, PixelFormat};
use regex::Captures;
use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64};
use rustc_serialize::json::{Json, ToJson};
Expand Down Expand Up @@ -440,12 +440,12 @@ impl Handler {
}

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

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

Expand Down

0 comments on commit f131818

Please sign in to comment.