Skip to content

Commit

Permalink
Partial Sync 'CSSRule.idl' and 'CSSStyleRule.idl' to Web Specification
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=262033
rdar://problem/116340666

Reviewed by Chris Dumez.

This patch is to align WebKit with Gecko/Firefox, Blink/Chromium and Web Specification [1] and [2].

[1] https://drafts.csswg.org/cssom/#the-cssrule-interface
[2] https://drafts.csswg.org/cssom/#the-cssstylerule-interface

In following PR, 'cssText' and 'selectorText' are changed to be 'DOMString' rather than 'DOMString?'
aligning with web-specification.

* Source/WebCore/css/CSSRule.idl:
* Source/WebCore/css/CSSStyleRule.idl:
* LayoutTests/fast/dom/css-element-attribute-js-null.html: Rebaselined
* LayoutTests/fast/dom/css-element-attribute-js-null-expected.txt: Rebaselined

Canonical link: https://commits.webkit.org/268783@main
  • Loading branch information
Ahmad-S792 authored and cdumez committed Oct 3, 2023
1 parent ffd8a01 commit a8eba40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This test setting various attributes of a CSSOM elements to JavaScript null.

TEST SUCCEEDED: The value was the string '.foo { color: black; }'. [tested CSSRule.cssText]

TEST SUCCEEDED: The value was the string '.foo'. [tested CSSStyleRule.selectorText]
TEST SUCCEEDED: The value was the string 'null'. [tested CSSStyleRule.selectorText]

TEST SUCCEEDED: The value was the empty string. [tested CSSStyleDeclaration.cssText]

Expand Down
14 changes: 6 additions & 8 deletions LayoutTests/fast/dom/css-element-attribute-js-null.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,29 @@
if (window.testRunner)
testRunner.dumpAsText();

var rules = document.getElementsByTagName('style')[1].sheet.cssRules;
var rules = document.styleSheets[1].cssRules;

var rule = rules.item(0);
var rule = rules[0];
var mediaRule = rules[1];
var style = rule.style;
var value = style.getPropertyCSSValue('color');
var mediaList = rules.item(1).media;
var mediaList = mediaRule.media;


var listing = [
{
type: 'CSSRule',
elementToUse: rule,
attributes: [
// for now, setting cssText does not doing anything. When it gets implemented, the expectedNull
// should become the empty string.
// 'null' is not a valid rule, so the setter does nothing.
{name: 'cssText', expectedNull: '.foo { color: black; }'}
]
},
{
type: 'CSSStyleRule',
elementToUse: rule,
attributes: [
// for now, setting selectorText does not doing anything. When it gets implemented, the expectedNull
// should become the empty string.
{name: 'selectorText', expectedNull: '.foo'}
{name: 'selectorText', expectedNull: 'null'}
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions Source/WebCore/css/CSSRule.idl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2006-2023 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
Expand All @@ -18,6 +18,8 @@
* Boston, MA 02110-1301, USA.
*/

// https://drafts.csswg.org/cssom/#the-cssrule-interface

[
CustomToJSObject,
ExportToWrappedFunction,
Expand All @@ -27,7 +29,7 @@
JSCustomMarkFunction,
ConstantsEnum=StyleRuleType
] interface CSSRule {
attribute DOMString? cssText;
attribute DOMString cssText;
readonly attribute CSSRule? parentRule;
readonly attribute CSSStyleSheet? parentStyleSheet;

Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/css/CSSStyleRule.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
* Boston, MA 02110-1301, USA.
*/

// https://drafts.csswg.org/cssom/#the-cssstylerule-interface

typedef USVString CSSOMString;

[
Exposed=Window
] interface CSSStyleRule : CSSRule {
attribute DOMString? selectorText;
attribute DOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;

// https://drafts.css-houdini.org/css-typed-om/#declared-stylepropertymap-objects
Expand Down

0 comments on commit a8eba40

Please sign in to comment.