Index: third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
diff --git a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
index b0862cb44698da1e639b9615b4c0a88571e98fd0..02f8d8d7f17e391ca83f143d7797fe52350f4435 100644 |
--- a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
+++ b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
@@ -58,6 +58,7 @@ |
#include "core/frame/LocalFrame.h" |
#include "core/html/HTMLFrameOwnerElement.h" |
#include "core/html/HTMLHeadElement.h" |
+#include "core/html/HTMLStyleElement.h" |
#include "core/html/VoidCallback.h" |
#include "core/inspector/IdentifiersFactory.h" |
#include "core/inspector/InspectedFrames.h" |
@@ -1554,11 +1555,8 @@ Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
// static |
void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, HeapVector<Member<CSSStyleSheet>>& result) |
{ |
- const HeapVector<Member<CSSStyleSheet>> activeStyleSheets = document->styleEngine().activeStyleSheetsForInspector(); |
- for (const auto& style : activeStyleSheets) { |
- CSSStyleSheet* styleSheet = style.get(); |
- InspectorCSSAgent::collectStyleSheets(styleSheet, result); |
- } |
+ for (const auto& style : document->styleEngine().activeStyleSheetsForInspector()) |
+ InspectorCSSAgent::collectStyleSheets(style.first, result); |
} |
// static |
@@ -1651,6 +1649,16 @@ InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* documen |
targetNode->appendChild(styleElement, exceptionState); |
// At this point the added stylesheet will get bound through the updateActiveStyleSheets() invocation. |
// We just need to pick the respective InspectorStyleSheet from m_documentToViaInspectorStyleSheet. |
+ HeapHashSet<Member<CSSStyleSheet>>* documentCSSStyleSheets = m_documentToCSSStyleSheets.get(document); |
+ if (!documentCSSStyleSheets) { |
+ documentCSSStyleSheets = new HeapHashSet<Member<CSSStyleSheet>>(); |
+ m_documentToCSSStyleSheets.set(document, documentCSSStyleSheets); |
+ } |
+ CSSStyleSheet* cssStyleSheet = toHTMLStyleElement(styleElement)->sheet(); |
+ InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); |
+ documentCSSStyleSheets->add(cssStyleSheet); |
+ if (frontend()) |
+ frontend()->styleSheetAdded(newStyleSheet->buildObjectForStyleSheetInfo()); |
m_creatingViaInspectorStyleSheet = false; |
} |