diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-23 10:58:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-23 10:58:54 -0500 |
commit | eeed5b6ec26f7d78a938abb2d4b6a1cce8bf2472 (patch) | |
tree | 10a5b9109d036d8be88edb9bb58707a3ca628513 /components | |
parent | c04d245bf2858fea1ef6ad4587b8b55be0f4b1eb (diff) | |
parent | 909f0da3c21e3074639995a2b352e243e2cc4557 (diff) | |
download | servo-eeed5b6ec26f7d78a938abb2d4b6a1cce8bf2472.tar.gz servo-eeed5b6ec26f7d78a938abb2d4b6a1cce8bf2472.zip |
Auto merge of #11735 - mrmiywj:reload-page-shortcut, r=jdm
add reload keyboard shortcut
<!-- Please describe your changes on the following line: -->
---
<!-- 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
- [X] These changes fix #11686 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because this cannot be automated tested.
<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11735)
<!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r-- | components/compositing/compositor.rs | 7 | ||||
-rw-r--r-- | components/compositing/windowing.rs | 3 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 22 | ||||
-rw-r--r-- | components/script/script_thread.rs | 12 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 4 |
5 files changed, 48 insertions, 0 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, } |