mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibWeb: Make MediaList GC-allocated
This commit is contained in:
parent
0176d42f49
commit
cfdb8f2a8e
9 changed files with 58 additions and 35 deletions
|
@ -1,16 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MediaListPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/MediaList.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
MediaList::MediaList(NonnullRefPtrVector<MediaQuery>&& media)
|
||||
: m_media(move(media))
|
||||
MediaList* MediaList::create(Bindings::WindowObject& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
{
|
||||
return window_object.heap().allocate<MediaList>(window_object.realm(), window_object, move(media));
|
||||
}
|
||||
|
||||
MediaList::MediaList(Bindings::WindowObject& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
: Bindings::LegacyPlatformObject(window_object.ensure_web_prototype<Bindings::MediaListPrototype>("MediaList"))
|
||||
, m_media(move(media))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -83,4 +92,11 @@ bool MediaList::matches() const
|
|||
return false;
|
||||
}
|
||||
|
||||
JS::Value MediaList::item_value(size_t index) const
|
||||
{
|
||||
if (index >= m_media.size())
|
||||
return JS::js_undefined();
|
||||
return JS::js_string(vm(), m_media[index].to_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue