mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
auto merge of #4951 : glennw/servo/set-title, r=jdm
This commit is contained in:
commit
dc31d96f65
4 changed files with 25 additions and 44 deletions
|
@ -70,6 +70,19 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTitleElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
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) {
|
fn bind_to_tree(&self, is_in_doc: bool) {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if is_in_doc {
|
if is_in_doc {
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -75,7 +75,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/servo/rust-cocoa#fdc033e2edf9e6979d6cd15da1a904b81a448b57"
|
source = "git+https://github.com/servo/rust-cocoa#7768a8f6af73d132b68e5cad6a0d81ec54102abe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -78,7 +78,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/servo/rust-cocoa#fdc033e2edf9e6979d6cd15da1a904b81a448b57"
|
source = "git+https://github.com/servo/rust-cocoa#7768a8f6af73d132b68e5cad6a0d81ec54102abe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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")]
|
#[cfg(feature = "window")]
|
||||||
use std::num::Float;
|
use std::num::Float;
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
use time::{self, Timespec};
|
|
||||||
#[cfg(feature = "window")]
|
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
|
||||||
#[cfg(all(feature = "headless", target_os="linux"))]
|
#[cfg(all(feature = "headless", target_os="linux"))]
|
||||||
|
@ -71,15 +69,13 @@ pub struct Window {
|
||||||
ready_state: Cell<ReadyState>,
|
ready_state: Cell<ReadyState>,
|
||||||
paint_state: Cell<PaintState>,
|
paint_state: Cell<PaintState>,
|
||||||
key_modifiers: Cell<KeyModifiers>,
|
key_modifiers: Cell<KeyModifiers>,
|
||||||
|
|
||||||
last_title_set_time: Cell<Timespec>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn new(is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>) -> Rc<Window> {
|
pub fn new(is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>) -> Rc<Window> {
|
||||||
let mut glutin_window = glutin::WindowBuilder::new()
|
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_dimensions(window_size.to_untyped().width, window_size.to_untyped().height)
|
||||||
.with_gl_version(Window::gl_version())
|
.with_gl_version(Window::gl_version())
|
||||||
.with_visibility(is_foreground)
|
.with_visibility(is_foreground)
|
||||||
|
@ -101,8 +97,6 @@ impl Window {
|
||||||
ready_state: Cell::new(ReadyState::Blank),
|
ready_state: Cell::new(ReadyState::Blank),
|
||||||
paint_state: Cell::new(PaintState::Idle),
|
paint_state: Cell::new(PaintState::Idle),
|
||||||
key_modifiers: Cell::new(KeyModifiers::empty()),
|
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);
|
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));
|
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 {
|
pub fn wait_events(&self) -> WindowEvent {
|
||||||
{
|
{
|
||||||
let mut event_queue = self.event_queue.borrow_mut();
|
let mut event_queue = self.event_queue.borrow_mut();
|
||||||
|
@ -478,20 +442,24 @@ impl WindowMethods for Window {
|
||||||
/// Sets the ready state.
|
/// Sets the ready state.
|
||||||
fn set_ready_state(&self, ready_state: ReadyState) {
|
fn set_ready_state(&self, ready_state: ReadyState) {
|
||||||
self.ready_state.set(ready_state);
|
self.ready_state.set(ready_state);
|
||||||
self.update_window_title()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the paint state.
|
/// Sets the paint state.
|
||||||
fn set_paint_state(&self, paint_state: PaintState) {
|
fn set_paint_state(&self, paint_state: PaintState) {
|
||||||
self.paint_state.set(paint_state);
|
self.paint_state.set(paint_state);
|
||||||
self.update_window_title()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
||||||
ScaleFactor(self.window.hidpi_factor())
|
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) {
|
fn set_page_load_data(&self, _: LoadData) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue