html_sys/embedded/
iframe.rs

1/// The HTML `<iframe>` element
2///
3/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
4#[doc(alias = "iframe")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct Iframe {
8    pub data_map: crate::DataMap,
9    global_attrs: crate::GlobalAttributes,
10    /// Address of the resource
11    pub src: std::option::Option<std::borrow::Cow<'static, str>>,
12    /// A document to render in the iframe
13    pub srcdoc: std::option::Option<std::borrow::Cow<'static, str>>,
14    /// Name of content navigable
15    pub name: std::option::Option<std::borrow::Cow<'static, str>>,
16    /// Security rules for nested content
17    pub sandbox: std::option::Option<std::borrow::Cow<'static, str>>,
18    /// Permissions policy to be applied to the iframe's contents
19    pub allow: std::option::Option<std::borrow::Cow<'static, str>>,
20    /// Whether to allow the iframe's contents to use requestFullscreen()
21    pub allowfullscreen: std::option::Option<std::borrow::Cow<'static, str>>,
22    /// Horizontal dimension
23    pub width: std::option::Option<std::borrow::Cow<'static, str>>,
24    /// Vertical dimension
25    pub height: std::option::Option<std::borrow::Cow<'static, str>>,
26    /// Referrer policy for fetches initiated by the element
27    pub referrerpolicy: std::option::Option<std::borrow::Cow<'static, str>>,
28    /// Used when determining loading deferral
29    pub loading: std::option::Option<std::borrow::Cow<'static, str>>,
30    /// Describes the role(s) the current element plays in the context of the document.
31    pub role: std::option::Option<std::borrow::Cow<'static, str>>,
32    /// Identifies the currently active element when DOM focus is on a composite widget, combobox, textbox, group, or application.
33    pub aria_active_descendant_element: std::option::Option<
34        std::borrow::Cow<'static, str>,
35    >,
36    /// Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
37    pub aria_atomic: bool,
38    /// Defines a string value that labels the current element, which is intended to be converted into Braille. See related aria-label.
39    pub aria_braille_label: std::option::Option<std::borrow::Cow<'static, str>>,
40    /// Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille. See related aria-roledescription.
41    pub aria_braille_role_description: std::option::Option<
42        std::borrow::Cow<'static, str>,
43    >,
44    /// Indicates an element is being modified and that assistive technologies could wait until the modifications are complete before exposing them to the user.
45    pub aria_busy: bool,
46    /// Identifies the element (or elements) whose contents or presence are controlled by the current element. See related aria-owns.
47    pub aria_controls_elements: std::option::Option<std::borrow::Cow<'static, str>>,
48    /// Indicates the element that represents the current item within a container or set of related elements.
49    pub aria_current: std::option::Option<std::borrow::Cow<'static, str>>,
50    /// Identifies the element (or elements) that describes the object. See related aria-labelledby and aria-description.
51    pub aria_described_by_elements: std::option::Option<std::borrow::Cow<'static, str>>,
52    /// Defines a string value that describes or annotates the current element. See related aria-describedby.
53    pub aria_description: std::option::Option<std::borrow::Cow<'static, str>>,
54    /// Identifies the element (or elements) that provide additional information related to the object. See related aria-describedby.
55    pub aria_details_elements: std::option::Option<std::borrow::Cow<'static, str>>,
56    /// Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. See related aria-hidden and aria-readonly.
57    pub aria_disabled: bool,
58    /// [Deprecated in ARIA 1.1] Indicates what functions can be performed when a dragged object is released on the drop target.
59    pub aria_drop_effect: std::option::Option<std::borrow::Cow<'static, str>>,
60    /// Identifies the element (or elements) that provides an error message for an object. See related aria-invalid and aria-describedby.
61    pub aria_error_message_elements: std::option::Option<std::borrow::Cow<'static, str>>,
62    /// Indicates whether a grouping element owned or controlled by this element is expanded or collapsed.
63    pub aria_expanded: bool,
64    /// Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.
65    pub aria_flow_to_elements: std::option::Option<std::borrow::Cow<'static, str>>,
66    /// [Deprecated in ARIA 1.1] Indicates an element's "grabbed" state in a drag-and-drop operation.
67    pub aria_grabbed: bool,
68    /// Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
69    pub aria_has_popup: std::option::Option<std::borrow::Cow<'static, str>>,
70    /// Indicates whether the element is exposed to an accessibility API. See related aria-disabled.
71    pub aria_hidden: bool,
72    /// Indicates the entered value does not conform to the format expected by the application. See related aria-errormessage.
73    pub aria_invalid: std::option::Option<std::borrow::Cow<'static, str>>,
74    /// Defines keyboard shortcuts that an author has implemented to activate or give focus to an element.
75    pub aria_key_shortcuts: std::option::Option<std::borrow::Cow<'static, str>>,
76    /// Defines a string value that labels the current element. See related aria-labelledby.
77    pub aria_label: std::option::Option<std::borrow::Cow<'static, str>>,
78    /// Identifies the element (or elements) that labels the current element. See related aria-label and aria-describedby.
79    pub aria_labelled_by_elements: std::option::Option<std::borrow::Cow<'static, str>>,
80    /// Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
81    pub aria_live: std::option::Option<std::borrow::Cow<'static, str>>,
82    /// Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship. See related aria-controls.
83    pub aria_owns_elements: std::option::Option<std::borrow::Cow<'static, str>>,
84    /// Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. See related aria-atomic.
85    pub aria_relevant: std::option::Option<std::borrow::Cow<'static, str>>,
86    /// Defines a human-readable, author-localized description for the role of an element.
87    pub aria_role_description: std::option::Option<std::borrow::Cow<'static, str>>,
88}
89impl crate::RenderElement for Iframe {
90    fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
91        write!(writer, "<iframe")?;
92        if let Some(field) = self.src.as_ref() {
93            write!(writer, r#" src="{field}""#)?;
94        }
95        if let Some(field) = self.srcdoc.as_ref() {
96            write!(writer, r#" srcdoc="{field}""#)?;
97        }
98        if let Some(field) = self.name.as_ref() {
99            write!(writer, r#" name="{field}""#)?;
100        }
101        if let Some(field) = self.sandbox.as_ref() {
102            write!(writer, r#" sandbox="{field}""#)?;
103        }
104        if let Some(field) = self.allow.as_ref() {
105            write!(writer, r#" allow="{field}""#)?;
106        }
107        if let Some(field) = self.allowfullscreen.as_ref() {
108            write!(writer, r#" allowfullscreen="{field}""#)?;
109        }
110        if let Some(field) = self.width.as_ref() {
111            write!(writer, r#" width="{field}""#)?;
112        }
113        if let Some(field) = self.height.as_ref() {
114            write!(writer, r#" height="{field}""#)?;
115        }
116        if let Some(field) = self.referrerpolicy.as_ref() {
117            write!(writer, r#" referrerpolicy="{field}""#)?;
118        }
119        if let Some(field) = self.loading.as_ref() {
120            write!(writer, r#" loading="{field}""#)?;
121        }
122        if let Some(field) = self.role.as_ref() {
123            write!(writer, r#" role="{field}""#)?;
124        }
125        if let Some(field) = self.aria_active_descendant_element.as_ref() {
126            write!(writer, r#" aria-activedescendant="{field}""#)?;
127        }
128        if self.aria_atomic {
129            write!(writer, r#" aria-atomic"#)?;
130        }
131        if let Some(field) = self.aria_braille_label.as_ref() {
132            write!(writer, r#" aria-braillelabel="{field}""#)?;
133        }
134        if let Some(field) = self.aria_braille_role_description.as_ref() {
135            write!(writer, r#" aria-brailleroledescription="{field}""#)?;
136        }
137        if self.aria_busy {
138            write!(writer, r#" aria-busy"#)?;
139        }
140        if let Some(field) = self.aria_controls_elements.as_ref() {
141            write!(writer, r#" aria-controls="{field}""#)?;
142        }
143        if let Some(field) = self.aria_current.as_ref() {
144            write!(writer, r#" aria-current="{field}""#)?;
145        }
146        if let Some(field) = self.aria_described_by_elements.as_ref() {
147            write!(writer, r#" aria-describedby="{field}""#)?;
148        }
149        if let Some(field) = self.aria_description.as_ref() {
150            write!(writer, r#" aria-description="{field}""#)?;
151        }
152        if let Some(field) = self.aria_details_elements.as_ref() {
153            write!(writer, r#" aria-details="{field}""#)?;
154        }
155        if self.aria_disabled {
156            write!(writer, r#" aria-disabled"#)?;
157        }
158        if let Some(field) = self.aria_drop_effect.as_ref() {
159            write!(writer, r#" aria-dropeffect="{field}""#)?;
160        }
161        if let Some(field) = self.aria_error_message_elements.as_ref() {
162            write!(writer, r#" aria-errormessage="{field}""#)?;
163        }
164        if self.aria_expanded {
165            write!(writer, r#" aria-expanded"#)?;
166        }
167        if let Some(field) = self.aria_flow_to_elements.as_ref() {
168            write!(writer, r#" aria-flowto="{field}""#)?;
169        }
170        if self.aria_grabbed {
171            write!(writer, r#" aria-grabbed"#)?;
172        }
173        if let Some(field) = self.aria_has_popup.as_ref() {
174            write!(writer, r#" aria-haspopup="{field}""#)?;
175        }
176        if self.aria_hidden {
177            write!(writer, r#" aria-hidden"#)?;
178        }
179        if let Some(field) = self.aria_invalid.as_ref() {
180            write!(writer, r#" aria-invalid="{field}""#)?;
181        }
182        if let Some(field) = self.aria_key_shortcuts.as_ref() {
183            write!(writer, r#" aria-keyshortcuts="{field}""#)?;
184        }
185        if let Some(field) = self.aria_label.as_ref() {
186            write!(writer, r#" aria-label="{field}""#)?;
187        }
188        if let Some(field) = self.aria_labelled_by_elements.as_ref() {
189            write!(writer, r#" aria-labelledby="{field}""#)?;
190        }
191        if let Some(field) = self.aria_live.as_ref() {
192            write!(writer, r#" aria-live="{field}""#)?;
193        }
194        if let Some(field) = self.aria_owns_elements.as_ref() {
195            write!(writer, r#" aria-owns="{field}""#)?;
196        }
197        if let Some(field) = self.aria_relevant.as_ref() {
198            write!(writer, r#" aria-relevant="{field}""#)?;
199        }
200        if let Some(field) = self.aria_role_description.as_ref() {
201            write!(writer, r#" aria-roledescription="{field}""#)?;
202        }
203        write!(writer, "{}", self.global_attrs)?;
204        write!(writer, "{}", self.data_map)?;
205        write!(writer, ">")?;
206        Ok(())
207    }
208    #[allow(unused_variables)]
209    fn write_closing_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
210        write!(writer, "</iframe>")?;
211        Ok(())
212    }
213}
214impl std::fmt::Display for Iframe {
215    fn fmt(&self, writer: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
216        use crate::RenderElement;
217        self.write_opening_tag(writer)?;
218        self.write_closing_tag(writer)?;
219        Ok(())
220    }
221}
222impl std::ops::Deref for Iframe {
223    type Target = crate::GlobalAttributes;
224    fn deref(&self) -> &Self::Target {
225        &self.global_attrs
226    }
227}
228impl std::ops::DerefMut for Iframe {
229    fn deref_mut(&mut self) -> &mut Self::Target {
230        &mut self.global_attrs
231    }
232}