mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support basic immutable CSSOM
This commit is contained in:
parent
2220fcdc0b
commit
177d6fa4ee
33 changed files with 861 additions and 43 deletions
|
@ -8,13 +8,14 @@ use dom::bindings::codegen::Bindings::HTMLMetaElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::cssstylesheet::CSSStyleSheet;
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeMutation, Element};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlheadelement::HTMLHeadElement;
|
||||
use dom::node::{Node, UnbindContext, document_from_node};
|
||||
use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use html5ever_atoms::LocalName;
|
||||
use parking_lot::RwLock;
|
||||
|
@ -30,6 +31,7 @@ pub struct HTMLMetaElement {
|
|||
htmlelement: HTMLElement,
|
||||
#[ignore_heap_size_of = "Arc"]
|
||||
stylesheet: DOMRefCell<Option<Arc<Stylesheet>>>,
|
||||
cssom_stylesheet: MutNullableHeap<JS<CSSStyleSheet>>,
|
||||
}
|
||||
|
||||
impl HTMLMetaElement {
|
||||
|
@ -39,6 +41,7 @@ impl HTMLMetaElement {
|
|||
HTMLMetaElement {
|
||||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||
stylesheet: DOMRefCell::new(None),
|
||||
cssom_stylesheet: MutNullableHeap::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +58,18 @@ impl HTMLMetaElement {
|
|||
self.stylesheet.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn get_cssom_stylesheet(&self) -> Option<Root<CSSStyleSheet>> {
|
||||
self.get_stylesheet().map(|sheet| {
|
||||
self.cssom_stylesheet.or_init(|| {
|
||||
CSSStyleSheet::new(&window_from_node(self),
|
||||
"text/css".into(),
|
||||
None, // todo handle location
|
||||
None, // todo handle title
|
||||
sheet)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn process_attributes(&self) {
|
||||
let element = self.upcast::<Element>();
|
||||
if let Some(name) = element.get_attribute(&ns!(), &local_name!("name")).r() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue