Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: Source/core/inspector/InspectorStyleSheet.h

Issue 1179323003: DevTools: do not use range indices outside of InspectorStyleSheet. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 public: 168 public:
169 static PassRefPtrWillBeRawPtr<InspectorStyleSheet> create(InspectorResourceA gent*, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, T ypeBuilder::CSS::StyleSheetOrigin::Enum, const String& documentURL, InspectorCSS Agent*); 169 static PassRefPtrWillBeRawPtr<InspectorStyleSheet> create(InspectorResourceA gent*, const String& id, PassRefPtrWillBeRawPtr<CSSStyleSheet> pageStyleSheet, T ypeBuilder::CSS::StyleSheetOrigin::Enum, const String& documentURL, InspectorCSS Agent*);
170 170
171 virtual ~InspectorStyleSheet(); 171 virtual ~InspectorStyleSheet();
172 DECLARE_VIRTUAL_TRACE(); 172 DECLARE_VIRTUAL_TRACE();
173 173
174 String finalURL() const; 174 String finalURL() const;
175 virtual Document* ownerDocument() const override; 175 virtual Document* ownerDocument() const override;
176 virtual bool setText(const String&, ExceptionState&) override; 176 virtual bool setText(const String&, ExceptionState&) override;
177 virtual bool getText(String* result) const override; 177 virtual bool getText(String* result) const override;
178 String ruleSelector(unsigned ruleIndex, ExceptionState&); 178 CSSStyleRule* setRuleSelector(const SourceRange&, const String& selector, So urceRange* newRange, String* oldSelector, ExceptionState&);
179 bool setRuleSelector(unsigned ruleIndex, const String& selector, ExceptionSt ate&); 179 CSSMediaRule* setMediaRuleText(const SourceRange&, const String& selector, S ourceRange* newRange, String* oldSelector, ExceptionState&);
180 String mediaRuleText(unsigned ruleIndex, ExceptionState&); 180 CSSStyleRule* addRule(const String& ruleText, const SourceRange& location, S ourceRange* addedRange, ExceptionState&);
181 bool setMediaRuleText(unsigned ruleIndex, const String& text, ExceptionState &); 181 bool deleteRule(const SourceRange&, ExceptionState&);
182 CSSStyleRule* addRule(const String& ruleText, const SourceRange& location, E xceptionState&);
183 bool deleteRule(unsigned ruleIndex, const String& oldText, ExceptionState&);
184 182
185 CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); } 183 CSSStyleSheet* pageStyleSheet() const { return m_pageStyleSheet.get(); }
186 184
187 PassRefPtr<TypeBuilder::CSS::CSSStyleSheetHeader> buildObjectForStyleSheetIn fo() const; 185 PassRefPtr<TypeBuilder::CSS::CSSStyleSheetHeader> buildObjectForStyleSheetIn fo() const;
188 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*, Pass RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> >); 186 PassRefPtr<TypeBuilder::CSS::CSSRule> buildObjectForRule(CSSStyleRule*, Pass RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> >);
189 187
190 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul e*); 188 PassRefPtr<TypeBuilder::CSS::SourceRange> ruleHeaderSourceRange(const CSSRul e*);
191 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex); 189 PassRefPtr<TypeBuilder::CSS::SourceRange> mediaQueryExpValueSourceRange(cons t CSSRule*, size_t mediaQueryIndex, size_t mediaQueryExpIndex);
192 190
193 unsigned indexOf(CSSStyleRule*) const; 191 unsigned indexOf(CSSStyleRule*) const;
194 CSSStyleRule* ruleAt(unsigned ruleIndex) const; 192 CSSStyleRule* ruleAt(unsigned ruleIndex) const;
195 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const; 193 CSSMediaRule* mediaRuleAt(unsigned ruleIndex) const;
196 194
197 virtual unsigned indexOf(CSSStyleDeclaration*) const override; 195 virtual unsigned indexOf(CSSStyleDeclaration*) const override;
198 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override; 196 virtual CSSStyleDeclaration* styleAt(unsigned ruleIndex) const override;
199 virtual bool setStyleText(unsigned ruleIndex, const String&) override; 197 virtual bool setStyleText(unsigned ruleIndex, const String&) override;
200 198
201 bool findRuleBySelectorRange(const SourceRange&, unsigned* ruleIndex);
202 bool findMediaRuleByRange(const SourceRange&, unsigned* ruleIndex);
203
204 const CSSRuleVector& flatRules(); 199 const CSSRuleVector& flatRules();
205 200
206 protected: 201 protected:
207 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override; 202 virtual PassRefPtrWillBeRawPtr<InspectorStyle> inspectorStyleAt(unsigned rul eIndex) override;
208 virtual unsigned ruleCount() override; 203 virtual unsigned ruleCount() override;
209 204
210 // Also accessed by friend class InspectorStyle. 205 // Also accessed by friend class InspectorStyle.
211 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned) const override; 206 virtual PassRefPtrWillBeRawPtr<CSSRuleSourceData> ruleSourceDataAt(unsigned) const override;
212 virtual bool ensureParsedDataReady() override; 207 virtual bool ensureParsedDataReady() override;
213 208
214 private: 209 private:
215 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu m, const String& documentURL, InspectorCSSAgent*); 210 InspectorStyleSheet(InspectorResourceAgent*, const String& id, PassRefPtrWil lBeRawPtr<CSSStyleSheet> pageStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Enu m, const String& documentURL, InspectorCSSAgent*);
216 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S ourceRange&); 211 unsigned ruleIndexBySourceRange(const CSSMediaRule* parentMediaRule, const S ourceRange&);
212 bool findRuleByHeaderRange(const SourceRange&, CSSRule**, CSSRuleSourceData* *);
217 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String& ruleText, ExceptionState&); 213 CSSStyleRule* insertCSSOMRuleInStyleSheet(const SourceRange&, const String& ruleText, ExceptionState&);
218 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&, const String& ruleText, ExceptionState&); 214 CSSStyleRule* insertCSSOMRuleInMediaRule(CSSMediaRule*, const SourceRange&, const String& ruleText, ExceptionState&);
219 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String& ruleText, ExceptionState&); 215 CSSStyleRule* insertCSSOMRuleBySourceRange(const SourceRange&, const String& ruleText, ExceptionState&);
220 bool verifyRuleText(const String& ruleText); 216 bool verifyRuleText(const String& ruleText);
221 bool verifySelectorText(const String& selectorText); 217 bool verifySelectorText(const String& selectorText);
222 bool verifyMediaText(const String& mediaText); 218 bool verifyMediaText(const String& mediaText);
223 String sourceMapURL() const; 219 String sourceMapURL() const;
224 String sourceURL() const; 220 String sourceURL() const;
225 bool ensureText() const; 221 bool ensureText() const;
226 void ensureFlatRules() const; 222 void ensureFlatRules() const;
227 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS tyleText, String* result); 223 bool styleSheetTextWithChangedStyle(CSSStyleDeclaration*, const String& newS tyleText, String* result);
228 bool originalStyleSheetText(String* result) const; 224 bool originalStyleSheetText(String* result) const;
229 bool resourceStyleSheetText(String* result) const; 225 bool resourceStyleSheetText(String* result) const;
230 bool inlineStyleSheetText(String* result) const; 226 bool inlineStyleSheetText(String* result) const;
231 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou rce(const CSSRuleSourceData*, const String&); 227 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Selector> > selectorsFromSou rce(const CSSRuleSourceData*, const String&);
232 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty leRule*); 228 PassRefPtr<TypeBuilder::CSS::SelectorList> buildObjectForSelectorList(CSSSty leRule*);
233 String url() const; 229 String url() const;
234 bool hasSourceURL() const; 230 bool hasSourceURL() const;
235 bool startsAtZero() const; 231 bool startsAtZero() const;
236 232
237 void updateText(const String& newText); 233 void replaceText(const SourceRange&, const String& text, SourceRange* newRan ge, String* oldText);
234 void innerSetText(const String& newText);
238 Element* ownerStyleElement() const; 235 Element* ownerStyleElement() const;
239 236
240 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; 237 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent;
241 RawPtrWillBeMember<InspectorResourceAgent> m_resourceAgent; 238 RawPtrWillBeMember<InspectorResourceAgent> m_resourceAgent;
242 RefPtrWillBeMember<CSSStyleSheet> m_pageStyleSheet; 239 RefPtrWillBeMember<CSSStyleSheet> m_pageStyleSheet;
243 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin; 240 TypeBuilder::CSS::StyleSheetOrigin::Enum m_origin;
244 String m_documentURL; 241 String m_documentURL;
245 OwnPtrWillBeMember<ParsedStyleSheet> m_parsedStyleSheet; 242 OwnPtrWillBeMember<ParsedStyleSheet> m_parsedStyleSheet;
246 mutable CSSRuleVector m_flatRules; 243 mutable CSSRuleVector m_flatRules;
247 mutable String m_sourceURL; 244 mutable String m_sourceURL;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 mutable String m_styleText; 281 mutable String m_styleText;
285 mutable bool m_isStyleTextValid; 282 mutable bool m_isStyleTextValid;
286 }; 283 };
287 284
288 285
289 } // namespace blink 286 } // namespace blink
290 287
291 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty); 288 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::InspectorStyleProperty);
292 289
293 #endif // !defined(InspectorStyleSheet_h) 290 #endif // !defined(InspectorStyleSheet_h)
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.cpp ('k') | Source/core/inspector/InspectorStyleSheet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698