aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <brunoabinader@gmail.com>2015-05-26 01:08:27 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2015-07-30 16:37:54 +0300
commitb3927d5a2d69a644971389230cd8445ea07267d5 (patch)
tree2fc28ee3047c4be28e277ae5426cc1b5b382499f
parent5873a5cf20b3db0fce59980b2a6b0b7b9da1e737 (diff)
downloadservo-b3927d5a2d69a644971389230cd8445ea07267d5.tar.gz
servo-b3927d5a2d69a644971389230cd8445ea07267d5.zip
Implement Msg::Status with serialized url upon mouseover
Credits for Mike Blumenkrantz (@zmike), I just rebased against trunk and fixed the url serialization. Fixes #6178.
-rw-r--r--components/compositing/compositor.rs4
-rw-r--r--components/compositing/compositor_task.rs3
-rw-r--r--components/compositing/constellation.rs4
-rw-r--r--components/compositing/headless.rs1
-rw-r--r--components/compositing/windowing.rs2
-rw-r--r--components/msg/constellation_msg.rs2
-rw-r--r--components/script/script_task.rs40
-rw-r--r--ports/cef/window.rs3
-rw-r--r--ports/glutin/window.rs6
-rw-r--r--ports/gonk/src/window.rs3
10 files changed, 67 insertions, 1 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index e0caae3f98d..3e786e94d93 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -420,6 +420,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.scroll_fragment_to_point(pipeline_id, layer_id, point);
}
+ (Msg::Status(message), ShutdownState::NotShuttingDown) => {
+ self.window.status(message);
+ }
+
(Msg::LoadStart(back, forward), ShutdownState::NotShuttingDown) => {
self.window.load_start(back, forward);
}
diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs
index 422c5be4f3b..d559630bfcf 100644
--- a/components/compositing/compositor_task.rs
+++ b/components/compositing/compositor_task.rs
@@ -199,6 +199,8 @@ pub enum Msg {
ReturnUnusedNativeSurfaces(Vec<NativeSurface>),
/// Collect memory reports and send them back to the given mem::ReportsChan.
CollectMemoryReports(mem::ReportsChan),
+ /// A status message to be displayed by the browser chrome.
+ Status(Option<String>),
}
impl Debug for Msg {
@@ -229,6 +231,7 @@ impl Debug for Msg {
Msg::HeadParsed => write!(f, "HeadParsed"),
Msg::ReturnUnusedNativeSurfaces(..) => write!(f, "ReturnUnusedNativeSurfaces"),
Msg::CollectMemoryReports(..) => write!(f, "CollectMemoryReports"),
+ Msg::Status(..) => write!(f, "Status"),
}
}
}
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index 429690702b1..86d1df9dc07 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -514,6 +514,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got create-WebGL-paint-task message");
self.handle_create_webgl_paint_task_msg(&size, attributes, sender)
}
+ ConstellationMsg::NodeStatus(message) => {
+ debug!("constellation got NodeStatus message");
+ self.compositor_proxy.send(CompositorMsg::Status(message));
+ }
}
true
}
diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs
index 7cda9ed635a..d56c50de1d2 100644
--- a/components/compositing/headless.rs
+++ b/components/compositing/headless.rs
@@ -97,6 +97,7 @@ impl CompositorEventListener for NullCompositor {
Msg::AssignPaintedBuffers(..) |
Msg::ChangeRunningAnimationsState(..) |
Msg::ScrollFragmentPoint(..) |
+ Msg::Status(..) |
Msg::LoadStart(..) |
Msg::LoadComplete(..) |
Msg::ScrollTimeout(..) |
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 218facad440..6ad7790edaa 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -107,6 +107,8 @@ pub trait WindowMethods {
fn set_page_title(&self, title: Option<String>);
/// Sets the load data for the current page.
fn set_page_url(&self, url: Url);
+ /// Called when the browser chrome should display a status message.
+ fn status(&self, Option<String>);
/// Called when the browser has started loading a frame.
fn load_start(&self, back: bool, forward: bool);
/// Called when the browser is done loading a frame.
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index 36bd8279319..97d673deecb 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -269,6 +269,8 @@ pub enum Msg {
CreateWebGLPaintTask(Size2D<i32>,
GLContextAttributes,
IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>),
+ /// Status message to be displayed in the chrome, eg. a link URL on mouseover.
+ NodeStatus(Option<String>),
}
#[derive(Clone, Eq, PartialEq, Deserialize, Serialize)]
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 9254d67b0f2..369622c0d6f 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -21,6 +21,7 @@
use document_loader::{LoadType, DocumentLoader, NotifierData};
use dom::bindings::cell::DOMRefCell;
+use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, NodeCast, EventCast};
use dom::bindings::conversions::FromJSValConvertible;
@@ -88,7 +89,7 @@ use js::jsapi::{JS_GetRuntime, JS_SetGCCallback, JSGCStatus, JSAutoRequest, SetD
use js::jsapi::{SetDOMProxyInformation, DOMProxyShadowsResult, HandleObject, HandleId, RootedValue};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
-use url::Url;
+use url::{Url, UrlParser};
use libc;
use std::any::Any;
@@ -1532,11 +1533,48 @@ impl ScriptTask {
}
let page = get_page(&self.root_page(), pipeline_id);
let document = page.document();
+
+ let mut prev_mouse_over_targets: RootedVec<JS<Node>> = RootedVec::new();
+ for target in self.mouse_over_targets.borrow_mut().iter() {
+ prev_mouse_over_targets.push(target.clone());
+ }
+
// We temporarily steal the list of targets over which the mouse is to pass it to
// handle_mouse_move_event() in a safe RootedVec container.
let mut mouse_over_targets = RootedVec::new();
std_mem::swap(&mut *self.mouse_over_targets.borrow_mut(), &mut *mouse_over_targets);
document.r().handle_mouse_move_event(self.js_runtime.rt(), point, &mut mouse_over_targets);
+
+ // Notify Constellation about anchors that are no longer mouse over targets.
+ for target in prev_mouse_over_targets.iter() {
+ if !mouse_over_targets.contains(target) {
+ if target.root().r().is_anchor_element() {
+ let event = ConstellationMsg::NodeStatus(None);
+ let ConstellationChan(ref chan) = self.constellation_chan;
+ chan.send(event).unwrap();
+ break;
+ }
+ }
+ }
+
+ // Notify Constellation about the topmost anchor mouse over target.
+ for target in mouse_over_targets.iter() {
+ let target = target.root();
+ if target.r().is_anchor_element() {
+ let element = ElementCast::to_ref(target.r()).unwrap();
+ let status = element.get_attribute(&ns!(""), &atom!("href"))
+ .and_then(|href| {
+ let value = href.r().Value();
+ let url = document.r().url();
+ UrlParser::new().base_url(&url).parse(&value).map(|url| url.serialize()).ok()
+ });
+ let event = ConstellationMsg::NodeStatus(status);
+ let ConstellationChan(ref chan) = self.constellation_chan;
+ chan.send(event).unwrap();
+ break;
+ }
+ }
+
std_mem::swap(&mut *self.mouse_over_targets.borrow_mut(), &mut *mouse_over_targets);
}
diff --git a/ports/cef/window.rs b/ports/cef/window.rs
index 29177022469..2149181ed16 100644
--- a/ports/cef/window.rs
+++ b/ports/cef/window.rs
@@ -316,6 +316,9 @@ impl WindowMethods for Window {
browser.downcast().favicons.borrow_mut().push(url.to_string().clone());
}
+ fn status(&self, _: Option<String>) {
+ }
+
fn load_start(&self, back: bool, forward: bool) {
let browser = self.cef_browser.borrow();
let browser = match *browser {
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index e8479211281..0e28d1abd85 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -554,6 +554,9 @@ impl WindowMethods for Window {
fn set_page_url(&self, _: Url) {
}
+ fn status(&self, _: Option<String>) {
+ }
+
fn load_start(&self, _: bool, _: bool) {
}
@@ -778,6 +781,9 @@ impl WindowMethods for Window {
fn set_favicon(&self, _: Url) {
}
+ fn status(&self, _: Option<String>) {
+ }
+
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
true
}
diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs
index 0d94ddaa7a4..88ba3ceca96 100644
--- a/ports/gonk/src/window.rs
+++ b/ports/gonk/src/window.rs
@@ -803,6 +803,9 @@ impl WindowMethods for Window {
fn set_page_url(&self, _: Url) {
}
+ fn status(&self, _: Option<String>) {
+ }
+
fn load_start(&self, _: bool, _: bool) {
}