| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 class Element; | 48 class Element; |
| 49 class ExceptionState; | 49 class ExceptionState; |
| 50 class InspectorCSSAgent; | 50 class InspectorCSSAgent; |
| 51 class InspectorResourceAgent; | 51 class InspectorResourceAgent; |
| 52 class InspectorStyleSheetBase; | 52 class InspectorStyleSheetBase; |
| 53 | 53 |
| 54 typedef WillBeHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector; | 54 typedef WillBeHeapVector<RefPtrWillBeMember<CSSRule> > CSSRuleVector; |
| 55 typedef String ErrorString; | 55 typedef String ErrorString; |
| 56 typedef Vector<unsigned> LineEndings; | 56 typedef Vector<unsigned> LineEndings; |
| 57 | 57 |
| 58 struct InspectorStyleProperty { | |
| 59 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 60 public: | |
| 61 explicit InspectorStyleProperty(CSSPropertySourceData sourceData) | |
| 62 : sourceData(sourceData) | |
| 63 , hasSource(true) | |
| 64 { | |
| 65 } | |
| 66 | |
| 67 InspectorStyleProperty(CSSPropertySourceData sourceData, bool hasSource) | |
| 68 : sourceData(sourceData) | |
| 69 , hasSource(hasSource) | |
| 70 { | |
| 71 } | |
| 72 | |
| 73 bool hasRawText() const { return !rawText.isEmpty(); } | |
| 74 | |
| 75 DEFINE_INLINE_TRACE() { visitor->trace(sourceData); } | |
| 76 | |
| 77 CSSPropertySourceData sourceData; | |
| 78 bool hasSource; | |
| 79 String rawText; | |
| 80 }; | |
| 81 | |
| 82 class InspectorStyle final : public RefCountedWillBeGarbageCollectedFinalized<In
spectorStyle> { | 58 class InspectorStyle final : public RefCountedWillBeGarbageCollectedFinalized<In
spectorStyle> { |
| 83 public: | 59 public: |
| 84 static PassRefPtrWillBeRawPtr<InspectorStyle> create(unsigned ruleIndex, Pas
sRefPtrWillBeRawPtr<CSSStyleDeclaration>, InspectorStyleSheetBase* parentStyleSh
eet); | 60 static PassRefPtrWillBeRawPtr<InspectorStyle> create(PassRefPtrWillBeRawPtr<
CSSStyleDeclaration>, PassRefPtrWillBeRawPtr<CSSRuleSourceData>, InspectorStyleS
heetBase* parentStyleSheet); |
| 85 | 61 |
| 86 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } | 62 CSSStyleDeclaration* cssStyle() const { return m_style.get(); } |
| 87 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; | 63 PassRefPtr<TypeBuilder::CSS::CSSStyle> buildObjectForStyle() const; |
| 88 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >
buildArrayForComputedStyle() const; | 64 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >
buildArrayForComputedStyle() const; |
| 89 bool styleText(String* result) const; | 65 bool styleText(String* result) const; |
| 90 bool textForRange(const SourceRange&, String* result) const; | 66 bool textForRange(const SourceRange&, String* result) const; |
| 91 | 67 |
| 92 DECLARE_TRACE(); | 68 DECLARE_TRACE(); |
| 93 | 69 |
| 94 private: | 70 private: |
| 95 InspectorStyle(unsigned ruleIndex, PassRefPtrWillBeRawPtr<CSSStyleDeclaratio
n>, InspectorStyleSheetBase* parentStyleSheet); | 71 InspectorStyle(PassRefPtrWillBeRawPtr<CSSStyleDeclaration>, PassRefPtrWillBe
RawPtr<CSSRuleSourceData>, InspectorStyleSheetBase* parentStyleSheet); |
| 96 | 72 |
| 97 void populateAllProperties(WillBeHeapVector<InspectorStyleProperty>& result)
const; | 73 void populateAllProperties(WillBeHeapVector<CSSPropertySourceData>& result)
const; |
| 98 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; | 74 PassRefPtr<TypeBuilder::CSS::CSSStyle> styleWithProperties() const; |
| 99 PassRefPtrWillBeRawPtr<CSSRuleSourceData> extractSourceData() const; | |
| 100 String shorthandValue(const String& shorthandProperty) const; | 75 String shorthandValue(const String& shorthandProperty) const; |
| 101 inline Document* ownerDocument() const; | 76 inline Document* ownerDocument() const; |
| 102 | 77 |
| 103 unsigned m_ruleIndex; | |
| 104 RefPtrWillBeMember<CSSStyleDeclaration> m_style; | 78 RefPtrWillBeMember<CSSStyleDeclaration> m_style; |
| 79 RefPtrWillBeMember<CSSRuleSourceData> m_sourceData; |
| 105 RawPtrWillBeMember<InspectorStyleSheetBase> m_parentStyleSheet; | 80 RawPtrWillBeMember<InspectorStyleSheetBase> m_parentStyleSheet; |
| 106 }; | 81 }; |
| 107 | 82 |
| 108 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized
<InspectorStyleSheetBase> { | 83 class InspectorStyleSheetBase : public RefCountedWillBeGarbageCollectedFinalized
<InspectorStyleSheetBase> { |
| 109 public: | 84 public: |
| 110 class CORE_EXPORT Listener { | 85 class CORE_EXPORT Listener { |
| 111 public: | 86 public: |
| 112 Listener() { } | 87 Listener() { } |
| 113 virtual ~Listener() { } | 88 virtual ~Listener() { } |
| 114 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; | 89 virtual void styleSheetChanged(InspectorStyleSheetBase*) = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 131 bool lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber,
unsigned* offset); | 106 bool lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber,
unsigned* offset); |
| 132 virtual bool isInlineStyle() = 0; | 107 virtual bool isInlineStyle() = 0; |
| 133 | 108 |
| 134 protected: | 109 protected: |
| 135 InspectorStyleSheetBase(const String& id, Listener*); | 110 InspectorStyleSheetBase(const String& id, Listener*); |
| 136 | 111 |
| 137 Listener* listener() const { return m_listener; } | 112 Listener* listener() const { return m_listener; } |
| 138 void onStyleSheetTextChanged(); | 113 void onStyleSheetTextChanged(); |
| 139 const LineEndings* lineEndings(); | 114 const LineEndings* lineEndings(); |
| 140 | 115 |
| 141 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) = 0; | 116 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyle(RefPtrWillBeRa
wPtr<CSSStyleDeclaration>) = 0; |
| 142 virtual unsigned ruleCount() = 0; | 117 virtual unsigned ruleCount() = 0; |
| 143 | 118 |
| 144 // Also accessed by friend class InspectorStyle. | 119 // Also accessed by friend class InspectorStyle. |
| 145 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned)
const = 0; | |
| 146 virtual bool ensureParsedDataReady() = 0; | 120 virtual bool ensureParsedDataReady() = 0; |
| 147 | 121 |
| 148 private: | 122 private: |
| 149 friend class InspectorStyle; | 123 friend class InspectorStyle; |
| 150 | 124 |
| 151 String m_id; | 125 String m_id; |
| 152 Listener* m_listener; | 126 Listener* m_listener; |
| 153 OwnPtr<LineEndings> m_lineEndings; | 127 OwnPtr<LineEndings> m_lineEndings; |
| 154 }; | 128 }; |
| 155 | 129 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 181 unsigned indexOf(CSSStyleRule*) const; | 155 unsigned indexOf(CSSStyleRule*) const; |
| 182 CSSStyleRule* ruleAt(unsigned ruleIndex) const; | 156 CSSStyleRule* ruleAt(unsigned ruleIndex) const; |
| 183 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; | 157 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; |
| 184 | 158 |
| 185 virtual unsigned indexOf(CSSStyleDeclaration*) const override; | 159 virtual unsigned indexOf(CSSStyleDeclaration*) const override; |
| 186 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; | 160 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; |
| 187 bool isInlineStyle() override { return false; } | 161 bool isInlineStyle() override { return false; } |
| 188 const CSSRuleVector& flatRules(); | 162 const CSSRuleVector& flatRules(); |
| 189 | 163 |
| 190 protected: | 164 protected: |
| 191 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; | 165 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyle(RefPtrWillBeRa
wPtr<CSSStyleDeclaration>) override; |
| 192 virtual unsigned ruleCount() override; | 166 virtual unsigned ruleCount() override; |
| 193 | 167 |
| 194 // Also accessed by friend class InspectorStyle. | 168 // Also accessed by friend class InspectorStyle. |
| 195 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned)
const override; | |
| 196 virtual bool ensureParsedDataReady() override; | 169 virtual bool ensureParsedDataReady() override; |
| 197 | 170 |
| 198 private: | 171 private: |
| 199 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil
lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu
m, const String& documentURL, InspectorCSSAgent*); | 172 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil
lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu
m, const String& documentURL, InspectorCSSAgent*); |
| 200 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S
ourceRange&); | 173 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S
ourceRange&); |
| 201 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData*
*); | 174 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData*
*); |
| 202 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**)
; | 175 bool findRuleByBodyRange(const SourceRange&, CSSRule**, CSSRuleSourceData**)
; |
| 203 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String&
ruleText, ExceptionState&); | 176 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String&
ruleText, ExceptionState&); |
| 204 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&,
const String& ruleText, ExceptionState&); | 177 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&,
const String& ruleText, ExceptionState&); |
| 205 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String&
ruleText, ExceptionState&); | 178 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String&
ruleText, ExceptionState&); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 virtual bool setText(const String&, ExceptionState&) override; | 212 virtual bool setText(const String&, ExceptionState&) override; |
| 240 virtual bool getText(String* result) const override; | 213 virtual bool getText(String* result) const override; |
| 241 | 214 |
| 242 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS
SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } | 215 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override { AS
SERT_UNUSED(ruleIndex, !ruleIndex); return inlineStyle(); } |
| 243 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return
0; } | 216 virtual unsigned indexOf(CSSStyleDeclaration* style) const override { return
0; } |
| 244 CSSStyleDeclaration* inlineStyle() const; | 217 CSSStyleDeclaration* inlineStyle() const; |
| 245 | 218 |
| 246 DECLARE_VIRTUAL_TRACE(); | 219 DECLARE_VIRTUAL_TRACE(); |
| 247 | 220 |
| 248 protected: | 221 protected: |
| 249 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul
eIndex) override; | 222 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyle(RefPtrWillBeRa
wPtr<CSSStyleDeclaration>) override; |
| 250 virtual unsigned ruleCount() override { return 1; } | 223 virtual unsigned ruleCount() override { return 1; } |
| 251 | 224 |
| 252 // Also accessed by friend class InspectorStyle. | 225 // Also accessed by friend class InspectorStyle. |
| 253 virtual bool ensureParsedDataReady() override; | 226 virtual bool ensureParsedDataReady() override; |
| 254 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned
ruleIndex) const override { ASSERT_UNUSED(ruleIndex, !ruleIndex); return m_ruleS
ourceData; } | |
| 255 bool isInlineStyle() override { return true; } | 227 bool isInlineStyle() override { return true; } |
| 256 | 228 |
| 257 private: | 229 private: |
| 258 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtrWillBeRawPtr<E
lement>, Listener*); | 230 InspectorStyleSheetForInlineStyle(const String& id, PassRefPtrWillBeRawPtr<E
lement>, Listener*); |
| 259 const String& elementStyleText() const; | 231 const String& elementStyleText() const; |
| 260 PassRefPtrWillBeRawPtr<CSSRuleSourceData> getStyleAttributeData() const; | |
| 261 | 232 |
| 262 RefPtrWillBeMember<Element> m_element; | 233 RefPtrWillBeMember<Element> m_element; |
| 263 RefPtrWillBeMember<CSSRuleSourceData> m_ruleSourceData; | |
| 264 RefPtrWillBeMember<InspectorStyle> m_inspectorStyle; | 234 RefPtrWillBeMember<InspectorStyle> m_inspectorStyle; |
| 265 | |
| 266 // Contains "style" attribute value. | |
| 267 mutable String m_styleText; | |
| 268 mutable bool m_isStyleTextValid; | |
| 269 }; | 235 }; |
| 270 | 236 |
| 271 | 237 |
| 272 | 238 |
| 273 } // namespace blink | 239 } // namespace blink |
| 274 | 240 |
| 275 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); | |
| 276 | |
| 277 #endif // !defined(InspectorStyleSheet_h) | 241 #endif // !defined(InspectorStyleSheet_h) |
| OLD | NEW |