Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 .setStyleSheetId(m_styleSheetId) | 94 .setStyleSheetId(m_styleSheetId) |
| 95 .setOrdinal(m_ordinal); | 95 .setOrdinal(m_ordinal); |
| 96 return result.release(); | 96 return result.release(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 String m_styleSheetId; | 100 String m_styleSheetId; |
| 101 unsigned m_ordinal; | 101 unsigned m_ordinal; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 struct InspectorStyleProperty { | 104 struct InspectorStyleProperty { |
|
haraken
2014/03/28 14:15:00
Again, I want to understand why we don't need to a
wibling-chromium
2014/03/31 09:38:28
I will let Erik answer this, but it should be a pu
Erik Corry
2014/03/31 09:55:53
It's not really a correctness issue (not having th
| |
| 105 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 106 public: | |
| 105 explicit InspectorStyleProperty(CSSPropertySourceData sourceData) | 107 explicit InspectorStyleProperty(CSSPropertySourceData sourceData) |
| 106 : sourceData(sourceData) | 108 : sourceData(sourceData) |
| 107 , hasSource(true) | 109 , hasSource(true) |
| 108 { | 110 { |
| 109 } | 111 } |
| 110 | 112 |
| 111 InspectorStyleProperty(CSSPropertySourceData sourceData, bool hasSource) | 113 InspectorStyleProperty(CSSPropertySourceData sourceData, bool hasSource) |
| 112 : sourceData(sourceData) | 114 : sourceData(sourceData) |
| 113 , hasSource(hasSource) | 115 , hasSource(hasSource) |
| 114 { | 116 { |
| 115 } | 117 } |
| 116 | 118 |
| 117 void setRawTextFromStyleDeclaration(const String& styleDeclaration) | 119 void setRawTextFromStyleDeclaration(const String& styleDeclaration) |
| 118 { | 120 { |
| 119 unsigned start = sourceData.range.start; | 121 unsigned start = sourceData.range.start; |
| 120 unsigned end = sourceData.range.end; | 122 unsigned end = sourceData.range.end; |
| 121 ASSERT(start < end); | 123 ASSERT(start < end); |
| 122 ASSERT(end <= styleDeclaration.length()); | 124 ASSERT(end <= styleDeclaration.length()); |
| 123 rawText = styleDeclaration.substring(start, end - start); | 125 rawText = styleDeclaration.substring(start, end - start); |
| 124 } | 126 } |
| 125 | 127 |
| 126 bool hasRawText() const { return !rawText.isEmpty(); } | 128 bool hasRawText() const { return !rawText.isEmpty(); } |
| 127 | 129 |
| 130 void trace(Visitor* visitor) { visitor->trace(sourceData); } | |
| 131 | |
| 128 CSSPropertySourceData sourceData; | 132 CSSPropertySourceData sourceData; |
| 129 bool hasSource; | 133 bool hasSource; |
| 130 String rawText; | 134 String rawText; |
| 131 }; | 135 }; |
| 132 | 136 |
| 133 class InspectorStyle FINAL : public RefCounted<InspectorStyle> { | 137 class InspectorStyle FINAL : public RefCounted<InspectorStyle> { |
| 134 public: | 138 public: |
| 135 static PassRefPtr<InspectorStyle> create(const InspectorCSSId&, PassRefPtr<C SSStyleDeclaration>, InspectorStyleSheetBase* parentStyleSheet); | 139 static PassRefPtr<InspectorStyle> create(const InspectorCSSId&, PassRefPtr<C SSStyleDeclaration>, InspectorStyleSheetBase* parentStyleSheet); |
| 136 | 140 |
| 137 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } | 141 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } |
| 138 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; | 142 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; |
| 139 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > buildArrayForComputedStyle() const; | 143 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > buildArrayForComputedStyle() const; |
| 140 bool setPropertyText(unsigned index, const String& text, bool overwrite, Exc eptionState&); | 144 bool setPropertyText(unsigned index, const String& text, bool overwrite, Exc eptionState&); |
| 141 bool styleText(String* result) const; | 145 bool styleText(String* result) const; |
| 142 | 146 |
| 143 private: | 147 private: |
| 144 InspectorStyle(const InspectorCSSId&, PassRefPtr<CSSStyleDeclaration>, Inspe ctorStyleSheetBase* parentStyleSheet); | 148 InspectorStyle(const InspectorCSSId&, PassRefPtr<CSSStyleDeclaration>, Inspe ctorStyleSheetBase* parentStyleSheet); |
| 145 | 149 |
| 146 bool verifyPropertyText(const String& propertyText, bool canOmitSemicolon); | 150 bool verifyPropertyText(const String& propertyText, bool canOmitSemicolon); |
| 147 void populateAllProperties(Vector<InspectorStyleProperty>& result) const; | 151 void populateAllProperties(WillBeHeapVector<InspectorStyleProperty>& result) const; |
| 148 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; | 152 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; |
| 149 PassRefPtr<CSSRuleSourceData> extractSourceData() const; | 153 PassRefPtrWillBeRawPtr<CSSRuleSourceData> extractSourceData() const; |
| 150 bool applyStyleText(const String&); | 154 bool applyStyleText(const String&); |
| 151 String shorthandValue(const String& shorthandProperty) const; | 155 String shorthandValue(const String& shorthandProperty) const; |
| 152 NewLineAndWhitespace& newLineAndWhitespaceDelimiters() const; | 156 NewLineAndWhitespace& newLineAndWhitespaceDelimiters() const; |
| 153 inline Document* ownerDocument() const; | 157 inline Document* ownerDocument() const; |
| 154 | 158 |
| 155 InspectorCSSId m_styleId; | 159 InspectorCSSId m_styleId; |
| 156 RefPtr<CSSStyleDeclaration> m_style; | 160 RefPtr<CSSStyleDeclaration> m_style; |
| 157 InspectorStyleSheetBase* m_parentStyleSheet; | 161 InspectorStyleSheetBase* m_parentStyleSheet; |
| 158 mutable std::pair<String, String> m_format; | 162 mutable std::pair<String, String> m_format; |
| 159 mutable bool m_formatAcquired; | 163 mutable bool m_formatAcquired; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 189 protected: | 193 protected: |
| 190 InspectorStyleSheetBase(const String& id, Listener*); | 194 InspectorStyleSheetBase(const String& id, Listener*); |
| 191 | 195 |
| 192 Listener* listener() const { return m_listener; } | 196 Listener* listener() const { return m_listener; } |
| 193 void fireStyleSheetChanged(); | 197 void fireStyleSheetChanged(); |
| 194 PassOwnPtr<Vector<unsigned> > lineEndings(); | 198 PassOwnPtr<Vector<unsigned> > lineEndings(); |
| 195 | 199 |
| 196 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) = 0; | 200 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) = 0; |
| 197 | 201 |
| 198 // Also accessed by friend class InspectorStyle. | 202 // Also accessed by friend class InspectorStyle. |
| 199 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* ) const = 0; | 203 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyle Declaration*) const = 0; |
| 200 virtual bool ensureParsedDataReady() = 0; | 204 virtual bool ensureParsedDataReady() = 0; |
| 201 | 205 |
| 202 private: | 206 private: |
| 203 friend class InspectorStyle; | 207 friend class InspectorStyle; |
| 204 | 208 |
| 205 String m_id; | 209 String m_id; |
| 206 Listener* m_listener; | 210 Listener* m_listener; |
| 207 }; | 211 }; |
| 208 | 212 |
| 209 class InspectorStyleSheet : public InspectorStyleSheetBase { | 213 class InspectorStyleSheet : public InspectorStyleSheetBase { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 232 CSSStyleRule* ruleForId(const InspectorCSSId&) const; | 236 CSSStyleRule* ruleForId(const InspectorCSSId&) const; |
| 233 | 237 |
| 234 virtual InspectorCSSId styleId(CSSStyleDeclaration*) const OVERRIDE; | 238 virtual InspectorCSSId styleId(CSSStyleDeclaration*) const OVERRIDE; |
| 235 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const OVERRID E; | 239 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId&) const OVERRID E; |
| 236 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; | 240 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; |
| 237 | 241 |
| 238 protected: | 242 protected: |
| 239 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) OVERRIDE; | 243 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) OVERRIDE; |
| 240 | 244 |
| 241 // Also accessed by friend class InspectorStyle. | 245 // Also accessed by friend class InspectorStyle. |
| 242 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* ) const OVERRIDE; | 246 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyle Declaration*) const OVERRIDE; |
| 243 virtual bool ensureParsedDataReady() OVERRIDE; | 247 virtual bool ensureParsedDataReady() OVERRIDE; |
| 244 | 248 |
| 245 private: | 249 private: |
| 246 InspectorStyleSheet(InspectorPageAgent*, InspectorResourceAgent*, const Stri ng& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS:: StyleSheetOrigin::Enum, const String& documentURL, Listener*); | 250 InspectorStyleSheet(InspectorPageAgent*, InspectorResourceAgent*, const Stri ng& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS:: StyleSheetOrigin::Enum, const String& documentURL, Listener*); |
| 247 | 251 |
| 248 unsigned ruleIndexByStyle(CSSStyleDeclaration*) const; | 252 unsigned ruleIndexByStyle(CSSStyleDeclaration*) const; |
| 249 String sourceMapURL() const; | 253 String sourceMapURL() const; |
| 250 String sourceURL() const; | 254 String sourceURL() const; |
| 251 bool ensureText() const; | 255 bool ensureText() const; |
| 252 void ensureFlatRules() const; | 256 void ensureFlatRules() const; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 281 | 285 |
| 282 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } | 286 virtual CSSStyleDeclaration* styleForId(const InspectorCSSId& id) const OVER RIDE { ASSERT_UNUSED(id, !id.ordinal()); return inlineStyle(); } |
| 283 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE { return InspectorCSSId(id(), 0); } | 287 virtual InspectorCSSId styleId(CSSStyleDeclaration* style) const OVERRIDE { return InspectorCSSId(id(), 0); } |
| 284 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; | 288 virtual bool setStyleText(const InspectorCSSId&, const String&) OVERRIDE; |
| 285 | 289 |
| 286 protected: | 290 protected: |
| 287 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) OVERRIDE; | 291 virtual PassRefPtr<InspectorStyle> inspectorStyleForId(const InspectorCSSId& ) OVERRIDE; |
| 288 | 292 |
| 289 // Also accessed by friend class InspectorStyle. | 293 // Also accessed by friend class InspectorStyle. |
| 290 virtual bool ensureParsedDataReady() OVERRIDE; | 294 virtual bool ensureParsedDataReady() OVERRIDE; |
| 291 virtual PassRefPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyleDeclaration* style) const OVERRIDE { ASSERT_UNUSED(style, style == inlineStyle()); return m_ ruleSourceData; } | 295 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataFor(CSSStyle Declaration* style) const OVERRIDE { ASSERT_UNUSED(style, style == inlineStyle() ); return m_ruleSourceData; } |
| 292 | 296 |
| 293 private: | 297 private: |
| 294 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis tener*); | 298 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtr<Element>, Lis tener*); |
| 295 CSSStyleDeclaration* inlineStyle() const; | 299 CSSStyleDeclaration* inlineStyle() const; |
| 296 const String& elementStyleText() const; | 300 const String& elementStyleText() const; |
| 297 PassRefPtr<CSSRuleSourceData> getStyleAttributeData() const; | 301 PassRefPtrWillBeRawPtr<CSSRuleSourceData> getStyleAttributeData() const; |
| 298 | 302 |
| 299 RefPtr<Element> m_element; | 303 RefPtr<Element> m_element; |
| 300 RefPtr<CSSRuleSourceData> m_ruleSourceData; | 304 RefPtrWillBePersistent<CSSRuleSourceData> m_ruleSourceData; |
| 301 RefPtr<InspectorStyle> m_inspectorStyle; | 305 RefPtr<InspectorStyle> m_inspectorStyle; |
| 302 | 306 |
| 303 // Contains "style" attribute value. | 307 // Contains "style" attribute value. |
| 304 mutable String m_styleText; | 308 mutable String m_styleText; |
| 305 mutable bool m_isStyleTextValid; | 309 mutable bool m_isStyleTextValid; |
| 306 }; | 310 }; |
| 307 | 311 |
| 308 | 312 |
| 309 } // namespace WebCore | 313 } // namespace WebCore |
| 310 | 314 |
| 311 #endif // !defined(InspectorStyleSheet_h) | 315 #endif // !defined(InspectorStyleSheet_h) |
| OLD | NEW |