diff --git a/Libraries/LibWeb/CSS/CSSMediaRule.h b/Libraries/LibWeb/CSS/CSSMediaRule.h index b64a2fc9b9a..e0dd578223e 100644 --- a/Libraries/LibWeb/CSS/CSSMediaRule.h +++ b/Libraries/LibWeb/CSS/CSSMediaRule.h @@ -24,6 +24,8 @@ public: virtual ~CSSMediaRule() = default; virtual String condition_text() const override; + bool matches() const { return condition_matches(); } + virtual bool condition_matches() const override { return m_media->matches(); } MediaList* media() const { return m_media; } diff --git a/Libraries/LibWeb/CSS/CSSMediaRule.idl b/Libraries/LibWeb/CSS/CSSMediaRule.idl index 7aea427789b..b4edaea781d 100644 --- a/Libraries/LibWeb/CSS/CSSMediaRule.idl +++ b/Libraries/LibWeb/CSS/CSSMediaRule.idl @@ -5,4 +5,5 @@ [Exposed=Window] interface CSSMediaRule : CSSConditionRule { [SameObject, PutForwards=mediaText] readonly attribute MediaList media; + readonly attribute boolean matches; }; diff --git a/Libraries/LibWeb/CSS/CSSSupportsRule.h b/Libraries/LibWeb/CSS/CSSSupportsRule.h index 215632550c5..8de559592b7 100644 --- a/Libraries/LibWeb/CSS/CSSSupportsRule.h +++ b/Libraries/LibWeb/CSS/CSSSupportsRule.h @@ -25,6 +25,8 @@ public: virtual ~CSSSupportsRule() = default; String condition_text() const override; + bool matches() const { return condition_matches(); } + virtual bool condition_matches() const override { return m_supports->matches(); } Supports const& supports() const { return m_supports; } diff --git a/Libraries/LibWeb/CSS/CSSSupportsRule.idl b/Libraries/LibWeb/CSS/CSSSupportsRule.idl index 4c3c19930c8..03eed837c11 100644 --- a/Libraries/LibWeb/CSS/CSSSupportsRule.idl +++ b/Libraries/LibWeb/CSS/CSSSupportsRule.idl @@ -3,4 +3,5 @@ // https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface [Exposed=Window] interface CSSSupportsRule : CSSConditionRule { + readonly attribute boolean matches; }; diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/idlharness.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/idlharness.txt new file mode 100644 index 00000000000..b2b837e0fe7 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/idlharness.txt @@ -0,0 +1,50 @@ +Harness status: OK + +Found 45 tests + +45 Pass +Pass idl_test setup +Pass idl_test validation +Pass Partial interface CSSRule: original interface defined +Pass Partial interface CSSRule: member names are unique +Pass Partial namespace CSS: original namespace defined +Pass Partial namespace CSS: member names are unique +Pass CSSConditionRule interface: existence and properties of interface object +Pass CSSConditionRule interface object length +Pass CSSConditionRule interface object name +Pass CSSConditionRule interface: existence and properties of interface prototype object +Pass CSSConditionRule interface: existence and properties of interface prototype object's "constructor" property +Pass CSSConditionRule interface: existence and properties of interface prototype object's @@unscopables property +Pass CSSConditionRule interface: attribute conditionText +Pass CSSMediaRule interface: existence and properties of interface object +Pass CSSMediaRule interface object length +Pass CSSMediaRule interface object name +Pass CSSMediaRule interface: existence and properties of interface prototype object +Pass CSSMediaRule interface: existence and properties of interface prototype object's "constructor" property +Pass CSSMediaRule interface: existence and properties of interface prototype object's @@unscopables property +Pass CSSMediaRule interface: attribute media +Pass CSSMediaRule interface: attribute matches +Pass CSSMediaRule must be primary interface of cssMediaRule +Pass Stringification of cssMediaRule +Pass CSSMediaRule interface: cssMediaRule must inherit property "media" with the proper type +Pass CSSMediaRule interface: cssMediaRule must inherit property "matches" with the proper type +Pass CSSConditionRule interface: cssMediaRule must inherit property "conditionText" with the proper type +Pass CSSRule interface: cssMediaRule must inherit property "SUPPORTS_RULE" with the proper type +Pass CSSSupportsRule interface: existence and properties of interface object +Pass CSSSupportsRule interface object length +Pass CSSSupportsRule interface object name +Pass CSSSupportsRule interface: existence and properties of interface prototype object +Pass CSSSupportsRule interface: existence and properties of interface prototype object's "constructor" property +Pass CSSSupportsRule interface: existence and properties of interface prototype object's @@unscopables property +Pass CSSSupportsRule interface: attribute matches +Pass CSSSupportsRule must be primary interface of cssSupportsRule +Pass Stringification of cssSupportsRule +Pass CSSSupportsRule interface: cssSupportsRule must inherit property "matches" with the proper type +Pass CSSConditionRule interface: cssSupportsRule must inherit property "conditionText" with the proper type +Pass CSSRule interface: cssSupportsRule must inherit property "SUPPORTS_RULE" with the proper type +Pass CSSRule interface: constant SUPPORTS_RULE on interface object +Pass CSSRule interface: constant SUPPORTS_RULE on interface prototype object +Pass CSSRule interface: cssRule must inherit property "SUPPORTS_RULE" with the proper type +Pass CSS namespace: operation escape(CSSOMString) +Pass CSS namespace: operation supports(CSSOMString, CSSOMString) +Pass CSS namespace: operation supports(CSSOMString) \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/idlharness.html b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/idlharness.html new file mode 100644 index 00000000000..6c253dc3ea6 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/idlharness.html @@ -0,0 +1,47 @@ + + + + + + CSS Conditional Rules IDL tests + + + + + + + + + + + + +
+ + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/interfaces/css-conditional.idl b/Tests/LibWeb/Text/input/wpt-import/interfaces/css-conditional.idl new file mode 100644 index 00000000000..eace34c0f49 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/interfaces/css-conditional.idl @@ -0,0 +1,29 @@ +// GENERATED CONTENT - DO NOT EDIT +// Content was automatically extracted by Reffy into webref +// (https://github.com/w3c/webref) +// Source: CSS Conditional Rules Module Level 3 (https://drafts.csswg.org/css-conditional-3/) + +partial interface CSSRule { + const unsigned short SUPPORTS_RULE = 12; +}; + +[Exposed=Window] +interface CSSConditionRule : CSSGroupingRule { + readonly attribute CSSOMString conditionText; +}; + +[Exposed=Window] +interface CSSMediaRule : CSSConditionRule { + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; + readonly attribute boolean matches; +}; + +[Exposed=Window] +interface CSSSupportsRule : CSSConditionRule { + readonly attribute boolean matches; +}; + +partial namespace CSS { + boolean supports(CSSOMString property, CSSOMString value); + boolean supports(CSSOMString conditionText); +};