ShadowRoot should have styleSheets property
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 23:33:39 +0000 (23:33 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 23:33:39 +0000 (23:33 +0000)
commita97b7d6aef98832c7432bb251e79fbf62274786c
treedbc605b68a508e52b89bcfa1134cfb62c90003ec
parentf9f2e46b6800d42ea7f12c1a5cefafaa322667a2
ShadowRoot should have styleSheets property
https://bugs.webkit.org/show_bug.cgi?id=191311
LayoutTests/imported/w3c:

Reviewed by Antti Koivisto.

Rebaselined the tests.

* web-platform-tests/css/css-scoping/stylesheet-title-002-expected.txt: Rebaselined. The test now
doesn't throw but fails with the actual check the test is intending to check.
* web-platform-tests/css/cssom/selectorText-modification-restyle-002-expected.txt: Rebaselined
now that all test cases pass.
* web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt: Ditto.

Source/WebCore:

Reviewed by Antti Koivisto.

Added the support for ShadowRoot.prototype.styleSheets by making StyleSheetList refer to either
a document or a shadow root. We don't support the named getter in shadow root since that's not
a standard feature: https://drafts.csswg.org/cssom/#the-stylesheetlist-interface

Tests: fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html
       imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html

* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::StyleSheetList): Added a variant which takes ShadowRoot.
(WebCore::StyleSheetList::styleSheets const):
(WebCore::StyleSheetList::ownerNode): Added. The replacement for document() since now the opaque
root could be either a Document or a ShadowRoot.
(WebCore::StyleSheetList::detach): Renamed from detachFromDocument.
(WebCore::StyleSheetList::namedItem const): Added a comment that the named getter is only supported
for Document since it's not in the standard.
* css/StyleSheetList.h:
(WebCore::StyleSheetList::create): Added a variant which takes ShadowRoot.
(WebCore::StyleSheetList::document): Deleted. Replaced by StyleSheetList::ownerNode in .cpp file.
* css/StyleSheetList.idl:
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::styleSheets):
* dom/Document.idl:
* dom/DocumentOrShadowRoot.idl: Moved the declaration of styleSheets here from Document.idl.
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::~ShadowRoot): Call detach.
(WebCore::ShadowRoot::styleSheets):
* dom/ShadowRoot.h:

LayoutTests:

<rdar://problem/46333290>

Reviewed by Antti Koivisto.

Added a regression test for testing that the JS wrapper of a StyleSheetList does not get collected
as long as its shadow root is alive.

* fast/shadow-dom/shadowroot-stylesheets-wrapper-gc-expected.txt: Added.
* fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/stylesheet-title-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorText-modification-restyle-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/StyleSheetList.cpp
Source/WebCore/css/StyleSheetList.h
Source/WebCore/css/StyleSheetList.idl
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.idl
Source/WebCore/dom/DocumentOrShadowRoot.idl
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h