mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 07:42:07 +00:00 
			
		
		
		
	 6e19ab2bbc
			
		
	
	
		6e19ab2bbc
		
	
	
	
	
		
			
			We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
		
			
				
	
	
		
			63 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/DeprecatedString.h>
 | |
| #include <AK/NonnullRefPtrVector.h>
 | |
| #include <AK/StringView.h>
 | |
| #include <LibWeb/Bindings/LegacyPlatformObject.h>
 | |
| #include <LibWeb/Forward.h>
 | |
| #include <LibWeb/WebIDL/ExceptionOr.h>
 | |
| 
 | |
| namespace Web::DOM {
 | |
| 
 | |
| // https://dom.spec.whatwg.org/#interface-namednodemap
 | |
| class NamedNodeMap : public Bindings::LegacyPlatformObject {
 | |
|     WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
 | |
| 
 | |
| public:
 | |
|     static JS::NonnullGCPtr<NamedNodeMap> create(Element&);
 | |
|     ~NamedNodeMap() = default;
 | |
| 
 | |
|     virtual bool is_supported_property_index(u32 index) const override;
 | |
|     virtual Vector<DeprecatedString> supported_property_names() const override;
 | |
|     virtual JS::Value item_value(size_t index) const override;
 | |
|     virtual JS::Value named_item_value(FlyString const& name) const override;
 | |
| 
 | |
|     size_t length() const { return m_attributes.size(); }
 | |
|     bool is_empty() const { return m_attributes.is_empty(); }
 | |
| 
 | |
|     // Methods defined by the spec for JavaScript:
 | |
|     Attr const* item(u32 index) const;
 | |
|     Attr const* get_named_item(StringView qualified_name) const;
 | |
|     WebIDL::ExceptionOr<Attr const*> set_named_item(Attr& attribute);
 | |
|     WebIDL::ExceptionOr<Attr const*> remove_named_item(StringView qualified_name);
 | |
| 
 | |
|     // Methods defined by the spec for internal use:
 | |
|     Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr);
 | |
|     Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const;
 | |
|     WebIDL::ExceptionOr<Attr const*> set_attribute(Attr& attribute);
 | |
|     void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index);
 | |
|     void append_attribute(Attr& attribute);
 | |
|     Attr const* remove_attribute(StringView qualified_name);
 | |
| 
 | |
| private:
 | |
|     explicit NamedNodeMap(Element&);
 | |
| 
 | |
|     virtual void visit_edges(Cell::Visitor&) override;
 | |
| 
 | |
|     Element& associated_element() { return *m_element; }
 | |
|     Element const& associated_element() const { return *m_element; }
 | |
| 
 | |
|     void remove_attribute_at_index(size_t attribute_index);
 | |
| 
 | |
|     JS::NonnullGCPtr<DOM::Element> m_element;
 | |
|     Vector<JS::NonnullGCPtr<Attr>> m_attributes;
 | |
| };
 | |
| 
 | |
| }
 |