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 10 matching lines...) Expand all Loading... | |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef InspectorStyleSheet_h | 25 #ifndef InspectorStyleSheet_h |
| 26 #define InspectorStyleSheet_h | 26 #define InspectorStyleSheet_h |
| 27 | 27 |
| 28 #include "core/InspectorTypeBuilder.h" | 28 #include "core/InspectorTypeBuilder.h" |
| 29 #include "core/css/CSSPropertySourceData.h" | 29 #include "core/css/CSSPropertySourceData.h" |
| 30 #include "core/css/CSSStyleDeclaration.h" | 30 #include "core/css/CSSStyleDeclaration.h" |
| 31 #include "core/inspector/InspectorStyleTextEditor.h" | |
| 32 #include "platform/JSONValues.h" | 31 #include "platform/JSONValues.h" |
| 33 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
| 34 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
| 35 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
| 36 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
| 37 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
| 38 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 39 | 38 |
| 40 class ParsedStyleSheet; | 39 class ParsedStyleSheet; |
| 41 | 40 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 String rawText; | 79 String rawText; |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 class InspectorStyle final : public RefCountedWillBeGarbageCollectedFinalized<In spectorStyle> { | 82 class InspectorStyle final : public RefCountedWillBeGarbageCollectedFinalized<In spectorStyle> { |
| 84 public: | 83 public: |
| 85 static PassRefPtrWillBeRawPtr<InspectorStyle> create(unsigned ruleIndex, Pas sRefPtrWillBeRawPtr<CSSStyleDeclaration>, InspectorStyleSheetBase* parentStyleSh eet); | 84 static PassRefPtrWillBeRawPtr<InspectorStyle> create(unsigned ruleIndex, Pas sRefPtrWillBeRawPtr<CSSStyleDeclaration>, InspectorStyleSheetBase* parentStyleSh eet); |
| 86 | 85 |
| 87 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } | 86 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } |
| 88 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; | 87 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; |
| 89 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > buildArrayForComputedStyle() const; | 88 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> > buildArrayForComputedStyle() const; |
| 90 bool setPropertyText(unsigned index, const String& text, bool overwrite, Exc eptionState&); | |
| 91 bool styleText(String* result) const; | 89 bool styleText(String* result) const; |
| 92 bool textForRange(const SourceRange&, String* result) const; | 90 bool textForRange(const SourceRange&, String* result) const; |
| 93 | 91 |
| 94 DECLARE_TRACE(); | 92 DECLARE_TRACE(); |
| 95 | 93 |
| 96 private: | 94 private: |
| 97 InspectorStyle(unsigned ruleIndex, PassRefPtrWillBeRawPtr<CSSStyleDeclaratio n>, InspectorStyleSheetBase* parentStyleSheet); | 95 InspectorStyle(unsigned ruleIndex, PassRefPtrWillBeRawPtr<CSSStyleDeclaratio n>, InspectorStyleSheetBase* parentStyleSheet); |
| 98 | 96 |
| 99 bool verifyPropertyText(const String& propertyText, bool canOmitSemicolon); | |
| 100 void populateAllProperties(WillBeHeapVector<InspectorStyleProperty>& result) const; | 97 void populateAllProperties(WillBeHeapVector<InspectorStyleProperty>& result) const; |
| 101 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; | 98 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; |
| 102 PassRefPtrWillBeRawPtr<CSSRuleSourceData> extractSourceData() const; | 99 PassRefPtrWillBeRawPtr<CSSRuleSourceData> extractSourceData() const; |
| 103 bool applyStyleText(const String&); | |
| 104 String shorthandValue(const String& shorthandProperty) const; | 100 String shorthandValue(const String& shorthandProperty) const; |
| 105 NewLineAndWhitespace& newLineAndWhitespaceDelimiters() const; | |
| 106 inline Document* ownerDocument() const; | 101 inline Document* ownerDocument() const; |
| 107 | 102 |
| 108 unsigned m_ruleIndex; | 103 unsigned m_ruleIndex; |
| 109 RefPtrWillBeMember<CSSStyleDeclaration> m_style; | 104 RefPtrWillBeMember<CSSStyleDeclaration> m_style; |
| 110 RawPtrWillBeMember<InspectorStyleSheetBase> m_parentStyleSheet; | 105 RawPtrWillBeMember<InspectorStyleSheetBase> m_parentStyleSheet; |
| 111 mutable std::pair<String, String> m_format; | 106 mutable std::pair<String, String> m_format; |
|
lushnikov
2015/06/19 15:34:20
nuke
pfeldman
2015/06/19 15:59:28
Done.
| |
| 112 mutable bool m_formatAcquired; | |
| 113 }; | 107 }; |
| 114 | 108 |
| 115 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized <InspectorStyleSheetBase> { | 109 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized <InspectorStyleSheetBase> { |
| 116 public: | 110 public: |
| 117 class CORE_EXPORT Listener { | 111 class CORE_EXPORT Listener { |
| 118 public: | 112 public: |
| 119 Listener() { } | 113 Listener() { } |
| 120 virtual ~Listener() { } | 114 virtual ~Listener() { } |
| 121 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; | 115 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; |
| 122 virtual void willReparseStyleSheet() = 0; | 116 virtual void willReparseStyleSheet() = 0; |
| 123 virtual void didReparseStyleSheet() = 0; | 117 virtual void didReparseStyleSheet() = 0; |
| 124 }; | 118 }; |
| 125 virtual ~InspectorStyleSheetBase() { } | 119 virtual ~InspectorStyleSheetBase() { } |
| 126 DEFINE_INLINE_VIRTUAL_TRACE() { } | 120 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 127 | 121 |
| 128 String id() const { return m_id; } | 122 String id() const { return m_id; } |
| 129 | 123 |
| 130 virtual Document* ownerDocument() const = 0; | 124 virtual Document* ownerDocument() const = 0; |
| 131 virtual bool setText(const String&, ExceptionState&) = 0; | 125 virtual bool setText(const String&, ExceptionState&) = 0; |
| 132 virtual bool getText(String* result) const = 0; | 126 virtual bool getText(String* result) const = 0; |
| 133 bool setPropertyText(unsigned ruleIndex, unsigned propertyIndex, const Strin g& text, bool overwrite, ExceptionState&); | |
| 134 | |
| 135 virtual bool setStyleText(unsigned ruleIndex, const String&) = 0; | |
| 136 bool getStyleText(unsigned ruleIndex, String*); | |
| 137 | 127 |
| 138 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const = 0; | 128 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const = 0; |
| 139 virtual unsigned indexOf(CSSStyleDeclaration*) const = 0; | 129 virtual unsigned indexOf(CSSStyleDeclaration*) const = 0; |
| 140 | 130 |
| 141 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclarati on*); | 131 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclarati on*); |
| 142 bool findPropertyByRange(const SourceRange&, unsigned* ruleIndex, unsigned* propertyIndex, bool* overwrite); | |
| 143 bool lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber, unsigned* offset); | 132 bool lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber, unsigned* offset); |
| 144 virtual bool isInlineStyle() = 0; | 133 virtual bool isInlineStyle() = 0; |
| 145 | 134 |
| 146 protected: | 135 protected: |
| 147 InspectorStyleSheetBase(const String& id, Listener*); | 136 InspectorStyleSheetBase(const String& id, Listener*); |
| 148 | 137 |
| 149 Listener* listener() const { return m_listener; } | 138 Listener* listener() const { return m_listener; } |
| 150 void onStyleSheetTextChanged(); | 139 void onStyleSheetTextChanged(); |
| 151 const LineEndings* lineEndings(); | 140 const LineEndings* lineEndings(); |
| 152 | 141 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 | 178 |
| 190 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul e*); | 179 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul e*); |
| 191 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex); | 180 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex); |
| 192 | 181 |
| 193 unsigned indexOf(CSSStyleRule*) const; | 182 unsigned indexOf(CSSStyleRule*) const; |
| 194 CSSStyleRule* ruleAt(unsigned ruleIndex) const; | 183 CSSStyleRule* ruleAt(unsigned ruleIndex) const; |
| 195 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; | 184 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; |
| 196 | 185 |
| 197 virtual unsigned indexOf(CSSStyleDeclaration*) const override; | 186 virtual unsigned indexOf(CSSStyleDeclaration*) const override; |
| 198 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; | 187 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; |
| 199 virtual bool setStyleText(unsigned ruleIndex, const String&) override; | |
| 200 bool isInlineStyle() override { return false; } | 188 bool isInlineStyle() override { return false; } |
| 201 const CSSRuleVector& flatRules(); | 189 const CSSRuleVector& flatRules(); |
| 202 | 190 |
| 203 protected: | 191 protected: |
| 204 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override; | 192 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override; |
| 205 virtual unsigned ruleCount() override; | 193 virtual unsigned ruleCount() override; |
| 206 | 194 |
| 207 // Also accessed by friend class InspectorStyle. | 195 // Also accessed by friend class InspectorStyle. |
| 208 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned) const override; | 196 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned) const override; |
| 209 virtual bool ensureParsedDataReady() override; | 197 virtual bool ensureParsedDataReady() override; |
| 210 | 198 |
| 211 private: | 199 private: |
| 212 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu m, const String& documentURL, InspectorCSSAgent*); | 200 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu m, const String& documentURL, InspectorCSSAgent*); |
| 213 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S ourceRange&); | 201 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S ourceRange&); |
| 214 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData* *); | 202 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData* *); |
| 215 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**) ; | 203 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**) ; |
| 216 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String& ruleText, ExceptionState&); | 204 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String& ruleText, ExceptionState&); |
| 217 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&, const String& ruleText, ExceptionState&); | 205 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&, const String& ruleText, ExceptionState&); |
| 218 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String& ruleText, ExceptionState&); | 206 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String& ruleText, ExceptionState&); |
| 219 String sourceMapURL() const; | 207 String sourceMapURL() const; |
| 220 String sourceURL() const; | 208 String sourceURL() const; |
| 221 bool ensureText() const; | 209 bool ensureText() const; |
| 222 void ensureFlatRules() const; | 210 void ensureFlatRules() const; |
| 223 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS tyleText, String* result); | |
| 224 bool originalStyleSheetText(String* result) const; | 211 bool originalStyleSheetText(String* result) const; |
| 225 bool resourceStyleSheetText(String* result) const; | 212 bool resourceStyleSheetText(String* result) const; |
| 226 bool inlineStyleSheetText(String* result) const; | 213 bool inlineStyleSheetText(String* result) const; |
| 227 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou rce(const CSSRuleSourceData*, const String&); | 214 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou rce(const CSSRuleSourceData*, const String&); |
| 228 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty leRule*); | 215 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty leRule*); |
| 229 String url() const; | 216 String url() const; |
| 230 bool hasSourceURL() const; | 217 bool hasSourceURL() const; |
| 231 bool startsAtZero() const; | 218 bool startsAtZero() const; |
| 232 | 219 |
| 233 void replaceText(const SourceRange&, const String& text, SourceRange* newRan ge, String* oldText); | 220 void replaceText(const SourceRange&, const String& text, SourceRange* newRan ge, String* oldText); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 248 public: | 235 public: |
| 249 static PassRefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> create(cons t String& id, PassRefPtrWillBeRawPtr<Element>, Listener*); | 236 static PassRefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> create(cons t String& id, PassRefPtrWillBeRawPtr<Element>, Listener*); |
| 250 | 237 |
| 251 void didModifyElementAttribute(); | 238 void didModifyElementAttribute(); |
| 252 virtual Document* ownerDocument() const override; | 239 virtual Document* ownerDocument() const override; |
| 253 virtual bool setText(const String&, ExceptionState&) override; | 240 virtual bool setText(const String&, ExceptionState&) override; |
| 254 virtual bool getText(String* result) const override; | 241 virtual bool getText(String* result) const override; |
| 255 | 242 |
| 256 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } | 243 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } |
| 257 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return 0; } | 244 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return 0; } |
| 258 virtual bool setStyleText(unsigned ruleIndex, const String&) override; | |
| 259 CSSStyleDeclaration* inlineStyle() const; | 245 CSSStyleDeclaration* inlineStyle() const; |
| 260 | 246 |
| 261 DECLARE_VIRTUAL_TRACE(); | 247 DECLARE_VIRTUAL_TRACE(); |
| 262 | 248 |
| 263 protected: | 249 protected: |
| 264 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override; | 250 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override; |
| 265 virtual unsigned ruleCount() override { return 1; } | 251 virtual unsigned ruleCount() override { return 1; } |
| 266 | 252 |
| 267 // Also accessed by friend class InspectorStyle. | 253 // Also accessed by friend class InspectorStyle. |
| 268 virtual bool ensureParsedDataReady() override; | 254 virtual bool ensureParsedDataReady() override; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 283 mutable bool m_isStyleTextValid; | 269 mutable bool m_isStyleTextValid; |
| 284 }; | 270 }; |
| 285 | 271 |
| 286 | 272 |
| 287 | 273 |
| 288 } // namespace blink | 274 } // namespace blink |
| 289 | 275 |
| 290 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); | 276 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); |
| 291 | 277 |
| 292 #endif // !defined(InspectorStyleSheet_h) | 278 #endif // !defined(InspectorStyleSheet_h) |
| OLD | NEW |