mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Implement Window.screen.
This commit is contained in:
parent
800b5e0f4a
commit
27f92239b0
6 changed files with 112 additions and 1 deletions
|
@ -16,10 +16,11 @@ use dom::eventtarget::{EventTarget, WindowTypeId, EventTargetHelpers};
|
|||
use dom::location::Location;
|
||||
use dom::navigator::Navigator;
|
||||
use dom::performance::Performance;
|
||||
|
||||
use dom::screen::Screen;
|
||||
use layout_interface::{ReflowForDisplay, DocumentDamageLevel};
|
||||
use page::Page;
|
||||
use script_task::{ExitWindowMsg, FireTimerMsg, ScriptChan, TriggerLoadMsg, TriggerFragmentMsg};
|
||||
|
||||
use servo_msg::compositor_msg::ScriptListener;
|
||||
use servo_net::image_cache_task::ImageCacheTask;
|
||||
use servo_util::str::DOMString;
|
||||
|
@ -86,6 +87,7 @@ pub struct Window {
|
|||
performance: Cell<Option<JS<Performance>>>,
|
||||
pub navigationStart: u64,
|
||||
pub navigationStartPrecise: f64,
|
||||
screen: Cell<Option<JS<Screen>>>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -142,6 +144,7 @@ pub trait WindowMethods {
|
|||
fn SetOnunload(&self, listener: Option<EventHandlerNonNull>);
|
||||
fn GetOnerror(&self) -> Option<OnErrorEventHandlerNonNull>;
|
||||
fn SetOnerror(&self, listener: Option<OnErrorEventHandlerNonNull>);
|
||||
fn Screen(&self) -> Temporary<Screen>;
|
||||
fn Debug(&self, message: DOMString);
|
||||
fn Gc(&self);
|
||||
}
|
||||
|
@ -265,6 +268,14 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
eventtarget.set_event_handler_common("error", listener)
|
||||
}
|
||||
|
||||
fn Screen(&self) -> Temporary<Screen> {
|
||||
if self.screen.get().is_none() {
|
||||
let screen = Screen::new(self);
|
||||
self.screen.assign(Some(screen));
|
||||
}
|
||||
Temporary::new(self.screen.get().get_ref().clone())
|
||||
}
|
||||
|
||||
fn Debug(&self, message: DOMString) {
|
||||
debug!("{:s}", message);
|
||||
}
|
||||
|
@ -433,6 +444,7 @@ impl Window {
|
|||
performance: Cell::new(None),
|
||||
navigationStart: time::get_time().sec as u64,
|
||||
navigationStartPrecise: time::precise_time_s(),
|
||||
screen: Cell::new(None),
|
||||
};
|
||||
|
||||
WindowBinding::Wrap(cx, win)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue