From c37a345dc9f4dda6ea29c42f96f6c7201c42cbac Mon Sep 17 00:00:00 2001 From: chansuke Date: Tue, 18 Sep 2018 23:24:15 +0900 Subject: Format script component --- components/script/dom/htmlstyleelement.rs | 61 +++++++++++++++++++------------ 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'components/script/dom/htmlstyleelement.rs') diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index bcecab9088b..cd0448fb602 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -42,10 +42,12 @@ pub struct HTMLStyleElement { } impl HTMLStyleElement { - fn new_inherited(local_name: LocalName, - prefix: Option, - document: &Document, - creator: ElementCreator) -> HTMLStyleElement { + fn new_inherited( + local_name: LocalName, + prefix: Option, + document: &Document, + creator: ElementCreator, + ) -> HTMLStyleElement { HTMLStyleElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), stylesheet: DomRefCell::new(None), @@ -59,13 +61,19 @@ impl HTMLStyleElement { } #[allow(unrooted_must_root)] - pub fn new(local_name: LocalName, - prefix: Option, - document: &Document, - creator: ElementCreator) -> DomRoot { - Node::reflect_node(Box::new(HTMLStyleElement::new_inherited(local_name, prefix, document, creator)), - document, - HTMLStyleElementBinding::Wrap) + pub fn new( + local_name: LocalName, + prefix: Option, + document: &Document, + creator: ElementCreator, + ) -> DomRoot { + Node::reflect_node( + Box::new(HTMLStyleElement::new_inherited( + local_name, prefix, document, creator, + )), + document, + HTMLStyleElementBinding::Wrap, + ) } pub fn parse_own_css(&self) { @@ -82,7 +90,9 @@ impl HTMLStyleElement { None => String::new(), }; - let data = node.GetTextContent().expect("Element.textContent must be a string"); + let data = node + .GetTextContent() + .expect("Element.textContent must be a string"); let url = window.get_url(); let css_error_reporter = window.css_error_reporter(); let context = CssParserContext::new_for_cssom( @@ -95,10 +105,8 @@ impl HTMLStyleElement { ); let shared_lock = node.owner_doc().style_shared_lock().clone(); let mut input = ParserInput::new(&mq_str); - let mq = Arc::new(shared_lock.wrap(MediaList::parse( - &context, - &mut CssParser::new(&mut input), - ))); + let mq = + Arc::new(shared_lock.wrap(MediaList::parse(&context, &mut CssParser::new(&mut input)))); let loader = StylesheetLoader::for_element(self.upcast()); let sheet = Stylesheet::from_str( &data, @@ -117,7 +125,11 @@ impl HTMLStyleElement { // No subresource loads were triggered, queue load event if self.pending_loads.get() == 0 { let window = window_from_node(self); - window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("load"), &window); + window.dom_manipulation_task_source().queue_simple_event( + self.upcast(), + atom!("load"), + &window, + ); } self.set_stylesheet(sheet); @@ -141,12 +153,14 @@ impl HTMLStyleElement { pub fn get_cssom_stylesheet(&self) -> Option> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { - CSSStyleSheet::new(&window_from_node(self), - self.upcast::(), - "text/css".into(), - None, // todo handle location - None, // todo handle title - sheet) + CSSStyleSheet::new( + &window_from_node(self), + self.upcast::(), + "text/css".into(), + None, // todo handle location + None, // todo handle title + sheet, + ) }) }) } @@ -243,7 +257,6 @@ impl StylesheetOwner for HTMLStyleElement { } } - impl HTMLStyleElementMethods for HTMLStyleElement { // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet fn GetSheet(&self) -> Option> { -- cgit v1.2.3