aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-18 14:42:49 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-18 14:42:49 -0700
commitdc31d96f65246def19cb7a23f3a62795cd7344a1 (patch)
treefcb569e983c51857b7fa71fbd3db36dd5c05e3df
parent25678f9c2f220fbbfaad61e3d3b53aa39428d53b (diff)
parentb7894248cffdc9365dd3963ea621c0973066f081 (diff)
downloadservo-dc31d96f65246def19cb7a23f3a62795cd7344a1.tar.gz
servo-dc31d96f65246def19cb7a23f3a62795cd7344a1.zip
auto merge of #4951 : glennw/servo/set-title, r=jdm
-rw-r--r--components/script/dom/htmltitleelement.rs13
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--ports/cef/Cargo.lock2
-rw-r--r--ports/glutin/window.rs52
4 files changed, 25 insertions, 44 deletions
diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs
index 9696e9ae7c0..76ef927f6e5 100644
--- a/components/script/dom/htmltitleelement.rs
+++ b/components/script/dom/htmltitleelement.rs
@@ -70,6 +70,19 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTitleElement> {
Some(htmlelement as &VirtualMethods)
}
+ fn child_inserted(&self, child: JSRef<Node>) {
+ match self.super_type() {
+ Some(ref s) => s.child_inserted(child),
+ _ => (),
+ }
+
+ let node: JSRef<Node> = NodeCast::from_ref(*self);
+ if node.is_in_doc() {
+ let document = node.owner_doc().root();
+ document.r().send_title_to_compositor();
+ }
+ }
+
fn bind_to_tree(&self, is_in_doc: bool) {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if is_in_doc {
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 37ac5a24115..f6db2335671 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -75,7 +75,7 @@ dependencies = [
[[package]]
name = "cocoa"
version = "0.1.1"
-source = "git+https://github.com/servo/rust-cocoa#fdc033e2edf9e6979d6cd15da1a904b81a448b57"
+source = "git+https://github.com/servo/rust-cocoa#7768a8f6af73d132b68e5cad6a0d81ec54102abe"
dependencies = [
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index abd58afdc40..4bbee6a3b44 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -78,7 +78,7 @@ dependencies = [
[[package]]
name = "cocoa"
version = "0.1.1"
-source = "git+https://github.com/servo/rust-cocoa#fdc033e2edf9e6979d6cd15da1a904b81a448b57"
+source = "git+https://github.com/servo/rust-cocoa#7768a8f6af73d132b68e5cad6a0d81ec54102abe"
dependencies = [
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index e5c52576400..2256d34b998 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -35,8 +35,6 @@ use std::cell::{Cell, RefCell};
#[cfg(feature = "window")]
use std::num::Float;
#[cfg(feature = "window")]
-use time::{self, Timespec};
-#[cfg(feature = "window")]
use util::opts;
#[cfg(all(feature = "headless", target_os="linux"))]
@@ -71,15 +69,13 @@ pub struct Window {
ready_state: Cell<ReadyState>,
paint_state: Cell<PaintState>,
key_modifiers: Cell<KeyModifiers>,
-
- last_title_set_time: Cell<Timespec>,
}
#[cfg(feature = "window")]
impl Window {
pub fn new(is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>) -> Rc<Window> {
let mut glutin_window = glutin::WindowBuilder::new()
- .with_title("Servo [glutin]".to_string())
+ .with_title("Servo".to_string())
.with_dimensions(window_size.to_untyped().width, window_size.to_untyped().height)
.with_gl_version(Window::gl_version())
.with_visibility(is_foreground)
@@ -101,8 +97,6 @@ impl Window {
ready_state: Cell::new(ReadyState::Blank),
paint_state: Cell::new(PaintState::Idle),
key_modifiers: Cell::new(KeyModifiers::empty()),
-
- last_title_set_time: Cell::new(Timespec::new(0, 0)),
};
gl::clear_color(0.6, 0.6, 0.6, 1.0);
@@ -256,36 +250,6 @@ impl Window {
self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event));
}
- fn update_window_title(&self) {
- let now = time::get_time();
- if now.sec == self.last_title_set_time.get().sec {
- return
- }
- self.last_title_set_time.set(now);
-
- match self.ready_state.get() {
- ReadyState::Blank => {
- self.window.set_title("blank - Servo [glutin]")
- }
- ReadyState::Loading => {
- self.window.set_title("Loading - Servo [glutin]")
- }
- ReadyState::PerformingLayout => {
- self.window.set_title("Performing Layout - Servo [glutin]")
- }
- ReadyState::FinishedLoading => {
- match self.paint_state.get() {
- PaintState::Painting => {
- self.window.set_title("Rendering - Servo [glutin]")
- }
- PaintState::Idle => {
- self.window.set_title("Servo [glutin]")
- }
- }
- }
- }
- }
-
pub fn wait_events(&self) -> WindowEvent {
{
let mut event_queue = self.event_queue.borrow_mut();
@@ -478,20 +442,24 @@ impl WindowMethods for Window {
/// Sets the ready state.
fn set_ready_state(&self, ready_state: ReadyState) {
self.ready_state.set(ready_state);
- self.update_window_title()
}
/// Sets the paint state.
fn set_paint_state(&self, paint_state: PaintState) {
self.paint_state.set(paint_state);
- self.update_window_title()
}
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
ScaleFactor(self.window.hidpi_factor())
}
- fn set_page_title(&self, _: Option<String>) {
+ fn set_page_title(&self, title: Option<String>) {
+ let title = match title {
+ Some(ref title) if title.len() > 0 => title.as_slice(),
+ _ => "untitled",
+ };
+ let title = format!("{} - Servo", title);
+ self.window.set_title(&title);
}
fn set_page_load_data(&self, _: LoadData) {
@@ -504,11 +472,11 @@ impl WindowMethods for Window {
#[cfg(target_os="macos")]
fn set_cursor(&self, _: Cursor) {
}
-
+
#[cfg(target_os="android")]
fn set_cursor(&self, _: Cursor) {
}
-
+
#[cfg(target_os="linux")]
fn set_cursor(&self, c: Cursor) {
use glutin::MouseCursor;