servo: Merge #4951 - Change window title to reflect document title (from glennw:set-title); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: dc31d96f65246def19cb7a23f3a62795cd7344a1
This commit is contained in:
Glenn Watson 2015-02-18 14:42:49 -07:00
Родитель 641741cfab
Коммит 92351aa8e2
4 изменённых файлов: 25 добавлений и 44 удалений

Просмотреть файл

@ -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 {

2
servo/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)",

2
servo/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)",

Просмотреть файл

@ -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;