Serenity Operating System
at master 48 lines 1.4 kB view raw
1/* 2 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibWeb/Bindings/Intrinsics.h> 8#include <LibWeb/HTML/ErrorEvent.h> 9 10namespace Web::HTML { 11 12WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) 13{ 14 return MUST_OR_THROW_OOM(realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init)); 15} 16 17WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) 18{ 19 return create(realm, event_name, event_init); 20} 21 22ErrorEvent::ErrorEvent(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) 23 : DOM::Event(realm, event_name.to_deprecated_fly_string()) 24 , m_message(event_init.message) 25 , m_filename(event_init.filename) 26 , m_lineno(event_init.lineno) 27 , m_colno(event_init.colno) 28 , m_error(event_init.error) 29{ 30} 31 32ErrorEvent::~ErrorEvent() = default; 33 34JS::ThrowCompletionOr<void> ErrorEvent::initialize(JS::Realm& realm) 35{ 36 MUST_OR_THROW_OOM(Base::initialize(realm)); 37 set_prototype(&Bindings::ensure_web_prototype<Bindings::ErrorEventPrototype>(realm, "ErrorEvent")); 38 39 return {}; 40} 41 42void ErrorEvent::visit_edges(Cell::Visitor& visitor) 43{ 44 Base::visit_edges(visitor); 45 visitor.visit(m_error); 46} 47 48}