| 
									
										
										
										
											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
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | #include <LibWeb/DOM/ARIARoleNames.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-01-10 06:28:20 -05:00
										 |  |  | void HTMLAreaElement::initialize(JS::Realm& realm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Base::initialize(realm); | 
					
						
							|  |  |  |     set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  | void HTMLAreaElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     HTMLElement::parse_attribute(name, value); | 
					
						
							|  |  |  |     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
										 |  |  | { | 
					
						
							|  |  |  |     return attribute(HTML::AttributeNames::href); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | void HTMLAreaElement::set_hyperlink_element_utils_href(DeprecatedString href) | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:12 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-30 17:50:04 +00:00
										 |  |  |     MUST(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-08 19:23:00 -05:00
										 |  |  | DeprecatedFlyString 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()) | 
					
						
							|  |  |  |         return DOM::ARIARoleNames::link; | 
					
						
							|  |  |  |     // https://www.w3.org/TR/html-aria/#el-area
 | 
					
						
							|  |  |  |     return DOM::ARIARoleNames::generic; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:04:26 +01:00
										 |  |  | } |