| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 virtual void willReparseStyleSheet() = 0; | 169 virtual void willReparseStyleSheet() = 0; |
| 170 virtual void didReparseStyleSheet() = 0; | 170 virtual void didReparseStyleSheet() = 0; |
| 171 }; | 171 }; |
| 172 virtual ~InspectorStyleSheetBase() { } | 172 virtual ~InspectorStyleSheetBase() { } |
| 173 | 173 |
| 174 String id() const { return m_id; } | 174 String id() const { return m_id; } |
| 175 | 175 |
| 176 virtual Document* ownerDocument() const = 0; | 176 virtual Document* ownerDocument() const = 0; |
| 177 virtual bool setText(const String&, ExceptionState&) = 0; | 177 virtual bool setText(const String&, ExceptionState&) = 0; |
| 178 virtual bool getText(String* result) const = 0; | 178 virtual bool getText(String* result) const = 0; |
| 179 virtual void reparseStyleSheet(const String&) = 0; | |
| 180 bool setPropertyText(const InspectorCSSId&, unsigned propertyIndex, const St
ring& text, bool overwrite, String* oldPropertyText, ExceptionState&); | 179 bool setPropertyText(const InspectorCSSId&, unsigned propertyIndex, const St
ring& text, bool overwrite, String* oldPropertyText, ExceptionState&); |
| 181 | 180 |
| 182 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const = 0; | 181 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const = 0; |
| 183 virtual InspectorCSSId styleId(CSSStyleDeclaration*) const = 0; | 182 virtual InspectorCSSId styleId(CSSStyleDeclaration*) const = 0; |
| 184 | 183 |
| 185 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclarati
on*); | 184 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclarati
on*); |
| 186 | 185 |
| 187 protected: | 186 protected: |
| 188 InspectorStyleSheetBase(const String& id, Listener*); | 187 InspectorStyleSheetBase(const String& id, Listener*); |
| 189 | 188 |
| 190 Listener* listener() const { return m_listener; } | 189 Listener* listener() const { return m_listener; } |
| 191 void fireStyleSheetChanged(); | 190 void fireStyleSheetChanged(); |
| 191 PassOwnPtr<Vector<unsigned> > lineEndings(); |
| 192 | 192 |
| 193 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) = 0; | 193 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) = 0; |
| 194 | 194 |
| 195 // Also accessed by friend class InspectorStyle. | 195 // Also accessed by friend class InspectorStyle. |
| 196 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
) const = 0; | 196 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
) const = 0; |
| 197 virtual bool setStyleText(CSSStyleDeclaration*, const String&) = 0; | 197 virtual bool setStyleText(CSSStyleDeclaration*, const String&) = 0; |
| 198 virtual PassOwnPtr<Vector<unsigned> > lineEndings() const = 0; | |
| 199 virtual bool ensureParsedDataReady() = 0; | 198 virtual bool ensureParsedDataReady() = 0; |
| 200 | 199 |
| 201 private: | 200 private: |
| 202 friend class InspectorStyle; | 201 friend class InspectorStyle; |
| 203 | 202 |
| 204 String m_id; | 203 String m_id; |
| 205 Listener* m_listener; | 204 Listener* m_listener; |
| 206 }; | 205 }; |
| 207 | 206 |
| 208 class InspectorStyleSheet : public InspectorStyleSheetBase { | 207 class InspectorStyleSheet : public InspectorStyleSheetBase { |
| 209 public: | 208 public: |
| 210 static PassRefPtr<InspectorStyleSheet> create(InspectorPageAgent*, Inspector
ResourceAgent*, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, Type
Builder::CSS::StyleSheetOrigin::Enum, const String& documentURL, Listener*); | 209 static PassRefPtr<InspectorStyleSheet> create(InspectorPageAgent*, Inspector
ResourceAgent*, const String& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, Type
Builder::CSS::StyleSheetOrigin::Enum, const String& documentURL, Listener*); |
| 211 | 210 |
| 212 virtual ~InspectorStyleSheet(); | 211 virtual ~InspectorStyleSheet(); |
| 213 | 212 |
| 214 String finalURL() const; | 213 String finalURL() const; |
| 215 virtual Document* ownerDocument() const OVERRIDE; | 214 virtual Document* ownerDocument() const OVERRIDE; |
| 216 virtual void reparseStyleSheet(const String&) OVERRIDE; | |
| 217 virtual bool setText(const String&, ExceptionState&) OVERRIDE; | 215 virtual bool setText(const String&, ExceptionState&) OVERRIDE; |
| 218 virtual bool getText(String* result) const OVERRIDE; | 216 virtual bool getText(String* result) const OVERRIDE; |
| 219 String ruleSelector(const InspectorCSSId&, ExceptionState&); | 217 String ruleSelector(const InspectorCSSId&, ExceptionState&); |
| 220 bool setRuleSelector(const InspectorCSSId&, const String& selector, Exceptio
nState&); | 218 bool setRuleSelector(const InspectorCSSId&, const String& selector, Exceptio
nState&); |
| 221 CSSStyleRule* addRule(const String& selector, ExceptionState&); | 219 CSSStyleRule* addRule(const String& selector, ExceptionState&); |
| 222 bool deleteRule(const InspectorCSSId&, ExceptionState&); | 220 bool deleteRule(const InspectorCSSId&, ExceptionState&); |
| 223 | 221 |
| 224 CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); } | 222 CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); } |
| 225 | 223 |
| 226 PassRefPtr<TypeBuilder::CSS::CSSStyleSheetHeader> buildObjectForStyleSheetIn
fo() const; | 224 PassRefPtr<TypeBuilder::CSS::CSSStyleSheetHeader> buildObjectForStyleSheetIn
fo() const; |
| 227 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*, Pass
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> >); | 225 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*, Pass
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> >); |
| 228 | 226 |
| 229 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul
e*); | 227 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul
e*); |
| 230 | 228 |
| 231 InspectorCSSId ruleId(CSSStyleRule*) const; | 229 InspectorCSSId ruleId(CSSStyleRule*) const; |
| 232 CSSStyleRule* ruleForId(const InspectorCSSId&) const; | 230 CSSStyleRule* ruleForId(const InspectorCSSId&) const; |
| 233 | 231 |
| 234 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE {
return ruleIdByStyle(style); } | 232 virtual InspectorCSSId styleId(CSSStyleDeclaration*) const OVERRIDE; |
| 235 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const OVERRID
E; | 233 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const OVERRID
E; |
| 236 | 234 |
| 237 protected: | 235 protected: |
| 238 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; | 236 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; |
| 239 | 237 |
| 240 // Also accessed by friend class InspectorStyle. | 238 // Also accessed by friend class InspectorStyle. |
| 241 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
) const OVERRIDE; | 239 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
) const OVERRIDE; |
| 242 virtual bool setStyleText(CSSStyleDeclaration*, const String&) OVERRIDE; | 240 virtual bool setStyleText(CSSStyleDeclaration*, const String&) OVERRIDE; |
| 243 virtual PassOwnPtr<Vector<unsigned> > lineEndings() const OVERRIDE; | |
| 244 virtual bool ensureParsedDataReady() OVERRIDE; | 241 virtual bool ensureParsedDataReady() OVERRIDE; |
| 245 | 242 |
| 246 private: | 243 private: |
| 247 InspectorStyleSheet(InspectorPageAgent*, InspectorResourceAgent*, const Stri
ng& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOr
igin::Enum, const String& documentURL, Listener*); | 244 InspectorStyleSheet(InspectorPageAgent*, InspectorResourceAgent*, const Stri
ng& id, PassRefPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOr
igin::Enum, const String& documentURL, Listener*); |
| 248 | 245 |
| 249 InspectorCSSId ruleIdByStyle(CSSStyleDeclaration*) const; | |
| 250 unsigned ruleIndexByStyle(CSSStyleDeclaration*) const; | 246 unsigned ruleIndexByStyle(CSSStyleDeclaration*) const; |
| 251 unsigned ruleIndexByRule(const CSSRule*) const; | |
| 252 String sourceMapURL() const; | 247 String sourceMapURL() const; |
| 253 String sourceURL() const; | 248 String sourceURL() const; |
| 254 bool checkPageStyleSheet(ExceptionState&) const; | |
| 255 bool ensureText() const; | 249 bool ensureText() const; |
| 256 void ensureFlatRules() const; | 250 void ensureFlatRules() const; |
| 257 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS
tyleText, String* result); | 251 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS
tyleText, String* result); |
| 258 bool originalStyleSheetText(String* result) const; | 252 bool originalStyleSheetText(String* result) const; |
| 259 bool resourceStyleSheetText(String* result) const; | 253 bool resourceStyleSheetText(String* result) const; |
| 260 bool inlineStyleSheetText(String* result) const; | 254 bool inlineStyleSheetText(String* result) const; |
| 261 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&) const; | 255 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&); |
| 262 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); | 256 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); |
| 263 String url() const; | 257 String url() const; |
| 264 bool hasSourceURL() const; | 258 bool hasSourceURL() const; |
| 265 bool startsAtZero() const; | 259 bool startsAtZero() const; |
| 266 | 260 |
| 267 InspectorPageAgent* m_pageAgent; | 261 InspectorPageAgent* m_pageAgent; |
| 268 InspectorResourceAgent* m_resourceAgent; | 262 InspectorResourceAgent* m_resourceAgent; |
| 269 RefPtr<CSSStyleSheet> m_pageStyleSheet; | 263 RefPtr<CSSStyleSheet> m_pageStyleSheet; |
| 270 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin; | 264 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin; |
| 271 String m_documentURL; | 265 String m_documentURL; |
| 272 OwnPtr<ParsedStyleSheet> m_parsedStyleSheet; | 266 OwnPtr<ParsedStyleSheet> m_parsedStyleSheet; |
| 273 mutable CSSRuleVector m_flatRules; | 267 mutable CSSRuleVector m_flatRules; |
| 274 mutable String m_sourceURL; | 268 mutable String m_sourceURL; |
| 275 }; | 269 }; |
| 276 | 270 |
| 277 class InspectorStyleSheetForInlineStyle FINAL : public InspectorStyleSheetBase { | 271 class InspectorStyleSheetForInlineStyle FINAL : public InspectorStyleSheetBase { |
| 278 public: | 272 public: |
| 279 static PassRefPtr<InspectorStyleSheetForInlineStyle> create(const String& id
, PassRefPtr<Element>, Listener*); | 273 static PassRefPtr<InspectorStyleSheetForInlineStyle> create(const String& id
, PassRefPtr<Element>, Listener*); |
| 280 | 274 |
| 281 void didModifyElementAttribute(); | 275 void didModifyElementAttribute(); |
| 282 virtual Document* ownerDocument() const OVERRIDE; | 276 virtual Document* ownerDocument() const OVERRIDE; |
| 283 virtual void reparseStyleSheet(const String&) OVERRIDE; | |
| 284 virtual bool setText(const String&, ExceptionState&) OVERRIDE; | 277 virtual bool setText(const String&, ExceptionState&) OVERRIDE; |
| 285 virtual bool getText(String* result) const OVERRIDE; | 278 virtual bool getText(String* result) const OVERRIDE; |
| 286 | 279 |
| 287 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER
RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } | 280 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER
RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } |
| 288 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE {
return InspectorCSSId(id(), 0); } | 281 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE {
return InspectorCSSId(id(), 0); } |
| 289 | 282 |
| 290 protected: | 283 protected: |
| 291 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; | 284 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId&
) OVERRIDE; |
| 292 | 285 |
| 293 // Also accessed by friend class InspectorStyle. | 286 // Also accessed by friend class InspectorStyle. |
| 294 virtual bool ensureParsedDataReady() OVERRIDE; | 287 virtual bool ensureParsedDataReady() OVERRIDE; |
| 295 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
style) const OVERRIDE { ASSERT_UNUSED(style, style == inlineStyle()); return m_
ruleSourceData; } | 288 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration*
style) const OVERRIDE { ASSERT_UNUSED(style, style == inlineStyle()); return m_
ruleSourceData; } |
| 296 virtual bool setStyleText(CSSStyleDeclaration*, const String&) OVERRIDE; | 289 virtual bool setStyleText(CSSStyleDeclaration*, const String&) OVERRIDE; |
| 297 virtual PassOwnPtr<Vector<unsigned> > lineEndings() const OVERRIDE; | |
| 298 | 290 |
| 299 private: | 291 private: |
| 300 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis
tener*); | 292 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis
tener*); |
| 301 CSSStyleDeclaration* inlineStyle() const; | 293 CSSStyleDeclaration* inlineStyle() const; |
| 302 const String& elementStyleText() const; | 294 const String& elementStyleText() const; |
| 303 PassRefPtr<CSSRuleSourceData> getStyleAttributeData() const; | 295 PassRefPtr<CSSRuleSourceData> getStyleAttributeData() const; |
| 304 | 296 |
| 305 RefPtr<Element> m_element; | 297 RefPtr<Element> m_element; |
| 306 RefPtr<CSSRuleSourceData> m_ruleSourceData; | 298 RefPtr<CSSRuleSourceData> m_ruleSourceData; |
| 307 RefPtr<InspectorStyle> m_inspectorStyle; | 299 RefPtr<InspectorStyle> m_inspectorStyle; |
| 308 | 300 |
| 309 // Contains "style" attribute value. | 301 // Contains "style" attribute value. |
| 310 mutable String m_styleText; | 302 mutable String m_styleText; |
| 311 mutable bool m_isStyleTextValid; | 303 mutable bool m_isStyleTextValid; |
| 312 }; | 304 }; |
| 313 | 305 |
| 314 | 306 |
| 315 } // namespace WebCore | 307 } // namespace WebCore |
| 316 | 308 |
| 317 #endif // !defined(InspectorStyleSheet_h) | 309 #endif // !defined(InspectorStyleSheet_h) |
| OLD | NEW |