mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:18:12 +00:00
LibWeb: Remove unecessary dependence on Window from CSS classes
These classes only needed Window to get at its realm. Pass a realm directly to construct CSS classes.
This commit is contained in:
parent
8de7e49a56
commit
a2ccb00e1d
37 changed files with 159 additions and 146 deletions
|
@ -5,15 +5,16 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSConditionRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSConditionRule.h>
|
#include <LibWeb/CSS/CSSConditionRule.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSConditionRule::CSSConditionRule(HTML::Window& window_object, CSSRuleList& rules)
|
CSSConditionRule::CSSConditionRule(JS::Realm& realm, CSSRuleList& rules)
|
||||||
: CSSGroupingRule(window_object, rules)
|
: CSSGroupingRule(realm, rules)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSConditionRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSConditionRulePrototype>(realm, "CSSConditionRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSConditionRule::for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const
|
void CSSConditionRule::for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const override;
|
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CSSConditionRule(HTML::Window&, CSSRuleList&);
|
CSSConditionRule(JS::Realm&, CSSRuleList&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,23 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSFontFaceRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
||||||
#include <LibWeb/CSS/Serialize.h>
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSFontFaceRule* CSSFontFaceRule::create(HTML::Window& window_object, FontFace&& font_face)
|
CSSFontFaceRule* CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSFontFaceRule>(window_object.realm(), window_object, move(font_face));
|
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSFontFaceRule::CSSFontFaceRule(HTML::Window& window_object, FontFace&& font_face)
|
CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face)
|
||||||
: CSSRule(window_object)
|
: CSSRule(realm)
|
||||||
, m_font_face(move(font_face))
|
, m_font_face(move(font_face))
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSFontFaceRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSFontFaceRulePrototype>(realm, "CSSFontFaceRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSStyleDeclaration* CSSFontFaceRule::style()
|
CSSStyleDeclaration* CSSFontFaceRule::style()
|
||||||
|
|
|
@ -16,7 +16,7 @@ class CSSFontFaceRule final : public CSSRule {
|
||||||
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSFontFaceRule* create(HTML::Window&, FontFace&&);
|
static CSSFontFaceRule* create(JS::Realm&, FontFace&&);
|
||||||
|
|
||||||
virtual ~CSSFontFaceRule() override = default;
|
virtual ~CSSFontFaceRule() override = default;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
CSSStyleDeclaration* style();
|
CSSStyleDeclaration* style();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CSSFontFaceRule(HTML::Window&, FontFace&&);
|
CSSFontFaceRule(JS::Realm&, FontFace&&);
|
||||||
|
|
||||||
virtual String serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSGroupingRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
#include <LibWeb/CSS/CSSGroupingRule.h>
|
#include <LibWeb/CSS/CSSGroupingRule.h>
|
||||||
#include <LibWeb/CSS/CSSRuleList.h>
|
#include <LibWeb/CSS/CSSRuleList.h>
|
||||||
|
@ -12,11 +14,11 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSGroupingRule::CSSGroupingRule(HTML::Window& window_object, CSSRuleList& rules)
|
CSSGroupingRule::CSSGroupingRule(JS::Realm& realm, CSSRuleList& rules)
|
||||||
: CSSRule(window_object)
|
: CSSRule(realm)
|
||||||
, m_rules(rules)
|
, m_rules(rules)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSGroupingRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSGroupingRulePrototype>(realm, "CSSGroupingRule"));
|
||||||
for (auto& rule : m_rules)
|
for (auto& rule : m_rules)
|
||||||
rule.set_parent_rule(this);
|
rule.set_parent_rule(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CSSGroupingRule(HTML::Window&, CSSRuleList&);
|
CSSGroupingRule(JS::Realm&, CSSRuleList&);
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
|
#include <LibWeb/Bindings/CSSImportRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSImportRule.h>
|
#include <LibWeb/CSS/CSSImportRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
@ -18,16 +20,16 @@ namespace Web::CSS {
|
||||||
|
|
||||||
CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document)
|
CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||||
{
|
{
|
||||||
auto& window_object = document.window();
|
auto& realm = document.realm();
|
||||||
return window_object.heap().allocate<CSSImportRule>(window_object.realm(), move(url), document);
|
return realm.heap().allocate<CSSImportRule>(realm, move(url), document);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
||||||
: CSSRule(document.window())
|
: CSSRule(document.realm())
|
||||||
, m_url(move(url))
|
, m_url(move(url))
|
||||||
, m_document(document)
|
, m_document(document)
|
||||||
{
|
{
|
||||||
set_prototype(&document.window().cached_web_prototype("CSSImportRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSImportRulePrototype>(document.realm(), "CSSImportRule"));
|
||||||
|
|
||||||
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Loading import URL: {}", m_url);
|
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Loading import URL: {}", m_url);
|
||||||
auto request = LoadRequest::create_for_url_on_page(m_url, document.page());
|
auto request = LoadRequest::create_for_url_on_page(m_url, document.page());
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibJS/Heap/Handle.h>
|
|
||||||
#include <LibWeb/CSS/CSSRule.h>
|
#include <LibWeb/CSS/CSSRule.h>
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
||||||
|
|
|
@ -5,21 +5,23 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
|
#include <LibWeb/Bindings/CSSMediaRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSMediaRule* CSSMediaRule::create(HTML::Window& window_object, MediaList& media_queries, CSSRuleList& rules)
|
CSSMediaRule* CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSMediaRule>(window_object.realm(), window_object, media_queries, rules);
|
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSMediaRule::CSSMediaRule(HTML::Window& window_object, MediaList& media, CSSRuleList& rules)
|
CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules)
|
||||||
: CSSConditionRule(window_object, rules)
|
: CSSConditionRule(realm, rules)
|
||||||
, m_media(media)
|
, m_media(media)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSMediaRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSMediaRulePrototype>(realm, "CSSMediaRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSMediaRule::visit_edges(Cell::Visitor& visitor)
|
void CSSMediaRule::visit_edges(Cell::Visitor& visitor)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CSSMediaRule final : public CSSConditionRule {
|
||||||
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSMediaRule* create(HTML::Window&, MediaList& media_queries, CSSRuleList&);
|
static CSSMediaRule* create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||||
|
|
||||||
virtual ~CSSMediaRule() = default;
|
virtual ~CSSMediaRule() = default;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
||||||
bool evaluate(HTML::Window const& window) { return m_media.evaluate(window); }
|
bool evaluate(HTML::Window const& window) { return m_media.evaluate(window); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CSSMediaRule(HTML::Window&, MediaList&, CSSRuleList&);
|
CSSMediaRule(JS::Realm&, MediaList&, CSSRuleList&);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
virtual String serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
|
|
||||||
#include <LibWeb/CSS/CSSRule.h>
|
#include <LibWeb/CSS/CSSRule.h>
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSRule::CSSRule(HTML::Window& window_object)
|
CSSRule::CSSRule(JS::Realm& realm)
|
||||||
: PlatformObject(window_object.cached_web_prototype("CSSRule"))
|
: PlatformObject(realm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
class CSSRule : public Bindings::PlatformObject {
|
class CSSRule : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(CSSRule, JS::Object);
|
WEB_PLATFORM_OBJECT(CSSRule, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~CSSRule() = default;
|
virtual ~CSSRule() = default;
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
bool fast_is() const = delete;
|
bool fast_is() const = delete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CSSRule(HTML::Window&);
|
explicit CSSRule(JS::Realm&);
|
||||||
|
|
||||||
virtual String serialized() const = 0;
|
virtual String serialized() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/TypeCasts.h>
|
#include <AK/TypeCasts.h>
|
||||||
|
#include <LibWeb/Bindings/CSSRuleListPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSImportRule.h>
|
#include <LibWeb/CSS/CSSImportRule.h>
|
||||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||||
#include <LibWeb/CSS/CSSRule.h>
|
#include <LibWeb/CSS/CSSRule.h>
|
||||||
|
@ -15,22 +17,22 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSRuleList* CSSRuleList::create(HTML::Window& window_object, JS::MarkedVector<CSSRule*> const& rules)
|
CSSRuleList* CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||||
{
|
{
|
||||||
auto* rule_list = window_object.heap().allocate<CSSRuleList>(window_object.realm(), window_object);
|
auto* rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||||
for (auto* rule : rules)
|
for (auto* rule : rules)
|
||||||
rule_list->m_rules.append(*rule);
|
rule_list->m_rules.append(*rule);
|
||||||
return rule_list;
|
return rule_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSRuleList::CSSRuleList(HTML::Window& window_object)
|
CSSRuleList::CSSRuleList(JS::Realm& realm)
|
||||||
: Bindings::LegacyPlatformObject(window_object.cached_web_prototype("CSSRuleList"))
|
: Bindings::LegacyPlatformObject(Bindings::ensure_web_prototype<Bindings::CSSRuleListPrototype>(realm, "CSSRuleList"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSRuleList* CSSRuleList::create_empty(HTML::Window& window_object)
|
CSSRuleList* CSSRuleList::create_empty(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSRuleList>(window_object.realm(), window_object);
|
return realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSRuleList::visit_edges(Cell::Visitor& visitor)
|
void CSSRuleList::visit_edges(Cell::Visitor& visitor)
|
||||||
|
@ -55,7 +57,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
|
||||||
|
|
||||||
// 2. If index is greater than length, then throw an IndexSizeError exception.
|
// 2. If index is greater than length, then throw an IndexSizeError exception.
|
||||||
if (index > length)
|
if (index > length)
|
||||||
return WebIDL::IndexSizeError::create(global_object(), "CSS rule index out of bounds.");
|
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds.");
|
||||||
|
|
||||||
// 3. Set new rule to the results of performing parse a CSS rule on argument rule.
|
// 3. Set new rule to the results of performing parse a CSS rule on argument rule.
|
||||||
// NOTE: The insert-a-css-rule spec expects `rule` to be a string, but the CSSStyleSheet.insertRule()
|
// NOTE: The insert-a-css-rule spec expects `rule` to be a string, but the CSSStyleSheet.insertRule()
|
||||||
|
@ -64,7 +66,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
|
||||||
CSSRule* new_rule = nullptr;
|
CSSRule* new_rule = nullptr;
|
||||||
if (rule.has<StringView>()) {
|
if (rule.has<StringView>()) {
|
||||||
new_rule = parse_css_rule(
|
new_rule = parse_css_rule(
|
||||||
CSS::Parser::ParsingContext { static_cast<HTML::Window&>(global_object()) },
|
CSS::Parser::ParsingContext { realm() },
|
||||||
rule.get<StringView>());
|
rule.get<StringView>());
|
||||||
} else {
|
} else {
|
||||||
new_rule = rule.get<CSSRule*>();
|
new_rule = rule.get<CSSRule*>();
|
||||||
|
@ -72,7 +74,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
|
||||||
|
|
||||||
// 4. If new rule is a syntax error, throw a SyntaxError exception.
|
// 4. If new rule is a syntax error, throw a SyntaxError exception.
|
||||||
if (!new_rule)
|
if (!new_rule)
|
||||||
return WebIDL::SyntaxError::create(global_object(), "Unable to parse CSS rule.");
|
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule.");
|
||||||
|
|
||||||
// FIXME: 5. If new rule cannot be inserted into list at the zero-index position index due to constraints specified by CSS, then throw a HierarchyRequestError exception. [CSS21]
|
// FIXME: 5. If new rule cannot be inserted into list at the zero-index position index due to constraints specified by CSS, then throw a HierarchyRequestError exception. [CSS21]
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
|
||||||
|
|
||||||
// 2. If index is greater than or equal to length, then throw an IndexSizeError exception.
|
// 2. If index is greater than or equal to length, then throw an IndexSizeError exception.
|
||||||
if (index >= length)
|
if (index >= length)
|
||||||
return WebIDL::IndexSizeError::create(global_object(), "CSS rule index out of bounds.");
|
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds.");
|
||||||
|
|
||||||
// 3. Set old rule to the indexth item in list.
|
// 3. Set old rule to the indexth item in list.
|
||||||
CSSRule& old_rule = m_rules[index];
|
CSSRule& old_rule = m_rules[index];
|
||||||
|
|
|
@ -23,10 +23,9 @@ class CSSRuleList : public Bindings::LegacyPlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSRuleList* create(HTML::Window&, JS::MarkedVector<CSSRule*> const&);
|
static CSSRuleList* create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);
|
||||||
static CSSRuleList* create_empty(HTML::Window&);
|
static CSSRuleList* create_empty(JS::Realm&);
|
||||||
|
|
||||||
explicit CSSRuleList(HTML::Window&);
|
|
||||||
~CSSRuleList() = default;
|
~CSSRuleList() = default;
|
||||||
|
|
||||||
CSSRule const* item(size_t index) const
|
CSSRule const* item(size_t index) const
|
||||||
|
@ -65,6 +64,8 @@ public:
|
||||||
bool evaluate_media_queries(HTML::Window const&);
|
bool evaluate_media_queries(HTML::Window const&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit CSSRuleList(JS::Realm&);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
Vector<CSSRule&> m_rules;
|
Vector<CSSRule&> m_rules;
|
||||||
|
|
|
@ -4,26 +4,27 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSStyleDeclarationPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSStyleDeclaration::CSSStyleDeclaration(HTML::Window& window_object)
|
CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
|
||||||
: PlatformObject(window_object.cached_web_prototype("CSSStyleDeclaration"))
|
: PlatformObject(Bindings::ensure_web_prototype<Bindings::CSSStyleDeclarationPrototype>(realm, "CSSStyleDeclaration"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(HTML::Window& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<PropertyOwningCSSStyleDeclaration>(window_object.realm(), window_object, move(properties), move(custom_properties));
|
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(HTML::Window& window_object, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||||
: CSSStyleDeclaration(window_object)
|
: CSSStyleDeclaration(realm)
|
||||||
, m_properties(move(properties))
|
, m_properties(move(properties))
|
||||||
, m_custom_properties(move(custom_properties))
|
, m_custom_properties(move(custom_properties))
|
||||||
{
|
{
|
||||||
|
@ -38,12 +39,12 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
||||||
|
|
||||||
ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||||
{
|
{
|
||||||
auto& window_object = element.document().window();
|
auto& realm = element.realm();
|
||||||
return window_object.heap().allocate<ElementInlineCSSStyleDeclaration>(window_object.realm(), element, move(properties), move(custom_properties));
|
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
|
||||||
: PropertyOwningCSSStyleDeclaration(element.document().window(), move(properties), move(custom_properties))
|
: PropertyOwningCSSStyleDeclaration(element.realm(), move(properties), move(custom_properties))
|
||||||
, m_element(element.make_weak_ptr<DOM::Element>())
|
, m_element(element.make_weak_ptr<DOM::Element>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CSSStyleDeclaration(HTML::Window&);
|
explicit CSSStyleDeclaration(JS::Realm&);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||||
|
@ -63,7 +63,7 @@ class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||||
friend class ElementInlineCSSStyleDeclaration;
|
friend class ElementInlineCSSStyleDeclaration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PropertyOwningCSSStyleDeclaration* create(HTML::Window&, Vector<StyleProperty>, HashMap<String, StyleProperty> custom_properties);
|
static PropertyOwningCSSStyleDeclaration* create(JS::Realm&, Vector<StyleProperty>, HashMap<String, StyleProperty> custom_properties);
|
||||||
|
|
||||||
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
virtual String serialized() const final override;
|
virtual String serialized() const final override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PropertyOwningCSSStyleDeclaration(HTML::Window&, Vector<StyleProperty>, HashMap<String, StyleProperty>);
|
PropertyOwningCSSStyleDeclaration(JS::Realm&, Vector<StyleProperty>, HashMap<String, StyleProperty>);
|
||||||
|
|
||||||
virtual void update_style_attribute() { }
|
virtual void update_style_attribute() { }
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
bool is_updating() const { return m_updating; }
|
bool is_updating() const { return m_updating; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ElementInlineCSSStyleDeclaration(DOM::Element&, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties);
|
ElementInlineCSSStyleDeclaration(DOM::Element&, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
|
|
@ -4,23 +4,24 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSStyleRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSStyleRule* CSSStyleRule::create(HTML::Window& window_object, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
|
CSSStyleRule* CSSStyleRule::create(JS::Realm& realm, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSStyleRule>(window_object.realm(), window_object, move(selectors), declaration);
|
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSStyleRule::CSSStyleRule(HTML::Window& window_object, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
|
CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||||
: CSSRule(window_object)
|
: CSSRule(realm)
|
||||||
, m_selectors(move(selectors))
|
, m_selectors(move(selectors))
|
||||||
, m_declaration(declaration)
|
, m_declaration(declaration)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSStyleRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleRulePrototype>(realm, "CSSStyleRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSStyleRule::visit_edges(Cell::Visitor& visitor)
|
void CSSStyleRule::visit_edges(Cell::Visitor& visitor)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class CSSStyleRule final : public CSSRule {
|
||||||
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
|
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSStyleRule* create(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
static CSSStyleRule* create(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||||
|
|
||||||
virtual ~CSSStyleRule() override = default;
|
virtual ~CSSStyleRule() override = default;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
CSSStyleDeclaration* style();
|
CSSStyleDeclaration* style();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSSStyleRule(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
CSSStyleRule(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
virtual String serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSStyleSheetPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/StyleSheetList.h>
|
#include <LibWeb/CSS/StyleSheetList.h>
|
||||||
|
@ -12,16 +14,16 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSStyleSheet* CSSStyleSheet::create(HTML::Window& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
CSSStyleSheet* CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, Optional<AK::URL> location)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSStyleSheet>(window_object.realm(), window_object, rules, move(location));
|
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, move(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSStyleSheet::CSSStyleSheet(HTML::Window& window_object, CSSRuleList& rules, Optional<AK::URL> location)
|
CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, Optional<AK::URL> location)
|
||||||
: StyleSheet(window_object)
|
: StyleSheet(realm)
|
||||||
, m_rules(&rules)
|
, m_rules(&rules)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSStyleSheet"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleSheetPrototype>(realm, "CSSStyleSheet"));
|
||||||
|
|
||||||
if (location.has_value())
|
if (location.has_value())
|
||||||
set_location(location->to_string());
|
set_location(location->to_string());
|
||||||
|
@ -50,7 +52,7 @@ WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsign
|
||||||
|
|
||||||
// 4. If parsed rule is a syntax error, return parsed rule.
|
// 4. If parsed rule is a syntax error, return parsed rule.
|
||||||
if (!parsed_rule)
|
if (!parsed_rule)
|
||||||
return WebIDL::SyntaxError::create(global_object(), "Unable to parse CSS rule.");
|
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule.");
|
||||||
|
|
||||||
// FIXME: 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
|
// FIXME: 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@ class CSSStyleSheet final
|
||||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSStyleSheet* create(HTML::Window&, CSSRuleList& rules, Optional<AK::URL> location);
|
static CSSStyleSheet* create(JS::Realm&, CSSRuleList& rules, Optional<AK::URL> location);
|
||||||
|
|
||||||
explicit CSSStyleSheet(HTML::Window&, CSSRuleList&, Optional<AK::URL> location);
|
|
||||||
virtual ~CSSStyleSheet() override = default;
|
virtual ~CSSStyleSheet() override = default;
|
||||||
|
|
||||||
void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; }
|
void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; }
|
||||||
|
@ -51,6 +50,8 @@ public:
|
||||||
void set_style_sheet_list(Badge<StyleSheetList>, StyleSheetList*);
|
void set_style_sheet_list(Badge<StyleSheetList>, StyleSheetList*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CSSStyleSheet(JS::Realm&, CSSRuleList&, Optional<AK::URL> location);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
CSSRuleList* m_rules { nullptr };
|
CSSRuleList* m_rules { nullptr };
|
||||||
|
|
|
@ -4,22 +4,23 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/CSSSupportsRulePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
CSSSupportsRule* CSSSupportsRule::create(HTML::Window& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
CSSSupportsRule* CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<CSSSupportsRule>(window_object.realm(), window_object, move(supports), rules);
|
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSSupportsRule::CSSSupportsRule(HTML::Window& window_object, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||||
: CSSConditionRule(window_object, rules)
|
: CSSConditionRule(realm, rules)
|
||||||
, m_supports(move(supports))
|
, m_supports(move(supports))
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("CSSSupportsRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSSupportsRulePrototype>(realm, "CSSSupportsRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String CSSSupportsRule::condition_text() const
|
String CSSSupportsRule::condition_text() const
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CSSSupportsRule final : public CSSConditionRule {
|
||||||
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSSSupportsRule* create(HTML::Window&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
static CSSSupportsRule* create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||||
|
|
||||||
virtual ~CSSSupportsRule() = default;
|
virtual ~CSSSupportsRule() = default;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual bool condition_matches() const override { return m_supports->matches(); }
|
virtual bool condition_matches() const override { return m_supports->matches(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CSSSupportsRule(HTML::Window&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||||
|
|
||||||
virtual String serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,20 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Bindings/MediaListPrototype.h>
|
||||||
#include <LibWeb/CSS/MediaList.h>
|
#include <LibWeb/CSS/MediaList.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
MediaList* MediaList::create(HTML::Window& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
MediaList* MediaList::create(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<MediaList>(window_object.realm(), window_object, move(media));
|
return realm.heap().allocate<MediaList>(realm, realm, move(media));
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaList::MediaList(HTML::Window& window_object, NonnullRefPtrVector<MediaQuery>&& media)
|
MediaList::MediaList(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
|
||||||
: Bindings::LegacyPlatformObject(window_object.cached_web_prototype("MediaList"))
|
: Bindings::LegacyPlatformObject(Bindings::ensure_web_prototype<Bindings::MediaListPrototype>(realm, "MediaList"))
|
||||||
, m_media(move(media))
|
, m_media(move(media))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MediaList final : public Bindings::LegacyPlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MediaList* create(HTML::Window&, NonnullRefPtrVector<MediaQuery>&& media);
|
static MediaList* create(JS::Realm&, NonnullRefPtrVector<MediaQuery>&& media);
|
||||||
~MediaList() = default;
|
~MediaList() = default;
|
||||||
|
|
||||||
String media_text() const;
|
String media_text() const;
|
||||||
|
@ -37,7 +37,7 @@ public:
|
||||||
bool matches() const;
|
bool matches() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit MediaList(HTML::Window&, NonnullRefPtrVector<MediaQuery>&&);
|
MediaList(JS::Realm&, NonnullRefPtrVector<MediaQuery>&&);
|
||||||
|
|
||||||
NonnullRefPtrVector<MediaQuery> m_media;
|
NonnullRefPtrVector<MediaQuery> m_media;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Bindings/MediaQueryListPrototype.h>
|
||||||
#include <LibWeb/CSS/MediaQueryList.h>
|
#include <LibWeb/CSS/MediaQueryList.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/EventDispatcher.h>
|
#include <LibWeb/DOM/EventDispatcher.h>
|
||||||
|
@ -23,7 +25,7 @@ MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<Medi
|
||||||
, m_document(document)
|
, m_document(document)
|
||||||
, m_media(move(media))
|
, m_media(move(media))
|
||||||
{
|
{
|
||||||
set_prototype(&document.window().cached_web_prototype("MediaQueryList"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListPrototype>(document.realm(), "MediaQueryList"));
|
||||||
evaluate();
|
evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,28 +4,23 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Bindings/MediaQueryListEventPrototype.h>
|
#include <LibWeb/Bindings/MediaQueryListEventPrototype.h>
|
||||||
#include <LibWeb/CSS/MediaQueryListEvent.h>
|
#include <LibWeb/CSS/MediaQueryListEvent.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
MediaQueryListEvent* MediaQueryListEvent::create(HTML::Window& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
MediaQueryListEvent* MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return window_object.heap().allocate<MediaQueryListEvent>(window_object.realm(), window_object, event_name, event_init);
|
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaQueryListEvent* MediaQueryListEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||||
{
|
: DOM::Event(realm, event_name, event_init)
|
||||||
return create(window_object, event_name, 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_media(event_init.media)
|
||||||
, m_matches(event_init.matches)
|
, m_matches(event_init.matches)
|
||||||
{
|
{
|
||||||
set_prototype(&window_object.cached_web_prototype("MediaQueryListEvent"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListEventPrototype>(realm, "MediaQueryListEvent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaQueryListEvent::~MediaQueryListEvent() = default;
|
MediaQueryListEvent::~MediaQueryListEvent() = default;
|
||||||
|
|
|
@ -19,16 +19,16 @@ class MediaQueryListEvent final : public DOM::Event {
|
||||||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MediaQueryListEvent* create(HTML::Window&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
static MediaQueryListEvent* construct_impl(JS::Realm&, 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(HTML::Window&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
|
||||||
virtual ~MediaQueryListEvent() override;
|
virtual ~MediaQueryListEvent() override;
|
||||||
|
|
||||||
String const& media() const { return m_media; }
|
String const& media() const { return m_media; }
|
||||||
bool matches() const { return m_matches; }
|
bool matches() const { return m_matches; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MediaQueryListEvent(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||||
|
|
||||||
String m_media;
|
String m_media;
|
||||||
bool m_matches;
|
bool m_matches;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,31 +40,31 @@ static void log_parse_error(SourceLocation const& location = SourceLocation::cur
|
||||||
namespace Web::CSS::Parser {
|
namespace Web::CSS::Parser {
|
||||||
|
|
||||||
ParsingContext::ParsingContext()
|
ParsingContext::ParsingContext()
|
||||||
: m_window_object(Bindings::main_thread_internal_window_object())
|
: m_realm(*Bindings::main_thread_vm().current_realm())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsingContext::ParsingContext(HTML::Window& window_object)
|
ParsingContext::ParsingContext(JS::Realm& realm)
|
||||||
: m_window_object(window_object)
|
: m_realm(realm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url)
|
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url)
|
||||||
: m_window_object(const_cast<HTML::Window&>(document.window()))
|
: m_realm(const_cast<JS::Realm&>(document.realm()))
|
||||||
, m_document(&document)
|
, m_document(&document)
|
||||||
, m_url(move(url))
|
, m_url(move(url))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsingContext::ParsingContext(DOM::Document const& document)
|
ParsingContext::ParsingContext(DOM::Document const& document)
|
||||||
: m_window_object(const_cast<HTML::Window&>(document.window()))
|
: m_realm(const_cast<JS::Realm&>(document.realm()))
|
||||||
, m_document(&document)
|
, m_document(&document)
|
||||||
, m_url(document.url())
|
, m_url(document.url())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsingContext::ParsingContext(DOM::ParentNode& parent_node)
|
ParsingContext::ParsingContext(DOM::ParentNode& parent_node)
|
||||||
: m_window_object(parent_node.document().window())
|
: m_realm(parent_node.realm())
|
||||||
, m_document(&parent_node.document())
|
, m_document(&parent_node.document())
|
||||||
, m_url(parent_node.document().url())
|
, m_url(parent_node.document().url())
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<AK::URL> location)
|
||||||
auto style_sheet = parse_a_stylesheet(m_token_stream, {});
|
auto style_sheet = parse_a_stylesheet(m_token_stream, {});
|
||||||
|
|
||||||
// Interpret all of the resulting top-level qualified rules as style rules, defined below.
|
// Interpret all of the resulting top-level qualified rules as style rules, defined below.
|
||||||
JS::MarkedVector<CSSRule*> rules(m_context.window_object().heap());
|
JS::MarkedVector<CSSRule*> rules(m_context.realm().heap());
|
||||||
for (auto& raw_rule : style_sheet.rules) {
|
for (auto& raw_rule : style_sheet.rules) {
|
||||||
auto* rule = convert_to_rule(raw_rule);
|
auto* rule = convert_to_rule(raw_rule);
|
||||||
// If any style rule is invalid, or any at-rule is not recognized or is invalid according to its grammar or context, it’s a parse error. Discard that rule.
|
// If any style rule is invalid, or any at-rule is not recognized or is invalid according to its grammar or context, it’s a parse error. Discard that rule.
|
||||||
|
@ -126,8 +126,8 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<AK::URL> location)
|
||||||
rules.append(rule);
|
rules.append(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* rule_list = CSSRuleList::create(m_context.window_object(), rules);
|
auto* rule_list = CSSRuleList::create(m_context.realm(), rules);
|
||||||
return CSSStyleSheet::create(m_context.window_object(), *rule_list, move(location));
|
return CSSStyleSheet::create(m_context.realm(), *rule_list, move(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<SelectorList> Parser::parse_as_selector(SelectorParsingMode parsing_mode)
|
Optional<SelectorList> Parser::parse_as_selector(SelectorParsingMode parsing_mode)
|
||||||
|
@ -2561,13 +2561,13 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
||||||
|
|
||||||
auto child_tokens = TokenStream { rule->block()->values() };
|
auto child_tokens = TokenStream { rule->block()->values() };
|
||||||
auto parser_rules = parse_a_list_of_rules(child_tokens);
|
auto parser_rules = parse_a_list_of_rules(child_tokens);
|
||||||
JS::MarkedVector<CSSRule*> child_rules(m_context.window_object().heap());
|
JS::MarkedVector<CSSRule*> child_rules(m_context.realm().heap());
|
||||||
for (auto& raw_rule : parser_rules) {
|
for (auto& raw_rule : parser_rules) {
|
||||||
if (auto* child_rule = convert_to_rule(raw_rule))
|
if (auto* child_rule = convert_to_rule(raw_rule))
|
||||||
child_rules.append(child_rule);
|
child_rules.append(child_rule);
|
||||||
}
|
}
|
||||||
auto* rule_list = CSSRuleList::create(m_context.window_object(), child_rules);
|
auto* rule_list = CSSRuleList::create(m_context.realm(), child_rules);
|
||||||
return CSSMediaRule::create(m_context.window_object(), *MediaList::create(m_context.window_object(), move(media_query_list)), *rule_list);
|
return CSSMediaRule::create(m_context.realm(), *MediaList::create(m_context.realm(), move(media_query_list)), *rule_list);
|
||||||
}
|
}
|
||||||
if (rule->at_rule_name().equals_ignoring_case("supports"sv)) {
|
if (rule->at_rule_name().equals_ignoring_case("supports"sv)) {
|
||||||
auto supports_tokens = TokenStream { rule->prelude() };
|
auto supports_tokens = TokenStream { rule->prelude() };
|
||||||
|
@ -2584,14 +2584,14 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
||||||
return {};
|
return {};
|
||||||
auto child_tokens = TokenStream { rule->block()->values() };
|
auto child_tokens = TokenStream { rule->block()->values() };
|
||||||
auto parser_rules = parse_a_list_of_rules(child_tokens);
|
auto parser_rules = parse_a_list_of_rules(child_tokens);
|
||||||
JS::MarkedVector<CSSRule*> child_rules(m_context.window_object().heap());
|
JS::MarkedVector<CSSRule*> child_rules(m_context.realm().heap());
|
||||||
for (auto& raw_rule : parser_rules) {
|
for (auto& raw_rule : parser_rules) {
|
||||||
if (auto* child_rule = convert_to_rule(raw_rule))
|
if (auto* child_rule = convert_to_rule(raw_rule))
|
||||||
child_rules.append(child_rule);
|
child_rules.append(child_rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* rule_list = CSSRuleList::create(m_context.window_object(), child_rules);
|
auto* rule_list = CSSRuleList::create(m_context.realm(), child_rules);
|
||||||
return CSSSupportsRule::create(m_context.window_object(), supports.release_nonnull(), *rule_list);
|
return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), *rule_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: More at rules!
|
// FIXME: More at rules!
|
||||||
|
@ -2629,7 +2629,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return CSSStyleRule::create(m_context.window_object(), move(selectors.value()), *declaration);
|
return CSSStyleRule::create(m_context.realm(), move(selectors.value()), *declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_and_at_rules) -> PropertiesAndCustomProperties
|
auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_and_at_rules) -> PropertiesAndCustomProperties
|
||||||
|
@ -2658,7 +2658,7 @@ auto Parser::extract_properties(Vector<DeclarationOrAtRule> const& declarations_
|
||||||
PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector<DeclarationOrAtRule> const& declarations_and_at_rules)
|
PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector<DeclarationOrAtRule> const& declarations_and_at_rules)
|
||||||
{
|
{
|
||||||
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
auto [properties, custom_properties] = extract_properties(declarations_and_at_rules);
|
||||||
return PropertyOwningCSSStyleDeclaration::create(m_context.window_object(), move(properties), move(custom_properties));
|
return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
||||||
|
@ -4890,7 +4890,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
|
||||||
unicode_range.empend(0x0u, 0x10FFFFu);
|
unicode_range.empend(0x0u, 0x10FFFFu);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CSSFontFaceRule::create(m_context.window_object(), FontFace { font_family.release_value(), move(src), move(unicode_range) });
|
return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), move(src), move(unicode_range) });
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values)
|
Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values)
|
||||||
|
@ -6505,7 +6505,7 @@ namespace Web {
|
||||||
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<AK::URL> location)
|
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<AK::URL> location)
|
||||||
{
|
{
|
||||||
if (css.is_empty())
|
if (css.is_empty())
|
||||||
return CSS::CSSStyleSheet::create(context.window_object(), *CSS::CSSRuleList::create_empty(context.window_object()), location);
|
return CSS::CSSStyleSheet::create(context.realm(), *CSS::CSSRuleList::create_empty(context.realm()), location);
|
||||||
CSS::Parser::Parser parser(context, css);
|
CSS::Parser::Parser parser(context, css);
|
||||||
return parser.parse_as_css_stylesheet(location);
|
return parser.parse_as_css_stylesheet(location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Web::CSS::Parser {
|
||||||
class ParsingContext {
|
class ParsingContext {
|
||||||
public:
|
public:
|
||||||
ParsingContext();
|
ParsingContext();
|
||||||
explicit ParsingContext(HTML::Window&);
|
explicit ParsingContext(JS::Realm&);
|
||||||
explicit ParsingContext(DOM::Document const&);
|
explicit ParsingContext(DOM::Document const&);
|
||||||
explicit ParsingContext(DOM::Document const&, AK::URL);
|
explicit ParsingContext(DOM::Document const&, AK::URL);
|
||||||
explicit ParsingContext(DOM::ParentNode&);
|
explicit ParsingContext(DOM::ParentNode&);
|
||||||
|
@ -48,10 +48,10 @@ public:
|
||||||
PropertyID current_property_id() const { return m_current_property_id; }
|
PropertyID current_property_id() const { return m_current_property_id; }
|
||||||
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
|
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
|
||||||
|
|
||||||
HTML::Window& window_object() const { return m_window_object; }
|
JS::Realm& realm() const { return m_realm; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTML::Window& m_window_object;
|
JS::Realm& m_realm;
|
||||||
DOM::Document const* m_document { nullptr };
|
DOM::Document const* m_document { nullptr };
|
||||||
PropertyID m_current_property_id { PropertyID::Invalid };
|
PropertyID m_current_property_id { PropertyID::Invalid };
|
||||||
AK::URL m_url;
|
AK::URL m_url;
|
||||||
|
|
|
@ -21,12 +21,11 @@ namespace Web::CSS {
|
||||||
|
|
||||||
ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||||
{
|
{
|
||||||
auto& window_object = element.document().window();
|
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element);
|
||||||
return window_object.heap().allocate<ResolvedCSSStyleDeclaration>(window_object.realm(), element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
|
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
|
||||||
: CSSStyleDeclaration(element.document().window())
|
: CSSStyleDeclaration(element.realm())
|
||||||
, m_element(element)
|
, m_element(element)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -541,14 +540,14 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
|
||||||
WebIDL::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
|
WebIDL::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
|
||||||
{
|
{
|
||||||
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
|
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
|
||||||
return WebIDL::NoModificationAllowedError::create(global_object(), "Cannot modify properties in result of getComputedStyle()");
|
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()");
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
|
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
|
||||||
WebIDL::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
|
WebIDL::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
|
||||||
{
|
{
|
||||||
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
|
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
|
||||||
return WebIDL::NoModificationAllowedError::create(global_object(), "Cannot remove properties from result of getComputedStyle()");
|
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove properties from result of getComputedStyle()");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ResolvedCSSStyleDeclaration::serialized() const
|
String ResolvedCSSStyleDeclaration::serialized() const
|
||||||
|
|
|
@ -15,7 +15,6 @@ class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ResolvedCSSStyleDeclaration* create(DOM::Element& element);
|
static ResolvedCSSStyleDeclaration* create(DOM::Element& element);
|
||||||
explicit ResolvedCSSStyleDeclaration(DOM::Element&);
|
|
||||||
|
|
||||||
virtual ~ResolvedCSSStyleDeclaration() override = default;
|
virtual ~ResolvedCSSStyleDeclaration() override = default;
|
||||||
|
|
||||||
|
@ -28,6 +27,8 @@ public:
|
||||||
virtual String serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit ResolvedCSSStyleDeclaration(DOM::Element&);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Bindings/ScreenPrototype.h>
|
||||||
#include <LibWeb/CSS/Screen.h>
|
#include <LibWeb/CSS/Screen.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/Page/Page.h>
|
#include <LibWeb/Page/Page.h>
|
||||||
|
@ -20,7 +22,7 @@ Screen::Screen(HTML::Window& window)
|
||||||
: PlatformObject(window.realm())
|
: PlatformObject(window.realm())
|
||||||
, m_window(window)
|
, m_window(window)
|
||||||
{
|
{
|
||||||
set_prototype(&window.cached_web_prototype("Screen"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(window.realm(), "Screen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::visit_edges(Cell::Visitor& visitor)
|
void Screen::visit_edges(Cell::Visitor& visitor)
|
||||||
|
|
|
@ -17,8 +17,6 @@ class Screen final : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using AllowOwnPtr = TrueType;
|
|
||||||
|
|
||||||
static JS::NonnullGCPtr<Screen> create(HTML::Window&);
|
static JS::NonnullGCPtr<Screen> create(HTML::Window&);
|
||||||
|
|
||||||
i32 width() const { return screen_rect().width(); }
|
i32 width() const { return screen_rect().width(); }
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/CSS/StyleSheet.h>
|
#include <LibWeb/CSS/StyleSheet.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
StyleSheet::StyleSheet(HTML::Window& window_object)
|
StyleSheet::StyleSheet(JS::Realm& realm)
|
||||||
: PlatformObject(window_object.cached_web_prototype("StyleSheet"))
|
: PlatformObject(realm)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
void set_parent_css_style_sheet(CSSStyleSheet*);
|
void set_parent_css_style_sheet(CSSStyleSheet*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit StyleSheet(HTML::Window&);
|
explicit StyleSheet(JS::Realm&);
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Bindings/StyleSheetListPrototype.h>
|
#include <LibWeb/Bindings/StyleSheetListPrototype.h>
|
||||||
#include <LibWeb/CSS/StyleSheetList.h>
|
#include <LibWeb/CSS/StyleSheetList.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
@ -36,12 +37,12 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
|
||||||
|
|
||||||
StyleSheetList* StyleSheetList::create(DOM::Document& document)
|
StyleSheetList* StyleSheetList::create(DOM::Document& document)
|
||||||
{
|
{
|
||||||
auto& realm = document.window().realm();
|
auto& realm = document.realm();
|
||||||
return realm.heap().allocate<StyleSheetList>(realm, document);
|
return realm.heap().allocate<StyleSheetList>(realm, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleSheetList::StyleSheetList(DOM::Document& document)
|
StyleSheetList::StyleSheetList(DOM::Document& document)
|
||||||
: Bindings::LegacyPlatformObject(document.window().cached_web_prototype("StyleSheetList"))
|
: Bindings::LegacyPlatformObject(Bindings::ensure_web_prototype<Bindings::StyleSheetListPrototype>(document.realm(), "StyleSheetList"))
|
||||||
, m_document(document)
|
, m_document(document)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1709,7 +1709,7 @@ void Document::evaluate_media_queries_and_report_changes()
|
||||||
CSS::MediaQueryListEventInit init;
|
CSS::MediaQueryListEventInit init;
|
||||||
init.media = media_query_list->media();
|
init.media = media_query_list->media();
|
||||||
init.matches = now_matches;
|
init.matches = now_matches;
|
||||||
auto event = CSS::MediaQueryListEvent::create(window(), HTML::EventNames::change, init);
|
auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init);
|
||||||
event->set_is_trusted(true);
|
event->set_is_trusted(true);
|
||||||
media_query_list->dispatch_event(*event);
|
media_query_list->dispatch_event(*event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue