mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
This commit is contained in:
parent
bb547ce1c4
commit
6f433c8656
445 changed files with 4797 additions and 4268 deletions
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MediaQueryListWrapper.h>
|
||||
#include <LibWeb/Bindings/MediaQueryListPrototype.h>
|
||||
#include <LibWeb/CSS/MediaQueryList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/EventDispatcher.h>
|
||||
|
@ -14,14 +14,26 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
{
|
||||
return *document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
|
||||
}
|
||||
|
||||
MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
: DOM::EventTarget()
|
||||
: DOM::EventTarget(document.realm())
|
||||
, m_document(document)
|
||||
, m_media(move(media))
|
||||
{
|
||||
set_prototype(&document.window().ensure_web_prototype<Bindings::MediaQueryListPrototype>("MediaQueryList"));
|
||||
evaluate();
|
||||
}
|
||||
|
||||
void MediaQueryList::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_document.ptr());
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media
|
||||
String MediaQueryList::media() const
|
||||
{
|
||||
|
@ -40,9 +52,6 @@ bool MediaQueryList::matches() const
|
|||
|
||||
bool MediaQueryList::evaluate()
|
||||
{
|
||||
if (!m_document)
|
||||
return false;
|
||||
|
||||
bool now_matches = false;
|
||||
for (auto& media : m_media) {
|
||||
now_matches = now_matches || media.evaluate(m_document->window());
|
||||
|
@ -51,11 +60,6 @@ bool MediaQueryList::evaluate()
|
|||
return now_matches;
|
||||
}
|
||||
|
||||
JS::Object* MediaQueryList::create_wrapper(JS::Realm& realm)
|
||||
{
|
||||
return wrap(realm, *this);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
|
||||
void MediaQueryList::add_listener(DOM::IDLEventListener* listener)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue