Changeset 190256 in webkit
- Timestamp:
- Sep 25, 2015, 3:06:09 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r190254 r190256 1 2015-09-25 Antti Koivisto <antti@apple.com> 2 3 Implement scoped styling for shadow DOM 4 https://bugs.webkit.org/show_bug.cgi?id=149230 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak-expected.html: Added. 9 * fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak.html: Added. 10 11 Add a test that verifies that shadow DOM style doesn't affect normal DOM. 12 13 * platform/mac/TestExpectations: 14 15 Enable fast/shadow-dom/css-scoping-shadow-with-rules.html 16 1 17 2015-09-25 Tim Horton <timothy_horton@apple.com> 2 18 -
trunk/LayoutTests/platform/mac/TestExpectations
r190245 r190256 1309 1309 1310 1310 webkit.org/b/148695 fast/shadow-dom [ Pass ] 1311 1312 webkit.org/b/149328 fast/shadow-dom/css-scoping-shadow-with-rules.html [ ImageOnlyFailure ]1313 1311 webkit.org/b/149328 fast/shadow-dom/css-scoping-shadow-host-rule.html [ ImageOnlyFailure ] 1314 1312 webkit.org/b/149328 fast/shadow-dom/css-scoping-shadow-host-functional-rule.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r190255 r190256 1 2015-09-25 Antti Koivisto <antti@apple.com> 2 3 Implement scoped styling for shadow DOM 4 https://bugs.webkit.org/show_bug.cgi?id=149230 5 6 Reviewed by Ryosuke Niwa. 7 8 Test: fast/shadow-dom/css-scoping-shadow-with-rules-no-style-leak.html 9 10 * css/ElementRuleCollector.cpp: 11 (WebCore::ElementRuleCollector::collectMatchingRules): 12 13 Only use special path here for user agent shadow trees. 14 15 * dom/AuthorStyleSheets.cpp: 16 (WebCore::AuthorStyleSheets::AuthorStyleSheets): 17 (WebCore::AuthorStyleSheets::removePendingSheet): 18 (WebCore::AuthorStyleSheets::updateActiveStyleSheets): 19 20 Basic support for ShadowRoot scoped stylesheets. 21 22 * dom/AuthorStyleSheets.h: 23 (WebCore::AuthorStyleSheets::activeStyleSheets): 24 * dom/InlineStyleSheetOwner.cpp: 25 (WebCore::InlineStyleSheetOwner::~InlineStyleSheetOwner): 26 (WebCore::authorStyleSheetsForElement): 27 (WebCore::InlineStyleSheetOwner::insertedIntoDocument): 28 (WebCore::InlineStyleSheetOwner::removedFromDocument): 29 (WebCore::InlineStyleSheetOwner::clearDocumentData): 30 (WebCore::InlineStyleSheetOwner::childrenChanged): 31 (WebCore::InlineStyleSheetOwner::createSheet): 32 (WebCore::InlineStyleSheetOwner::isLoading): 33 (WebCore::InlineStyleSheetOwner::sheetLoaded): 34 (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet): 35 36 Basic support for ShadowRoot scoped inline stylesheets. 37 38 * dom/InlineStyleSheetOwner.h: 39 (WebCore::InlineStyleSheetOwner::sheet): 40 * dom/ShadowRoot.cpp: 41 (WebCore::ShadowRoot::styleResolver): 42 43 Create and initialize ShadowRoot scoped style resolver. 44 45 (WebCore::ShadowRoot::resetStyleResolver): 46 (WebCore::ShadowRoot::authorStyleSheets): 47 48 Collection of author stylesheets in the shadow tree. 49 50 (WebCore::ShadowRoot::updateStyle): 51 52 Trigger style recalc when stylesheets change. 53 54 (WebCore::ShadowRoot::cloneNode): 55 * dom/ShadowRoot.h: 56 (WebCore::ShadowRoot::resetStyleInheritance): 57 * html/HTMLStyleElement.h: 58 * svg/SVGStyleElement.h: 59 1 60 2015-09-25 Alex Christensen <achristensen@webkit.org> 2 61 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r182130 r190256 41 41 #include "SVGElement.h" 42 42 #include "SelectorCompiler.h" 43 #include "ShadowRoot.h" 43 44 #include "StyleProperties.h" 44 45 #include "StyledElement.h" … … 153 154 #endif 154 155 155 if (m_element.isInShadowTree()) { 156 auto* shadowRoot = m_element.containingShadowRoot(); 157 if (shadowRoot && shadowRoot->type() == ShadowRoot::Type::UserAgent) { 156 158 const AtomicString& pseudoId = m_element.shadowPseudoId(); 157 159 if (!pseudoId.isEmpty()) -
trunk/Source/WebCore/dom/AuthorStyleSheets.cpp
r190169 r190256 42 42 #include "SVGStyleElement.h" 43 43 #include "Settings.h" 44 #include "ShadowRoot.h" 44 45 #include "StyleInvalidationAnalysis.h" 45 46 #include "StyleResolver.h" … … 55 56 using namespace HTMLNames; 56 57 57 AuthorStyleSheets::AuthorStyleSheets(TreeScope& treeScope) 58 : m_document(treeScope.documentScope()) 58 AuthorStyleSheets::AuthorStyleSheets(Document& document) 59 : m_document(document) 60 { 61 } 62 63 AuthorStyleSheets::AuthorStyleSheets(ShadowRoot& shadowRoot) 64 : m_document(shadowRoot.documentScope()) 65 , m_shadowRoot(&shadowRoot) 59 66 { 60 67 } … … 80 87 return; 81 88 } 82 89 90 if (m_shadowRoot) { 91 m_shadowRoot->updateStyle(); 92 return; 93 } 94 83 95 m_document.didRemoveAllPendingStylesheet(); 84 96 } … … 300 312 analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc); 301 313 302 if (styleResolverUpdateType == Reconstruct) 303 m_document.clearStyleResolver(); 304 else { 314 if (styleResolverUpdateType == Reconstruct) { 315 if (m_shadowRoot) 316 m_shadowRoot->resetStyleResolver(); 317 else 318 m_document.clearStyleResolver(); 319 } else { 305 320 StyleResolver& styleResolver = m_document.ensureStyleResolver(); 306 321 if (styleResolverUpdateType == Reset) { -
trunk/Source/WebCore/dom/AuthorStyleSheets.h
r190169 r190256 46 46 class StyleSheetContents; 47 47 class StyleSheetList; 48 class ShadowRoot; 48 49 class TreeScope; 49 50 … … 51 52 WTF_MAKE_FAST_ALLOCATED; 52 53 public: 53 explicit AuthorStyleSheets(TreeScope&); 54 explicit AuthorStyleSheets(Document&); 55 explicit AuthorStyleSheets(ShadowRoot&); 54 56 55 57 const Vector<RefPtr<CSSStyleSheet>>& activeStyleSheets() const { return m_activeStyleSheets; } … … 108 110 109 111 Document& m_document; 112 ShadowRoot* m_shadowRoot { nullptr }; 110 113 111 114 Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList; -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp
r190169 r190256 28 28 #include "MediaQueryEvaluator.h" 29 29 #include "ScriptableDocumentParser.h" 30 #include "ShadowRoot.h" 30 31 #include "StyleSheetContents.h" 31 32 #include "TextNodeTraversal.h" … … 47 48 } 48 49 49 void InlineStyleSheetOwner::insertedIntoDocument(Document& document,Element& element)50 static AuthorStyleSheets& authorStyleSheetsForElement(Element& element) 50 51 { 51 document.authorStyleSheets().addStyleSheetCandidateNode(element, m_isParsingChildren); 52 auto* shadowRoot = element.containingShadowRoot(); 53 return shadowRoot ? shadowRoot->authorStyleSheets() : element.document().authorStyleSheets(); 54 } 55 56 void InlineStyleSheetOwner::insertedIntoDocument(Document&, Element& element) 57 { 58 authorStyleSheetsForElement(element).addStyleSheetCandidateNode(element, m_isParsingChildren); 52 59 53 60 if (m_isParsingChildren) … … 58 65 void InlineStyleSheetOwner::removedFromDocument(Document& document, Element& element) 59 66 { 60 document.authorStyleSheets().removeStyleSheetCandidateNode(element);67 authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element); 61 68 62 69 if (m_sheet) … … 68 75 } 69 76 70 void InlineStyleSheetOwner::clearDocumentData(Document& document, Element& element)77 void InlineStyleSheetOwner::clearDocumentData(Document&, Element& element) 71 78 { 72 79 if (m_sheet) … … 75 82 if (!element.inDocument()) 76 83 return; 77 document.authorStyleSheets().removeStyleSheetCandidateNode(element);84 authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element); 78 85 } 79 86 … … 139 146 return; 140 147 141 document.authorStyleSheets().addPendingSheet();148 authorStyleSheetsForElement(element).addPendingSheet(); 142 149 143 150 m_loading = true; … … 161 168 } 162 169 163 bool InlineStyleSheetOwner::sheetLoaded( Document& document)170 bool InlineStyleSheetOwner::sheetLoaded(Element& element) 164 171 { 165 172 if (isLoading()) 166 173 return false; 167 174 168 document.authorStyleSheets().removePendingSheet();175 authorStyleSheetsForElement(element).removePendingSheet(); 169 176 return true; 170 177 } 171 178 172 void InlineStyleSheetOwner::startLoadingDynamicSheet( Document& document)179 void InlineStyleSheetOwner::startLoadingDynamicSheet(Element& element) 173 180 { 174 document.authorStyleSheets().addPendingSheet();181 authorStyleSheetsForElement(element).addPendingSheet(); 175 182 } 176 183 -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.h
r181426 r190256 42 42 43 43 bool isLoading() const; 44 bool sheetLoaded( Document&);45 void startLoadingDynamicSheet( Document&);44 bool sheetLoaded(Element&); 45 void startLoadingDynamicSheet(Element&); 46 46 47 47 void insertedIntoDocument(Document&, Element&); -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r190120 r190256 28 28 #include "ShadowRoot.h" 29 29 30 #include "AuthorStyleSheets.h" 31 #include "CSSStyleSheet.h" 30 32 #include "ElementTraversal.h" 31 33 #include "InsertionPoint.h" … … 41 43 unsigned countersAndFlags[1]; 42 44 void* styleResolver; 45 void* authorStyleSheets; 43 46 void* host; 44 47 #if ENABLE(SHADOW_DOM) … … 74 77 StyleResolver& ShadowRoot::styleResolver() 75 78 { 76 if (m_styleResolver) 77 return *m_styleResolver; 78 79 return document().ensureStyleResolver(); 79 // FIXME: Use isolated style resolver for user agent shadow roots. 80 if (m_type == Type::UserAgent) 81 return document().ensureStyleResolver(); 82 83 if (!m_styleResolver) { 84 // FIXME: We could share style resolver with shadow roots that have identical style. 85 m_styleResolver = std::make_unique<StyleResolver>(document(), true); 86 if (m_authorStyleSheets) 87 m_styleResolver->appendAuthorStyleSheets(0, m_authorStyleSheets->activeStyleSheets()); 88 } 89 return *m_styleResolver; 90 } 91 92 void ShadowRoot::resetStyleResolver() 93 { 94 m_styleResolver = nullptr; 95 } 96 97 AuthorStyleSheets& ShadowRoot::authorStyleSheets() 98 { 99 if (!m_authorStyleSheets) 100 m_authorStyleSheets = std::make_unique<AuthorStyleSheets>(*this); 101 return *m_authorStyleSheets; 102 } 103 104 void ShadowRoot::updateStyle() 105 { 106 bool shouldRecalcStyle = false; 107 108 if (m_authorStyleSheets) { 109 // FIXME: Make optimized updated work. 110 shouldRecalcStyle = m_authorStyleSheets->updateActiveStyleSheets(AuthorStyleSheets::FullUpdate); 111 } 112 113 if (shouldRecalcStyle) 114 setNeedsStyleRecalc(); 80 115 } 81 116 -
trunk/Source/WebCore/dom/ShadowRoot.h
r190109 r190256 37 37 namespace WebCore { 38 38 39 class AuthorStyleSheets; 39 40 class ContentDistributor; 40 41 class HTMLSlotElement; … … 57 58 58 59 StyleResolver& styleResolver(); 60 AuthorStyleSheets& authorStyleSheets(); 61 62 void updateStyle(); 63 void resetStyleResolver(); 59 64 60 65 bool resetStyleInheritance() const { return m_resetStyleInheritance; } … … 103 108 Type m_type; 104 109 110 Element* m_host; 111 105 112 std::unique_ptr<StyleResolver> m_styleResolver; 106 107 Element* m_host; 113 std::unique_ptr<AuthorStyleSheets> m_authorStyleSheets; 108 114 109 115 #if ENABLE(SHADOW_DOM) -
trunk/Source/WebCore/html/HTMLStyleElement.h
r177996 r190256 60 60 61 61 bool isLoading() const { return m_styleSheetOwner.isLoading(); } 62 virtual bool sheetLoaded() override { return m_styleSheetOwner.sheetLoaded( document()); }62 virtual bool sheetLoaded() override { return m_styleSheetOwner.sheetLoaded(*this); } 63 63 virtual void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) override; 64 virtual void startLoadingDynamicSheet() override { m_styleSheetOwner.startLoadingDynamicSheet( document()); }64 virtual void startLoadingDynamicSheet() override { m_styleSheetOwner.startLoadingDynamicSheet(*this); } 65 65 66 66 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const override; -
trunk/Source/WebCore/svg/SVGStyleElement.h
r182121 r190256 60 60 61 61 virtual bool isLoading() const { return m_styleSheetOwner.isLoading(); } 62 virtual bool sheetLoaded() override { return m_styleSheetOwner.sheetLoaded( document()); }63 virtual void startLoadingDynamicSheet() override { m_styleSheetOwner.startLoadingDynamicSheet( document()); }62 virtual bool sheetLoaded() override { return m_styleSheetOwner.sheetLoaded(*this); } 63 virtual void startLoadingDynamicSheet() override { m_styleSheetOwner.startLoadingDynamicSheet(*this); } 64 64 virtual Timer* svgLoadEventTimer() override { return &m_svgLoadEventTimer; } 65 65
Note:
See TracChangeset
for help on using the changeset viewer.