mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibWeb: Apply suggested fixes.
This commit is contained in:
parent
1c7a834278
commit
2981f10a5e
Notes:
sideshowbarker
2024-07-19 00:56:47 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/2981f10a5e4 Pull-request: https://github.com/SerenityOS/serenity/pull/4318 Reviewed-by: https://github.com/Lubrsi Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
@ -132,6 +132,7 @@ public:
|
||||
virtual bool is_global_object() const { return false; }
|
||||
virtual bool is_typed_array() 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 void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibWeb/Bindings/RangeConstructor.h>
|
||||
#include <LibWeb/Bindings/RangePrototype.h>
|
||||
#include <LibWeb/Bindings/RangeWrapper.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
@ -39,14 +40,17 @@ RangeConstructor::RangeConstructor(JS::GlobalObject& global_object)
|
||||
|
||||
void RangeConstructor::initialize(JS::GlobalObject& global_object)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(global_object);
|
||||
|
||||
define_property("length", JS::Value(0), JS::Attribute::Configurable);
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
define_property(vm.names.prototype, window.range_prototype(), 0);
|
||||
define_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS::Value RangeConstructor::call()
|
||||
{
|
||||
return construct(*this);
|
||||
vm().throw_exception<JS::TypeError>(global_object(), JS::ErrorType::ConstructorWithoutNew, "Range");
|
||||
return {};
|
||||
}
|
||||
|
||||
JS::Value RangeConstructor::construct(Function&)
|
||||
|
@ -80,8 +80,8 @@ JS_DEFINE_NATIVE_FUNCTION(RangePrototype::set_start)
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
if (!static_cast<NodeWrapper*>(arg0)->is_node_wrapper()) {
|
||||
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Range");
|
||||
if (!arg0->is_node_wrapper()) {
|
||||
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Node");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -103,8 +103,8 @@ JS_DEFINE_NATIVE_FUNCTION(RangePrototype::set_end)
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
if (!static_cast<NodeWrapper*>(arg0)->is_node_wrapper()) {
|
||||
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Range");
|
||||
if (!arg0->is_node_wrapper()) {
|
||||
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Node");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,6 @@ void WindowObject::initialize()
|
||||
add_constructor("XMLHttpRequest", m_xhr_constructor, m_xhr_prototype);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -104,6 +102,8 @@ void WindowObject::visit_edges(Visitor& visitor)
|
||||
GlobalObject::visit_edges(visitor);
|
||||
visitor.visit(m_xhr_constructor);
|
||||
visitor.visit(m_xhr_prototype);
|
||||
visitor.visit(m_range_constructor);
|
||||
visitor.visit(m_range_prototype);
|
||||
}
|
||||
|
||||
Origin WindowObject::origin() const
|
||||
|
@ -476,9 +476,8 @@ public:
|
||||
}
|
||||
|
||||
generator.append(R"~~~(
|
||||
virtual bool is_@wrapper_class:snakecase@() const final { return true; }
|
||||
|
||||
private:
|
||||
virtual bool is_@wrapper_class:snakecase@() const final { return true; }
|
||||
)~~~");
|
||||
|
||||
for (auto& function : interface.functions) {
|
||||
|
Loading…
Reference in New Issue
Block a user