mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:32:43 +00:00 
			
		
		
		
	LibWeb: Implement HTMLTableElement tfoot attributes
* tFoot - Getter for the tfoot element The setter is not currently implemented * createTFoot - If necessary, creates a new tfoot element and add it to the table after any tbody elements * deleteTFoot - If a tfoot element exists in the table, delete it
This commit is contained in:
		
							parent
							
								
									b3f7ea9914
								
							
						
					
					
						commit
						d2e3e98b6b
					
				
					 3 changed files with 56 additions and 0 deletions
				
			
		|  | @ -163,6 +163,53 @@ void HTMLTableElement::delete_t_head() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | RefPtr<HTMLTableSectionElement> HTMLTableElement::t_foot() | ||||||
|  | { | ||||||
|  |     for (auto* child = first_child(); child; child = child->next_sibling()) { | ||||||
|  |         if (is<HTMLTableSectionElement>(*child)) { | ||||||
|  |             auto table_section_element = &downcast<HTMLTableSectionElement>(*child); | ||||||
|  |             if (table_section_element->tag_name() == TagNames::tfoot) | ||||||
|  |                 return table_section_element; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return nullptr; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | DOM::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement& tfoot) | ||||||
|  | { | ||||||
|  |     if (tfoot.tag_name() != TagNames::tfoot) | ||||||
|  |         return DOM::HierarchyRequestError::create("Element is not tfoot"); | ||||||
|  | 
 | ||||||
|  |     // FIXME: The spec requires deleting the current tfoot if tfoot is null
 | ||||||
|  |     //        Currently the wrapper generator doesn't send us a nullable value
 | ||||||
|  |     delete_t_foot(); | ||||||
|  | 
 | ||||||
|  |     // We insert the new tfoot at the end of the table
 | ||||||
|  |     append_child(tfoot); | ||||||
|  | 
 | ||||||
|  |     return {}; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | NonnullRefPtr<HTMLTableSectionElement> HTMLTableElement::create_t_foot() | ||||||
|  | { | ||||||
|  |     auto maybe_tfoot = t_foot(); | ||||||
|  |     if (maybe_tfoot) | ||||||
|  |         return *maybe_tfoot; | ||||||
|  | 
 | ||||||
|  |     auto tfoot = DOM::create_element(document(), TagNames::tfoot, Namespace::HTML); | ||||||
|  |     append_child(tfoot); | ||||||
|  |     return tfoot; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void HTMLTableElement::delete_t_foot() | ||||||
|  | { | ||||||
|  |     auto maybe_tfoot = t_foot(); | ||||||
|  |     if (maybe_tfoot) { | ||||||
|  |         maybe_tfoot->remove(false); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| NonnullRefPtr<DOM::HTMLCollection> HTMLTableElement::rows() | NonnullRefPtr<DOM::HTMLCollection> HTMLTableElement::rows() | ||||||
| { | { | ||||||
|     HTMLTableElement* table_node = this; |     HTMLTableElement* table_node = this; | ||||||
|  |  | ||||||
|  | @ -31,6 +31,11 @@ public: | ||||||
|     NonnullRefPtr<HTMLTableSectionElement> create_t_head(); |     NonnullRefPtr<HTMLTableSectionElement> create_t_head(); | ||||||
|     void delete_t_head(); |     void delete_t_head(); | ||||||
| 
 | 
 | ||||||
|  |     RefPtr<HTMLTableSectionElement> t_foot(); | ||||||
|  |     DOM::ExceptionOr<void> set_t_foot(HTMLTableSectionElement& thead); | ||||||
|  |     NonnullRefPtr<HTMLTableSectionElement> create_t_foot(); | ||||||
|  |     void delete_t_foot(); | ||||||
|  | 
 | ||||||
|     NonnullRefPtr<DOM::HTMLCollection> rows(); |     NonnullRefPtr<DOM::HTMLCollection> rows(); | ||||||
|     DOM::ExceptionOr<NonnullRefPtr<HTMLTableRowElement>> insert_row(long index); |     DOM::ExceptionOr<NonnullRefPtr<HTMLTableRowElement>> insert_row(long index); | ||||||
|     DOM::ExceptionOr<void> delete_row(long index); |     DOM::ExceptionOr<void> delete_row(long index); | ||||||
|  |  | ||||||
|  | @ -8,6 +8,10 @@ interface HTMLTableElement : HTMLElement { | ||||||
|     HTMLTableSectionElement createTHead(); |     HTMLTableSectionElement createTHead(); | ||||||
|     undefined deleteTHead(); |     undefined deleteTHead(); | ||||||
| 
 | 
 | ||||||
|  |     attribute HTMLTableSectionElement? tFoot; | ||||||
|  |     HTMLTableSectionElement createTFoot(); | ||||||
|  |     undefined deleteTFoot(); | ||||||
|  | 
 | ||||||
|     readonly attribute HTMLCollection rows; |     readonly attribute HTMLCollection rows; | ||||||
|     HTMLTableRowElement insertRow(optional long index = -1); |     HTMLTableRowElement insertRow(optional long index = -1); | ||||||
|     undefined deleteRow(long index); |     undefined deleteRow(long index); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Adam Hodgen
						Adam Hodgen