| Index: Source/core/inspector/InspectorCSSAgent.cpp
|
| diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
|
| index 1601e47d11bab6a57b314dba8fda55459fe6f698..82645d6e39cda700e3ea22d76bc96274e50e3fab 100644
|
| --- a/Source/core/inspector/InspectorCSSAgent.cpp
|
| +++ b/Source/core/inspector/InspectorCSSAgent.cpp
|
| @@ -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,14 +512,7 @@
|
| return;
|
| }
|
|
|
| - Vector<Document*> toDispose;
|
| - for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin(); it != m_documentToCSSStyleSheets.end(); ++it) {
|
| - Document* document = it->key;
|
| - if (!document->frame() || document->frame() == frame)
|
| - toDispose.append(document);
|
| - }
|
| - for (Vector<Document*>::iterator it = toDispose.begin(); it != toDispose.end(); ++it)
|
| - documentDisposed(*it);
|
| + updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
|
| }
|
|
|
| void InspectorCSSAgent::mediaQueryResultChanged()
|
| @@ -564,28 +559,33 @@
|
| {
|
| if (styleSheetEditInProgress())
|
| return;
|
| - updateActiveStyleSheets(document, ExistingFrontendRefresh);
|
| -}
|
| -
|
| -void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsUpdateType styleSheetsUpdateType)
|
| -{
|
| + updateActiveStyleSheetsForDocument(document, ExistingFrontendRefresh);
|
| +}
|
| +
|
| +void InspectorCSSAgent::updateActiveStyleSheetsForDocument(Document* document, StyleSheetsUpdateType styleSheetsUpdateType)
|
| +{
|
| + LocalFrame* frame = document->frame();
|
| + if (!frame)
|
| + return;
|
| Vector<CSSStyleSheet*> newSheetsVector;
|
| collectAllDocumentStyleSheets(document, newSheetsVector);
|
| - setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
|
| -}
|
| -
|
| -void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CSSStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType)
|
| + updateActiveStyleSheets(frame, newSheetsVector, 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*> removedSheets(*documentCSSStyleSheets);
|
| + 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 = frameCSSStyleSheets->begin(); it != frameCSSStyleSheets->end(); ++it)
|
| + removedSheets.add(*it);
|
|
|
| HashSet<CSSStyleSheet*> addedSheets;
|
| for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) {
|
| @@ -604,9 +604,9 @@
|
| RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspectorStyleSheet.get(cssStyleSheet);
|
| ASSERT(inspectorStyleSheet);
|
|
|
| - documentCSSStyleSheets->remove(cssStyleSheet);
|
| if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
|
| String id = unbindStyleSheet(inspectorStyleSheet.get());
|
| + frameCSSStyleSheets->remove(cssStyleSheet);
|
| if (m_frontend && !isInitialFrontendLoad)
|
| m_frontend->styleSheetRemoved(id);
|
| }
|
| @@ -617,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);
|
| -}
|
| -
|
| -void InspectorCSSAgent::documentDisposed(Document* document)
|
| -{
|
| - setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
|
| + if (frameCSSStyleSheets->isEmpty())
|
| + m_frameToCSSStyleSheets.remove(frame);
|
| }
|
|
|
| void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame)
|
| {
|
| - documentDisposed(frame->document());
|
| + updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRefresh);
|
| }
|
|
|
| bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType)
|
|
|