html_sys/embedded/
area.rs

1/// The HTML `<area>` element
2///
3/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/area)
4#[doc(alias = "area")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct ImageMapArea {
8    pub data_map: crate::DataMap,
9    global_attrs: crate::GlobalAttributes,
10    /// Replacement text for use when images are not available
11    pub alt: std::option::Option<std::borrow::Cow<'static, str>>,
12    /// Coordinates for the shape to be created in an image map
13    pub coords: std::option::Option<std::borrow::Cow<'static, str>>,
14    /// The kind of shape to be created in an image map
15    pub shape: std::option::Option<std::borrow::Cow<'static, str>>,
16    /// Address of the hyperlink
17    pub href: std::option::Option<std::borrow::Cow<'static, str>>,
18    /// Navigable for hyperlink navigation
19    pub target: std::option::Option<std::borrow::Cow<'static, str>>,
20    /// Whether to download the resource instead of navigating to it, and its filename if so
21    pub download: std::option::Option<std::borrow::Cow<'static, str>>,
22    /// URLs to ping
23    pub ping: std::option::Option<std::borrow::Cow<'static, str>>,
24    /// Relationship between the location in the document containing the hyperlink and the destination resource
25    pub rel: 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    /// Describes the role(s) the current element plays in the context of the document.
29    pub role: std::option::Option<std::borrow::Cow<'static, str>>,
30    /// 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.
31    pub aria_atomic: bool,
32    /// Defines a string value that labels the current element, which is intended to be converted into Braille. See related aria-label.
33    pub aria_braille_label: std::option::Option<std::borrow::Cow<'static, str>>,
34    /// 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.
35    pub aria_braille_role_description: std::option::Option<
36        std::borrow::Cow<'static, str>,
37    >,
38    /// Indicates an element is being modified and that assistive technologies could wait until the modifications are complete before exposing them to the user.
39    pub aria_busy: bool,
40    /// Identifies the element (or elements) whose contents or presence are controlled by the current element. See related aria-owns.
41    pub aria_controls_elements: std::option::Option<std::borrow::Cow<'static, str>>,
42    /// Indicates the element that represents the current item within a container or set of related elements.
43    pub aria_current: std::option::Option<std::borrow::Cow<'static, str>>,
44    /// Identifies the element (or elements) that describes the object. See related aria-labelledby and aria-description.
45    pub aria_described_by_elements: std::option::Option<std::borrow::Cow<'static, str>>,
46    /// Defines a string value that describes or annotates the current element. See related aria-describedby.
47    pub aria_description: std::option::Option<std::borrow::Cow<'static, str>>,
48    /// Identifies the element (or elements) that provide additional information related to the object. See related aria-describedby.
49    pub aria_details_elements: std::option::Option<std::borrow::Cow<'static, str>>,
50    /// Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. See related aria-hidden and aria-readonly.
51    pub aria_disabled: bool,
52    /// [Deprecated in ARIA 1.1] Indicates what functions can be performed when a dragged object is released on the drop target.
53    pub aria_drop_effect: std::option::Option<std::borrow::Cow<'static, str>>,
54    /// Identifies the element (or elements) that provides an error message for an object. See related aria-invalid and aria-describedby.
55    pub aria_error_message_elements: std::option::Option<std::borrow::Cow<'static, str>>,
56    /// Indicates whether a grouping element owned or controlled by this element is expanded or collapsed.
57    pub aria_expanded: bool,
58    /// 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.
59    pub aria_flow_to_elements: std::option::Option<std::borrow::Cow<'static, str>>,
60    /// [Deprecated in ARIA 1.1] Indicates an element's "grabbed" state in a drag-and-drop operation.
61    pub aria_grabbed: bool,
62    /// Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
63    pub aria_has_popup: std::option::Option<std::borrow::Cow<'static, str>>,
64    /// Indicates whether the element is exposed to an accessibility API. See related aria-disabled.
65    pub aria_hidden: bool,
66    /// Indicates the entered value does not conform to the format expected by the application. See related aria-errormessage.
67    pub aria_invalid: std::option::Option<std::borrow::Cow<'static, str>>,
68    /// Defines keyboard shortcuts that an author has implemented to activate or give focus to an element.
69    pub aria_key_shortcuts: std::option::Option<std::borrow::Cow<'static, str>>,
70    /// Defines a string value that labels the current element. See related aria-labelledby.
71    pub aria_label: std::option::Option<std::borrow::Cow<'static, str>>,
72    /// Identifies the element (or elements) that labels the current element. See related aria-label and aria-describedby.
73    pub aria_labelled_by_elements: std::option::Option<std::borrow::Cow<'static, str>>,
74    /// 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.
75    pub aria_live: std::option::Option<std::borrow::Cow<'static, str>>,
76    /// 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.
77    pub aria_owns_elements: std::option::Option<std::borrow::Cow<'static, str>>,
78    /// Indicates the current "pressed" state of toggle buttons. See related aria-checked and aria-selected.
79    pub aria_pressed: std::option::Option<std::borrow::Cow<'static, str>>,
80    /// Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. See related aria-atomic.
81    pub aria_relevant: std::option::Option<std::borrow::Cow<'static, str>>,
82    /// Defines a human-readable, author-localized description for the role of an element.
83    pub aria_role_description: std::option::Option<std::borrow::Cow<'static, str>>,
84}
85impl crate::RenderElement for ImageMapArea {
86    fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
87        write!(writer, "<area")?;
88        if let Some(field) = self.alt.as_ref() {
89            write!(writer, r#" alt="{field}""#)?;
90        }
91        if let Some(field) = self.coords.as_ref() {
92            write!(writer, r#" coords="{field}""#)?;
93        }
94        if let Some(field) = self.shape.as_ref() {
95            write!(writer, r#" shape="{field}""#)?;
96        }
97        if let Some(field) = self.href.as_ref() {
98            write!(writer, r#" href="{field}""#)?;
99        }
100        if let Some(field) = self.target.as_ref() {
101            write!(writer, r#" target="{field}""#)?;
102        }
103        if let Some(field) = self.download.as_ref() {
104            write!(writer, r#" download="{field}""#)?;
105        }
106        if let Some(field) = self.ping.as_ref() {
107            write!(writer, r#" ping="{field}""#)?;
108        }
109        if let Some(field) = self.rel.as_ref() {
110            write!(writer, r#" rel="{field}""#)?;
111        }
112        if let Some(field) = self.referrerpolicy.as_ref() {
113            write!(writer, r#" referrerpolicy="{field}""#)?;
114        }
115        if let Some(field) = self.role.as_ref() {
116            write!(writer, r#" role="{field}""#)?;
117        }
118        if self.aria_atomic {
119            write!(writer, r#" aria-atomic"#)?;
120        }
121        if let Some(field) = self.aria_braille_label.as_ref() {
122            write!(writer, r#" aria-braillelabel="{field}""#)?;
123        }
124        if let Some(field) = self.aria_braille_role_description.as_ref() {
125            write!(writer, r#" aria-brailleroledescription="{field}""#)?;
126        }
127        if self.aria_busy {
128            write!(writer, r#" aria-busy"#)?;
129        }
130        if let Some(field) = self.aria_controls_elements.as_ref() {
131            write!(writer, r#" aria-controls="{field}""#)?;
132        }
133        if let Some(field) = self.aria_current.as_ref() {
134            write!(writer, r#" aria-current="{field}""#)?;
135        }
136        if let Some(field) = self.aria_described_by_elements.as_ref() {
137            write!(writer, r#" aria-describedby="{field}""#)?;
138        }
139        if let Some(field) = self.aria_description.as_ref() {
140            write!(writer, r#" aria-description="{field}""#)?;
141        }
142        if let Some(field) = self.aria_details_elements.as_ref() {
143            write!(writer, r#" aria-details="{field}""#)?;
144        }
145        if self.aria_disabled {
146            write!(writer, r#" aria-disabled"#)?;
147        }
148        if let Some(field) = self.aria_drop_effect.as_ref() {
149            write!(writer, r#" aria-dropeffect="{field}""#)?;
150        }
151        if let Some(field) = self.aria_error_message_elements.as_ref() {
152            write!(writer, r#" aria-errormessage="{field}""#)?;
153        }
154        if self.aria_expanded {
155            write!(writer, r#" aria-expanded"#)?;
156        }
157        if let Some(field) = self.aria_flow_to_elements.as_ref() {
158            write!(writer, r#" aria-flowto="{field}""#)?;
159        }
160        if self.aria_grabbed {
161            write!(writer, r#" aria-grabbed"#)?;
162        }
163        if let Some(field) = self.aria_has_popup.as_ref() {
164            write!(writer, r#" aria-haspopup="{field}""#)?;
165        }
166        if self.aria_hidden {
167            write!(writer, r#" aria-hidden"#)?;
168        }
169        if let Some(field) = self.aria_invalid.as_ref() {
170            write!(writer, r#" aria-invalid="{field}""#)?;
171        }
172        if let Some(field) = self.aria_key_shortcuts.as_ref() {
173            write!(writer, r#" aria-keyshortcuts="{field}""#)?;
174        }
175        if let Some(field) = self.aria_label.as_ref() {
176            write!(writer, r#" aria-label="{field}""#)?;
177        }
178        if let Some(field) = self.aria_labelled_by_elements.as_ref() {
179            write!(writer, r#" aria-labelledby="{field}""#)?;
180        }
181        if let Some(field) = self.aria_live.as_ref() {
182            write!(writer, r#" aria-live="{field}""#)?;
183        }
184        if let Some(field) = self.aria_owns_elements.as_ref() {
185            write!(writer, r#" aria-owns="{field}""#)?;
186        }
187        if let Some(field) = self.aria_pressed.as_ref() {
188            write!(writer, r#" aria-pressed="{field}""#)?;
189        }
190        if let Some(field) = self.aria_relevant.as_ref() {
191            write!(writer, r#" aria-relevant="{field}""#)?;
192        }
193        if let Some(field) = self.aria_role_description.as_ref() {
194            write!(writer, r#" aria-roledescription="{field}""#)?;
195        }
196        write!(writer, "{}", self.global_attrs)?;
197        write!(writer, "{}", self.data_map)?;
198        write!(writer, ">")?;
199        Ok(())
200    }
201    #[allow(unused_variables)]
202    fn write_closing_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
203        Ok(())
204    }
205}
206impl std::fmt::Display for ImageMapArea {
207    fn fmt(&self, writer: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
208        use crate::RenderElement;
209        self.write_opening_tag(writer)?;
210        self.write_closing_tag(writer)?;
211        Ok(())
212    }
213}
214impl std::ops::Deref for ImageMapArea {
215    type Target = crate::GlobalAttributes;
216    fn deref(&self) -> &Self::Target {
217        &self.global_attrs
218    }
219}
220impl std::ops::DerefMut for ImageMapArea {
221    fn deref_mut(&mut self) -> &mut Self::Target {
222        &mut self.global_attrs
223    }
224}