mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	LibWeb: Apply suggested fixes.
This commit is contained in:
		
							parent
							
								
									1c7a834278
								
							
						
					
					
						commit
						2981f10a5e
					
				
					 5 changed files with 15 additions and 11 deletions
				
			
		|  | @ -132,6 +132,7 @@ public: | ||||||
|     virtual bool is_global_object() const { return false; } |     virtual bool is_global_object() const { return false; } | ||||||
|     virtual bool is_typed_array() const { return false; } |     virtual bool is_typed_array() const { return false; } | ||||||
|     virtual bool is_array_buffer() const { return false; } |     virtual bool is_array_buffer() const { return false; } | ||||||
|  |     virtual bool is_node_wrapper() const { return false; } | ||||||
| 
 | 
 | ||||||
|     virtual const char* class_name() const override { return "Object"; } |     virtual const char* class_name() const override { return "Object"; } | ||||||
|     virtual void visit_edges(Cell::Visitor&) override; |     virtual void visit_edges(Cell::Visitor&) override; | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibJS/Heap/Heap.h> | #include <LibJS/Heap/Heap.h> | ||||||
| #include <LibWeb/Bindings/RangeConstructor.h> | #include <LibWeb/Bindings/RangeConstructor.h> | ||||||
|  | #include <LibWeb/Bindings/RangePrototype.h> | ||||||
| #include <LibWeb/Bindings/RangeWrapper.h> | #include <LibWeb/Bindings/RangeWrapper.h> | ||||||
| #include <LibWeb/Bindings/WindowObject.h> | #include <LibWeb/Bindings/WindowObject.h> | ||||||
| #include <LibWeb/DOM/Range.h> | #include <LibWeb/DOM/Range.h> | ||||||
|  | @ -39,14 +40,17 @@ RangeConstructor::RangeConstructor(JS::GlobalObject& global_object) | ||||||
| 
 | 
 | ||||||
| void RangeConstructor::initialize(JS::GlobalObject& global_object) | void RangeConstructor::initialize(JS::GlobalObject& global_object) | ||||||
| { | { | ||||||
|  |     auto& vm = this->vm(); | ||||||
|     NativeFunction::initialize(global_object); |     NativeFunction::initialize(global_object); | ||||||
| 
 |     auto& window = static_cast<WindowObject&>(global_object); | ||||||
|     define_property("length", JS::Value(0), JS::Attribute::Configurable); |     define_property(vm.names.prototype, window.range_prototype(), 0); | ||||||
|  |     define_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| JS::Value RangeConstructor::call() | JS::Value RangeConstructor::call() | ||||||
| { | { | ||||||
|     return construct(*this); |     vm().throw_exception<JS::TypeError>(global_object(), JS::ErrorType::ConstructorWithoutNew, "Range"); | ||||||
|  |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| JS::Value RangeConstructor::construct(Function&) | JS::Value RangeConstructor::construct(Function&) | ||||||
|  |  | ||||||
|  | @ -80,8 +80,8 @@ JS_DEFINE_NATIVE_FUNCTION(RangePrototype::set_start) | ||||||
|     if (vm.exception()) |     if (vm.exception()) | ||||||
|         return {}; |         return {}; | ||||||
| 
 | 
 | ||||||
|     if (!static_cast<NodeWrapper*>(arg0)->is_node_wrapper()) { |     if (!arg0->is_node_wrapper()) { | ||||||
|         vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Range"); |         vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Node"); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -103,8 +103,8 @@ JS_DEFINE_NATIVE_FUNCTION(RangePrototype::set_end) | ||||||
|     if (vm.exception()) |     if (vm.exception()) | ||||||
|         return {}; |         return {}; | ||||||
| 
 | 
 | ||||||
|     if (!static_cast<NodeWrapper*>(arg0)->is_node_wrapper()) { |     if (!arg0->is_node_wrapper()) { | ||||||
|         vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Range"); |         vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Node"); | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -90,8 +90,6 @@ void WindowObject::initialize() | ||||||
|     add_constructor("XMLHttpRequest", m_xhr_constructor, m_xhr_prototype); |     add_constructor("XMLHttpRequest", m_xhr_constructor, m_xhr_prototype); | ||||||
| 
 | 
 | ||||||
|     m_range_prototype = heap().allocate<RangePrototype>(*this, *this); |     m_range_prototype = heap().allocate<RangePrototype>(*this, *this); | ||||||
|     m_range_constructor = heap().allocate<RangeConstructor>(*this, *this); |  | ||||||
|     m_range_constructor->define_property("prototype", m_range_prototype); |  | ||||||
|     add_constructor("Range", m_range_constructor, m_range_prototype); |     add_constructor("Range", m_range_constructor, m_range_prototype); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -104,6 +102,8 @@ void WindowObject::visit_edges(Visitor& visitor) | ||||||
|     GlobalObject::visit_edges(visitor); |     GlobalObject::visit_edges(visitor); | ||||||
|     visitor.visit(m_xhr_constructor); |     visitor.visit(m_xhr_constructor); | ||||||
|     visitor.visit(m_xhr_prototype); |     visitor.visit(m_xhr_prototype); | ||||||
|  |     visitor.visit(m_range_constructor); | ||||||
|  |     visitor.visit(m_range_prototype); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Origin WindowObject::origin() const | Origin WindowObject::origin() const | ||||||
|  |  | ||||||
|  | @ -476,9 +476,8 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     generator.append(R"~~~( |     generator.append(R"~~~( | ||||||
|     virtual bool is_@wrapper_class:snakecase@() const final { return true; } |  | ||||||
| 
 |  | ||||||
| private: | private: | ||||||
|  |     virtual bool is_@wrapper_class:snakecase@() const final { return true; } | ||||||
| )~~~"); | )~~~"); | ||||||
| 
 | 
 | ||||||
|     for (auto& function : interface.functions) { |     for (auto& function : interface.functions) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 asynts
						asynts