mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +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
|
@ -6,12 +6,12 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSConditionRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSConditionRule.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSConditionRule::CSSConditionRule(Bindings::WindowObject& window_object, CSSRuleList& rules)
|
||||
CSSConditionRule::CSSConditionRule(HTML::Window& window_object, CSSRuleList& rules)
|
||||
: CSSGroupingRule(window_object, rules)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::CSSConditionRulePrototype>("CSSConditionRule"));
|
||||
|
|
|
@ -13,13 +13,9 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class CSSConditionRule : public CSSGroupingRule {
|
||||
AK_MAKE_NONCOPYABLE(CSSConditionRule);
|
||||
AK_MAKE_NONMOVABLE(CSSConditionRule);
|
||||
JS_OBJECT(CSSConditionRule, CSSGroupingRule);
|
||||
WEB_PLATFORM_OBJECT(CSSConditionRule, CSSGroupingRule);
|
||||
|
||||
public:
|
||||
CSSConditionRule& impl() { return *this; }
|
||||
|
||||
virtual ~CSSConditionRule() = default;
|
||||
|
||||
virtual String condition_text() const = 0;
|
||||
|
@ -29,12 +25,9 @@ public:
|
|||
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const override;
|
||||
|
||||
protected:
|
||||
explicit CSSConditionRule(Bindings::WindowObject&, CSSRuleList&);
|
||||
explicit CSSConditionRule(HTML::Window&, CSSRuleList&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSConditionRule& object) { return &object; }
|
||||
using CSSConditionRuleWrapper = Web::CSS::CSSConditionRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSConditionRule, Web::CSS)
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSFontFaceRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSFontFaceRule* CSSFontFaceRule::create(Bindings::WindowObject& window_object, FontFace&& font_face)
|
||||
CSSFontFaceRule* CSSFontFaceRule::create(HTML::Window& window_object, FontFace&& font_face)
|
||||
{
|
||||
return window_object.heap().allocate<CSSFontFaceRule>(window_object.realm(), window_object, move(font_face));
|
||||
}
|
||||
|
||||
CSSFontFaceRule::CSSFontFaceRule(Bindings::WindowObject& window_object, FontFace&& font_face)
|
||||
CSSFontFaceRule::CSSFontFaceRule(HTML::Window& window_object, FontFace&& font_face)
|
||||
: CSSRule(window_object)
|
||||
, m_font_face(move(font_face))
|
||||
{
|
||||
|
|
|
@ -13,16 +13,12 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class CSSFontFaceRule final : public CSSRule {
|
||||
AK_MAKE_NONCOPYABLE(CSSFontFaceRule);
|
||||
AK_MAKE_NONMOVABLE(CSSFontFaceRule);
|
||||
JS_OBJECT(CSSFontFaceRule, CSSRule);
|
||||
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
||||
|
||||
public:
|
||||
static CSSFontFaceRule* create(Bindings::WindowObject&, FontFace&&);
|
||||
explicit CSSFontFaceRule(Bindings::WindowObject&, FontFace&&);
|
||||
static CSSFontFaceRule* create(HTML::Window&, FontFace&&);
|
||||
|
||||
virtual ~CSSFontFaceRule() override = default;
|
||||
CSSFontFaceRule& impl() { return *this; }
|
||||
|
||||
virtual Type type() const override { return Type::FontFace; }
|
||||
|
||||
|
@ -30,6 +26,8 @@ public:
|
|||
CSSStyleDeclaration* style();
|
||||
|
||||
private:
|
||||
explicit CSSFontFaceRule(HTML::Window&, FontFace&&);
|
||||
|
||||
virtual String serialized() const override;
|
||||
|
||||
FontFace m_font_face;
|
||||
|
@ -40,7 +38,4 @@ inline bool CSSRule::fast_is<CSSFontFaceRule>() const { return type() == CSSRule
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSFontFaceRule& object) { return &object; }
|
||||
using CSSFontFaceRuleWrapper = Web::CSS::CSSFontFaceRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSFontFaceRule, Web::CSS)
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
#include <LibWeb/Bindings/CSSGroupingRulePrototype.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSGroupingRule.h>
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSGroupingRule::CSSGroupingRule(Bindings::WindowObject& window_object, CSSRuleList& rules)
|
||||
CSSGroupingRule::CSSGroupingRule(HTML::Window& window_object, CSSRuleList& rules)
|
||||
: CSSRule(window_object)
|
||||
, m_rules(rules)
|
||||
{
|
||||
|
|
|
@ -15,13 +15,9 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class CSSGroupingRule : public CSSRule {
|
||||
AK_MAKE_NONCOPYABLE(CSSGroupingRule);
|
||||
AK_MAKE_NONMOVABLE(CSSGroupingRule);
|
||||
JS_OBJECT(CSSGroupingRule, CSSRule);
|
||||
WEB_PLATFORM_OBJECT(CSSGroupingRule, CSSRule);
|
||||
|
||||
public:
|
||||
CSSGroupingRule& impl() { return *this; }
|
||||
|
||||
virtual ~CSSGroupingRule() = default;
|
||||
|
||||
CSSRuleList const& css_rules() const { return m_rules; }
|
||||
|
@ -35,7 +31,7 @@ public:
|
|||
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
||||
|
||||
protected:
|
||||
explicit CSSGroupingRule(Bindings::WindowObject&, CSSRuleList&);
|
||||
explicit CSSGroupingRule(HTML::Window&, CSSRuleList&);
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
|
@ -44,7 +40,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSGroupingRule& object) { return &object; }
|
||||
using CSSGroupingRuleWrapper = Web::CSS::CSSGroupingRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSGroupingRule, Web::CSS)
|
||||
|
|
|
@ -9,26 +9,26 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibWeb/Bindings/CSSImportRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||
{
|
||||
auto& window_object = document.preferred_window_object();
|
||||
auto& window_object = document.window();
|
||||
return window_object.heap().allocate<CSSImportRule>(window_object.realm(), move(url), document);
|
||||
}
|
||||
|
||||
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
||||
: CSSRule(document.preferred_window_object())
|
||||
: CSSRule(document.window())
|
||||
, m_url(move(url))
|
||||
, m_document(document)
|
||||
{
|
||||
set_prototype(&document.preferred_window_object().ensure_web_prototype<Bindings::CSSImportRulePrototype>("CSSImportRule"));
|
||||
set_prototype(&document.window().ensure_web_prototype<Bindings::CSSImportRulePrototype>("CSSImportRule"));
|
||||
|
||||
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Loading import URL: {}", m_url);
|
||||
auto request = LoadRequest::create_for_url_on_page(m_url, document.page());
|
||||
|
|
|
@ -19,18 +19,13 @@ namespace Web::CSS {
|
|||
class CSSImportRule final
|
||||
: public CSSRule
|
||||
, public ResourceClient {
|
||||
AK_MAKE_NONCOPYABLE(CSSImportRule);
|
||||
AK_MAKE_NONMOVABLE(CSSImportRule);
|
||||
JS_OBJECT(CSSImportRule, CSSRule);
|
||||
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
|
||||
|
||||
public:
|
||||
static CSSImportRule* create(AK::URL, DOM::Document&);
|
||||
CSSImportRule(AK::URL, DOM::Document&);
|
||||
|
||||
virtual ~CSSImportRule() = default;
|
||||
|
||||
CSSImportRule& impl() { return *this; }
|
||||
|
||||
AK::URL const& url() const { return m_url; }
|
||||
// FIXME: This should return only the specified part of the url. eg, "stuff/foo.css", not "https://example.com/stuff/foo.css".
|
||||
String href() const { return m_url.to_string(); }
|
||||
|
@ -44,6 +39,8 @@ public:
|
|||
virtual Type type() const override { return Type::Import; };
|
||||
|
||||
private:
|
||||
CSSImportRule(AK::URL, DOM::Document&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
virtual String serialized() const override;
|
||||
|
@ -63,7 +60,4 @@ inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSImportRule& object) { return &object; }
|
||||
using CSSImportRuleWrapper = Web::CSS::CSSImportRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSImportRule, Web::CSS)
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSMediaRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSMediaRule* CSSMediaRule::create(Bindings::WindowObject& window_object, MediaList& media_queries, CSSRuleList& rules)
|
||||
CSSMediaRule* CSSMediaRule::create(HTML::Window& window_object, MediaList& media_queries, CSSRuleList& rules)
|
||||
{
|
||||
return window_object.heap().allocate<CSSMediaRule>(window_object.realm(), window_object, media_queries, rules);
|
||||
}
|
||||
|
||||
CSSMediaRule::CSSMediaRule(Bindings::WindowObject& window_object, MediaList& media, CSSRuleList& rules)
|
||||
CSSMediaRule::CSSMediaRule(HTML::Window& window_object, MediaList& media, CSSRuleList& rules)
|
||||
: CSSConditionRule(window_object, rules)
|
||||
, m_media(media)
|
||||
{
|
||||
|
|
|
@ -15,15 +15,10 @@ namespace Web::CSS {
|
|||
|
||||
// https://www.w3.org/TR/css-conditional-3/#the-cssmediarule-interface
|
||||
class CSSMediaRule final : public CSSConditionRule {
|
||||
AK_MAKE_NONCOPYABLE(CSSMediaRule);
|
||||
AK_MAKE_NONMOVABLE(CSSMediaRule);
|
||||
JS_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||
|
||||
public:
|
||||
CSSMediaRule& impl() { return *this; }
|
||||
|
||||
static CSSMediaRule* create(Bindings::WindowObject&, MediaList& media_queries, CSSRuleList&);
|
||||
explicit CSSMediaRule(Bindings::WindowObject&, MediaList&, CSSRuleList&);
|
||||
static CSSMediaRule* create(HTML::Window&, MediaList& media_queries, CSSRuleList&);
|
||||
|
||||
virtual ~CSSMediaRule() = default;
|
||||
|
||||
|
@ -38,6 +33,8 @@ public:
|
|||
bool evaluate(HTML::Window const& window) { return m_media.evaluate(window); }
|
||||
|
||||
private:
|
||||
explicit CSSMediaRule(HTML::Window&, MediaList&, CSSRuleList&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
|
||||
|
@ -49,7 +46,4 @@ inline bool CSSRule::fast_is<CSSMediaRule>() const { return type() == CSSRule::T
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSMediaRule& object) { return &object; }
|
||||
using CSSMediaRuleWrapper = Web::CSS::CSSMediaRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSMediaRule, Web::CSS)
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSRule::CSSRule(Bindings::WindowObject& window_object)
|
||||
CSSRule::CSSRule(HTML::Window& window_object)
|
||||
: PlatformObject(window_object.ensure_web_prototype<Bindings::CSSRulePrototype>("CSSRule"))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class CSSRule : public Bindings::PlatformObject {
|
||||
JS_OBJECT(CSSRule, JS::Object);
|
||||
WEB_PLATFORM_OBJECT(CSSRule, JS::Object);
|
||||
|
||||
public:
|
||||
CSSRule& impl() { return *this; }
|
||||
virtual ~CSSRule() = default;
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssrule-type
|
||||
|
@ -46,7 +45,7 @@ public:
|
|||
bool fast_is() const = delete;
|
||||
|
||||
protected:
|
||||
explicit CSSRule(Bindings::WindowObject&);
|
||||
explicit CSSRule(HTML::Window&);
|
||||
|
||||
virtual String serialized() const = 0;
|
||||
|
||||
|
@ -58,7 +57,4 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSRule& object) { return &object; }
|
||||
using CSSRuleWrapper = Web::CSS::CSSRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSRule, Web::CSS)
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/Bindings/CSSRuleListPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSRuleList* CSSRuleList::create(Bindings::WindowObject& window_object, JS::MarkedVector<CSSRule*> const& rules)
|
||||
CSSRuleList* CSSRuleList::create(HTML::Window& window_object, JS::MarkedVector<CSSRule*> const& rules)
|
||||
{
|
||||
auto* rule_list = window_object.heap().allocate<CSSRuleList>(window_object.realm(), window_object);
|
||||
for (auto* rule : rules)
|
||||
|
@ -24,12 +24,12 @@ CSSRuleList* CSSRuleList::create(Bindings::WindowObject& window_object, JS::Mark
|
|||
return rule_list;
|
||||
}
|
||||
|
||||
CSSRuleList::CSSRuleList(Bindings::WindowObject& window_object)
|
||||
CSSRuleList::CSSRuleList(HTML::Window& window_object)
|
||||
: Bindings::LegacyPlatformObject(window_object.ensure_web_prototype<Bindings::CSSRuleListPrototype>("CSSRuleList"))
|
||||
{
|
||||
}
|
||||
|
||||
CSSRuleList* CSSRuleList::create_empty(Bindings::WindowObject& window_object)
|
||||
CSSRuleList* CSSRuleList::create_empty(HTML::Window& window_object)
|
||||
{
|
||||
return window_object.heap().allocate<CSSRuleList>(window_object.realm(), window_object);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ DOM::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CS
|
|||
CSSRule* new_rule = nullptr;
|
||||
if (rule.has<StringView>()) {
|
||||
new_rule = parse_css_rule(
|
||||
CSS::Parser::ParsingContext { static_cast<Bindings::WindowObject&>(global_object()) },
|
||||
CSS::Parser::ParsingContext { static_cast<HTML::Window&>(global_object()) },
|
||||
rule.get<StringView>());
|
||||
} else {
|
||||
new_rule = rule.get<CSSRule*>();
|
||||
|
|
|
@ -20,15 +20,13 @@ namespace Web::CSS {
|
|||
|
||||
// https://www.w3.org/TR/cssom/#the-cssrulelist-interface
|
||||
class CSSRuleList : public Bindings::LegacyPlatformObject {
|
||||
JS_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
CSSRuleList& impl() { return *this; }
|
||||
static CSSRuleList* create(HTML::Window&, JS::MarkedVector<CSSRule*> const&);
|
||||
static CSSRuleList* create_empty(HTML::Window&);
|
||||
|
||||
static CSSRuleList* create(Bindings::WindowObject&, JS::MarkedVector<CSSRule*> const&);
|
||||
static CSSRuleList* create_empty(Bindings::WindowObject&);
|
||||
|
||||
explicit CSSRuleList(Bindings::WindowObject&);
|
||||
explicit CSSRuleList(HTML::Window&);
|
||||
~CSSRuleList() = default;
|
||||
|
||||
CSSRule const* item(size_t index) const
|
||||
|
@ -74,7 +72,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSRuleList& object) { return &object; }
|
||||
using CSSRuleListWrapper = Web::CSS::CSSRuleList;
|
||||
}
|
||||
WRAPPER_HACK(CSSRuleList, Web::CSS)
|
||||
|
|
|
@ -5,25 +5,25 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSStyleDeclarationPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSStyleDeclaration::CSSStyleDeclaration(Bindings::WindowObject& window_object)
|
||||
CSSStyleDeclaration::CSSStyleDeclaration(HTML::Window& window_object)
|
||||
: PlatformObject(window_object.ensure_web_prototype<Bindings::CSSStyleDeclarationPrototype>("CSSStyleDeclaration"))
|
||||
{
|
||||
}
|
||||
|
||||
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(Bindings::WindowObject& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(HTML::Window& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
{
|
||||
return window_object.heap().allocate<PropertyOwningCSSStyleDeclaration>(window_object.realm(), window_object, move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(Bindings::WindowObject& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(HTML::Window& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
: CSSStyleDeclaration(window_object)
|
||||
, m_properties(move(properties))
|
||||
, m_custom_properties(move(custom_properties))
|
||||
|
@ -39,16 +39,22 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
|||
|
||||
ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
{
|
||||
auto& window_object = element.document().preferred_window_object();
|
||||
auto& window_object = element.document().window();
|
||||
return window_object.heap().allocate<ElementInlineCSSStyleDeclaration>(window_object.realm(), element, move(properties), move(custom_properties));
|
||||
}
|
||||
|
||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||
: PropertyOwningCSSStyleDeclaration(element.document().preferred_window_object(), move(properties), move(custom_properties))
|
||||
: PropertyOwningCSSStyleDeclaration(element.document().window(), move(properties), move(custom_properties))
|
||||
, m_element(element.make_weak_ptr<DOM::Element>())
|
||||
{
|
||||
}
|
||||
|
||||
void ElementInlineCSSStyleDeclaration::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_element.ptr());
|
||||
}
|
||||
|
||||
size_t PropertyOwningCSSStyleDeclaration::length() const
|
||||
{
|
||||
return m_properties.size();
|
||||
|
|
|
@ -26,13 +26,11 @@ struct StyleProperty {
|
|||
};
|
||||
|
||||
class CSSStyleDeclaration : public Bindings::PlatformObject {
|
||||
JS_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
|
||||
WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
virtual ~CSSStyleDeclaration() = default;
|
||||
|
||||
CSSStyleDeclaration& impl() { return *this; }
|
||||
|
||||
virtual size_t length() const = 0;
|
||||
virtual String item(size_t index) const = 0;
|
||||
|
||||
|
@ -57,16 +55,15 @@ public:
|
|||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
|
||||
|
||||
protected:
|
||||
CSSStyleDeclaration(Bindings::WindowObject&);
|
||||
explicit CSSStyleDeclaration(HTML::Window&);
|
||||
};
|
||||
|
||||
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||
JS_OBJECT(PropertyOwningCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
WEB_PLATFORM_OBJECT(PropertyOwningCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
friend class ElementInlineCSSStyleDeclaration;
|
||||
|
||||
public:
|
||||
static PropertyOwningCSSStyleDeclaration* create(Bindings::WindowObject&, Vector<StyleProperty>, HashMap<String, StyleProperty> custom_properties);
|
||||
PropertyOwningCSSStyleDeclaration(Bindings::WindowObject&, Vector<StyleProperty>, HashMap<String, StyleProperty>);
|
||||
static PropertyOwningCSSStyleDeclaration* create(HTML::Window&, Vector<StyleProperty>, HashMap<String, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
||||
|
||||
|
@ -86,6 +83,8 @@ public:
|
|||
virtual String serialized() const final override;
|
||||
|
||||
protected:
|
||||
PropertyOwningCSSStyleDeclaration(HTML::Window&, Vector<StyleProperty>, HashMap<String, StyleProperty>);
|
||||
|
||||
virtual void update_style_attribute() { }
|
||||
|
||||
private:
|
||||
|
@ -96,11 +95,10 @@ private:
|
|||
};
|
||||
|
||||
class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDeclaration {
|
||||
JS_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
static ElementInlineCSSStyleDeclaration* create(DOM::Element&, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties);
|
||||
explicit ElementInlineCSSStyleDeclaration(DOM::Element&, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~ElementInlineCSSStyleDeclaration() override = default;
|
||||
|
||||
|
@ -110,9 +108,13 @@ public:
|
|||
bool is_updating() const { return m_updating; }
|
||||
|
||||
private:
|
||||
explicit ElementInlineCSSStyleDeclaration(DOM::Element&, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
virtual void update_style_attribute() override;
|
||||
|
||||
WeakPtr<DOM::Element> m_element;
|
||||
JS::GCPtr<DOM::Element> m_element;
|
||||
|
||||
// https://drafts.csswg.org/cssom/#cssstyledeclaration-updating-flag
|
||||
bool m_updating { false };
|
||||
|
@ -120,7 +122,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSStyleDeclaration& object) { return &object; }
|
||||
using CSSStyleDeclarationWrapper = Web::CSS::CSSStyleDeclaration;
|
||||
}
|
||||
WRAPPER_HACK(CSSStyleDeclaration, Web::CSS)
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSStyleRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSStyleRule* CSSStyleRule::create(Bindings::WindowObject& window_object, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
CSSStyleRule* CSSStyleRule::create(HTML::Window& window_object, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
{
|
||||
return window_object.heap().allocate<CSSStyleRule>(window_object.realm(), window_object, move(selectors), declaration);
|
||||
}
|
||||
|
||||
CSSStyleRule::CSSStyleRule(Bindings::WindowObject& window_object, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
CSSStyleRule::CSSStyleRule(HTML::Window& window_object, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
: CSSRule(window_object)
|
||||
, m_selectors(move(selectors))
|
||||
, m_declaration(declaration)
|
||||
|
|
|
@ -16,18 +16,13 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class CSSStyleRule final : public CSSRule {
|
||||
JS_OBJECT(CSSStyleRule, CSSRule);
|
||||
AK_MAKE_NONCOPYABLE(CSSStyleRule);
|
||||
AK_MAKE_NONMOVABLE(CSSStyleRule);
|
||||
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
|
||||
|
||||
public:
|
||||
static CSSStyleRule* create(Bindings::WindowObject&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||
CSSStyleRule(Bindings::WindowObject&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||
static CSSStyleRule* create(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||
|
||||
virtual ~CSSStyleRule() override = default;
|
||||
|
||||
CSSStyleRule& impl() { return *this; }
|
||||
|
||||
NonnullRefPtrVector<Selector> const& selectors() const { return m_selectors; }
|
||||
CSSStyleDeclaration const& declaration() const { return m_declaration; }
|
||||
|
||||
|
@ -39,6 +34,8 @@ public:
|
|||
CSSStyleDeclaration* style();
|
||||
|
||||
private:
|
||||
CSSStyleRule(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
|
||||
|
@ -51,7 +48,4 @@ inline bool CSSRule::fast_is<CSSStyleRule>() const { return type() == CSSRule::T
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSStyleRule& object) { return &object; }
|
||||
using CSSStyleRuleWrapper = Web::CSS::CSSStyleRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSStyleRule, Web::CSS)
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSStyleSheet* CSSStyleSheet::create(Bindings::WindowObject& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
||||
CSSStyleSheet* CSSStyleSheet::create(HTML::Window& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
||||
{
|
||||
return window_object.heap().allocate<CSSStyleSheet>(window_object.realm(), window_object, rules, move(location));
|
||||
}
|
||||
|
||||
CSSStyleSheet::CSSStyleSheet(Bindings::WindowObject& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
||||
CSSStyleSheet::CSSStyleSheet(HTML::Window& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
||||
: StyleSheet(window_object)
|
||||
, m_rules(&rules)
|
||||
{
|
||||
|
|
|
@ -21,16 +21,14 @@ class CSSImportRule;
|
|||
class CSSStyleSheet final
|
||||
: public StyleSheet
|
||||
, public Weakable<CSSStyleSheet> {
|
||||
JS_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
|
||||
public:
|
||||
static CSSStyleSheet* create(Bindings::WindowObject&, CSSRuleList& rules, Optional<AK::URL> location);
|
||||
static CSSStyleSheet* create(HTML::Window&, CSSRuleList& rules, Optional<AK::URL> location);
|
||||
|
||||
explicit CSSStyleSheet(Bindings::WindowObject&, CSSRuleList&, Optional<AK::URL> location);
|
||||
explicit CSSStyleSheet(HTML::Window&, CSSRuleList&, Optional<AK::URL> location);
|
||||
virtual ~CSSStyleSheet() override = default;
|
||||
|
||||
CSSStyleSheet& impl() { return *this; }
|
||||
|
||||
void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; }
|
||||
|
||||
virtual String type() const override { return "text/css"; }
|
||||
|
@ -63,7 +61,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSStyleSheet& object) { return &object; }
|
||||
using CSSStyleSheetWrapper = Web::CSS::CSSStyleSheet;
|
||||
}
|
||||
WRAPPER_HACK(CSSStyleSheet, Web::CSS)
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSSupportsRulePrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
CSSSupportsRule* CSSSupportsRule::create(Bindings::WindowObject& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
CSSSupportsRule* CSSSupportsRule::create(HTML::Window& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
{
|
||||
return window_object.heap().allocate<CSSSupportsRule>(window_object.realm(), window_object, move(supports), rules);
|
||||
}
|
||||
|
||||
CSSSupportsRule::CSSSupportsRule(Bindings::WindowObject& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
CSSSupportsRule::CSSSupportsRule(HTML::Window& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
: CSSConditionRule(window_object, rules)
|
||||
, m_supports(move(supports))
|
||||
{
|
||||
|
|
|
@ -17,18 +17,13 @@ namespace Web::CSS {
|
|||
|
||||
// https://www.w3.org/TR/css-conditional-3/#the-csssupportsrule-interface
|
||||
class CSSSupportsRule final : public CSSConditionRule {
|
||||
JS_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||
AK_MAKE_NONCOPYABLE(CSSSupportsRule);
|
||||
AK_MAKE_NONMOVABLE(CSSSupportsRule);
|
||||
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||
|
||||
public:
|
||||
static CSSSupportsRule* create(Bindings::WindowObject&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
explicit CSSSupportsRule(Bindings::WindowObject&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
static CSSSupportsRule* create(HTML::Window&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
||||
virtual ~CSSSupportsRule() = default;
|
||||
|
||||
CSSSupportsRule& impl() { return *this; }
|
||||
|
||||
virtual Type type() const override { return Type::Supports; };
|
||||
|
||||
String condition_text() const override;
|
||||
|
@ -36,6 +31,8 @@ public:
|
|||
virtual bool condition_matches() const override { return m_supports->matches(); }
|
||||
|
||||
private:
|
||||
explicit CSSSupportsRule(HTML::Window&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
||||
virtual String serialized() const override;
|
||||
|
||||
NonnullRefPtr<Supports> m_supports;
|
||||
|
@ -46,7 +43,4 @@ inline bool CSSRule::fast_is<CSSSupportsRule>() const { return type() == CSSRule
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSSupportsRule& object) { return &object; }
|
||||
using CSSSupportsRuleWrapper = Web::CSS::CSSSupportsRule;
|
||||
}
|
||||
WRAPPER_HACK(CSSSupportsRule, Web::CSS)
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MediaListPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/MediaList.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
MediaList* MediaList::create(Bindings::WindowObject& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
MediaList* MediaList::create(HTML::Window& 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)
|
||||
MediaList::MediaList(HTML::Window& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
: Bindings::LegacyPlatformObject(window_object.ensure_web_prototype<Bindings::MediaListPrototype>("MediaList"))
|
||||
, m_media(move(media))
|
||||
{
|
||||
|
|
|
@ -17,17 +17,12 @@ namespace Web::CSS {
|
|||
|
||||
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
|
||||
class MediaList final : public Bindings::LegacyPlatformObject {
|
||||
AK_MAKE_NONCOPYABLE(MediaList);
|
||||
AK_MAKE_NONMOVABLE(MediaList);
|
||||
JS_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
||||
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static MediaList* create(Bindings::WindowObject&, NonnullRefPtrVector<MediaQuery>&& media);
|
||||
explicit MediaList(Bindings::WindowObject&, NonnullRefPtrVector<MediaQuery>&&);
|
||||
static MediaList* create(HTML::Window&, NonnullRefPtrVector<MediaQuery>&& media);
|
||||
~MediaList() = default;
|
||||
|
||||
MediaList& impl() { return *this; }
|
||||
|
||||
String media_text() const;
|
||||
void set_media_text(String const&);
|
||||
size_t length() const { return m_media.size(); }
|
||||
|
@ -42,12 +37,11 @@ public:
|
|||
bool matches() const;
|
||||
|
||||
private:
|
||||
explicit MediaList(HTML::Window&, NonnullRefPtrVector<MediaQuery>&&);
|
||||
|
||||
NonnullRefPtrVector<MediaQuery> m_media;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::MediaList& object) { return &object; }
|
||||
using MediaListWrapper = Web::CSS::MediaList;
|
||||
}
|
||||
WRAPPER_HACK(MediaList, Web::CSS)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -17,22 +17,11 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
|
||||
class MediaQueryList final
|
||||
: public RefCounted<MediaQueryList>
|
||||
, public Weakable<MediaQueryList>
|
||||
, public DOM::EventTarget
|
||||
, public Bindings::Wrappable {
|
||||
class MediaQueryList final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::MediaQueryListWrapper;
|
||||
|
||||
using RefCounted::ref;
|
||||
using RefCounted::unref;
|
||||
|
||||
static NonnullRefPtr<MediaQueryList> create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media_queries)
|
||||
{
|
||||
return adopt_ref(*new MediaQueryList(document, move(media_queries)));
|
||||
}
|
||||
static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
|
||||
|
||||
virtual ~MediaQueryList() override = default;
|
||||
|
||||
|
@ -40,11 +29,6 @@ public:
|
|||
bool matches() const;
|
||||
bool evaluate();
|
||||
|
||||
// ^EventTarget
|
||||
virtual void ref_event_target() override { ref(); }
|
||||
virtual void unref_event_target() override { unref(); }
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
void add_listener(DOM::IDLEventListener*);
|
||||
void remove_listener(DOM::IDLEventListener*);
|
||||
|
||||
|
@ -54,14 +38,12 @@ public:
|
|||
private:
|
||||
MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
|
||||
|
||||
WeakPtr<DOM::Document> m_document;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
NonnullRefPtrVector<MediaQuery> m_media;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
MediaQueryListWrapper* wrap(JS::Realm&, CSS::MediaQueryList&);
|
||||
|
||||
}
|
||||
WRAPPER_HACK(MediaQueryList, Web::CSS)
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MediaQueryListEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/MediaQueryListEvent.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
MediaQueryListEvent* MediaQueryListEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
MediaQueryListEvent* MediaQueryListEvent::create(HTML::Window& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<MediaQueryListEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent* MediaQueryListEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
MediaQueryListEvent* MediaQueryListEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(Bindings::WindowObject& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
MediaQueryListEvent::MediaQueryListEvent(HTML::Window& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
|
|
|
@ -16,17 +16,15 @@ struct MediaQueryListEventInit : public DOM::EventInit {
|
|||
};
|
||||
|
||||
class MediaQueryListEvent final : public DOM::Event {
|
||||
JS_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
static MediaQueryListEvent* create(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
static MediaQueryListEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
static MediaQueryListEvent* create(HTML::Window&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
static MediaQueryListEvent* create_with_global_object(HTML::Window&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
|
||||
MediaQueryListEvent(Bindings::WindowObject&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
MediaQueryListEvent(HTML::Window&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
MediaQueryListEvent& impl() { return *this; }
|
||||
|
||||
String const& media() const { return m_media; }
|
||||
bool matches() const { return m_matches; }
|
||||
|
||||
|
|
|
@ -44,27 +44,27 @@ ParsingContext::ParsingContext()
|
|||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(Bindings::WindowObject& window_object)
|
||||
ParsingContext::ParsingContext(HTML::Window& window_object)
|
||||
: m_window_object(window_object)
|
||||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url)
|
||||
: m_window_object(document.preferred_window_object())
|
||||
: m_window_object(const_cast<HTML::Window&>(document.window()))
|
||||
, m_document(&document)
|
||||
, m_url(move(url))
|
||||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::Document const& document)
|
||||
: m_window_object(document.preferred_window_object())
|
||||
: m_window_object(const_cast<HTML::Window&>(document.window()))
|
||||
, m_document(&document)
|
||||
, m_url(document.url())
|
||||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::ParentNode& parent_node)
|
||||
: m_window_object(parent_node.document().preferred_window_object())
|
||||
: m_window_object(parent_node.document().window())
|
||||
, m_document(&parent_node.document())
|
||||
, m_url(parent_node.document().url())
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Web::CSS::Parser {
|
|||
class ParsingContext {
|
||||
public:
|
||||
ParsingContext();
|
||||
explicit ParsingContext(Bindings::WindowObject&);
|
||||
explicit ParsingContext(HTML::Window&);
|
||||
explicit ParsingContext(DOM::Document const&);
|
||||
explicit ParsingContext(DOM::Document const&, AK::URL);
|
||||
explicit ParsingContext(DOM::ParentNode&);
|
||||
|
@ -47,10 +47,10 @@ public:
|
|||
PropertyID current_property_id() const { return m_current_property_id; }
|
||||
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
|
||||
|
||||
Bindings::WindowObject& window_object() const { return m_window_object; }
|
||||
HTML::Window& window_object() const { return m_window_object; }
|
||||
|
||||
private:
|
||||
Bindings::WindowObject& m_window_object;
|
||||
HTML::Window& m_window_object;
|
||||
DOM::Document const* m_document { nullptr };
|
||||
PropertyID m_current_property_id { PropertyID::Invalid };
|
||||
AK::URL m_url;
|
||||
|
|
|
@ -21,16 +21,22 @@ namespace Web::CSS {
|
|||
|
||||
ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||
{
|
||||
auto& window_object = element.document().preferred_window_object();
|
||||
auto& window_object = element.document().window();
|
||||
return window_object.heap().allocate<ResolvedCSSStyleDeclaration>(window_object.realm(), element);
|
||||
}
|
||||
|
||||
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
|
||||
: CSSStyleDeclaration(element.document().preferred_window_object())
|
||||
: CSSStyleDeclaration(element.document().window())
|
||||
, m_element(element)
|
||||
{
|
||||
}
|
||||
|
||||
void ResolvedCSSStyleDeclaration::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_element.ptr());
|
||||
}
|
||||
|
||||
size_t ResolvedCSSStyleDeclaration::length() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||
JS_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
static ResolvedCSSStyleDeclaration* create(DOM::Element& element);
|
||||
|
@ -28,9 +28,11 @@ public:
|
|||
virtual String serialized() const override;
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||
|
||||
NonnullRefPtr<DOM::Element> m_element;
|
||||
JS::NonnullGCPtr<DOM::Element> m_element;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
Screen::Screen(HTML::Window& window)
|
||||
: RefCountForwarder(window)
|
||||
: m_window(JS::make_handle(window))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class Screen final
|
||||
: public RefCountForwarder<HTML::Window>
|
||||
: public RefCounted<Screen>
|
||||
, public Bindings::Wrappable {
|
||||
|
||||
public:
|
||||
|
@ -37,9 +37,11 @@ public:
|
|||
private:
|
||||
explicit Screen(HTML::Window&);
|
||||
|
||||
HTML::Window const& window() const { return ref_count_target(); }
|
||||
HTML::Window const& window() const { return *m_window; }
|
||||
|
||||
Gfx::IntRect screen_rect() const;
|
||||
|
||||
JS::Handle<HTML::Window> m_window;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/StyleSheetPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleSheet.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
StyleSheet::StyleSheet(Bindings::WindowObject& window_object)
|
||||
StyleSheet::StyleSheet(HTML::Window& window_object)
|
||||
: PlatformObject(window_object.ensure_web_prototype<Bindings::StyleSheetPrototype>("StyleSheet"))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,11 +13,9 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class StyleSheet : public Bindings::PlatformObject {
|
||||
JS_OBJECT(StyleSheet, Bindings::PlatformObject);
|
||||
WEB_PLATFORM_OBJECT(StyleSheet, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
StyleSheet& impl() { return *this; }
|
||||
|
||||
virtual ~StyleSheet() = default;
|
||||
|
||||
virtual String type() const = 0;
|
||||
|
@ -48,7 +46,7 @@ public:
|
|||
void set_parent_css_style_sheet(CSSStyleSheet*);
|
||||
|
||||
protected:
|
||||
explicit StyleSheet(Bindings::WindowObject&);
|
||||
explicit StyleSheet(HTML::Window&);
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
|
@ -68,7 +66,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::StyleSheet& object) { return &object; }
|
||||
using StyleSheetWrapper = Web::CSS::StyleSheet;
|
||||
}
|
||||
WRAPPER_HACK(StyleSheet, Web::CSS)
|
||||
|
|
|
@ -31,12 +31,12 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
|
|||
|
||||
StyleSheetList* StyleSheetList::create(DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.preferred_window_object().realm();
|
||||
auto& realm = document.window().realm();
|
||||
return realm.heap().allocate<StyleSheetList>(realm, document);
|
||||
}
|
||||
|
||||
StyleSheetList::StyleSheetList(DOM::Document& document)
|
||||
: Bindings::LegacyPlatformObject(document.preferred_window_object().ensure_web_prototype<Bindings::StyleSheetListPrototype>("StyleSheetList"))
|
||||
: Bindings::LegacyPlatformObject(document.window().ensure_web_prototype<Bindings::StyleSheetListPrototype>("StyleSheetList"))
|
||||
, m_document(document)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class StyleSheetList : public Bindings::LegacyPlatformObject {
|
||||
JS_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
|
||||
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
StyleSheetList& impl() { return *this; }
|
||||
static StyleSheetList* create(DOM::Document& document);
|
||||
explicit StyleSheetList(DOM::Document&);
|
||||
|
||||
void add_sheet(CSSStyleSheet&);
|
||||
void remove_sheet(CSSStyleSheet&);
|
||||
|
@ -45,6 +43,8 @@ public:
|
|||
DOM::Document const& document() const { return m_document; }
|
||||
|
||||
private:
|
||||
explicit StyleSheetList(DOM::Document&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
DOM::Document& m_document;
|
||||
|
@ -53,7 +53,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::StyleSheetList& object) { return &object; }
|
||||
using StyleSheetListWrapper = Web::CSS::StyleSheetList;
|
||||
}
|
||||
WRAPPER_HACK(StyleSheetList, Web::CSS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue