| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-28 22:46:44 +02:00
										 |  |  |  * Copyright (c) 2020, the SerenityOS developers. | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  | #include <LibWeb/ARIA/Roles.h>
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | #include <LibWeb/HTML/HTMLAreaElement.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | #include <LibWeb/HTML/Window.h>
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-18 21:00:52 +01:00
										 |  |  | HTMLAreaElement::HTMLAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name) | 
					
						
							| 
									
										
										
										
											2021-02-07 11:20:15 +01:00
										 |  |  |     : HTMLElement(document, move(qualified_name)) | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-14 13:21:51 -06:00
										 |  |  | HTMLAreaElement::~HTMLAreaElement() = default; | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  | void HTMLAreaElement::initialize(JS::Realm& realm) | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  |     Base::initialize(realm); | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  |     set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-03 17:08:37 +02:00
										 |  |  | void HTMLAreaElement::attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value) | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-07-03 17:08:37 +02:00
										 |  |  |     HTMLElement::attribute_changed(name, value); | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  |     if (name == HTML::AttributeNames::href) { | 
					
						
							|  |  |  |         set_the_url(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | DeprecatedString HTMLAreaElement::hyperlink_element_utils_href() const | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-09-03 14:58:18 +12:00
										 |  |  |     return deprecated_attribute(HTML::AttributeNames::href); | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-25 20:37:57 +01:00
										 |  |  | WebIDL::ExceptionOr<void> HTMLAreaElement::set_hyperlink_element_utils_href(DeprecatedString href) | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2023-05-25 20:37:57 +01:00
										 |  |  |     return set_attribute(HTML::AttributeNames::href, move(href)); | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-05 03:58:14 +00:00
										 |  |  | // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
 | 
					
						
							|  |  |  | i32 HTMLAreaElement::default_tab_index_value() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // See the base function for the spec comments.
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  | Optional<ARIA::Role> HTMLAreaElement::default_role() const | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | { | 
					
						
							|  |  |  |     // https://www.w3.org/TR/html-aria/#el-area-no-href
 | 
					
						
							|  |  |  |     if (!href().is_null()) | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  |         return ARIA::Role::link; | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  |     // https://www.w3.org/TR/html-aria/#el-area
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  |     return ARIA::Role::generic; | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | } |