summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-12-08 23:54:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-09 21:05:06 +0100
commit2981f10a5e43fa1e1217966d7a492a7c0e052b54 (patch)
tree96791eed49e778268dbb448f244b40fa601ab6d2 /Libraries/LibWeb
parent1c7a8342782f9abdb7f0bcead40dc7d030c19835 (diff)
downloadserenity-2981f10a5e43fa1e1217966d7a492a7c0e052b54.zip
LibWeb: Apply suggested fixes.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/Bindings/RangeConstructor.cpp10
-rw-r--r--Libraries/LibWeb/Bindings/RangePrototype.cpp8
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp4
-rw-r--r--Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp3
4 files changed, 14 insertions, 11 deletions
diff --git a/Libraries/LibWeb/Bindings/RangeConstructor.cpp b/Libraries/LibWeb/Bindings/RangeConstructor.cpp
index 72f2bc0c52..27311c4420 100644
--- a/Libraries/LibWeb/Bindings/RangeConstructor.cpp
+++ b/Libraries/LibWeb/Bindings/RangeConstructor.cpp
@@ -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&)
diff --git a/Libraries/LibWeb/Bindings/RangePrototype.cpp b/Libraries/LibWeb/Bindings/RangePrototype.cpp
index 6bde99794f..9215e449f7 100644
--- a/Libraries/LibWeb/Bindings/RangePrototype.cpp
+++ b/Libraries/LibWeb/Bindings/RangePrototype.cpp
@@ -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 {};
}
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index 3722ca56d9..58b2045134 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -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
diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
index fb160f741e..6ad65d1656 100644
--- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
+++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
@@ -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) {