Implement scoped styling for shadow DOM
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Sep 2015 22:06:09 +0000 (22:06 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Sep 2015 22:06:09 +0000 (22:06 +0000)
commit6ec42d713bcf7c8b9206ec68bc61367a36c666ab
tree23f429019a85b3361c934cd8a0907feec37371d9
parenta71e524e4cac2b8cec55ba9624e479bf61c2460c
Implement scoped styling for shadow DOM
https://bugs.webkit.org/show_bug.cgi?id=149230

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak.html

* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRules):

    Only use special path here for user agent shadow trees.

* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::AuthorStyleSheets):
(WebCore::AuthorStyleSheets::removePendingSheet):
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):

    Basic support for ShadowRoot scoped stylesheets.

* dom/AuthorStyleSheets.h:
(WebCore::AuthorStyleSheets::activeStyleSheets):
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::~InlineStyleSheetOwner):
(WebCore::authorStyleSheetsForElement):
(WebCore::InlineStyleSheetOwner::insertedIntoDocument):
(WebCore::InlineStyleSheetOwner::removedFromDocument):
(WebCore::InlineStyleSheetOwner::clearDocumentData):
(WebCore::InlineStyleSheetOwner::childrenChanged):
(WebCore::InlineStyleSheetOwner::createSheet):
(WebCore::InlineStyleSheetOwner::isLoading):
(WebCore::InlineStyleSheetOwner::sheetLoaded):
(WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):

    Basic support for ShadowRoot scoped inline stylesheets.

* dom/InlineStyleSheetOwner.h:
(WebCore::InlineStyleSheetOwner::sheet):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::styleResolver):

    Create and initialize ShadowRoot scoped style resolver.

(WebCore::ShadowRoot::resetStyleResolver):
(WebCore::ShadowRoot::authorStyleSheets):

    Collection of author stylesheets in the shadow tree.

(WebCore::ShadowRoot::updateStyle):

    Trigger style recalc when stylesheets change.

(WebCore::ShadowRoot::cloneNode):
* dom/ShadowRoot.h:
(WebCore::ShadowRoot::resetStyleInheritance):
* html/HTMLStyleElement.h:
* svg/SVGStyleElement.h:

LayoutTests:

* fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak-expected.html: Added.
* fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak.html: Added.

    Add a test that verifies that shadow DOM style doesn't affect normal DOM.

* platform/mac/TestExpectations:

    Enable fast/shadow-dom/css-scoping-shadow-with-rules.html

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190256 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak-expected.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/dom/AuthorStyleSheets.cpp
Source/WebCore/dom/AuthorStyleSheets.h
Source/WebCore/dom/InlineStyleSheetOwner.cpp
Source/WebCore/dom/InlineStyleSheetOwner.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/html/HTMLStyleElement.h
Source/WebCore/svg/SVGStyleElement.h