RESOLVED FIXED 164247
Web Inspector: Shadow DOM scoped styles are missing
https://bugs.webkit.org/show_bug.cgi?id=164247
Summary Web Inspector: Shadow DOM scoped styles are missing
Joseph Pecoraro
Reported 2016-10-31 15:55:38 PDT
Summary: Shadow DOM scoped styles are missing Test: <div><div id="host"></div></div> <script> (function() { let shadowRoot = document.getElementById("host").attachShadow({mode: "open"}); shadowRoot.innerHTML = ` <style> :host { padding: 20px; } div { color: blue; } </style> <div id="inner">Shadow Content</div> `; })(); </script> Steps to Reproduce: 1. Inspect #host on test page 2. Show Styles > Rules sidebar => Expected to see :host rule in sidebar 3. Inspect #inner on test page => Expected to see scoped "div { color: blue }" rule in sidebar
Attachments
[PATCH] Proposed Fix (18.29 KB, patch)
2016-10-31 16:05 PDT, Joseph Pecoraro
koivisto: review+
koivisto: commit-queue-
Joseph Pecoraro
Comment 1 2016-10-31 16:05:08 PDT
Created attachment 293484 [details] [PATCH] Proposed Fix
Radar WebKit Bug Importer
Comment 2 2016-10-31 16:22:32 PDT
Devin Rousso
Comment 3 2016-10-31 16:38:12 PDT
Comment on attachment 293484 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=293484&action=review > Source/WebCore/css/InspectorCSSOMWrappers.cpp:101 > + for (unsigned i = 0; i < sheets.size(); ++i) { Would it not be better to use a range based for-loop here?
Joseph Pecoraro
Comment 4 2016-10-31 17:03:46 PDT
Comment on attachment 293484 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=293484&action=review >> Source/WebCore/css/InspectorCSSOMWrappers.cpp:101 >> + for (unsigned i = 0; i < sheets.size(); ++i) { > > Would it not be better to use a range based for-loop here? I tried and got a compiler error that I didn't want to waste time figuring out. The compiler didn't like: for (auto* sheet : sheets) I welcome suggestions, my C++foo is quite poor =)
Antti Koivisto
Comment 5 2016-10-31 17:11:47 PDT
Comment on attachment 293484 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=293484&action=review >>> Source/WebCore/css/InspectorCSSOMWrappers.cpp:101 >>> + for (unsigned i = 0; i < sheets.size(); ++i) { >> >> Would it not be better to use a range based for-loop here? > > I tried and got a compiler error that I didn't want to waste time figuring out. The compiler didn't like: > > for (auto* sheet : sheets) > > I welcome suggestions, my C++foo is quite poor =) for (auto& sheet : sheets) should work. > Source/WebCore/inspector/InspectorCSSAgent.cpp:1018 > +static Style::Scope& containingStyleScopeForElement(Element* element) > +{ > + if (auto* shadowRoot = element->containingShadowRoot()) > + return shadowRoot->styleScope(); > + return element->document().styleScope(); > +} > + You should just use Style::Scope::forNode() instead of this.
Matt Baker
Comment 6 2016-10-31 17:14:03 PDT
Comment on attachment 293484 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=293484&action=review >>>> Source/WebCore/css/InspectorCSSOMWrappers.cpp:101 >>>> + for (unsigned i = 0; i < sheets.size(); ++i) { >>> >>> Would it not be better to use a range based for-loop here? >> >> I tried and got a compiler error that I didn't want to waste time figuring out. The compiler didn't like: >> >> for (auto* sheet : sheets) >> >> I welcome suggestions, my C++foo is quite poor =) > > for (auto& sheet : sheets) > > should work. The only requirement for using range-based for loops with class types is that the class have members begin() and end(). WTF::Vector has these members, you just need to write the loop as Antti suggested, or: for (const auto& sheet : sheets) for the const-happy.
Joseph Pecoraro
Comment 7 2016-10-31 18:19:47 PDT
Note You need to log in before you can comment on or make changes to this bug.