OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 new EnableResourceClient(this, styleSheetsToFetch, prpCallback); | 681 new EnableResourceClient(this, styleSheetsToFetch, prpCallback); |
682 } | 682 } |
683 | 683 |
684 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) | 684 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) |
685 { | 685 { |
686 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { | 686 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { |
687 // We were disabled while fetching resources. | 687 // We were disabled while fetching resources. |
688 return; | 688 return; |
689 } | 689 } |
690 | 690 |
691 Vector<InspectorStyleSheet*> styleSheets; | |
692 collectAllStyleSheets(styleSheets); | |
693 for (size_t i = 0; i < styleSheets.size(); ++i) | |
694 m_frontend->styleSheetAdded(styleSheets.at(i)->buildObjectForStyleSheetI
nfo()); | |
695 | |
696 // More styleSheetAdded events will be generated below. | |
697 m_instrumentingAgents->setInspectorCSSAgent(this); | 691 m_instrumentingAgents->setInspectorCSSAgent(this); |
698 Vector<Document*> documents = m_domAgent->documents(); | 692 Vector<Document*> documents = m_domAgent->documents(); |
699 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) | 693 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) { |
700 (*it)->styleEngine()->updateActiveStyleSheets(FullStyleUpdate); | 694 Document* document = *it; |
| 695 Vector<CSSStyleSheet*> newSheetsVector; |
| 696 collectAllDocumentStyleSheets(document, newSheetsVector); |
| 697 updateActiveStyleSheets(document, newSheetsVector, InitialFrontendLoad); |
| 698 } |
701 | 699 |
702 if (callback) | 700 if (callback) |
703 callback->sendSuccess(); | 701 callback->sendSuccess(); |
704 } | 702 } |
705 | 703 |
706 void InspectorCSSAgent::disable(ErrorString*) | 704 void InspectorCSSAgent::disable(ErrorString*) |
707 { | 705 { |
708 m_instrumentingAgents->setInspectorCSSAgent(0); | 706 m_instrumentingAgents->setInspectorCSSAgent(0); |
709 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); | 707 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); |
710 } | 708 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, named
Flow, documentNodeId)); | 821 m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, named
Flow, documentNodeId)); |
824 } | 822 } |
825 | 823 |
826 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) | 824 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) |
827 { | 825 { |
828 if (styleSheetEditInProgress()) | 826 if (styleSheetEditInProgress()) |
829 return; | 827 return; |
830 | 828 |
831 Vector<CSSStyleSheet*> newSheetsVector; | 829 Vector<CSSStyleSheet*> newSheetsVector; |
832 collectAllDocumentStyleSheets(document, newSheetsVector); | 830 collectAllDocumentStyleSheets(document, newSheetsVector); |
833 updateActiveStyleSheets(document, newSheetsVector); | 831 updateActiveStyleSheets(document, newSheetsVector, ExistingFrontendRefresh); |
834 } | 832 } |
835 | 833 |
836 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector
<CSSStyleSheet*>& allSheetsVector) | 834 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector
<CSSStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) |
837 { | 835 { |
| 836 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; |
| 837 |
838 HashSet<CSSStyleSheet*> removedSheets; | 838 HashSet<CSSStyleSheet*> removedSheets; |
839 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp
ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it)
{ | 839 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp
ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it)
{ |
840 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner
Document() == document)) | 840 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner
Document() == document)) |
841 removedSheets.add(it->key); | 841 removedSheets.add(it->key); |
842 } | 842 } |
843 | 843 |
844 HashSet<CSSStyleSheet*> addedSheets; | 844 HashSet<CSSStyleSheet*> addedSheets; |
845 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it
!= allSheetsVector.end(); ++it) { | 845 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it
!= allSheetsVector.end(); ++it) { |
846 CSSStyleSheet* cssStyleSheet = *it; | 846 CSSStyleSheet* cssStyleSheet = *it; |
847 if (removedSheets.contains(cssStyleSheet)) | 847 if (removedSheets.contains(cssStyleSheet)) { |
848 removedSheets.remove(cssStyleSheet); | 848 removedSheets.remove(cssStyleSheet); |
849 else | 849 if (isInitialFrontendLoad) |
| 850 addedSheets.add(cssStyleSheet); |
| 851 } else { |
850 addedSheets.add(cssStyleSheet); | 852 addedSheets.add(cssStyleSheet); |
| 853 } |
851 } | 854 } |
852 | 855 |
853 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { | 856 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { |
854 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe
ctorStyleSheet.get(*it); | 857 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe
ctorStyleSheet.get(*it); |
855 ASSERT(inspectorStyleSheet); | 858 ASSERT(inspectorStyleSheet); |
856 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { | 859 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
857 String id = unbindStyleSheet(inspectorStyleSheet.get()); | 860 String id = unbindStyleSheet(inspectorStyleSheet.get()); |
858 if (m_frontend) | 861 if (m_frontend && !isInitialFrontendLoad) |
859 m_frontend->styleSheetRemoved(id); | 862 m_frontend->styleSheetRemoved(id); |
860 } | 863 } |
861 } | 864 } |
862 | 865 |
863 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added
Sheets.end(); ++it) { | 866 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added
Sheets.end(); ++it) { |
864 if (!m_cssStyleSheetToInspectorStyleSheet.contains(*it)) { | 867 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh
eet.contains(*it); |
| 868 if (isNew) { |
865 InspectorStyleSheet* newStyleSheet = bindStyleSheet(*it); | 869 InspectorStyleSheet* newStyleSheet = bindStyleSheet(*it); |
866 if (m_frontend) | 870 if (m_frontend) |
867 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); | 871 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); |
868 } | 872 } |
869 } | 873 } |
870 } | 874 } |
871 | 875 |
872 void InspectorCSSAgent::frameDetachedFromParent(Frame* frame) | 876 void InspectorCSSAgent::frameDetachedFromParent(Frame* frame) |
873 { | 877 { |
874 Document* document = frame->document(); | 878 Document* document = frame->document(); |
875 if (!document) | 879 if (!document) |
876 return; | 880 return; |
877 const Vector<CSSStyleSheet*> styleSheets; | 881 const Vector<CSSStyleSheet*> styleSheets; |
878 updateActiveStyleSheets(document, styleSheets); | 882 updateActiveStyleSheets(document, styleSheets, ExistingFrontendRefresh); |
879 } | 883 } |
880 | 884 |
881 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) | 885 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) |
882 { | 886 { |
883 if (m_nodeIdToForcedPseudoState.isEmpty()) | 887 if (m_nodeIdToForcedPseudoState.isEmpty()) |
884 return false; | 888 return false; |
885 | 889 |
886 int nodeId = m_domAgent->boundNodeId(element); | 890 int nodeId = m_domAgent->boundNodeId(element); |
887 if (!nodeId) | 891 if (!nodeId) |
888 return false; | 892 return false; |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 documentsToChange.add(element->ownerDocument()); | 1754 documentsToChange.add(element->ownerDocument()); |
1751 } | 1755 } |
1752 | 1756 |
1753 m_nodeIdToForcedPseudoState.clear(); | 1757 m_nodeIdToForcedPseudoState.clear(); |
1754 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1758 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1755 (*it)->setNeedsStyleRecalc(); | 1759 (*it)->setNeedsStyleRecalc(); |
1756 } | 1760 } |
1757 | 1761 |
1758 } // namespace WebCore | 1762 } // namespace WebCore |
1759 | 1763 |
OLD | NEW |