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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class CSSStyleDeclaration; | 45 class CSSStyleDeclaration; |
46 class CSSStyleRule; | 46 class CSSStyleRule; |
47 class CSSStyleSheet; | 47 class CSSStyleSheet; |
48 class Document; | 48 class Document; |
49 class Element; | 49 class Element; |
50 class ExceptionState; | 50 class ExceptionState; |
51 class InspectorPageAgent; | 51 class InspectorPageAgent; |
52 class InspectorResourceAgent; | 52 class InspectorResourceAgent; |
53 class InspectorStyleSheetBase; | 53 class InspectorStyleSheetBase; |
54 | 54 |
55 typedef WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector; | 55 typedef WillBeHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector; |
56 typedef String ErrorString; | 56 typedef String ErrorString; |
57 | 57 |
58 class InspectorCSSId { | 58 class InspectorCSSId { |
59 public: | 59 public: |
60 InspectorCSSId() | 60 InspectorCSSId() |
61 : m_ordinal(0) | 61 : m_ordinal(0) |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
65 InspectorCSSId(const String& styleSheetId, unsigned ordinal) | 65 InspectorCSSId(const String& styleSheetId, unsigned ordinal) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 NewLineAndWhitespace& newLineAndWhitespaceDelimiters() const; | 133 NewLineAndWhitespace& newLineAndWhitespaceDelimiters() const; |
134 inline Document* ownerDocument() const; | 134 inline Document* ownerDocument() const; |
135 | 135 |
136 InspectorCSSId m_styleId; | 136 InspectorCSSId m_styleId; |
137 RefPtrWillBePersistent<CSSStyleDeclaration> m_style; | 137 RefPtrWillBePersistent<CSSStyleDeclaration> m_style; |
138 InspectorStyleSheetBase* m_parentStyleSheet; | 138 InspectorStyleSheetBase* m_parentStyleSheet; |
139 mutable std::pair<String, String> m_format; | 139 mutable std::pair<String, String> m_format; |
140 mutable bool m_formatAcquired; | 140 mutable bool m_formatAcquired; |
141 }; | 141 }; |
142 | 142 |
143 class InspectorStyleSheetBase : public RefCounted<InspectorStyleSheetBase> { | 143 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized
<InspectorStyleSheetBase> { |
144 public: | 144 public: |
145 class Listener { | 145 class Listener { |
146 public: | 146 public: |
147 Listener() { } | 147 Listener() { } |
148 virtual ~Listener() { } | 148 virtual ~Listener() { } |
149 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; | 149 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; |
150 virtual void willReparseStyleSheet() = 0; | 150 virtual void willReparseStyleSheet() = 0; |
151 virtual void didReparseStyleSheet() = 0; | 151 virtual void didReparseStyleSheet() = 0; |
152 }; | 152 }; |
153 virtual ~InspectorStyleSheetBase() { } | 153 virtual ~InspectorStyleSheetBase() { } |
| 154 virtual void trace(Visitor*) { } |
154 | 155 |
155 String id() const { return m_id; } | 156 String id() const { return m_id; } |
156 | 157 |
157 virtual Document* ownerDocument() const = 0; | 158 virtual Document* ownerDocument() const = 0; |
158 virtual bool setText(const String&, ExceptionState&) = 0; | 159 virtual bool setText(const String&, ExceptionState&) = 0; |
159 virtual bool getText(String* result) const = 0; | 160 virtual bool getText(String* result) const = 0; |
160 bool setPropertyText(const InspectorCSSId&, unsigned propertyIndex, const St
ring& text, bool overwrite, ExceptionState&); | 161 bool setPropertyText(const InspectorCSSId&, unsigned propertyIndex, const St
ring& text, bool overwrite, ExceptionState&); |
161 | 162 |
162 virtual bool setStyleText(const InspectorCSSId&, const String&) = 0; | 163 virtual bool setStyleText(const InspectorCSSId&, const String&) = 0; |
163 bool getStyleText(const InspectorCSSId&, String*); | 164 bool getStyleText(const InspectorCSSId&, String*); |
(...skipping 21 matching lines...) Expand all Loading... |
185 | 186 |
186 private: | 187 private: |
187 friend class InspectorStyle; | 188 friend class InspectorStyle; |
188 | 189 |
189 String m_id; | 190 String m_id; |
190 Listener* m_listener; | 191 Listener* m_listener; |
191 }; | 192 }; |
192 | 193 |
193 class InspectorStyleSheet : public InspectorStyleSheetBase { | 194 class InspectorStyleSheet : public InspectorStyleSheetBase { |
194 public: | 195 public: |
195 static PassRefPtr<InspectorStyleSheet> create(InspectorPageAgent*, Inspector
ResourceAgent*, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyl
eSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum, const String& documentURL, Lis
tener*); | 196 static PassRefPtrWillBeRawPtr<InspectorStyleSheet> create(InspectorPageAgent
*, InspectorResourceAgent*, const String& id, PassRefPtrWillBeRawPtr<CSSStyleShe
et> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enum, const String& docu
mentURL, Listener*); |
196 | 197 |
197 virtual ~InspectorStyleSheet(); | 198 virtual ~InspectorStyleSheet(); |
| 199 virtual void trace(Visitor*) OVERRIDE; |
198 | 200 |
199 String finalURL() const; | 201 String finalURL() const; |
200 virtual Document* ownerDocument() const OVERRIDE; | 202 virtual Document* ownerDocument() const OVERRIDE; |
201 virtual bool setText(const String&, ExceptionState&) OVERRIDE; | 203 virtual bool setText(const String&, ExceptionState&) OVERRIDE; |
202 virtual bool getText(String* result) const OVERRIDE; | 204 virtual bool getText(String* result) const OVERRIDE; |
203 String ruleSelector(const InspectorCSSId&, ExceptionState&); | 205 String ruleSelector(const InspectorCSSId&, ExceptionState&); |
204 bool setRuleSelector(const InspectorCSSId&, const String& selector, Exceptio
nState&); | 206 bool setRuleSelector(const InspectorCSSId&, const String& selector, Exceptio
nState&); |
205 CSSStyleRule* addRule(const String& selector, ExceptionState&); | 207 CSSStyleRule* addRule(const String& selector, ExceptionState&); |
206 bool deleteRule(const InspectorCSSId&, ExceptionState&); | 208 bool deleteRule(const InspectorCSSId&, ExceptionState&); |
207 | 209 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS
tyleText, String* result); | 242 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS
tyleText, String* result); |
241 bool originalStyleSheetText(String* result) const; | 243 bool originalStyleSheetText(String* result) const; |
242 bool resourceStyleSheetText(String* result) const; | 244 bool resourceStyleSheetText(String* result) const; |
243 bool inlineStyleSheetText(String* result) const; | 245 bool inlineStyleSheetText(String* result) const; |
244 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&); | 246 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&); |
245 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); | 247 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); |
246 String url() const; | 248 String url() const; |
247 bool hasSourceURL() const; | 249 bool hasSourceURL() const; |
248 bool startsAtZero() const; | 250 bool startsAtZero() const; |
249 | 251 |
250 InspectorPageAgent* m_pageAgent; | 252 RawPtrWillBeMember<InspectorPageAgent> m_pageAgent; |
251 InspectorResourceAgent* m_resourceAgent; | 253 RawPtrWillBeMember<InspectorResourceAgent> m_resourceAgent; |
252 RefPtrWillBePersistent<CSSStyleSheet> m_pageStyleSheet; | 254 RefPtrWillBeMember<CSSStyleSheet> m_pageStyleSheet; |
253 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin; | 255 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin; |
254 String m_documentURL; | 256 String m_documentURL; |
255 OwnPtr<ParsedStyleSheet> m_parsedStyleSheet; | 257 OwnPtr<ParsedStyleSheet> m_parsedStyleSheet; |
256 mutable CSSRuleVector m_flatRules; | 258 mutable CSSRuleVector m_flatRules; |
257 mutable String m_sourceURL; | 259 mutable String m_sourceURL; |
258 }; | 260 }; |
259 | 261 |
260 class InspectorStyleSheetForInlineStyle FINAL : public InspectorStyleSheetBase { | 262 class InspectorStyleSheetForInlineStyle FINAL : public InspectorStyleSheetBase { |
261 public: | 263 public: |
262 static PassRefPtr<InspectorStyleSheetForInlineStyle> create(const String& id
, PassRefPtr<Element>, Listener*); | 264 static PassRefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> create(cons
t String& id, PassRefPtr<Element>, Listener*); |
263 | 265 |
264 void didModifyElementAttribute(); | 266 void didModifyElementAttribute(); |
265 virtual Document* ownerDocument() const OVERRIDE; | 267 virtual Document* ownerDocument() const OVERRIDE; |
266 virtual bool setText(const String&, ExceptionState&) OVERRIDE; | 268 virtual bool setText(const String&, ExceptionState&) OVERRIDE; |
267 virtual bool getText(String* result) const OVERRIDE; | 269 virtual bool getText(String* result) const OVERRIDE; |
268 | 270 |
269 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER
RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } | 271 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER
RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } |
270 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE {
return InspectorCSSId(id(), 0); } | 272 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE {
return InspectorCSSId(id(), 0); } |
271 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; | 273 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; |
272 | 274 |
| 275 virtual void trace(Visitor*) OVERRIDE; |
| 276 |
273 protected: | 277 protected: |
274 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; | 278 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; |
275 virtual unsigned ruleCount() OVERRIDE { return 1; } | 279 virtual unsigned ruleCount() OVERRIDE { return 1; } |
276 | 280 |
277 // Also accessed by friend class InspectorStyle. | 281 // Also accessed by friend class InspectorStyle. |
278 virtual bool ensureParsedDataReady() OVERRIDE; | 282 virtual bool ensureParsedDataReady() OVERRIDE; |
279 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned
ruleIndex) const OVERRIDE { ASSERT_UNUSED(ruleIndex, !ruleIndex); return m_ruleS
ourceData; } | 283 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned
ruleIndex) const OVERRIDE { ASSERT_UNUSED(ruleIndex, !ruleIndex); return m_ruleS
ourceData; } |
280 | 284 |
281 private: | 285 private: |
282 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis
tener*); | 286 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis
tener*); |
283 CSSStyleDeclaration* inlineStyle() const; | 287 CSSStyleDeclaration* inlineStyle() const; |
284 const String& elementStyleText() const; | 288 const String& elementStyleText() const; |
285 PassRefPtrWillBeRawPtr<CSSRuleSourceData> getStyleAttributeData() const; | 289 PassRefPtrWillBeRawPtr<CSSRuleSourceData> getStyleAttributeData() const; |
286 | 290 |
287 RefPtr<Element> m_element; | 291 RefPtr<Element> m_element; |
288 RefPtrWillBePersistent<CSSRuleSourceData> m_ruleSourceData; | 292 RefPtrWillBeMember<CSSRuleSourceData> m_ruleSourceData; |
289 RefPtr<InspectorStyle> m_inspectorStyle; | 293 RefPtr<InspectorStyle> m_inspectorStyle; |
290 | 294 |
291 // Contains "style" attribute value. | 295 // Contains "style" attribute value. |
292 mutable String m_styleText; | 296 mutable String m_styleText; |
293 mutable bool m_isStyleTextValid; | 297 mutable bool m_isStyleTextValid; |
294 }; | 298 }; |
295 | 299 |
296 | 300 |
297 } // namespace WebCore | 301 } // namespace WebCore |
298 | 302 |
299 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(WebCore::InspectorStyleProperty); | 303 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(WebCore::InspectorStyleProperty); |
300 | 304 |
301 #endif // !defined(InspectorStyleSheet_h) | 305 #endif // !defined(InspectorStyleSheet_h) |
OLD | NEW |