Skip to content

Commit 2913d65

Browse files
author
bors-servo
authored
Auto merge of servo#17726 - paulrouget:rm_WindowNavigateMsg, r=jdm
Remove WindowNavigateMsg Two reasons: - We want to be able to jump further in history from the embedder. - We don't want to have an extra translation step in the compositor, where `WindowNavigateMsg` is translated to `TraversalDirection` --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17726) <!-- Reviewable:end -->
2 parents bb0c05d + 0cce577 commit 2913d65

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

components/compositing/compositor.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use time::{precise_time_ns, precise_time_s};
3535
use touch::{TouchHandler, TouchAction};
3636
use webrender;
3737
use webrender_api::{self, ClipId, LayoutPoint, LayoutVector2D, ScrollEventPhase, ScrollLocation, ScrollClamping};
38-
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
38+
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods};
3939

4040
#[derive(Debug, PartialEq)]
4141
enum UnableToComposite {
@@ -1294,11 +1294,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
12941294
});
12951295
}
12961296

1297-
fn on_navigation_window_event(&self, direction: WindowNavigateMsg) {
1298-
let direction = match direction {
1299-
windowing::WindowNavigateMsg::Forward => TraversalDirection::Forward(1),
1300-
windowing::WindowNavigateMsg::Back => TraversalDirection::Back(1),
1301-
};
1297+
fn on_navigation_window_event(&self, direction: TraversalDirection) {
13021298
let top_level_browsing_context_id = match self.root_pipeline {
13031299
Some(ref pipeline) => pipeline.top_level_browsing_context_id,
13041300
None => return warn!("Sending navigation to constellation with no root pipeline."),

components/compositing/windowing.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use compositor_thread::EventLoopWaker;
88
use euclid::{Point2D, Size2D};
99
use euclid::{TypedPoint2D, TypedRect, ScaleFactor, TypedSize2D};
1010
use gleam::gl;
11-
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
11+
use msg::constellation_msg::{Key, KeyModifiers, KeyState, TraversalDirection};
1212
use net_traits::net_error_list::NetError;
1313
use script_traits::{DevicePixel, LoadData, MouseButton, TouchEventType, TouchId, TouchpadPressurePhase};
1414
use servo_geometry::DeviceIndependentPixel;
@@ -25,12 +25,6 @@ pub enum MouseWindowEvent {
2525
MouseUp(MouseButton, TypedPoint2D<f32, DevicePixel>),
2626
}
2727

28-
#[derive(Clone)]
29-
pub enum WindowNavigateMsg {
30-
Forward,
31-
Back,
32-
}
33-
3428
/// Events that the windowing system sends to Servo.
3529
#[derive(Clone)]
3630
pub enum WindowEvent {
@@ -66,7 +60,7 @@ pub enum WindowEvent {
6660
/// Sent when the user resets zoom to default.
6761
ResetZoom,
6862
/// Sent when the user uses chrome navigation (i.e. backspace or shift-backspace).
69-
Navigation(WindowNavigateMsg),
63+
Navigation(TraversalDirection),
7064
/// Sent when the user quits the application
7165
Quit,
7266
/// Sent when a key input state changes

ports/cef/browser.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ use frame::{ServoCefFrame, ServoCefFrameExtensions};
88
use interfaces::{CefBrowser, CefBrowserHost, CefClient, CefFrame, CefRequestContext};
99
use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t};
1010
use interfaces::{cef_request_context_t};
11+
use msg::constellation_msg::TraversalDirection;
1112
use servo::Browser;
1213
use servo::servo_url::ServoUrl;
1314
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t};
1415
use window;
1516
use wrappers::CefWrap;
1617

17-
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
18+
use compositing::windowing::WindowEvent;
1819
use glutin_app;
1920
use libc::c_int;
2021
use std::cell::{Cell, RefCell};
@@ -69,11 +70,11 @@ cef_class_impl! {
6970
}}
7071

7172
fn go_back(&this,) -> () {{
72-
this.send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Back));
73+
this.send_window_event(WindowEvent::Navigation(TraversalDirection::Back(1)));
7374
}}
7475

7576
fn go_forward(&this,) -> () {{
76-
this.send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Forward));
77+
this.send_window_event(WindowEvent::Navigation(TraversalDirection::Forward(1)));
7778
}}
7879

7980
// Returns the main (top-level) frame for the browser window.

ports/glutin/window.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use NestedEventLoopListener;
88
use compositing::compositor_thread::EventLoopWaker;
9-
use compositing::windowing::{AnimationState, MouseWindowEvent, WindowNavigateMsg};
9+
use compositing::windowing::{AnimationState, MouseWindowEvent};
1010
use compositing::windowing::{WindowEvent, WindowMethods};
1111
use euclid::{Point2D, Size2D, TypedPoint2D, TypedVector2D, TypedRect, ScaleFactor, TypedSize2D};
1212
#[cfg(target_os = "windows")]
@@ -20,7 +20,7 @@ use glutin::TouchPhase;
2020
#[cfg(target_os = "macos")]
2121
use glutin::os::macos::{ActivationPolicy, WindowBuilderExt};
2222
use msg::constellation_msg::{self, Key};
23-
use msg::constellation_msg::{ALT, CONTROL, KeyState, NONE, SHIFT, SUPER};
23+
use msg::constellation_msg::{ALT, CONTROL, KeyState, NONE, SHIFT, SUPER, TraversalDirection};
2424
use net_traits::net_error_list::NetError;
2525
#[cfg(any(target_os = "linux", target_os = "macos"))]
2626
use osmesa_sys;
@@ -930,10 +930,10 @@ impl Window {
930930
fn platform_handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) {
931931
match (mods, key) {
932932
(CMD_OR_CONTROL, Key::LeftBracket) => {
933-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back));
933+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Back(1)));
934934
}
935935
(CMD_OR_CONTROL, Key::RightBracket) => {
936-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward));
936+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Forward(1)));
937937
}
938938
_ => {}
939939
}
@@ -1220,10 +1220,10 @@ impl WindowMethods for Window {
12201220
}
12211221

12221222
(NONE, None, Key::NavigateForward) => {
1223-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward));
1223+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Forward(1)));
12241224
}
12251225
(NONE, None, Key::NavigateBackward) => {
1226-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back));
1226+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Back(1)));
12271227
}
12281228

12291229
(NONE, None, Key::Escape) => {
@@ -1233,10 +1233,10 @@ impl WindowMethods for Window {
12331233
}
12341234

12351235
(CMD_OR_ALT, None, Key::Right) => {
1236-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward));
1236+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Forward(1)));
12371237
}
12381238
(CMD_OR_ALT, None, Key::Left) => {
1239-
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back));
1239+
self.event_queue.borrow_mut().push(WindowEvent::Navigation(TraversalDirection::Back(1)));
12401240
}
12411241

12421242
(NONE, None, Key::PageDown) => {

0 commit comments

Comments
 (0)