Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp

Issue 2703473004: DevTools: simplify CSS agent's setActiveStyleSheets method (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorCSSAgent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e9b1379ff8d076e6fba0a0eb72e00cf6bb27d4e9..605eff551194b8dc50dca4c944805f40d48fa26c 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp
@@ -699,7 +699,7 @@ void InspectorCSSAgent::flushPendingProtocolNotifications() {
HeapHashSet<Member<Document>> invalidatedDocuments;
m_invalidatedDocuments.swap(invalidatedDocuments);
for (Document* document : invalidatedDocuments)
- updateActiveStyleSheets(document, ExistingFrontendRefresh);
+ updateActiveStyleSheets(document);
}
void InspectorCSSAgent::reset() {
@@ -745,7 +745,7 @@ void InspectorCSSAgent::wasEnabled() {
m_domAgent->setDOMListener(this);
HeapVector<Member<Document>> documents = m_domAgent->documents();
for (Document* document : documents)
- updateActiveStyleSheets(document, InitialFrontendLoad);
+ updateActiveStyleSheets(document);
}
Response InspectorCSSAgent::disable() {
@@ -778,20 +778,15 @@ void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) {
m_invalidatedDocuments.add(document);
}
-void InspectorCSSAgent::updateActiveStyleSheets(
- Document* document,
- StyleSheetsUpdateType styleSheetsUpdateType) {
+void InspectorCSSAgent::updateActiveStyleSheets(Document* document) {
HeapVector<Member<CSSStyleSheet>> newSheetsVector;
InspectorCSSAgent::collectAllDocumentStyleSheets(document, newSheetsVector);
- setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
+ setActiveStyleSheets(document, newSheetsVector);
}
void InspectorCSSAgent::setActiveStyleSheets(
Document* document,
- const HeapVector<Member<CSSStyleSheet>>& allSheetsVector,
- StyleSheetsUpdateType styleSheetsUpdateType) {
- bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad;
-
+ const HeapVector<Member<CSSStyleSheet>>& allSheetsVector) {
HeapHashSet<Member<CSSStyleSheet>>* documentCSSStyleSheets =
m_documentToCSSStyleSheets.get(document);
if (!documentCSSStyleSheets) {
@@ -804,8 +799,6 @@ void InspectorCSSAgent::setActiveStyleSheets(
for (CSSStyleSheet* cssStyleSheet : allSheetsVector) {
if (removedSheets.contains(cssStyleSheet)) {
removedSheets.remove(cssStyleSheet);
- if (isInitialFrontendLoad)
- addedSheets.push_back(cssStyleSheet);
} else {
addedSheets.push_back(cssStyleSheet);
}
@@ -819,21 +812,18 @@ void InspectorCSSAgent::setActiveStyleSheets(
documentCSSStyleSheets->remove(cssStyleSheet);
if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
String id = unbindStyleSheet(inspectorStyleSheet);
- if (frontend() && !isInitialFrontendLoad)
+ if (frontend())
frontend()->styleSheetRemoved(id);
}
}
for (CSSStyleSheet* cssStyleSheet : addedSheets) {
- bool isNew = isInitialFrontendLoad ||
- !m_cssStyleSheetToInspectorStyleSheet.contains(cssStyleSheet);
- if (isNew) {
InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet);
documentCSSStyleSheets->add(cssStyleSheet);
- if (frontend())
+ if (frontend()) {
frontend()->styleSheetAdded(
newStyleSheet->buildObjectForStyleSheetInfo());
- }
+ }
}
if (documentCSSStyleSheets->isEmpty())
@@ -842,8 +832,7 @@ void InspectorCSSAgent::setActiveStyleSheets(
void InspectorCSSAgent::documentDetached(Document* document) {
m_invalidatedDocuments.remove(document);
- setActiveStyleSheets(document, HeapVector<Member<CSSStyleSheet>>(),
- ExistingFrontendRefresh);
+ setActiveStyleSheets(document, HeapVector<Member<CSSStyleSheet>>());
}
bool InspectorCSSAgent::forcePseudoState(Element* element,
@@ -1508,7 +1497,7 @@ Response InspectorCSSAgent::createStyleSheet(
if (!inspectorStyleSheet)
return Response::Error("No target stylesheet found");
- updateActiveStyleSheets(document, ExistingFrontendRefresh);
+ updateActiveStyleSheets(document);
*outStyleSheetId = inspectorStyleSheet->id();
return Response::OK();
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorCSSAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698