mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	LibHTML: Add HTMLHeadingElement for <h1> through <h6>
This commit is contained in:
		
							parent
							
								
									f38b0f667e
								
							
						
					
					
						commit
						5b942b519c
					
				
					 4 changed files with 31 additions and 1 deletions
				
			
		
							
								
								
									
										10
									
								
								Libraries/LibHTML/DOM/HTMLHeadingElement.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								Libraries/LibHTML/DOM/HTMLHeadingElement.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | #include <LibHTML/DOM/HTMLHeadingElement.h> | ||||||
|  | 
 | ||||||
|  | HTMLHeadingElement::HTMLHeadingElement(Document& document, const String& tag_name) | ||||||
|  |     : HTMLElement(document, tag_name) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | HTMLHeadingElement::~HTMLHeadingElement() | ||||||
|  | { | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								Libraries/LibHTML/DOM/HTMLHeadingElement.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Libraries/LibHTML/DOM/HTMLHeadingElement.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <LibHTML/DOM/HTMLElement.h> | ||||||
|  | 
 | ||||||
|  | class HTMLHeadingElement : public HTMLElement { | ||||||
|  | public: | ||||||
|  |     HTMLHeadingElement(Document&, const String& tag_name); | ||||||
|  |     virtual ~HTMLHeadingElement() override; | ||||||
|  | }; | ||||||
|  | @ -4,6 +4,7 @@ LIBHTML_OBJS = \ | ||||||
|     DOM/Element.o \ |     DOM/Element.o \ | ||||||
|     DOM/HTMLElement.o \ |     DOM/HTMLElement.o \ | ||||||
|     DOM/HTMLAnchorElement.o \ |     DOM/HTMLAnchorElement.o \ | ||||||
|  |     DOM/HTMLHeadingElement.o \ | ||||||
|     DOM/Document.o \ |     DOM/Document.o \ | ||||||
|     DOM/Text.o \ |     DOM/Text.o \ | ||||||
|     CSS/Selector.o \ |     CSS/Selector.o \ | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibHTML/DOM/Element.h> | #include <LibHTML/DOM/Element.h> | ||||||
| #include <LibHTML/DOM/HTMLAnchorElement.h> | #include <LibHTML/DOM/HTMLAnchorElement.h> | ||||||
|  | #include <LibHTML/DOM/HTMLHeadingElement.h> | ||||||
| #include <LibHTML/DOM/Text.h> | #include <LibHTML/DOM/Text.h> | ||||||
| #include <LibHTML/Parser/HTMLParser.h> | #include <LibHTML/Parser/HTMLParser.h> | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
|  | @ -9,8 +10,17 @@ | ||||||
| 
 | 
 | ||||||
| static NonnullRefPtr<Element> create_element(Document& document, const String& tag_name) | static NonnullRefPtr<Element> create_element(Document& document, const String& tag_name) | ||||||
| { | { | ||||||
|     if (tag_name.to_lowercase() == "a") |     auto lowercase_tag_name = tag_name.to_lowercase(); | ||||||
|  |     if (lowercase_tag_name == "a") | ||||||
|         return adopt(*new HTMLAnchorElement(document, tag_name)); |         return adopt(*new HTMLAnchorElement(document, tag_name)); | ||||||
|  |     if (lowercase_tag_name == "h1" | ||||||
|  |         || lowercase_tag_name == "h2" | ||||||
|  |         || lowercase_tag_name == "h3" | ||||||
|  |         || lowercase_tag_name == "h4" | ||||||
|  |         || lowercase_tag_name == "h5" | ||||||
|  |         || lowercase_tag_name == "h6") { | ||||||
|  |         return adopt(*new HTMLHeadingElement(document, tag_name)); | ||||||
|  |     } | ||||||
|     return adopt(*new Element(document, tag_name)); |     return adopt(*new Element(document, tag_name)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling