Chromium Code Reviews| Index: Source/core/inspector/InspectorCSSAgent.cpp |
| diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp |
| index 03096a8802c116b5882ab7a9e05d13d6c841c3fc..8baa8c4efe0e095283f1a2a64d13d7211cf4d5ee 100644 |
| --- a/Source/core/inspector/InspectorCSSAgent.cpp |
| +++ b/Source/core/inspector/InspectorCSSAgent.cpp |
| @@ -688,16 +688,14 @@ void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) |
| return; |
| } |
| - Vector<InspectorStyleSheet*> styleSheets; |
| - collectAllStyleSheets(styleSheets); |
| - for (size_t i = 0; i < styleSheets.size(); ++i) |
| - m_frontend->styleSheetAdded(styleSheets.at(i)->buildObjectForStyleSheetInfo()); |
| - |
| - // More styleSheetAdded events will be generated below. |
| m_instrumentingAgents->setInspectorCSSAgent(this); |
| Vector<Document*> documents = m_domAgent->documents(); |
| - for (Vector<Document*>::iterator it = documents.begin(); it != documents.end(); ++it) |
| - (*it)->styleEngine()->updateActiveStyleSheets(FullStyleUpdate); |
| + for (Vector<Document*>::iterator it = documents.begin(); it != documents.end(); ++it) { |
| + Document* document = *it; |
| + Vector<CSSStyleSheet*> newSheetsVector; |
| + collectAllDocumentStyleSheets(document, newSheetsVector); |
| + updateActiveStyleSheets(document, newSheetsVector, true); |
| + } |
| if (callback) |
| callback->sendSuccess(); |
| @@ -830,10 +828,10 @@ void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) |
| Vector<CSSStyleSheet*> newSheetsVector; |
| collectAllDocumentStyleSheets(document, newSheetsVector); |
| - updateActiveStyleSheets(document, newSheetsVector); |
| + updateActiveStyleSheets(document, newSheetsVector, false); |
| } |
| -void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector<CSSStyleSheet*>& allSheetsVector) |
| +void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector<CSSStyleSheet*>& allSheetsVector, bool initial) |
|
lushnikov
2013/12/27 08:20:17
nit: consider using default value
bool initial =
apavlov
2013/12/27 08:27:40
Default argument values are disproved in Blink, ac
|
| { |
| HashSet<CSSStyleSheet*> removedSheets; |
| for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInspectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) { |
| @@ -844,10 +842,13 @@ void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector |
| HashSet<CSSStyleSheet*> addedSheets; |
| for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { |
| CSSStyleSheet* cssStyleSheet = *it; |
| - if (removedSheets.contains(cssStyleSheet)) |
| + if (removedSheets.contains(cssStyleSheet)) { |
| removedSheets.remove(cssStyleSheet); |
| - else |
| + if (initial) |
| + addedSheets.add(cssStyleSheet); |
| + } else { |
| addedSheets.add(cssStyleSheet); |
| + } |
| } |
| for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != removedSheets.end(); ++it) { |
| @@ -855,13 +856,14 @@ void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector |
| ASSERT(inspectorStyleSheet); |
| if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
| String id = unbindStyleSheet(inspectorStyleSheet.get()); |
| - if (m_frontend) |
| + if (m_frontend && !initial) |
| m_frontend->styleSheetRemoved(id); |
| } |
| } |
| for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != addedSheets.end(); ++it) { |
| - if (!m_cssStyleSheetToInspectorStyleSheet.contains(*it)) { |
| + bool isNew = initial || !m_cssStyleSheetToInspectorStyleSheet.contains(*it); |
|
apavlov
2013/12/27 07:12:30
The var name does not seem to fully reflect the id
|
| + if (isNew) { |
| InspectorStyleSheet* newStyleSheet = bindStyleSheet(*it); |
| if (m_frontend) |
| m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSheetInfo()); |
| @@ -875,7 +877,7 @@ void InspectorCSSAgent::frameDetachedFromParent(Frame* frame) |
| if (!document) |
| return; |
| const Vector<CSSStyleSheet*> styleSheets; |
| - updateActiveStyleSheets(document, styleSheets); |
| + updateActiveStyleSheets(document, styleSheets, false); |
| } |
| bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType) |