WebKit Bugzilla
Attachment 356210 Details for
Bug 191311
: ShadowRoot should have styleSheets property
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Rebaselined the tests
bug-191311-20181130114711.patch (text/plain), 17.54 KB, created by
Ryosuke Niwa
on 2018-11-30 11:47:11 PST
(
hide
)
Description:
Rebaselined the tests
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-11-30 11:47:11 PST
Size:
17.54 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 238706) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,39 @@ >+2018-11-30 Ryosuke Niwa <rniwa@webkit.org> >+ >+ ShadowRoot should have styleSheets property >+ https://bugs.webkit.org/show_bug.cgi?id=191311 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2018-11-29 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC][Quirk] Body and html height stretching. >Index: Source/WebCore/css/StyleSheetList.cpp >=================================================================== >--- Source/WebCore/css/StyleSheetList.cpp (revision 238706) >+++ Source/WebCore/css/StyleSheetList.cpp (working copy) >@@ -25,6 +25,7 @@ > #include "Document.h" > #include "HTMLNames.h" > #include "HTMLStyleElement.h" >+#include "ShadowRoot.h" > #include "StyleScope.h" > #include <wtf/text/WTFString.h> > >@@ -32,24 +33,46 @@ namespace WebCore { > > using namespace HTMLNames; > >-StyleSheetList::StyleSheetList(Document* document) >- : m_document(document) >+StyleSheetList::StyleSheetList(Document& document) >+ : m_document(&document) > { > } > >-StyleSheetList::~StyleSheetList() = default; >- >-inline const Vector<RefPtr<StyleSheet>>& StyleSheetList::styleSheets() const >+StyleSheetList::StyleSheetList(ShadowRoot& shadowRoot) >+ : m_shadowRoot(&shadowRoot) > { >- if (!m_document) >- return m_detachedStyleSheets; >- return m_document->styleScope().styleSheetsForStyleSheetList(); > } > >-void StyleSheetList::detachFromDocument() >+StyleSheetList::~StyleSheetList() = default; >+ >+inline const Vector<RefPtr<StyleSheet>>& StyleSheetList::styleSheets() const > { >- m_detachedStyleSheets = m_document->styleScope().styleSheetsForStyleSheetList(); >- m_document = nullptr; >+ if (m_document) >+ return m_document->styleScope().styleSheetsForStyleSheetList(); >+ if (m_shadowRoot) >+ return m_shadowRoot->styleScope().styleSheetsForStyleSheetList(); >+ return m_detachedStyleSheets; >+} >+ >+Node* StyleSheetList::ownerNode() const >+{ >+ if (m_document) >+ return m_document; >+ return m_shadowRoot; >+} >+ >+void StyleSheetList::detach() >+{ >+ if (m_document) { >+ ASSERT(!m_shadowRoot); >+ m_detachedStyleSheets = m_document->styleScope().styleSheetsForStyleSheetList(); >+ m_document = nullptr; >+ } else if (m_shadowRoot) { >+ ASSERT(!m_document); >+ m_detachedStyleSheets = m_shadowRoot->styleScope().styleSheetsForStyleSheetList(); >+ m_shadowRoot = nullptr; >+ } else >+ ASSERT_NOT_REACHED(); > } > > unsigned StyleSheetList::length() const >@@ -65,6 +88,7 @@ StyleSheet* StyleSheetList::item(unsigne > > CSSStyleSheet* StyleSheetList::namedItem(const AtomicString& name) const > { >+ // Support the named getter on document for backwards compatibility. > if (!m_document) > return nullptr; > >Index: Source/WebCore/css/StyleSheetList.h >=================================================================== >--- Source/WebCore/css/StyleSheetList.h (revision 238706) >+++ Source/WebCore/css/StyleSheetList.h (working copy) >@@ -28,12 +28,15 @@ namespace WebCore { > > class Document; > class HTMLStyleElement; >+class Node; >+class ShadowRoot; > class StyleSheet; > class CSSStyleSheet; > > class StyleSheetList final : public RefCounted<StyleSheetList> { > public: >- static Ref<StyleSheetList> create(Document* document) { return adoptRef(*new StyleSheetList(document)); } >+ static Ref<StyleSheetList> create(Document& document) { return adoptRef(*new StyleSheetList(document)); } >+ static Ref<StyleSheetList> create(ShadowRoot& shadowRoot) { return adoptRef(*new StyleSheetList(shadowRoot)); } > WEBCORE_EXPORT ~StyleSheetList(); > > WEBCORE_EXPORT unsigned length() const; >@@ -42,15 +45,17 @@ public: > CSSStyleSheet* namedItem(const AtomicString&) const; > Vector<AtomicString> supportedPropertyNames(); > >- Document* document() { return m_document; } >+ Node* ownerNode() const; > >- void detachFromDocument(); >+ void detach(); > > private: >- StyleSheetList(Document*); >+ StyleSheetList(Document&); >+ StyleSheetList(ShadowRoot&); > const Vector<RefPtr<StyleSheet>>& styleSheets() const; > >- Document* m_document; >+ Document* m_document { nullptr }; >+ ShadowRoot* m_shadowRoot { nullptr }; > Vector<RefPtr<StyleSheet>> m_detachedStyleSheets; > }; > >Index: Source/WebCore/css/StyleSheetList.idl >=================================================================== >--- Source/WebCore/css/StyleSheetList.idl (revision 238706) >+++ Source/WebCore/css/StyleSheetList.idl (working copy) >@@ -20,7 +20,7 @@ > > [ > ExportToWrappedFunction, >- GenerateIsReachable=ImplDocument, >+ GenerateIsReachable=ImplOwnerNodeRoot, > ImplementationLacksVTable, > ] interface StyleSheetList { > readonly attribute unsigned long length; >Index: Source/WebCore/dom/Document.cpp >=================================================================== >--- Source/WebCore/dom/Document.cpp (revision 238706) >+++ Source/WebCore/dom/Document.cpp (working copy) >@@ -637,7 +637,7 @@ Document::~Document() > m_decoder = nullptr; > > if (m_styleSheetList) >- m_styleSheetList->detachFromDocument(); >+ m_styleSheetList->detach(); > > extensionStyleSheets().detachFromDocument(); > >@@ -3830,7 +3830,7 @@ void Document::cloneDataFromDocument(con > StyleSheetList& Document::styleSheets() > { > if (!m_styleSheetList) >- m_styleSheetList = StyleSheetList::create(this); >+ m_styleSheetList = StyleSheetList::create(*this); > return *m_styleSheetList; > } > >Index: Source/WebCore/dom/Document.idl >=================================================================== >--- Source/WebCore/dom/Document.idl (revision 238706) >+++ Source/WebCore/dom/Document.idl (working copy) >@@ -130,10 +130,6 @@ typedef ( > // Special event handler IDL attributes that only apply to Document objects. > [LenientThis] attribute EventHandler onreadystatechange; > >- // Extensions from the CSSOM specification (https://drafts.csswg.org/cssom/#extensions-to-the-document-interface). >- // FIXME: Should likely be moved to DocumentOrShadowRoot. >- readonly attribute StyleSheetList styleSheets; // FIXME: Should be [SameObject]. >- > // Extensions from the CSSOM-View specification (https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface). > [ImplementedAs=scrollingElementForAPI] readonly attribute Element? scrollingElement; > >Index: Source/WebCore/dom/DocumentOrShadowRoot.idl >=================================================================== >--- Source/WebCore/dom/DocumentOrShadowRoot.idl (revision 238706) >+++ Source/WebCore/dom/DocumentOrShadowRoot.idl (working copy) >@@ -34,7 +34,9 @@ > sequence<Element> elementsFromPoint(double x, double y); > // CaretPosition? caretPositionFromPoint(double x, double y); // FIXME: Implement this. > readonly attribute Element? activeElement; >- // readonly attribute StyleSheetList styleSheets; // FIXME: Implement this. >+ >+ // Extensions from the CSSOM specification (https://drafts.csswg.org/cssom/#extensions-to-the-document-interface). >+ readonly attribute StyleSheetList styleSheets; // FIXME: Should be [SameObject]. > > // Extensions from Pointer Lock API (https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin). > [Conditional=POINTER_LOCK] readonly attribute Element? pointerLockElement; >Index: Source/WebCore/dom/ShadowRoot.cpp >=================================================================== >--- Source/WebCore/dom/ShadowRoot.cpp (revision 238706) >+++ Source/WebCore/dom/ShadowRoot.cpp (working copy) >@@ -36,6 +36,7 @@ > #include "SlotAssignment.h" > #include "StyleResolver.h" > #include "StyleScope.h" >+#include "StyleSheetList.h" > #include "markup.h" > #include <wtf/IsoMallocInlines.h> > >@@ -46,6 +47,7 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(ShadowRoot); > struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { > unsigned countersAndFlags[1]; > void* styleScope; >+ void* styleSheetList; > void* host; > void* slotAssignment; > }; >@@ -76,6 +78,9 @@ ShadowRoot::~ShadowRoot() > if (isConnected()) > document().didRemoveInDocumentShadowRoot(*this); > >+ if (m_styleSheetList) >+ m_styleSheetList->detach(); >+ > // We cannot let ContainerNode destructor call willBeDeletedFrom() > // for this ShadowRoot instance because TreeScope destructor > // clears Node::m_treeScope thus ContainerNode is no longer able >@@ -151,6 +156,13 @@ Style::Scope& ShadowRoot::styleScope() > return *m_styleScope; > } > >+StyleSheetList& ShadowRoot::styleSheets() >+{ >+ if (!m_styleSheetList) >+ m_styleSheetList = StyleSheetList::create(*this); >+ return *m_styleSheetList; >+} >+ > String ShadowRoot::innerHTML() const > { > return serializeFragment(*this, SerializedNodes::SubtreesOfChildren); >Index: Source/WebCore/dom/ShadowRoot.h >=================================================================== >--- Source/WebCore/dom/ShadowRoot.h (revision 238706) >+++ Source/WebCore/dom/ShadowRoot.h (working copy) >@@ -35,6 +35,7 @@ namespace WebCore { > > class HTMLSlotElement; > class SlotAssignment; >+class StyleSheetList; > > class ShadowRoot final : public DocumentFragment, public TreeScope { > WTF_MAKE_ISO_ALLOCATED(ShadowRoot); >@@ -54,6 +55,7 @@ public: > using TreeScope::rootNode; > > Style::Scope& styleScope(); >+ StyleSheetList& styleSheets(); > > bool resetStyleInheritance() const { return m_resetStyleInheritance; } > void setResetStyleInheritance(bool); >@@ -110,6 +112,7 @@ private: > ShadowRootMode m_type { ShadowRootMode::UserAgent }; > > Element* m_host { nullptr }; >+ RefPtr<StyleSheetList> m_styleSheetList; > > std::unique_ptr<Style::Scope> m_styleScope; > std::unique_ptr<SlotAssignment> m_slotAssignment; >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 238725) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,17 @@ >+2018-11-30 Ryosuke Niwa <rniwa@webkit.org> >+ >+ ShadowRoot should have styleSheets property >+ https://bugs.webkit.org/show_bug.cgi?id=191311 >+ <rdar://problem/46333290> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ > 2018-11-29 Simon Fraser <simon.fraser@apple.com> > > Overflow scrolling layers need to be self-painting >Index: LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc-expected.txt >=================================================================== >--- LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc-expected.txt (nonexistent) >+++ LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc-expected.txt (working copy) >@@ -0,0 +1,13 @@ >+This tests that StyleSheetList of a shadow root does not get collected as long as the shadow root is alive. >+ >+PASS >+PASS >+PASS >+PASS >+PASS >+PASS >+PASS >+PASS >+PASS >+PASS >+ >Index: LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html >=================================================================== >--- LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html (nonexistent) >+++ LayoutTests/fast/shadow-dom/shadowroot-stylesheets-wrapper-gc.html (working copy) >@@ -0,0 +1,27 @@ >+<!DOCTYPE html> >+<html> >+<body> >+<script src="../../resources/gc.js"></script> >+<p>This tests that StyleSheetList of a shadow root does not get collected as long as the shadow root is alive.</p> >+<pre><script> >+ >+if (window.testRunner) >+ testRunner.dumpAsText(); >+ >+function createShadow() { >+ const host = document.createElement('div'); >+ const shadowRoot = host.attachShadow({mode: 'closed'}); >+ shadowRoot.styleSheets.alive = true; >+ return shadowRoot; >+} >+ >+for (let i = 0; i < 10; i++) { >+ const shadowRoot = createShadow(); >+ gc(); >+ document.write(shadowRoot.styleSheets.alive ? 'PASS' : 'FAIL - styleSheets got collected'); >+ document.write('<br>'); >+} >+ >+</script></pre> >+</body> >+</html> >Index: LayoutTests/imported/w3c/ChangeLog >=================================================================== >--- LayoutTests/imported/w3c/ChangeLog (revision 238746) >+++ LayoutTests/imported/w3c/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2018-11-30 Ryosuke Niwa <rniwa@webkit.org> >+ >+ ShadowRoot should have styleSheets property >+ https://bugs.webkit.org/show_bug.cgi?id=191311 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ > 2018-11-28 Ryosuke Niwa <rniwa@webkit.org> > > Update web-platform-tests/shadow-dom >Index: LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/stylesheet-title-002-expected.txt >=================================================================== >--- LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/stylesheet-title-002-expected.txt (revision 238706) >+++ LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/stylesheet-title-002-expected.txt (working copy) >@@ -1,3 +1,3 @@ > >-FAIL Title attribute in stylesheets not in the document tree is ignored undefined is not an object (evaluating 'host.shadowRoot.styleSheets.length') >+FAIL Title attribute in stylesheets not in the document tree is ignored assert_equals: expected 3 but got 2 > >Index: LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorText-modification-restyle-002-expected.txt >=================================================================== >--- LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorText-modification-restyle-002-expected.txt (revision 238706) >+++ LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorText-modification-restyle-002-expected.txt (working copy) >@@ -1,4 +1,4 @@ > > PASS Check initial color. >-FAIL Check that color changes correctly after shadow stylesheet selector and #container class is changed. undefined is not an object (evaluating 'root.styleSheets[0]') >+PASS Check that color changes correctly after shadow stylesheet selector and #container class is changed. > >Index: LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt >=================================================================== >--- LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt (revision 238706) >+++ LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt (working copy) >@@ -9,6 +9,6 @@ PASS ShadowRoot.innerHTML must return th > PASS ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed. > PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open. > PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed. >-FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open. undefined is not an object (evaluating 'shadowRoot.styleSheets.length') >-FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed. undefined is not an object (evaluating 'shadowRoot.styleSheets.length') >+PASS ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open. >+PASS ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed. >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191311
:
356117
|
356129
|
356144
|
356145
|
356152
|
356157
| 356210