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

Unified Diff: trunk/Source/core/inspector/InspectorCSSAgent.cpp

Issue 202443003: Revert 169354 "DevTools: track stylesheets by document, not loca..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 6 years, 9 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
Index: trunk/Source/core/inspector/InspectorCSSAgent.cpp
===================================================================
--- trunk/Source/core/inspector/InspectorCSSAgent.cpp (revision 169388)
+++ trunk/Source/core/inspector/InspectorCSSAgent.cpp (working copy)
@@ -435,7 +435,7 @@
{
m_idToInspectorStyleSheet.clear();
m_cssStyleSheetToInspectorStyleSheet.clear();
- m_documentToCSSStyleSheets.clear();
+ m_frameToCSSStyleSheets.clear();
m_nodeToInspectorStyleSheet.clear();
m_documentToViaInspectorStyleSheet.clear();
resetNonPersistentData();
@@ -490,8 +490,10 @@
m_instrumentingAgents->setInspectorCSSAgent(this);
Vector<Document*> documents = m_domAgent->documents();
- for (Vector<Document*>::iterator it = documents.begin(); it != documents.end(); ++it)
- updateActiveStyleSheets(*it, InitialFrontendLoad);
+ for (Vector<Document*>::iterator it = documents.begin(); it != documents.end(); ++it) {
+ Document* document = *it;
+ updateActiveStyleSheetsForDocument(document, InitialFrontendLoad);
+ }
if (callback)
callback->sendSuccess();
@@ -510,11 +512,7 @@
return;
}
- for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin(); it != m_documentToCSSStyleSheets.end(); ++it) {
- Document* document = it->key;
- if (!document->frame() || document->frame() == frame)
- documentDisposed(document);
- }
+ updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
}
void InspectorCSSAgent::mediaQueryResultChanged()
@@ -561,29 +559,32 @@
{
if (styleSheetEditInProgress())
return;
- updateActiveStyleSheets(document, ExistingFrontendRefresh);
+ updateActiveStyleSheetsForDocument(document, ExistingFrontendRefresh);
}
-void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsUpdateType styleSheetsUpdateType)
+void InspectorCSSAgent::updateActiveStyleSheetsForDocument(Document* document, StyleSheetsUpdateType styleSheetsUpdateType)
{
+ LocalFrame* frame = document->frame();
+ if (!frame)
+ return;
Vector<CSSStyleSheet*> newSheetsVector;
collectAllDocumentStyleSheets(document, newSheetsVector);
- setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
+ updateActiveStyleSheets(frame, newSheetsVector, styleSheetsUpdateType);
}
-void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CSSStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType)
+void InspectorCSSAgent::updateActiveStyleSheets(LocalFrame* frame, const Vector<CSSStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType)
{
bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad;
- HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets.get(document);
- if (!documentCSSStyleSheets) {
- documentCSSStyleSheets = new HashSet<CSSStyleSheet*>();
- OwnPtr<HashSet<CSSStyleSheet*> > documentCSSStyleSheetsPtr = adoptPtr(documentCSSStyleSheets);
- m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.release());
+ HashSet<CSSStyleSheet*>* frameCSSStyleSheets = m_frameToCSSStyleSheets.get(frame);
+ if (!frameCSSStyleSheets) {
+ frameCSSStyleSheets = new HashSet<CSSStyleSheet*>();
+ OwnPtr<HashSet<CSSStyleSheet*> > frameCSSStyleSheetsPtr = adoptPtr(frameCSSStyleSheets);
+ m_frameToCSSStyleSheets.set(frame, frameCSSStyleSheetsPtr.release());
}
HashSet<CSSStyleSheet*> removedSheets;
- for (HashSet<CSSStyleSheet*>::iterator it = documentCSSStyleSheets->begin(); it != documentCSSStyleSheets->end(); ++it)
+ for (HashSet<CSSStyleSheet*>::iterator it = frameCSSStyleSheets->begin(); it != frameCSSStyleSheets->end(); ++it)
removedSheets.add(*it);
HashSet<CSSStyleSheet*> addedSheets;
@@ -605,7 +606,7 @@
if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
String id = unbindStyleSheet(inspectorStyleSheet.get());
- documentCSSStyleSheets->remove(cssStyleSheet);
+ frameCSSStyleSheets->remove(cssStyleSheet);
if (m_frontend && !isInitialFrontendLoad)
m_frontend->styleSheetRemoved(id);
}
@@ -616,24 +617,19 @@
bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSheet.contains(cssStyleSheet);
if (isNew) {
InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet);
- documentCSSStyleSheets->add(cssStyleSheet);
+ frameCSSStyleSheets->add(cssStyleSheet);
if (m_frontend)
m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSheetInfo());
}
}
- if (documentCSSStyleSheets->isEmpty())
- m_documentToCSSStyleSheets.remove(document);
+ if (frameCSSStyleSheets->isEmpty())
+ m_frameToCSSStyleSheets.remove(frame);
}
-void InspectorCSSAgent::documentDisposed(Document* document)
-{
- setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
-}
-
void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame)
{
- documentDisposed(frame->document());
+ updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
}
bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType)
« no previous file with comments | « trunk/Source/core/inspector/InspectorCSSAgent.h ('k') | trunk/Source/core/inspector/InspectorInstrumentation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698