diff options
author | Warren Fisher <github@warrenfisher.dev> | 2020-01-04 15:52:45 -0400 |
---|---|---|
committer | Warren Fisher <github@warrenfisher.dev> | 2020-01-04 16:14:03 -0400 |
commit | 6e296150f84f84c3679ea89d7b9f2c8e6325b242 (patch) | |
tree | a29a48ed38ceb64309ced2babaa8693628a9432c /components/script/dom | |
parent | afa1b85766caeb55254b739529aef205f04d3585 (diff) | |
download | servo-6e296150f84f84c3679ea89d7b9f2c8e6325b242.tar.gz servo-6e296150f84f84c3679ea89d7b9f2c8e6325b242.zip |
use create_html_element for HTMLAudioElement and HTMLImageElement
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/htmlaudioelement.rs | 15 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 17 |
2 files changed, 24 insertions, 8 deletions
diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index af92835af6a..a510ab93a5f 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -10,12 +10,12 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; -use crate::dom::element::Element; +use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator}; use crate::dom::htmlmediaelement::HTMLMediaElement; use crate::dom::node::Node; use crate::dom::window::Window; use dom_struct::dom_struct; -use html5ever::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix, QualName}; #[dom_struct] pub struct HTMLAudioElement { @@ -50,8 +50,15 @@ impl HTMLAudioElement { // https://html.spec.whatwg.org/multipage/#dom-audio pub fn Audio(window: &Window, src: Option<DOMString>) -> Fallible<DomRoot<HTMLAudioElement>> { - let document = window.Document(); - let audio = HTMLAudioElement::new(local_name!("audio"), None, &document); + let element = Element::create( + QualName::new(None, ns!(html), local_name!("audio")), + None, + &window.Document(), + ElementCreator::ScriptCreated, + CustomElementCreationMode::Synchronous, + ); + + let audio = DomRoot::downcast::<HTMLAudioElement>(element).unwrap(); audio .upcast::<Element>() diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 5b6bd321534..bdb3a313482 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -22,7 +22,9 @@ use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::document::Document; use crate::dom::element::{cors_setting_for_element, referrer_policy_for_element}; use crate::dom::element::{reflect_cross_origin_attribute, set_cross_origin_attribute}; -use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; +use crate::dom::element::{ + AttributeMutation, CustomElementCreationMode, Element, ElementCreator, RawLayoutElementHelpers, +}; use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; @@ -51,7 +53,7 @@ use app_units::{Au, AU_PER_PX}; use cssparser::{Parser, ParserInput}; use dom_struct::dom_struct; use euclid::Point2D; -use html5ever::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix, QualName}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use mime::{self, Mime}; @@ -1256,8 +1258,15 @@ impl HTMLImageElement { width: Option<u32>, height: Option<u32>, ) -> Fallible<DomRoot<HTMLImageElement>> { - let document = window.Document(); - let image = HTMLImageElement::new(local_name!("img"), None, &document); + let element = Element::create( + QualName::new(None, ns!(html), local_name!("img")), + None, + &window.Document(), + ElementCreator::ScriptCreated, + CustomElementCreationMode::Synchronous, + ); + + let image = DomRoot::downcast::<HTMLImageElement>(element).unwrap(); if let Some(w) = width { image.SetWidth(w); } |