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

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

Issue 202103002: DevTools: refactor InspectorStyleSheet (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: introduce InspectorStyleSheetBase class 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 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 class Node; 56 class Node;
57 class NodeList; 57 class NodeList;
58 class PlatformFontUsage; 58 class PlatformFontUsage;
59 class RenderText; 59 class RenderText;
60 class StyleResolver; 60 class StyleResolver;
61 61
62 class InspectorCSSAgent FINAL 62 class InspectorCSSAgent FINAL
63 : public InspectorBaseAgent<InspectorCSSAgent> 63 : public InspectorBaseAgent<InspectorCSSAgent>
64 , public InspectorDOMAgent::DOMListener 64 , public InspectorDOMAgent::DOMListener
65 , public InspectorBackendDispatcher::CSSCommandHandler 65 , public InspectorBackendDispatcher::CSSCommandHandler
66 , public InspectorStyleSheet::Listener { 66 , public InspectorStyleSheetBase::Listener {
67 WTF_MAKE_NONCOPYABLE(InspectorCSSAgent); 67 WTF_MAKE_NONCOPYABLE(InspectorCSSAgent);
68 public: 68 public:
69 enum MediaListSource { 69 enum MediaListSource {
70 MediaListSourceLinkedSheet, 70 MediaListSourceLinkedSheet,
71 MediaListSourceInlineSheet, 71 MediaListSourceInlineSheet,
72 MediaListSourceMediaRule, 72 MediaListSourceMediaRule,
73 MediaListSourceImportRule 73 MediaListSourceImportRule
74 }; 74 };
75 75
76 enum StyleSheetsUpdateType { 76 enum StyleSheetsUpdateType {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 class StyleSheetAction; 141 class StyleSheetAction;
142 class SetStyleSheetTextAction; 142 class SetStyleSheetTextAction;
143 class SetPropertyTextAction; 143 class SetPropertyTextAction;
144 class SetRuleSelectorAction; 144 class SetRuleSelectorAction;
145 class AddRuleAction; 145 class AddRuleAction;
146 class EnableResourceClient; 146 class EnableResourceClient;
147 147
148 InspectorCSSAgent(InspectorDOMAgent*, InspectorPageAgent*, InspectorResource Agent*); 148 InspectorCSSAgent(InspectorDOMAgent*, InspectorPageAgent*, InspectorResource Agent*);
149 149
150 typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleShee t; 150 typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleShee t;
151 typedef HashMap<String, RefPtr<InspectorStyleSheetForInlineStyle> > IdToInsp ectorStyleSheetForInlineStyle;
151 typedef HashMap<Node*, RefPtr<InspectorStyleSheetForInlineStyle> > NodeToIns pectorStyleSheet; // bogus "stylesheets" with elements' inline styles 152 typedef HashMap<Node*, RefPtr<InspectorStyleSheetForInlineStyle> > NodeToIns pectorStyleSheet; // bogus "stylesheets" with elements' inline styles
152 typedef HashMap<int, unsigned> NodeIdToForcedPseudoState; 153 typedef HashMap<int, unsigned> NodeIdToForcedPseudoState;
153 154
154 void wasEnabled(PassRefPtr<EnableCallback>); 155 void wasEnabled(PassRefPtr<EnableCallback>);
155 void resetNonPersistentData(); 156 void resetNonPersistentData();
156 InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element); 157 InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element);
157 Element* elementForId(ErrorString*, int nodeId); 158 Element* elementForId(ErrorString*, int nodeId);
158 void collectAllStyleSheets(Vector<InspectorStyleSheet*>&); 159 void collectAllStyleSheets(Vector<InspectorStyleSheet*>&);
159 void collectAllDocumentStyleSheets(Document*, Vector<CSSStyleSheet*>&); 160 void collectAllDocumentStyleSheets(Document*, Vector<CSSStyleSheet*>&);
160 void collectStyleSheets(CSSStyleSheet*, Vector<CSSStyleSheet*>&); 161 void collectStyleSheets(CSSStyleSheet*, Vector<CSSStyleSheet*>&);
161 162
162 void updateActiveStyleSheetsForDocument(Document*, StyleSheetsUpdateType); 163 void updateActiveStyleSheetsForDocument(Document*, StyleSheetsUpdateType);
163 void updateActiveStyleSheets(LocalFrame*, const Vector<CSSStyleSheet*>&, Sty leSheetsUpdateType); 164 void updateActiveStyleSheets(LocalFrame*, const Vector<CSSStyleSheet*>&, Sty leSheetsUpdateType);
164 165
165 void collectPlatformFontsForRenderer(RenderText*, HashCountedSet<String>*); 166 void collectPlatformFontsForRenderer(RenderText*, HashCountedSet<String>*);
166 167
167 InspectorStyleSheet* bindStyleSheet(CSSStyleSheet*); 168 InspectorStyleSheet* bindStyleSheet(CSSStyleSheet*);
168 String unbindStyleSheet(InspectorStyleSheet*); 169 String unbindStyleSheet(InspectorStyleSheet*);
169 InspectorStyleSheet* viaInspectorStyleSheet(Document*, bool createIfAbsent); 170 InspectorStyleSheet* viaInspectorStyleSheet(Document*, bool createIfAbsent);
170 InspectorStyleSheet* assertStyleSheetForId(ErrorString*, const String&); 171 InspectorStyleSheet* assertInspectorStyleSheetForId(ErrorString*, const Stri ng&);
172 InspectorStyleSheetBase* assertStyleSheetForId(ErrorString*, const String&);
171 TypeBuilder::CSS::StyleSheetOrigin::Enum detectOrigin(CSSStyleSheet* pageSty leSheet, Document* ownerDocument); 173 TypeBuilder::CSS::StyleSheetOrigin::Enum detectOrigin(CSSStyleSheet* pageSty leSheet, Document* ownerDocument);
172 bool styleSheetEditInProgress() const { return m_styleSheetsPendingMutation || m_styleDeclarationPendingMutation || m_isSettingStyleSheetText; } 174 bool styleSheetEditInProgress() const { return m_styleSheetsPendingMutation || m_styleDeclarationPendingMutation || m_isSettingStyleSheetText; }
173 175
174 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*); 176 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*);
175 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > buildArrayForMa tchedRuleList(CSSRuleList*, Element*); 177 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > buildArrayForMa tchedRuleList(CSSRuleList*, Element*);
176 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForAttributesStyle(Element *); 178 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForAttributesStyle(Element *);
177 179
178 // InspectorDOMAgent::DOMListener implementation 180 // InspectorDOMAgent::DOMListener implementation
179 virtual void didRemoveDocument(Document*) OVERRIDE; 181 virtual void didRemoveDocument(Document*) OVERRIDE;
180 virtual void didRemoveDOMNode(Node*) OVERRIDE; 182 virtual void didRemoveDOMNode(Node*) OVERRIDE;
181 virtual void didModifyDOMAttr(Element*) OVERRIDE; 183 virtual void didModifyDOMAttr(Element*) OVERRIDE;
182 184
183 // InspectorStyleSheet::Listener implementation 185 // InspectorStyleSheet::Listener implementation
184 virtual void styleSheetChanged(InspectorStyleSheet*) OVERRIDE; 186 virtual void styleSheetChanged(InspectorStyleSheetBase*) OVERRIDE;
185 virtual void willReparseStyleSheet() OVERRIDE; 187 virtual void willReparseStyleSheet() OVERRIDE;
186 virtual void didReparseStyleSheet() OVERRIDE; 188 virtual void didReparseStyleSheet() OVERRIDE;
187 189
188 void resetPseudoStates(); 190 void resetPseudoStates();
189 191
190 InspectorFrontend::CSS* m_frontend; 192 InspectorFrontend::CSS* m_frontend;
191 InspectorDOMAgent* m_domAgent; 193 InspectorDOMAgent* m_domAgent;
192 InspectorPageAgent* m_pageAgent; 194 InspectorPageAgent* m_pageAgent;
193 InspectorResourceAgent* m_resourceAgent; 195 InspectorResourceAgent* m_resourceAgent;
194 196
195 IdToInspectorStyleSheet m_idToInspectorStyleSheet; 197 IdToInspectorStyleSheet m_idToInspectorStyleSheet;
198 IdToInspectorStyleSheetForInlineStyle m_idToInspectorStyleSheetForInlineStyl e;
196 HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > m_cssStyleSheetToInspe ctorStyleSheet; 199 HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > m_cssStyleSheetToInspe ctorStyleSheet;
197 HashMap<LocalFrame*, OwnPtr<HashSet<CSSStyleSheet*> > > m_frameToCSSStyleShe ets; 200 HashMap<LocalFrame*, OwnPtr<HashSet<CSSStyleSheet*> > > m_frameToCSSStyleShe ets;
198 201
199 NodeToInspectorStyleSheet m_nodeToInspectorStyleSheet; 202 NodeToInspectorStyleSheet m_nodeToInspectorStyleSheet;
200 HashMap<RefPtr<Document>, RefPtr<InspectorStyleSheet> > m_documentToViaInspe ctorStyleSheet; // "via inspector" stylesheets 203 HashMap<RefPtr<Document>, RefPtr<InspectorStyleSheet> > m_documentToViaInspe ctorStyleSheet; // "via inspector" stylesheets
201 NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState; 204 NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState;
202 205
203 RefPtr<CSSStyleSheet> m_inspectorUserAgentStyleSheet; 206 RefPtr<CSSStyleSheet> m_inspectorUserAgentStyleSheet;
204 207
205 int m_lastStyleSheetId; 208 int m_lastStyleSheetId;
206 int m_styleSheetsPendingMutation; 209 int m_styleSheetsPendingMutation;
207 bool m_styleDeclarationPendingMutation; 210 bool m_styleDeclarationPendingMutation;
208 bool m_creatingViaInspectorStyleSheet; 211 bool m_creatingViaInspectorStyleSheet;
209 bool m_isSettingStyleSheetText; 212 bool m_isSettingStyleSheetText;
210 213
211 friend class EnableResourceClient; 214 friend class EnableResourceClient;
212 friend class StyleSheetBinder; 215 friend class StyleSheetBinder;
213 }; 216 };
214 217
215 218
216 } // namespace WebCore 219 } // namespace WebCore
217 220
218 #endif // !defined(InspectorCSSAgent_h) 221 #endif // !defined(InspectorCSSAgent_h)
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/InspectorCSSAgent.cpp » ('j') | Source/core/inspector/InspectorStyleSheet.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698