| 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; | |
| 112 mutable bool m_formatAcquired; | |
| 113 }; | 106 }; |
| 114 | 107 |
| 115 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized
<InspectorStyleSheetBase> { | 108 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized
<InspectorStyleSheetBase> { |
| 116 public: | 109 public: |
| 117 class CORE_EXPORT Listener { | 110 class CORE_EXPORT Listener { |
| 118 public: | 111 public: |
| 119 Listener() { } | 112 Listener() { } |
| 120 virtual ~Listener() { } | 113 virtual ~Listener() { } |
| 121 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; | 114 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; |
| 122 virtual void willReparseStyleSheet() = 0; | 115 virtual void willReparseStyleSheet() = 0; |
| 123 virtual void didReparseStyleSheet() = 0; | 116 virtual void didReparseStyleSheet() = 0; |
| 124 }; | 117 }; |
| 125 virtual ~InspectorStyleSheetBase() { } | 118 virtual ~InspectorStyleSheetBase() { } |
| 126 DEFINE_INLINE_VIRTUAL_TRACE() { } | 119 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 127 | 120 |
| 128 String id() const { return m_id; } | 121 String id() const { return m_id; } |
| 129 | 122 |
| 130 virtual Document* ownerDocument() const = 0; | 123 virtual Document* ownerDocument() const = 0; |
| 131 virtual bool setText(const String&, ExceptionState&) = 0; | 124 virtual bool setText(const String&, ExceptionState&) = 0; |
| 132 virtual bool getText(String* result) const = 0; | 125 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 | 126 |
| 138 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const = 0; | 127 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const = 0; |
| 139 virtual unsigned indexOf(CSSStyleDeclaration*) const = 0; | 128 virtual unsigned indexOf(CSSStyleDeclaration*) const = 0; |
| 140 | 129 |
| 141 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle(CSSStyleDeclarati
on*); | 130 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); | 131 bool lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber,
unsigned* offset); |
| 144 virtual bool isInlineStyle() = 0; | 132 virtual bool isInlineStyle() = 0; |
| 145 | 133 |
| 146 protected: | 134 protected: |
| 147 InspectorStyleSheetBase(const String& id, Listener*); | 135 InspectorStyleSheetBase(const String& id, Listener*); |
| 148 | 136 |
| 149 Listener* listener() const { return m_listener; } | 137 Listener* listener() const { return m_listener; } |
| 150 void onStyleSheetTextChanged(); | 138 void onStyleSheetTextChanged(); |
| 151 const LineEndings* lineEndings(); | 139 const LineEndings* lineEndings(); |
| 152 | 140 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 177 |
| 190 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul
e*); | 178 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul
e*); |
| 191 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons
t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex); | 179 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons
t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex); |
| 192 | 180 |
| 193 unsigned indexOf(CSSStyleRule*) const; | 181 unsigned indexOf(CSSStyleRule*) const; |
| 194 CSSStyleRule* ruleAt(unsigned ruleIndex) const; | 182 CSSStyleRule* ruleAt(unsigned ruleIndex) const; |
| 195 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; | 183 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; |
| 196 | 184 |
| 197 virtual unsigned indexOf(CSSStyleDeclaration*) const override; | 185 virtual unsigned indexOf(CSSStyleDeclaration*) const override; |
| 198 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; | 186 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; |
| 199 virtual bool setStyleText(unsigned ruleIndex, const String&) override; | |
| 200 bool isInlineStyle() override { return false; } | 187 bool isInlineStyle() override { return false; } |
| 201 const CSSRuleVector& flatRules(); | 188 const CSSRuleVector& flatRules(); |
| 202 | 189 |
| 203 protected: | 190 protected: |
| 204 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; | 191 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; |
| 205 virtual unsigned ruleCount() override; | 192 virtual unsigned ruleCount() override; |
| 206 | 193 |
| 207 // Also accessed by friend class InspectorStyle. | 194 // Also accessed by friend class InspectorStyle. |
| 208 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned)
const override; | 195 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned)
const override; |
| 209 virtual bool ensureParsedDataReady() override; | 196 virtual bool ensureParsedDataReady() override; |
| 210 | 197 |
| 211 private: | 198 private: |
| 212 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil
lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu
m, const String& documentURL, InspectorCSSAgent*); | 199 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&); | 200 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S
ourceRange&); |
| 214 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData*
*); | 201 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData*
*); |
| 215 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**)
; | 202 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**)
; |
| 216 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String&
ruleText, ExceptionState&); | 203 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String&
ruleText, ExceptionState&); |
| 217 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&,
const String& ruleText, ExceptionState&); | 204 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&,
const String& ruleText, ExceptionState&); |
| 218 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String&
ruleText, ExceptionState&); | 205 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String&
ruleText, ExceptionState&); |
| 219 String sourceMapURL() const; | 206 String sourceMapURL() const; |
| 220 String sourceURL() const; | 207 String sourceURL() const; |
| 221 bool ensureText() const; | 208 bool ensureText() const; |
| 222 void ensureFlatRules() const; | 209 void ensureFlatRules() const; |
| 223 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS
tyleText, String* result); | |
| 224 bool originalStyleSheetText(String* result) const; | 210 bool originalStyleSheetText(String* result) const; |
| 225 bool resourceStyleSheetText(String* result) const; | 211 bool resourceStyleSheetText(String* result) const; |
| 226 bool inlineStyleSheetText(String* result) const; | 212 bool inlineStyleSheetText(String* result) const; |
| 227 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&); | 213 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou
rce(const CSSRuleSourceData*, const String&); |
| 228 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); | 214 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty
leRule*); |
| 229 String url() const; | 215 String url() const; |
| 230 bool hasSourceURL() const; | 216 bool hasSourceURL() const; |
| 231 bool startsAtZero() const; | 217 bool startsAtZero() const; |
| 232 | 218 |
| 233 void replaceText(const SourceRange&, const String& text, SourceRange* newRan
ge, String* oldText); | 219 void replaceText(const SourceRange&, const String& text, SourceRange* newRan
ge, String* oldText); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 248 public: | 234 public: |
| 249 static PassRefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> create(cons
t String& id, PassRefPtrWillBeRawPtr<Element>, Listener*); | 235 static PassRefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> create(cons
t String& id, PassRefPtrWillBeRawPtr<Element>, Listener*); |
| 250 | 236 |
| 251 void didModifyElementAttribute(); | 237 void didModifyElementAttribute(); |
| 252 virtual Document* ownerDocument() const override; | 238 virtual Document* ownerDocument() const override; |
| 253 virtual bool setText(const String&, ExceptionState&) override; | 239 virtual bool setText(const String&, ExceptionState&) override; |
| 254 virtual bool getText(String* result) const override; | 240 virtual bool getText(String* result) const override; |
| 255 | 241 |
| 256 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS
SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } | 242 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS
SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } |
| 257 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return
0; } | 243 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return
0; } |
| 258 virtual bool setStyleText(unsigned ruleIndex, const String&) override; | |
| 259 CSSStyleDeclaration* inlineStyle() const; | 244 CSSStyleDeclaration* inlineStyle() const; |
| 260 | 245 |
| 261 DECLARE_VIRTUAL_TRACE(); | 246 DECLARE_VIRTUAL_TRACE(); |
| 262 | 247 |
| 263 protected: | 248 protected: |
| 264 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; | 249 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; |
| 265 virtual unsigned ruleCount() override { return 1; } | 250 virtual unsigned ruleCount() override { return 1; } |
| 266 | 251 |
| 267 // Also accessed by friend class InspectorStyle. | 252 // Also accessed by friend class InspectorStyle. |
| 268 virtual bool ensureParsedDataReady() override; | 253 virtual bool ensureParsedDataReady() override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 283 mutable bool m_isStyleTextValid; | 268 mutable bool m_isStyleTextValid; |
| 284 }; | 269 }; |
| 285 | 270 |
| 286 | 271 |
| 287 | 272 |
| 288 } // namespace blink | 273 } // namespace blink |
| 289 | 274 |
| 290 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); | 275 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); |
| 291 | 276 |
| 292 #endif // !defined(InspectorStyleSheet_h) | 277 #endif // !defined(InspectorStyleSheet_h) |
| OLD | NEW |