mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibJS+LibWeb: Pass prototype to Object constructor
Everyone who constructs an Object must now pass a prototype object when applicable. There's still a fair amount of code that passes something fetched from the Interpreter, but this brings us closer to being able to detach prototypes from Interpreter eventually.
This commit is contained in:
parent
f6d57c82f6
commit
bc1ece7f37
30 changed files with 60 additions and 28 deletions
|
@ -44,7 +44,8 @@ CanvasRenderingContext2DWrapper* wrap(JS::Heap& heap, CanvasRenderingContext2D&
|
|||
}
|
||||
|
||||
CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRenderingContext2D& impl)
|
||||
: m_impl(impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
put_native_property("fillStyle", fill_style_getter, fill_style_setter);
|
||||
put_native_function("fillRect", fill_rect, 4);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
class CanvasRenderingContext2DWrapper : public Wrapper {
|
||||
class CanvasRenderingContext2DWrapper final : public Wrapper {
|
||||
public:
|
||||
explicit CanvasRenderingContext2DWrapper(CanvasRenderingContext2D&);
|
||||
virtual ~CanvasRenderingContext2DWrapper() override;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibWeb/Bindings/EventListenerWrapper.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
@ -32,7 +33,8 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
EventListenerWrapper::EventListenerWrapper(EventListener& impl)
|
||||
: m_impl(impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
EventTargetWrapper::EventTargetWrapper(EventTarget& impl)
|
||||
: m_impl(impl)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
put_native_function("addEventListener", add_event_listener, 2);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/MouseEventWrapper.h>
|
||||
#include <LibWeb/DOM/MouseEvent.h>
|
||||
|
@ -39,7 +40,8 @@ EventWrapper* wrap(JS::Heap& heap, Event& event)
|
|||
}
|
||||
|
||||
EventWrapper::EventWrapper(Event& event)
|
||||
: m_event(event)
|
||||
: Wrapper(*interpreter().object_prototype())
|
||||
, m_event(event)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,14 @@
|
|||
*/
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibWeb/Bindings/NavigatorObject.h>
|
||||
|
||||
namespace Web {
|
||||
namespace Bindings {
|
||||
|
||||
NavigatorObject::NavigatorObject()
|
||||
: Object(interpreter().object_prototype())
|
||||
{
|
||||
put("appCodeName", js_string(heap(), "Mozilla"));
|
||||
put("appName", js_string(heap(), "Netscape"));
|
||||
|
|
|
@ -38,7 +38,10 @@ class Wrapper
|
|||
: public JS::Object
|
||||
, public Weakable<Wrapper> {
|
||||
protected:
|
||||
explicit Wrapper() {}
|
||||
explicit Wrapper(Object& prototype)
|
||||
: Object(&prototype)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
XMLHttpRequestConstructor::XMLHttpRequestConstructor()
|
||||
: NativeFunction(*interpreter().function_prototype())
|
||||
{
|
||||
put("length", JS::Value(1));
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
XMLHttpRequestPrototype::XMLHttpRequestPrototype()
|
||||
: Object(interpreter().object_prototype())
|
||||
{
|
||||
put_native_function("open", open, 2);
|
||||
put_native_function("send", send, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue