aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/compositor.rs7
-rw-r--r--components/compositing/windowing.rs3
-rw-r--r--components/constellation/constellation.rs22
-rw-r--r--components/script/script_thread.rs12
-rw-r--r--components/script_traits/lib.rs4
-rw-r--r--ports/glutin/window.rs7
-rw-r--r--python/servo/package_commands.py2
-rw-r--r--python/servo/post_build_commands.py2
-rw-r--r--resources/prefs.json2
9 files changed, 57 insertions, 4 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index a987bd7bdd3..1c37c0df19c 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -1341,6 +1341,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.start_shutting_down();
}
}
+
+ WindowEvent::Reload => {
+ let msg = ConstellationMsg::Reload;
+ if let Err(e) = self.constellation_chan.send(msg) {
+ warn!("Sending reload to constellation failed ({}).", e);
+ }
+ }
}
}
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 72cb276121d..b67803b07c6 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -77,6 +77,8 @@ pub enum WindowEvent {
Quit,
/// Sent when a key input state changes
KeyEvent(Key, KeyState, KeyModifiers),
+ /// Sent when Ctr+R/Apple+R is called to reload the current page.
+ Reload,
}
impl Debug for WindowEvent {
@@ -99,6 +101,7 @@ impl Debug for WindowEvent {
WindowEvent::ResetZoom => write!(f, "ResetZoom"),
WindowEvent::Navigation(..) => write!(f, "Navigation"),
WindowEvent::Quit => write!(f, "Quit"),
+ WindowEvent::Reload => write!(f, "Reload"),
}
}
}
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 1197912a276..be73d3895d9 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -618,6 +618,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
debug!("constellation got webdriver command message");
self.handle_webdriver_msg(command);
}
+ FromCompositorMsg::Reload => {
+ debug!("constellation got reload message");
+ self.handle_reload_msg();
+ }
}
}
@@ -1421,6 +1425,24 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
+ fn handle_reload_msg(&mut self) {
+ // Send Reload constellation msg to root script channel.
+ let root_pipeline_id = self.root_frame_id
+ .and_then(|root_frame_id| self.frames.get(&root_frame_id))
+ .map(|root_frame| root_frame.current);
+
+ if let Some(pipeline_id) = root_pipeline_id {
+ let msg = ConstellationControlMsg::Reload(pipeline_id);
+ let result = match self.pipelines.get(&pipeline_id) {
+ Some(pipeline) => pipeline.script_chan.send(msg),
+ None => return debug!("Pipeline {:?} got reload event after closure.", pipeline_id),
+ };
+ if let Err(e) = result {
+ self.handle_send_error(pipeline_id, e);
+ }
+ }
+ }
+
fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) {
let result = match self.pipelines.get(&pipeline_id) {
None => return self.compositor_proxy.send(ToCompositorMsg::ChangePageTitle(pipeline_id, None)),
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 8418071e908..e4b68c4952f 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -24,6 +24,8 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use document_loader::DocumentLoader;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
+use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
+use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior};
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
@@ -955,6 +957,8 @@ impl ScriptThread {
self.handle_framed_content_changed(containing_pipeline_id, subpage_id),
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
+ ConstellationControlMsg::Reload(pipeline_id) =>
+ self.handle_reload(pipeline_id),
}
}
@@ -2106,6 +2110,14 @@ impl ScriptThread {
sender.send(message).unwrap();
}
}
+
+ fn handle_reload(&self, pipeline_id: PipelineId) {
+ if let Some(context) = self.find_child_context(pipeline_id) {
+ let win = context.active_window();
+ let location = win.Location();
+ location.Reload();
+ }
+ }
}
impl Drop for ScriptThread {
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index cc8a06bf18e..5b1b169e8aa 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -193,6 +193,8 @@ pub enum ConstellationControlMsg {
FramedContentChanged(PipelineId, SubpageId),
/// Report an error from a CSS parser for the given pipeline
ReportCSSError(PipelineId, String, usize, usize, String),
+ /// Reload the given page.
+ Reload(PipelineId),
}
/// Used to determine if a script has any pending asynchronous activity.
@@ -553,4 +555,6 @@ pub enum ConstellationMsg {
TickAnimation(PipelineId, AnimationTickType),
/// Dispatch a webdriver command
WebDriverCommand(WebDriverCommandMsg),
+ /// Reload the current page.
+ Reload,
}
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index bd106eddd6c..235afd4733c 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -822,7 +822,7 @@ impl WindowMethods for Window {
}
(NONE, Key::Escape) => {
- if let Some(true) = prefs::get_pref("shell.quit-on-escape.enabled").as_boolean() {
+ if let Some(true) = prefs::get_pref("shell.builtin-key-shortcuts.enabled").as_boolean() {
self.event_queue.borrow_mut().push(WindowEvent::Quit);
}
}
@@ -864,6 +864,11 @@ impl WindowMethods for Window {
(NONE, Key::Right) => {
self.scroll_window(-LINE_HEIGHT, 0.0, TouchEventType::Move);
}
+ (CMD_OR_CONTROL, Key::R) => {
+ if let Some(true) = prefs::get_pref("shell.builtin-key-shortcuts.enabled").as_boolean() {
+ self.event_queue.borrow_mut().push(WindowEvent::Reload);
+ }
+ }
_ => {
self.platform_handle_key(key, mods);
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 972fa484e8b..0c44fdaf3dc 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -90,7 +90,7 @@ class PackageCommands(CommandBase):
servo_args = ['-w', '-b',
'--pref', 'dom.mozbrowser.enabled',
'--pref', 'dom.forcetouch.enabled',
- '--pref', 'shell.quit-on-escape.enabled=false',
+ '--pref', 'shell.builtin-key-shortcuts=false',
path.join(browserhtml_path, 'out', 'index.html')]
runservo = os.open(dir_to_package + 'runservo.sh', os.O_WRONLY | os.O_CREAT, int("0755", 8))
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py
index ece3ce584af..67ec4662fdd 100644
--- a/python/servo/post_build_commands.py
+++ b/python/servo/post_build_commands.py
@@ -114,7 +114,7 @@ class PostBuildCommands(CommandBase):
args = args + ['-w',
'--pref', 'dom.mozbrowser.enabled',
'--pref', 'dom.forcetouch.enabled',
- '--pref', 'shell.quit-on-escape.enabled=false',
+ '--pref', 'shell.builtin-key-shortcuts=false',
path.join(browserhtml_path, 'out', 'index.html')]
# Borrowed and modified from:
diff --git a/resources/prefs.json b/resources/prefs.json
index 6124c2376c3..c6ffd343a67 100644
--- a/resources/prefs.json
+++ b/resources/prefs.json
@@ -59,5 +59,5 @@
"network.mime.sniff": false,
"shell.homepage": "http://servo.org",
"shell.native-titlebar.enabled": true,
- "shell.quit-on-escape.enabled": true
+ "shell.builtin-key-shortcuts.enabled": true
}