diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmltitleelement.rs | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index abc16d0d037..c88261e5987 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use std::cell::Cell; + use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use js::rust::HandleObject; @@ -19,6 +21,7 @@ use crate::dom::virtualmethods::VirtualMethods; #[dom_struct] pub struct HTMLTitleElement { htmlelement: HTMLElement, + popped: Cell<bool>, } impl HTMLTitleElement { @@ -29,6 +32,7 @@ impl HTMLTitleElement { ) -> HTMLTitleElement { HTMLTitleElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), + popped: Cell::new(false), } } @@ -47,6 +51,13 @@ impl HTMLTitleElement { proto, ) } + + fn notify_title_changed(&self) { + let node = self.upcast::<Node>(); + if node.is_in_doc() { + node.owner_doc().title_changed(); + } + } } impl HTMLTitleElementMethods for HTMLTitleElement { @@ -70,9 +81,11 @@ impl VirtualMethods for HTMLTitleElement { if let Some(s) = self.super_type() { s.children_changed(mutation); } - let node = self.upcast::<Node>(); - if node.is_in_doc() { - node.owner_doc().title_changed(); + + // Notify of title changes only after the initial full parsing + // of the element. + if self.popped.get() { + self.notify_title_changed(); } } @@ -85,4 +98,16 @@ impl VirtualMethods for HTMLTitleElement { node.owner_doc().title_changed(); } } + + fn pop(&self) { + if let Some(s) = self.super_type() { + s.pop(); + } + + self.popped.set(true); + + // Initial notification of title change, once the full text + // is available. + self.notify_title_changed(); + } } |