Skip to content

Commit

Permalink
web/core: Add HtmlImageElement
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Dec 17, 2023
1 parent 9dfd1f8 commit b916213
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/web/core/src/dom/dom_objects/html_image_element.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use dom_derive::inherit;

use super::HtmlElement;

/// <https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element>
#[inherit(HtmlElement)]
pub struct HtmlImageElement {}

impl HtmlImageElement {
pub fn new(html_element: HtmlElement) -> Self {
Self {
__parent: html_element,
}
}
}
2 changes: 2 additions & 0 deletions crates/web/core/src/dom/dom_objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod html_form_element;
mod html_head_element;
mod html_heading_element;
mod html_html_element;
mod html_image_element;
mod html_li_element;
mod html_link_element;
mod html_meta_element;
Expand Down Expand Up @@ -42,6 +43,7 @@ pub use html_form_element::HtmlFormElement;
pub use html_head_element::HtmlHeadElement;
pub use html_heading_element::HtmlHeadingElement;
pub use html_html_element::HtmlHtmlElement;
pub use html_image_element::HtmlImageElement;
pub use html_li_element::HtmlLiElement;
pub use html_link_element::HtmlLinkElement;
pub use html_meta_element::HtmlMetaElement;
Expand Down
5 changes: 5 additions & 0 deletions crates/web/core/src/dom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub use dom_ptr::{DomPtr, WeakDomPtr};

use crate::{infra::Namespace, static_interned, InternedString};

use self::dom_objects::HtmlImageElement;

/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub enum ElementCustomState {
Expand Down Expand Up @@ -149,6 +151,9 @@ fn create_element_for_interface(
static_interned!("html") => {
DomPtr::new(HtmlHtmlElement::new(HtmlElement::new(element_data))).upcast()
},
static_interned!("img") => {
DomPtr::new(HtmlImageElement::new(HtmlElement::new(element_data))).upcast()
},
static_interned!("link") => {
DomPtr::new(HtmlLinkElement::new(HtmlElement::new(element_data))).upcast()
},
Expand Down

0 comments on commit b916213

Please sign in to comment.