Commit 3b7d9e9d authored by vsevik@chromium.org's avatar vsevik@chromium.org

DevTools: Show rules from imported stylesheets.

BUG=378778

Review URL: https://codereview.chromium.org/313083005

git-svn-id: svn://svn.chromium.org/blink/trunk@175668 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 81901ea9
.square
{
background-color: red;
display: inline-block;
width: 200px;
height: 200px;
}
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="imported-stylesheet.css"/>
\ No newline at end of file
Tests that rules from imported stylesheets are correctly shown in inspector.
[expanded]
element.style { ()
[expanded]
.square { (imported-stylesheet.css:1 -> imported-stylesheet.css:1:1)
background-color: red;
display: inline-block;
[expanded]
div { (user agent stylesheet)
/-- overloaded --/ display: block;
<html>
<head>
<link rel="import" href="resources/imported-stylesheet.html"/>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
InspectorTest.selectNodeAndWaitForStyles("square", step1);
function step1()
{
InspectorTest.dumpSelectedElementStyles(true, false, true);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>Tests that rules from imported stylesheets are correctly shown in inspector.</p>
<div id="square" class="square"></div>
</body>
</html>
...@@ -14,10 +14,16 @@ function injectStyleSheet() ...@@ -14,10 +14,16 @@ function injectStyleSheet()
function test() function test()
{ {
InspectorTest.evaluateInPage("injectStyleSheet()", step1); InspectorTest.selectNodeAndWaitForStyles("container", step0);
function step0()
{
InspectorTest.evaluateInPage("injectStyleSheet()", step1);
}
function step1() function step1()
{ {
InspectorTest.selectNodeAndWaitForStyles("container", step2); InspectorTest.waitForStyles("container", step2);
} }
function step2() function step2()
......
...@@ -398,20 +398,20 @@ bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) ...@@ -398,20 +398,20 @@ bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode)
return requiresFullStyleRecalc; return requiresFullStyleRecalc;
} }
const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > StyleEngine::activeStyleSheetsForInspector() const const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > StyleEngine::activeStyleSheetsForInspector() const
{ {
if (m_activeTreeScopes.isEmpty()) if (m_activeTreeScopes.isEmpty())
return documentStyleSheetCollection()->styleSheetsForStyleSheetList(); return documentStyleSheetCollection()->activeAuthorStyleSheets();
WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets; WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets;
activeStyleSheets.appendVector(documentStyleSheetCollection()->styleSheetsForStyleSheetList()); activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorStyleSheets());
TreeScopeSet::const_iterator begin = m_activeTreeScopes.begin(); TreeScopeSet::const_iterator begin = m_activeTreeScopes.begin();
TreeScopeSet::const_iterator end = m_activeTreeScopes.end(); TreeScopeSet::const_iterator end = m_activeTreeScopes.end();
for (TreeScopeSet::const_iterator it = begin; it != end; ++it) { for (TreeScopeSet::const_iterator it = begin; it != end; ++it) {
if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it)) if (TreeScopeStyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it))
activeStyleSheets.appendVector(collection->styleSheetsForStyleSheetList()); activeStyleSheets.appendVector(collection->activeAuthorStyleSheets());
} }
// FIXME: Inspector needs a vector which has all active stylesheets. // FIXME: Inspector needs a vector which has all active stylesheets.
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& documentAuthorStyleSheets() const { return m_authorStyleSheets; } const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& injectedAuthorStyleSheets() const; const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& injectedAuthorStyleSheets() const;
const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheetsForInspector() const; const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheetsForInspector() const;
void modifiedStyleSheet(StyleSheet*); void modifiedStyleSheet(StyleSheet*);
void addStyleSheetCandidateNode(Node*, bool createdByParser); void addStyleSheetCandidateNode(Node*, bool createdByParser);
......
...@@ -1181,11 +1181,10 @@ void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu ...@@ -1181,11 +1181,10 @@ void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu
void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector<CSSStyleSheet*>& result) void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector<CSSStyleSheet*>& result)
{ {
const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector(); const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets = document->styleEngine()->activeStyleSheetsForInspector();
for (WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { for (WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >::const_iterator it = activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) {
StyleSheet* styleSheet = it->get(); CSSStyleSheet* styleSheet = it->get();
if (styleSheet->isCSSStyleSheet()) collectStyleSheets(styleSheet, result);
collectStyleSheets(toCSSStyleSheet(styleSheet), result);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment