diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 8 | ||||
-rw-r--r-- | components/script/dom/htmltitleelement.rs | 22 | ||||
-rw-r--r-- | components/script/dom/virtualmethods.rs | 8 | ||||
-rw-r--r-- | components/script/page.rs | 17 | ||||
-rw-r--r-- | components/script/script_task.rs | 17 |
5 files changed, 62 insertions, 10 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 4fbdaab837d..738ac6be90e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -189,6 +189,7 @@ pub trait DocumentHelpers<'a> { fn begin_focus_transaction(self); fn request_focus(self, elem: JSRef<Element>); fn commit_focus_transaction(self); + fn send_title_to_compositor(self); } impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> { @@ -369,6 +370,12 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> { //TODO: dispatch blur, focus, focusout, and focusin events self.focused.assign(self.possibly_focused.get()); } + + /// Sends this document's title to the compositor. + fn send_title_to_compositor(self) { + let window = self.window().root(); + window.page().send_title_to_compositor(); + } } #[deriving(PartialEq)] @@ -985,3 +992,4 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { global_event_handlers!() event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange) } + diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index ef8b70aa4fa..4e6e9f7e9bb 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -5,15 +5,17 @@ use dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use dom::bindings::codegen::Bindings::HTMLTitleElementBinding::HTMLTitleElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use dom::bindings::codegen::InheritTypes::{HTMLTitleElementDerived, NodeCast, TextCast}; +use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTitleElementDerived, NodeCast}; +use dom::bindings::codegen::InheritTypes::{TextCast}; use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector}; -use dom::document::Document; +use dom::document::{Document, DocumentHelpers}; use dom::element::HTMLTitleElementTypeId; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::htmlelement::HTMLElement; use dom::node::{Node, NodeHelpers, ElementNodeTypeId}; use dom::text::Text; +use dom::virtualmethods::VirtualMethods; use servo_util::str::DOMString; #[dom_struct] @@ -68,3 +70,19 @@ impl Reflectable for HTMLTitleElement { self.htmlelement.reflector() } } + +impl<'a> VirtualMethods for JSRef<'a, HTMLTitleElement> { + fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { + let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self); + Some(htmlelement as &VirtualMethods) + } + + fn bind_to_tree(&self, is_in_doc: bool) { + let node: JSRef<Node> = NodeCast::from_ref(*self); + if is_in_doc { + let document = node.owner_doc().root(); + document.send_title_to_compositor() + } + } +} + diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 66378463a82..a90055bc50d 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -24,6 +24,7 @@ use dom::bindings::codegen::InheritTypes::HTMLSelectElementCast; use dom::bindings::codegen::InheritTypes::HTMLStyleElementCast; use dom::bindings::codegen::InheritTypes::HTMLTableCellElementCast; use dom::bindings::codegen::InheritTypes::HTMLTextAreaElementCast; +use dom::bindings::codegen::InheritTypes::HTMLTitleElementCast; use dom::bindings::js::JSRef; use dom::document::Document; use dom::element::Element; @@ -47,6 +48,7 @@ use dom::element::HTMLStyleElementTypeId; use dom::element::HTMLTableDataCellElementTypeId; use dom::element::HTMLTableHeaderCellElementTypeId; use dom::element::HTMLTextAreaElementTypeId; +use dom::element::HTMLTitleElementTypeId; use dom::event::Event; use dom::htmlanchorelement::HTMLAnchorElement; use dom::htmlareaelement::HTMLAreaElement; @@ -67,6 +69,7 @@ use dom::htmlselectelement::HTMLSelectElement; use dom::htmlstyleelement::HTMLStyleElement; use dom::htmltablecellelement::HTMLTableCellElement; use dom::htmltextareaelement::HTMLTextAreaElement; +use dom::htmltitleelement::HTMLTitleElement; use dom::node::{Node, NodeHelpers, ElementNodeTypeId, CloneChildrenFlag}; use servo_util::str::DOMString; @@ -232,6 +235,11 @@ pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a VirtualMethods + 'a { let element: &'a JSRef<'a, HTMLTextAreaElement> = HTMLTextAreaElementCast::to_borrowed_ref(node).unwrap(); element as &'a VirtualMethods + 'a } + ElementNodeTypeId(HTMLTitleElementTypeId) => { + let element: &'a JSRef<'a, HTMLTitleElement> = + HTMLTitleElementCast::to_borrowed_ref(node).unwrap(); + element as &'a VirtualMethods + 'a + } ElementNodeTypeId(ElementTypeId_) => { let element: &'a JSRef<'a, Element> = ElementCast::to_borrowed_ref(node).unwrap(); element as &'a VirtualMethods + 'a diff --git a/components/script/page.rs b/components/script/page.rs index 37f4ba155bb..c8e46463077 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -21,7 +21,6 @@ use script_traits::{UntrustedNodeAddress, ScriptControlChan}; use geom::{Point2D, Rect, Size2D}; use js::rust::Cx; -use servo_msg::compositor_msg::PerformingLayout; use servo_msg::compositor_msg::ScriptListener; use servo_msg::constellation_msg::{ConstellationChan, WindowSizeData}; use servo_msg::constellation_msg::{PipelineId, SubpageId}; @@ -266,6 +265,17 @@ impl Page { // because it was built for infinite clip (MAX_RECT). had_clip_rect } + + pub fn send_title_to_compositor(&self) { + match *self.frame() { + None => {} + Some(ref frame) => { + let window = frame.window.root(); + let document = frame.document.root(); + window.compositor().set_title(self.id, Some(document.Title())); + } + } + } } impl Iterator<Rc<Page>> for PageIterator { @@ -356,7 +366,7 @@ impl Page { pub fn reflow(&self, goal: ReflowGoal, script_chan: ScriptControlChan, - compositor: &mut ScriptListener, + _: &mut ScriptListener, query_type: ReflowQueryType) { let root = match *self.frame() { None => return, @@ -376,9 +386,6 @@ impl Page { // Now, join the layout so that they will see the latest changes we have made. self.join_layout(); - // Tell the user that we're performing layout. - compositor.set_ready_state(self.id, PerformingLayout); - // Layout will let us know when it's done. let (join_chan, join_port) = channel(); let mut layout_join_port = self.layout_join_port.borrow_mut(); diff --git a/components/script/script_task.rs b/components/script/script_task.rs index f41558b598c..b4fdaa6f833 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -43,10 +43,12 @@ use script_traits::{MouseMoveEvent, MouseUpEvent, ConstellationControlMsg, Scrip use script_traits::{ResizeMsg, AttachLayoutMsg, LoadMsg, ViewportMsg, SendEventMsg}; use script_traits::{ResizeInactiveMsg, ExitPipelineMsg, NewLayoutInfo, OpaqueScriptLayoutChannel}; use script_traits::{ScriptControlChan, ReflowCompleteMsg, UntrustedNodeAddress, KeyEvent}; -use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading}; +use script_traits::{GetTitleMsg}; +use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading, PerformingLayout}; use servo_msg::compositor_msg::{ScriptListener}; -use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg, LoadUrlMsg, NavigationDirection}; -use servo_msg::constellation_msg::{LoadData, PipelineId, Failure, FailureMsg, WindowSizeData, Key, KeyState}; +use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg}; +use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, NavigationDirection, PipelineId}; +use servo_msg::constellation_msg::{Failure, FailureMsg, WindowSizeData, Key, KeyState}; use servo_msg::constellation_msg::{KeyModifiers, SUPER, SHIFT, CONTROL, ALT, Repeated, Pressed}; use servo_msg::constellation_msg::{Released}; use servo_msg::constellation_msg; @@ -550,6 +552,9 @@ impl ScriptTask { FromConstellation(ViewportMsg(..)) => panic!("should have handled ViewportMsg already"), FromScript(ExitWindowMsg(id)) => self.handle_exit_window_msg(id), FromConstellation(ResizeMsg(..)) => panic!("should have handled ResizeMsg already"), + FromConstellation(GetTitleMsg(pipeline_id)) => { + self.handle_get_title_msg(pipeline_id) + } FromScript(XHRProgressMsg(addr, progress)) => XMLHttpRequest::handle_progress(addr, progress), FromScript(XHRReleaseMsg(addr)) => XMLHttpRequest::handle_release(addr), FromScript(DOMMessage(..)) => panic!("unexpected message"), @@ -661,6 +666,11 @@ impl ScriptTask { self.compositor.borrow_mut().close(); } + /// Handles a request for the window title. + fn handle_get_title_msg(&self, pipeline_id: PipelineId) { + get_page(&*self.page.borrow(), pipeline_id).send_title_to_compositor(); + } + /// Handles a request to exit the script task and shut down layout. /// Returns true if the script task should shut down and false otherwise. fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool { @@ -784,6 +794,7 @@ impl ScriptTask { parse_html(*document, parser_input, &final_url); document.set_ready_state(DocumentReadyStateValues::Interactive); + self.compositor.borrow_mut().set_ready_state(pipeline_id, PerformingLayout); // Kick off the initial reflow of the page. debug!("kicking off initial reflow of {}", final_url); |