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

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 121263002: DevTools: Do not force style sheets update on inspector start. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 6 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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, true);
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
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, false);
834 } 832 }
835 833
836 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, const Vector <CSSStyleSheet*>& allSheetsVector) 834 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
837 { 835 {
838 HashSet<CSSStyleSheet*> removedSheets; 836 HashSet<CSSStyleSheet*> removedSheets;
839 for (CSSStyleSheetToInspectorStyleSheet::iterator it = m_cssStyleSheetToInsp ectorStyleSheet.begin(); it != m_cssStyleSheetToInspectorStyleSheet.end(); ++it) { 837 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)) 838 if (it->value->canBind() && (!it->key->ownerDocument() || it->key->owner Document() == document))
841 removedSheets.add(it->key); 839 removedSheets.add(it->key);
842 } 840 }
843 841
844 HashSet<CSSStyleSheet*> addedSheets; 842 HashSet<CSSStyleSheet*> addedSheets;
845 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) { 843 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it != allSheetsVector.end(); ++it) {
846 CSSStyleSheet* cssStyleSheet = *it; 844 CSSStyleSheet* cssStyleSheet = *it;
847 if (removedSheets.contains(cssStyleSheet)) 845 if (removedSheets.contains(cssStyleSheet)) {
848 removedSheets.remove(cssStyleSheet); 846 removedSheets.remove(cssStyleSheet);
849 else 847 if (initial)
848 addedSheets.add(cssStyleSheet);
849 } else {
850 addedSheets.add(cssStyleSheet); 850 addedSheets.add(cssStyleSheet);
851 }
851 } 852 }
852 853
853 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem ovedSheets.end(); ++it) { 854 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem ovedSheets.end(); ++it) {
854 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(*it); 855 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe ctorStyleSheet.get(*it);
855 ASSERT(inspectorStyleSheet); 856 ASSERT(inspectorStyleSheet);
856 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { 857 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) {
857 String id = unbindStyleSheet(inspectorStyleSheet.get()); 858 String id = unbindStyleSheet(inspectorStyleSheet.get());
858 if (m_frontend) 859 if (m_frontend && !initial)
859 m_frontend->styleSheetRemoved(id); 860 m_frontend->styleSheetRemoved(id);
860 } 861 }
861 } 862 }
862 863
863 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added Sheets.end(); ++it) { 864 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added Sheets.end(); ++it) {
864 if (!m_cssStyleSheetToInspectorStyleSheet.contains(*it)) { 865 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
866 if (isNew) {
865 InspectorStyleSheet* newStyleSheet = bindStyleSheet(*it); 867 InspectorStyleSheet* newStyleSheet = bindStyleSheet(*it);
866 if (m_frontend) 868 if (m_frontend)
867 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); 869 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo());
868 } 870 }
869 } 871 }
870 } 872 }
871 873
872 void InspectorCSSAgent::frameDetachedFromParent(Frame* frame) 874 void InspectorCSSAgent::frameDetachedFromParent(Frame* frame)
873 { 875 {
874 Document* document = frame->document(); 876 Document* document = frame->document();
875 if (!document) 877 if (!document)
876 return; 878 return;
877 const Vector<CSSStyleSheet*> styleSheets; 879 const Vector<CSSStyleSheet*> styleSheets;
878 updateActiveStyleSheets(document, styleSheets); 880 updateActiveStyleSheets(document, styleSheets, false);
879 } 881 }
880 882
881 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType) 883 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType)
882 { 884 {
883 if (m_nodeIdToForcedPseudoState.isEmpty()) 885 if (m_nodeIdToForcedPseudoState.isEmpty())
884 return false; 886 return false;
885 887
886 int nodeId = m_domAgent->boundNodeId(element); 888 int nodeId = m_domAgent->boundNodeId(element);
887 if (!nodeId) 889 if (!nodeId)
888 return false; 890 return false;
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 documentsToChange.add(element->ownerDocument()); 1752 documentsToChange.add(element->ownerDocument());
1751 } 1753 }
1752 1754
1753 m_nodeIdToForcedPseudoState.clear(); 1755 m_nodeIdToForcedPseudoState.clear();
1754 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1756 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1755 (*it)->setNeedsStyleRecalc(); 1757 (*it)->setNeedsStyleRecalc();
1756 } 1758 }
1757 1759
1758 } // namespace WebCore 1760 } // namespace WebCore
1759 1761
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698