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 24 matching lines...) Expand all Loading... |
35 #include "wtf/HashCountedSet.h" | 35 #include "wtf/HashCountedSet.h" |
36 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
37 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
41 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class ChangeRegionOversetTask; | |
46 struct CSSParserString; | 45 struct CSSParserString; |
47 class CSSRule; | 46 class CSSRule; |
48 class CSSRuleList; | 47 class CSSRuleList; |
49 class CSSStyleRule; | 48 class CSSStyleRule; |
50 class CSSStyleSheet; | 49 class CSSStyleSheet; |
51 class Document; | 50 class Document; |
52 class Element; | 51 class Element; |
53 class InspectorFrontend; | 52 class InspectorFrontend; |
54 class InspectorResourceAgent; | 53 class InspectorResourceAgent; |
55 class InstrumentingAgents; | 54 class InstrumentingAgents; |
56 class MediaList; | 55 class MediaList; |
57 class Node; | 56 class Node; |
58 class NodeList; | 57 class NodeList; |
59 class PlatformFontUsage; | 58 class PlatformFontUsage; |
60 class RenderText; | 59 class RenderText; |
61 class StyleResolver; | 60 class StyleResolver; |
62 class UpdateRegionLayoutTask; | |
63 | 61 |
64 class InspectorCSSAgent FINAL | 62 class InspectorCSSAgent FINAL |
65 : public InspectorBaseAgent<InspectorCSSAgent> | 63 : public InspectorBaseAgent<InspectorCSSAgent> |
66 , public InspectorDOMAgent::DOMListener | 64 , public InspectorDOMAgent::DOMListener |
67 , public InspectorBackendDispatcher::CSSCommandHandler | 65 , public InspectorBackendDispatcher::CSSCommandHandler |
68 , public InspectorStyleSheet::Listener { | 66 , public InspectorStyleSheet::Listener { |
69 WTF_MAKE_NONCOPYABLE(InspectorCSSAgent); | 67 WTF_MAKE_NONCOPYABLE(InspectorCSSAgent); |
70 public: | 68 public: |
71 enum MediaListSource { | 69 enum MediaListSource { |
72 MediaListSourceLinkedSheet, | 70 MediaListSourceLinkedSheet, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bool forcePseudoState(Element*, CSSSelector::PseudoType); | 106 bool forcePseudoState(Element*, CSSSelector::PseudoType); |
109 virtual void setFrontend(InspectorFrontend*) OVERRIDE; | 107 virtual void setFrontend(InspectorFrontend*) OVERRIDE; |
110 virtual void clearFrontend() OVERRIDE; | 108 virtual void clearFrontend() OVERRIDE; |
111 virtual void discardAgent() OVERRIDE; | 109 virtual void discardAgent() OVERRIDE; |
112 virtual void restore() OVERRIDE; | 110 virtual void restore() OVERRIDE; |
113 virtual void enable(ErrorString*, PassRefPtr<EnableCallback>) OVERRIDE; | 111 virtual void enable(ErrorString*, PassRefPtr<EnableCallback>) OVERRIDE; |
114 virtual void disable(ErrorString*) OVERRIDE; | 112 virtual void disable(ErrorString*) OVERRIDE; |
115 void reset(); | 113 void reset(); |
116 void didCommitLoad(Frame*, DocumentLoader*); | 114 void didCommitLoad(Frame*, DocumentLoader*); |
117 void mediaQueryResultChanged(); | 115 void mediaQueryResultChanged(); |
118 void didCreateNamedFlow(Document*, NamedFlow*); | |
119 void willRemoveNamedFlow(Document*, NamedFlow*); | |
120 void willMutateRules(); | 116 void willMutateRules(); |
121 void didMutateRules(CSSStyleSheet*); | 117 void didMutateRules(CSSStyleSheet*); |
122 void willMutateStyle(); | 118 void willMutateStyle(); |
123 void didMutateStyle(CSSStyleDeclaration*, bool); | 119 void didMutateStyle(CSSStyleDeclaration*, bool); |
124 | 120 |
125 private: | |
126 void regionLayoutUpdated(NamedFlow*, int documentNodeId); | |
127 void regionOversetChanged(NamedFlow*, int documentNodeId); | |
128 | |
129 public: | 121 public: |
130 void didUpdateRegionLayout(Document*, NamedFlow*); | |
131 void didChangeRegionOverset(Document*, NamedFlow*); | |
132 | |
133 void activeStyleSheetsUpdated(Document*); | 122 void activeStyleSheetsUpdated(Document*); |
134 void frameDetachedFromParent(Frame*); | 123 void frameDetachedFromParent(Frame*); |
135 | 124 |
136 virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBu
ilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&) OVERRIDE; | 125 virtual void getComputedStyleForNode(ErrorString*, int nodeId, RefPtr<TypeBu
ilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >&) OVERRIDE; |
137 virtual void getPlatformFontsForNode(ErrorString*, int nodeId, String* cssFa
milyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage> >&) OVE
RRIDE; | 126 virtual void getPlatformFontsForNode(ErrorString*, int nodeId, String* cssFa
milyName, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage> >&) OVE
RRIDE; |
138 virtual void getInlineStylesForNode(ErrorString*, int nodeId, RefPtr<TypeBui
lder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::CSSStyle>& attribute
s) OVERRIDE; | 127 virtual void getInlineStylesForNode(ErrorString*, int nodeId, RefPtr<TypeBui
lder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::CSSStyle>& attribute
s) OVERRIDE; |
139 virtual void getMatchedStylesForNode(ErrorString*, int nodeId, const bool* i
ncludePseudo, const bool* includeInherited, RefPtr<TypeBuilder::Array<TypeBuilde
r::CSS::RuleMatch> >& matchedCSSRules, RefPtr<TypeBuilder::Array<TypeBuilder::CS
S::PseudoIdMatches> >&, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedSty
leEntry> >& inheritedEntries) OVERRIDE; | 128 virtual void getMatchedStylesForNode(ErrorString*, int nodeId, const bool* i
ncludePseudo, const bool* includeInherited, RefPtr<TypeBuilder::Array<TypeBuilde
r::CSS::RuleMatch> >& matchedCSSRules, RefPtr<TypeBuilder::Array<TypeBuilder::CS
S::PseudoIdMatches> >&, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedSty
leEntry> >& inheritedEntries) OVERRIDE; |
140 virtual void getStyleSheet(ErrorString*, const String& styleSheetId, RefPtr<
TypeBuilder::CSS::CSSStyleSheetBody>& result) OVERRIDE; | 129 virtual void getStyleSheet(ErrorString*, const String& styleSheetId, RefPtr<
TypeBuilder::CSS::CSSStyleSheetBody>& result) OVERRIDE; |
141 virtual void getStyleSheetText(ErrorString*, const String& styleSheetId, Str
ing* result) OVERRIDE; | 130 virtual void getStyleSheetText(ErrorString*, const String& styleSheetId, Str
ing* result) OVERRIDE; |
142 virtual void setStyleSheetText(ErrorString*, const String& styleSheetId, con
st String& text) OVERRIDE; | 131 virtual void setStyleSheetText(ErrorString*, const String& styleSheetId, con
st String& text) OVERRIDE; |
143 virtual void setPropertyText(ErrorString*, const RefPtr<JSONObject>& styleId
, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS
::CSSStyle>& result) OVERRIDE; | 132 virtual void setPropertyText(ErrorString*, const RefPtr<JSONObject>& styleId
, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS
::CSSStyle>& result) OVERRIDE; |
144 virtual void setRuleSelector(ErrorString*, const RefPtr<JSONObject>& ruleId,
const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) OVERRIDE; | 133 virtual void setRuleSelector(ErrorString*, const RefPtr<JSONObject>& ruleId,
const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) OVERRIDE; |
145 virtual void addRule(ErrorString*, int contextNodeId, const String& selector
, RefPtr<TypeBuilder::CSS::CSSRule>& result) OVERRIDE; | 134 virtual void addRule(ErrorString*, int contextNodeId, const String& selector
, RefPtr<TypeBuilder::CSS::CSSRule>& result) OVERRIDE; |
146 virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<JSONArr
ay>& forcedPseudoClasses) OVERRIDE; | 135 virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<JSONArr
ay>& forcedPseudoClasses) OVERRIDE; |
147 virtual void getNamedFlowCollection(ErrorString*, int documentNodeId, RefPtr
<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result) OVERRIDE; | |
148 | 136 |
149 PassRefPtr<TypeBuilder::CSS::CSSMedia> buildMediaObject(const MediaList*, Me
diaListSource, const String&, CSSStyleSheet*); | 137 PassRefPtr<TypeBuilder::CSS::CSSMedia> buildMediaObject(const MediaList*, Me
diaListSource, const String&, CSSStyleSheet*); |
150 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > buildMediaListCh
ain(CSSRule*); | 138 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > buildMediaListCh
ain(CSSRule*); |
151 | 139 |
152 private: | 140 private: |
153 class StyleSheetAction; | 141 class StyleSheetAction; |
154 class SetStyleSheetTextAction; | 142 class SetStyleSheetTextAction; |
155 class SetPropertyTextAction; | 143 class SetPropertyTextAction; |
156 class SetRuleSelectorAction; | 144 class SetRuleSelectorAction; |
157 class AddRuleAction; | 145 class AddRuleAction; |
158 class EnableResourceClient; | 146 class EnableResourceClient; |
159 | 147 |
160 InspectorCSSAgent(InspectorDOMAgent*, InspectorPageAgent*, InspectorResource
Agent*); | 148 InspectorCSSAgent(InspectorDOMAgent*, InspectorPageAgent*, InspectorResource
Agent*); |
161 | 149 |
162 typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleShee
t; | 150 typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleShee
t; |
163 typedef HashMap<Node*, RefPtr<InspectorStyleSheetForInlineStyle> > NodeToIns
pectorStyleSheet; // bogus "stylesheets" with elements' inline styles | 151 typedef HashMap<Node*, RefPtr<InspectorStyleSheetForInlineStyle> > NodeToIns
pectorStyleSheet; // bogus "stylesheets" with elements' inline styles |
164 typedef HashMap<int, unsigned> NodeIdToForcedPseudoState; | 152 typedef HashMap<int, unsigned> NodeIdToForcedPseudoState; |
165 | 153 |
166 void wasEnabled(PassRefPtr<EnableCallback>); | 154 void wasEnabled(PassRefPtr<EnableCallback>); |
167 void resetNonPersistentData(); | 155 void resetNonPersistentData(); |
168 InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element); | 156 InspectorStyleSheetForInlineStyle* asInspectorStyleSheet(Element* element); |
169 Element* elementForId(ErrorString*, int nodeId); | 157 Element* elementForId(ErrorString*, int nodeId); |
170 int documentNodeWithRequestedFlowsId(Document*); | |
171 void collectAllStyleSheets(Vector<InspectorStyleSheet*>&); | 158 void collectAllStyleSheets(Vector<InspectorStyleSheet*>&); |
172 void collectAllDocumentStyleSheets(Document*, Vector<CSSStyleSheet*>&); | 159 void collectAllDocumentStyleSheets(Document*, Vector<CSSStyleSheet*>&); |
173 void collectStyleSheets(CSSStyleSheet*, Vector<CSSStyleSheet*>&); | 160 void collectStyleSheets(CSSStyleSheet*, Vector<CSSStyleSheet*>&); |
174 | 161 |
175 void updateActiveStyleSheetsForDocument(Document*, StyleSheetsUpdateType); | 162 void updateActiveStyleSheetsForDocument(Document*, StyleSheetsUpdateType); |
176 void updateActiveStyleSheets(Frame*, const Vector<CSSStyleSheet*>&, StyleShe
etsUpdateType); | 163 void updateActiveStyleSheets(Frame*, const Vector<CSSStyleSheet*>&, StyleShe
etsUpdateType); |
177 | 164 |
178 void collectPlatformFontsForRenderer(RenderText*, HashCountedSet<String>*); | 165 void collectPlatformFontsForRenderer(RenderText*, HashCountedSet<String>*); |
179 | 166 |
180 InspectorStyleSheet* bindStyleSheet(CSSStyleSheet*); | 167 InspectorStyleSheet* bindStyleSheet(CSSStyleSheet*); |
181 String unbindStyleSheet(InspectorStyleSheet*); | 168 String unbindStyleSheet(InspectorStyleSheet*); |
182 InspectorStyleSheet* viaInspectorStyleSheet(Document*, bool createIfAbsent); | 169 InspectorStyleSheet* viaInspectorStyleSheet(Document*, bool createIfAbsent); |
183 InspectorStyleSheet* assertStyleSheetForId(ErrorString*, const String&); | 170 InspectorStyleSheet* assertStyleSheetForId(ErrorString*, const String&); |
184 TypeBuilder::CSS::StyleSheetOrigin::Enum detectOrigin(CSSStyleSheet* pageSty
leSheet, Document* ownerDocument); | 171 TypeBuilder::CSS::StyleSheetOrigin::Enum detectOrigin(CSSStyleSheet* pageSty
leSheet, Document* ownerDocument); |
185 bool styleSheetEditInProgress() const { return m_styleSheetsPendingMutation
|| m_styleDeclarationPendingMutation || m_isSettingStyleSheetText; } | 172 bool styleSheetEditInProgress() const { return m_styleSheetsPendingMutation
|| m_styleDeclarationPendingMutation || m_isSettingStyleSheetText; } |
186 | 173 |
187 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*); | 174 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*); |
188 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSRule> > buildArrayForRule
List(CSSRuleList*); | 175 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSRule> > buildArrayForRule
List(CSSRuleList*); |
189 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > buildArrayForMa
tchedRuleList(CSSRuleList*, Element*); | 176 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > buildArrayForMa
tchedRuleList(CSSRuleList*, Element*); |
190 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForAttributesStyle(Element
*); | 177 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForAttributesStyle(Element
*); |
191 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Region> > buildArrayForRegio
ns(ErrorString*, PassRefPtr<NodeList>, int documentNodeId); | |
192 PassRefPtr<TypeBuilder::CSS::NamedFlow> buildObjectForNamedFlow(ErrorString*
, NamedFlow*, int documentNodeId); | |
193 | 178 |
194 // InspectorDOMAgent::DOMListener implementation | 179 // InspectorDOMAgent::DOMListener implementation |
195 virtual void didRemoveDocument(Document*) OVERRIDE; | 180 virtual void didRemoveDocument(Document*) OVERRIDE; |
196 virtual void didRemoveDOMNode(Node*) OVERRIDE; | 181 virtual void didRemoveDOMNode(Node*) OVERRIDE; |
197 virtual void didModifyDOMAttr(Element*) OVERRIDE; | 182 virtual void didModifyDOMAttr(Element*) OVERRIDE; |
198 | 183 |
199 // InspectorStyleSheet::Listener implementation | 184 // InspectorStyleSheet::Listener implementation |
200 virtual void styleSheetChanged(InspectorStyleSheet*) OVERRIDE; | 185 virtual void styleSheetChanged(InspectorStyleSheet*) OVERRIDE; |
201 virtual void willReparseStyleSheet() OVERRIDE; | 186 virtual void willReparseStyleSheet() OVERRIDE; |
202 virtual void didReparseStyleSheet() OVERRIDE; | 187 virtual void didReparseStyleSheet() OVERRIDE; |
203 | 188 |
204 void resetPseudoStates(); | 189 void resetPseudoStates(); |
205 | 190 |
206 InspectorFrontend::CSS* m_frontend; | 191 InspectorFrontend::CSS* m_frontend; |
207 InspectorDOMAgent* m_domAgent; | 192 InspectorDOMAgent* m_domAgent; |
208 InspectorPageAgent* m_pageAgent; | 193 InspectorPageAgent* m_pageAgent; |
209 InspectorResourceAgent* m_resourceAgent; | 194 InspectorResourceAgent* m_resourceAgent; |
210 | 195 |
211 IdToInspectorStyleSheet m_idToInspectorStyleSheet; | 196 IdToInspectorStyleSheet m_idToInspectorStyleSheet; |
212 HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > m_cssStyleSheetToInspe
ctorStyleSheet; | 197 HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > m_cssStyleSheetToInspe
ctorStyleSheet; |
213 HashMap<Frame*, OwnPtr<HashSet<CSSStyleSheet*> > > m_frameToCSSStyleSheets; | 198 HashMap<Frame*, OwnPtr<HashSet<CSSStyleSheet*> > > m_frameToCSSStyleSheets; |
214 | 199 |
215 NodeToInspectorStyleSheet m_nodeToInspectorStyleSheet; | 200 NodeToInspectorStyleSheet m_nodeToInspectorStyleSheet; |
216 HashMap<RefPtr<Document>, RefPtr<InspectorStyleSheet> > m_documentToViaInspe
ctorStyleSheet; // "via inspector" stylesheets | 201 HashMap<RefPtr<Document>, RefPtr<InspectorStyleSheet> > m_documentToViaInspe
ctorStyleSheet; // "via inspector" stylesheets |
217 NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState; | 202 NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState; |
218 HashSet<int> m_namedFlowCollectionsRequested; | |
219 OwnPtr<UpdateRegionLayoutTask> m_updateRegionLayoutTask; | |
220 OwnPtr<ChangeRegionOversetTask> m_changeRegionOversetTask; | |
221 | 203 |
222 RefPtr<CSSStyleSheet> m_inspectorUserAgentStyleSheet; | 204 RefPtr<CSSStyleSheet> m_inspectorUserAgentStyleSheet; |
223 | 205 |
224 int m_lastStyleSheetId; | 206 int m_lastStyleSheetId; |
225 int m_styleSheetsPendingMutation; | 207 int m_styleSheetsPendingMutation; |
226 bool m_styleDeclarationPendingMutation; | 208 bool m_styleDeclarationPendingMutation; |
227 bool m_creatingViaInspectorStyleSheet; | 209 bool m_creatingViaInspectorStyleSheet; |
228 bool m_isSettingStyleSheetText; | 210 bool m_isSettingStyleSheetText; |
229 | 211 |
230 friend class ChangeRegionOversetTask; | |
231 friend class EnableResourceClient; | 212 friend class EnableResourceClient; |
232 friend class StyleSheetBinder; | 213 friend class StyleSheetBinder; |
233 friend class UpdateRegionLayoutTask; | |
234 }; | 214 }; |
235 | 215 |
236 | 216 |
237 } // namespace WebCore | 217 } // namespace WebCore |
238 | 218 |
239 #endif // !defined(InspectorCSSAgent_h) | 219 #endif // !defined(InspectorCSSAgent_h) |
OLD | NEW |