| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 else if (pseudoClass == visited) | 114 else if (pseudoClass == visited) |
| 115 result |= PseudoVisited; | 115 result |= PseudoVisited; |
| 116 } | 116 } |
| 117 | 117 |
| 118 return result; | 118 return result; |
| 119 } | 119 } |
| 120 | 120 |
| 121 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { | 121 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
| 122 WTF_MAKE_NONCOPYABLE(StyleSheetAction); | 122 WTF_MAKE_NONCOPYABLE(StyleSheetAction); |
| 123 public: | 123 public: |
| 124 StyleSheetAction(const String& name, InspectorStyleSheet* styleSheet) | 124 StyleSheetAction(const String& name) |
| 125 : InspectorHistory::Action(name) | 125 : InspectorHistory::Action(name) |
| 126 , m_styleSheet(styleSheet) | |
| 127 { | 126 { |
| 128 } | 127 } |
| 129 | |
| 130 protected: | |
| 131 RefPtr<InspectorStyleSheet> m_styleSheet; | |
| 132 }; | 128 }; |
| 133 | 129 |
| 134 class InspectorCSSAgent::EnableResourceClient FINAL : public StyleSheetResourceC
lient { | 130 class InspectorCSSAgent::EnableResourceClient FINAL : public StyleSheetResourceC
lient { |
| 135 public: | 131 public: |
| 136 EnableResourceClient(InspectorCSSAgent*, const Vector<InspectorStyleSheet*>&
, PassRefPtr<EnableCallback>); | 132 EnableResourceClient(InspectorCSSAgent*, const Vector<InspectorStyleSheet*>&
, PassRefPtr<EnableCallback>); |
| 137 | 133 |
| 138 virtual void setCSSStyleSheet(const String&, const KURL&, const String&, con
st CSSStyleSheetResource*) OVERRIDE; | 134 virtual void setCSSStyleSheet(const String&, const KURL&, const String&, con
st CSSStyleSheetResource*) OVERRIDE; |
| 139 | 135 |
| 140 private: | 136 private: |
| 141 RefPtr<EnableCallback> m_callback; | 137 RefPtr<EnableCallback> m_callback; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 168 | 164 |
| 169 // enable always succeeds. | 165 // enable always succeeds. |
| 170 if (m_callback->isActive()) | 166 if (m_callback->isActive()) |
| 171 m_cssAgent->wasEnabled(m_callback.release()); | 167 m_cssAgent->wasEnabled(m_callback.release()); |
| 172 delete this; | 168 delete this; |
| 173 } | 169 } |
| 174 | 170 |
| 175 class InspectorCSSAgent::SetStyleSheetTextAction FINAL : public InspectorCSSAgen
t::StyleSheetAction { | 171 class InspectorCSSAgent::SetStyleSheetTextAction FINAL : public InspectorCSSAgen
t::StyleSheetAction { |
| 176 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); | 172 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); |
| 177 public: | 173 public: |
| 178 SetStyleSheetTextAction(InspectorStyleSheet* styleSheet, const String& text) | 174 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) |
| 179 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText", styleSheet) | 175 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") |
| 176 , m_styleSheet(styleSheet) |
| 180 , m_text(text) | 177 , m_text(text) |
| 181 { | 178 { |
| 182 } | 179 } |
| 183 | 180 |
| 184 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 181 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
| 185 { | 182 { |
| 186 if (!m_styleSheet->getText(&m_oldText)) | 183 if (!m_styleSheet->getText(&m_oldText)) |
| 187 return false; | 184 return false; |
| 188 return redo(exceptionState); | 185 return redo(exceptionState); |
| 189 } | 186 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 213 | 210 |
| 214 virtual void merge(PassOwnPtr<Action> action) OVERRIDE | 211 virtual void merge(PassOwnPtr<Action> action) OVERRIDE |
| 215 { | 212 { |
| 216 ASSERT(action->mergeId() == mergeId()); | 213 ASSERT(action->mergeId() == mergeId()); |
| 217 | 214 |
| 218 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 215 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
| 219 m_text = other->m_text; | 216 m_text = other->m_text; |
| 220 } | 217 } |
| 221 | 218 |
| 222 private: | 219 private: |
| 220 RefPtr<InspectorStyleSheetBase> m_styleSheet; |
| 223 String m_text; | 221 String m_text; |
| 224 String m_oldText; | 222 String m_oldText; |
| 225 }; | 223 }; |
| 226 | 224 |
| 227 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 225 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
| 228 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 226 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
| 229 public: | 227 public: |
| 230 SetPropertyTextAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, unsigned propertyIndex, const String& text, bool overwrite) | 228 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) |
| 231 : InspectorCSSAgent::StyleSheetAction("SetPropertyText", styleSheet) | 229 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
| 230 , m_styleSheet(styleSheet) |
| 232 , m_cssId(cssId) | 231 , m_cssId(cssId) |
| 233 , m_propertyIndex(propertyIndex) | 232 , m_propertyIndex(propertyIndex) |
| 234 , m_text(text) | 233 , m_text(text) |
| 235 , m_overwrite(overwrite) | 234 , m_overwrite(overwrite) |
| 236 { | 235 { |
| 237 } | 236 } |
| 238 | 237 |
| 239 virtual String toString() OVERRIDE | 238 virtual String toString() OVERRIDE |
| 240 { | 239 { |
| 241 return mergeId() + ": " + m_oldText + " -> " + m_text; | 240 return mergeId() + ": " + m_oldText + " -> " + m_text; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 267 | 266 |
| 268 virtual void merge(PassOwnPtr<Action> action) OVERRIDE | 267 virtual void merge(PassOwnPtr<Action> action) OVERRIDE |
| 269 { | 268 { |
| 270 ASSERT(action->mergeId() == mergeId()); | 269 ASSERT(action->mergeId() == mergeId()); |
| 271 | 270 |
| 272 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 271 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
| 273 m_text = other->m_text; | 272 m_text = other->m_text; |
| 274 } | 273 } |
| 275 | 274 |
| 276 private: | 275 private: |
| 276 RefPtr<InspectorStyleSheetBase> m_styleSheet; |
| 277 InspectorCSSId m_cssId; | 277 InspectorCSSId m_cssId; |
| 278 unsigned m_propertyIndex; | 278 unsigned m_propertyIndex; |
| 279 String m_text; | 279 String m_text; |
| 280 String m_oldText; | 280 String m_oldText; |
| 281 bool m_overwrite; | 281 bool m_overwrite; |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 284 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { |
| 285 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 285 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
| 286 public: | 286 public: |
| 287 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, const String& selector) | 287 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, const String& selector) |
| 288 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector", styleSheet) | 288 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector") |
| 289 , m_styleSheet(styleSheet) |
| 289 , m_cssId(cssId) | 290 , m_cssId(cssId) |
| 290 , m_selector(selector) | 291 , m_selector(selector) |
| 291 { | 292 { |
| 292 } | 293 } |
| 293 | 294 |
| 294 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 295 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
| 295 { | 296 { |
| 296 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState); | 297 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState); |
| 297 if (exceptionState.hadException()) | 298 if (exceptionState.hadException()) |
| 298 return false; | 299 return false; |
| 299 return redo(exceptionState); | 300 return redo(exceptionState); |
| 300 } | 301 } |
| 301 | 302 |
| 302 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 303 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
| 303 { | 304 { |
| 304 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 305 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); |
| 305 } | 306 } |
| 306 | 307 |
| 307 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 308 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
| 308 { | 309 { |
| 309 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 310 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); |
| 310 } | 311 } |
| 311 | 312 |
| 312 private: | 313 private: |
| 314 RefPtr<InspectorStyleSheet> m_styleSheet; |
| 313 InspectorCSSId m_cssId; | 315 InspectorCSSId m_cssId; |
| 314 String m_selector; | 316 String m_selector; |
| 315 String m_oldSelector; | 317 String m_oldSelector; |
| 316 }; | 318 }; |
| 317 | 319 |
| 318 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { | 320 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { |
| 319 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 321 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
| 320 public: | 322 public: |
| 321 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) | 323 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) |
| 322 : InspectorCSSAgent::StyleSheetAction("AddRule", styleSheet) | 324 : InspectorCSSAgent::StyleSheetAction("AddRule") |
| 325 , m_styleSheet(styleSheet) |
| 323 , m_selector(selector) | 326 , m_selector(selector) |
| 324 { | 327 { |
| 325 } | 328 } |
| 326 | 329 |
| 327 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 330 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
| 328 { | 331 { |
| 329 return redo(exceptionState); | 332 return redo(exceptionState); |
| 330 } | 333 } |
| 331 | 334 |
| 332 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 335 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
| 333 { | 336 { |
| 334 return m_styleSheet->deleteRule(m_newId, exceptionState); | 337 return m_styleSheet->deleteRule(m_newId, exceptionState); |
| 335 } | 338 } |
| 336 | 339 |
| 337 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 340 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
| 338 { | 341 { |
| 339 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); | 342 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception
State); |
| 340 if (exceptionState.hadException()) | 343 if (exceptionState.hadException()) |
| 341 return false; | 344 return false; |
| 342 m_newId = m_styleSheet->ruleId(cssStyleRule); | 345 m_newId = m_styleSheet->ruleId(cssStyleRule); |
| 343 return true; | 346 return true; |
| 344 } | 347 } |
| 345 | 348 |
| 346 InspectorCSSId newRuleId() { return m_newId; } | 349 InspectorCSSId newRuleId() { return m_newId; } |
| 347 | 350 |
| 348 private: | 351 private: |
| 352 RefPtr<InspectorStyleSheet> m_styleSheet; |
| 349 InspectorCSSId m_newId; | 353 InspectorCSSId m_newId; |
| 350 String m_selector; | 354 String m_selector; |
| 351 String m_oldSelector; | 355 String m_oldSelector; |
| 352 }; | 356 }; |
| 353 | 357 |
| 354 // static | 358 // static |
| 355 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 359 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
| 356 { | 360 { |
| 357 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 361 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
| 358 return 0; | 362 return 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 return; | 441 return; |
| 438 HashSet<Document*> invalidatedDocuments; | 442 HashSet<Document*> invalidatedDocuments; |
| 439 m_invalidatedDocuments.swap(&invalidatedDocuments); | 443 m_invalidatedDocuments.swap(&invalidatedDocuments); |
| 440 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i
nvalidatedDocuments.end(); ++it) | 444 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i
nvalidatedDocuments.end(); ++it) |
| 441 updateActiveStyleSheets(*it, ExistingFrontendRefresh); | 445 updateActiveStyleSheets(*it, ExistingFrontendRefresh); |
| 442 } | 446 } |
| 443 | 447 |
| 444 void InspectorCSSAgent::reset() | 448 void InspectorCSSAgent::reset() |
| 445 { | 449 { |
| 446 m_idToInspectorStyleSheet.clear(); | 450 m_idToInspectorStyleSheet.clear(); |
| 451 m_idToInspectorStyleSheetForInlineStyle.clear(); |
| 447 m_cssStyleSheetToInspectorStyleSheet.clear(); | 452 m_cssStyleSheetToInspectorStyleSheet.clear(); |
| 448 m_documentToCSSStyleSheets.clear(); | 453 m_documentToCSSStyleSheets.clear(); |
| 449 m_invalidatedDocuments.clear(); | 454 m_invalidatedDocuments.clear(); |
| 450 m_nodeToInspectorStyleSheet.clear(); | 455 m_nodeToInspectorStyleSheet.clear(); |
| 451 m_documentToViaInspectorStyleSheet.clear(); | 456 m_documentToViaInspectorStyleSheet.clear(); |
| 452 resetNonPersistentData(); | 457 resetNonPersistentData(); |
| 453 } | 458 } |
| 454 | 459 |
| 455 void InspectorCSSAgent::resetNonPersistentData() | 460 void InspectorCSSAgent::resetNonPersistentData() |
| 456 { | 461 { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat
s.end(); it != end; ++it) { | 817 for (HashCountedSet<String>::iterator it = fontStats.begin(), end = fontStat
s.end(); it != end; ++it) { |
| 813 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::
CSS::PlatformFontUsage::create() | 818 RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::
CSS::PlatformFontUsage::create() |
| 814 .setFamilyName(it->key) | 819 .setFamilyName(it->key) |
| 815 .setGlyphCount(it->value); | 820 .setGlyphCount(it->value); |
| 816 platformFonts->addItem(platformFont); | 821 platformFonts->addItem(platformFont); |
| 817 } | 822 } |
| 818 } | 823 } |
| 819 | 824 |
| 820 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String
& styleSheetId, String* result) | 825 void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String
& styleSheetId, String* result) |
| 821 { | 826 { |
| 822 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 827 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); |
| 823 if (!inspectorStyleSheet) | 828 if (!inspectorStyleSheet) |
| 824 return; | 829 return; |
| 825 | 830 |
| 826 inspectorStyleSheet->getText(result); | 831 inspectorStyleSheet->getText(result); |
| 827 } | 832 } |
| 828 | 833 |
| 829 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) | 834 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String
& styleSheetId, const String& text) |
| 830 { | 835 { |
| 831 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 836 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); |
| 832 if (!inspectorStyleSheet) { | 837 if (!inspectorStyleSheet) { |
| 833 *errorString = "Style sheet with id " + styleSheetId + " not found."; | 838 *errorString = "Style sheet with id " + styleSheetId + " not found."; |
| 834 return; | 839 return; |
| 835 } | 840 } |
| 836 | 841 |
| 837 TrackExceptionState exceptionState; | 842 TrackExceptionState exceptionState; |
| 838 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); | 843 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto
rStyleSheet, text)), exceptionState); |
| 839 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 844 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 840 } | 845 } |
| 841 | 846 |
| 842 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) | 847 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J
SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite,
RefPtr<TypeBuilder::CSS::CSSStyle>& result) |
| 843 { | 848 { |
| 844 InspectorCSSId compoundId(fullStyleId); | 849 InspectorCSSId compoundId(fullStyleId); |
| 845 ASSERT(!compoundId.isEmpty()); | 850 ASSERT(!compoundId.isEmpty()); |
| 846 | 851 |
| 847 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, compoundId.styleSheetId()); | 852 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, compoundId.styleSheetId()); |
| 848 if (!inspectorStyleSheet) | 853 if (!inspectorStyleSheet) |
| 849 return; | 854 return; |
| 850 | 855 |
| 851 TrackExceptionState exceptionState; | 856 TrackExceptionState exceptionState; |
| 852 bool success = m_domAgent->history()->perform(adoptPtr(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); | 857 bool success = m_domAgent->history()->perform(adoptPtr(new SetPropertyTextAc
tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio
nState); |
| 853 if (success) | 858 if (success) |
| 854 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); | 859 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); |
| 855 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 860 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 856 } | 861 } |
| 857 | 862 |
| 858 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J
SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule
>& result) | 863 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J
SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule
>& result) |
| 859 { | 864 { |
| 860 InspectorCSSId compoundId(fullRuleId); | 865 InspectorCSSId compoundId(fullRuleId); |
| 861 ASSERT(!compoundId.isEmpty()); | 866 ASSERT(!compoundId.isEmpty()); |
| 862 | 867 |
| 863 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, compoundId.styleSheetId()); | 868 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, compoundId.styleSheetId()); |
| 864 if (!inspectorStyleSheet) | 869 if (!inspectorStyleSheet) |
| 865 return; | 870 return; |
| 866 | 871 |
| 867 TrackExceptionState exceptionState; | 872 TrackExceptionState exceptionState; |
| 868 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); | 873 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc
tion(inspectorStyleSheet, compoundId, selector)), exceptionState); |
| 869 | 874 |
| 870 if (success) { | 875 if (success) { |
| 871 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); | 876 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); |
| 872 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); | 877 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); |
| 873 } | 878 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 894 return; | 899 return; |
| 895 } | 900 } |
| 896 | 901 |
| 897 updateActiveStyleSheets(document, ExistingFrontendRefresh); | 902 updateActiveStyleSheets(document, ExistingFrontendRefresh); |
| 898 | 903 |
| 899 *outStyleSheetId = inspectorStyleSheet->id(); | 904 *outStyleSheetId = inspectorStyleSheet->id(); |
| 900 } | 905 } |
| 901 | 906 |
| 902 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) | 907 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) |
| 903 { | 908 { |
| 904 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 909 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
| 905 if (!inspectorStyleSheet) | 910 if (!inspectorStyleSheet) |
| 906 return; | 911 return; |
| 907 | 912 |
| 908 TrackExceptionState exceptionState; | 913 TrackExceptionState exceptionState; |
| 909 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee
t, selector)); | 914 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee
t, selector)); |
| 910 AddRuleAction* rawAction = action.get(); | 915 AddRuleAction* rawAction = action.get(); |
| 911 bool success = m_domAgent->history()->perform(action.release(), exceptionSta
te); | 916 bool success = m_domAgent->history()->perform(action.release(), exceptionSta
te); |
| 912 if (!success) { | 917 if (!success) { |
| 913 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 918 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 914 return; | 919 return; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 { | 1054 { |
| 1050 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1055 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1051 if (it != m_nodeToInspectorStyleSheet.end()) | 1056 if (it != m_nodeToInspectorStyleSheet.end()) |
| 1052 return it->value.get(); | 1057 return it->value.get(); |
| 1053 | 1058 |
| 1054 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; | 1059 CSSStyleDeclaration* style = element->isStyledElement() ? element->style() :
0; |
| 1055 if (!style) | 1060 if (!style) |
| 1056 return 0; | 1061 return 0; |
| 1057 | 1062 |
| 1058 String newStyleSheetId = String::number(m_lastStyleSheetId++); | 1063 String newStyleSheetId = String::number(m_lastStyleSheetId++); |
| 1059 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(m_pageAgent, m_resourceAgent, newStyleSheetId, ele
ment, this); | 1064 RefPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorSty
leSheetForInlineStyle::create(newStyleSheetId, element, this); |
| 1060 m_idToInspectorStyleSheet.set(newStyleSheetId, inspectorStyleSheet); | 1065 m_idToInspectorStyleSheetForInlineStyle.set(newStyleSheetId, inspectorStyleS
heet); |
| 1061 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); | 1066 m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); |
| 1062 return inspectorStyleSheet.get(); | 1067 return inspectorStyleSheet.get(); |
| 1063 } | 1068 } |
| 1064 | 1069 |
| 1065 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) | 1070 Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) |
| 1066 { | 1071 { |
| 1067 Node* node = m_domAgent->nodeForId(nodeId); | 1072 Node* node = m_domAgent->nodeForId(nodeId); |
| 1068 if (!node) { | 1073 if (!node) { |
| 1069 *errorString = "No node with given id found"; | 1074 *errorString = "No node with given id found"; |
| 1070 return 0; | 1075 return 0; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 // At this point the added stylesheet will get bound through the updateA
ctiveStyleSheets() invocation. | 1172 // At this point the added stylesheet will get bound through the updateA
ctiveStyleSheets() invocation. |
| 1168 // We just need to pick the respective InspectorStyleSheet from m_docume
ntToViaInspectorStyleSheet. | 1173 // We just need to pick the respective InspectorStyleSheet from m_docume
ntToViaInspectorStyleSheet. |
| 1169 m_creatingViaInspectorStyleSheet = false; | 1174 m_creatingViaInspectorStyleSheet = false; |
| 1170 } | 1175 } |
| 1171 if (exceptionState.hadException()) | 1176 if (exceptionState.hadException()) |
| 1172 return 0; | 1177 return 0; |
| 1173 | 1178 |
| 1174 return m_documentToViaInspectorStyleSheet.get(document); | 1179 return m_documentToViaInspectorStyleSheet.get(document); |
| 1175 } | 1180 } |
| 1176 | 1181 |
| 1177 InspectorStyleSheet* InspectorCSSAgent::assertStyleSheetForId(ErrorString* error
String, const String& styleSheetId) | 1182 InspectorStyleSheet* InspectorCSSAgent::assertInspectorStyleSheetForId(ErrorStri
ng* errorString, const String& styleSheetId) |
| 1178 { | 1183 { |
| 1179 IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.find(styleS
heetId); | 1184 IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.find(styleS
heetId); |
| 1180 if (it == m_idToInspectorStyleSheet.end()) { | 1185 if (it == m_idToInspectorStyleSheet.end()) { |
| 1181 *errorString = "No style sheet with given id found"; | 1186 *errorString = "No style sheet with given id found"; |
| 1182 return 0; | 1187 return 0; |
| 1183 } | 1188 } |
| 1184 return it->value.get(); | 1189 return it->value.get(); |
| 1185 } | 1190 } |
| 1186 | 1191 |
| 1192 InspectorStyleSheetBase* InspectorCSSAgent::assertStyleSheetForId(ErrorString* e
rrorString, const String& styleSheetId) |
| 1193 { |
| 1194 String placeholder; |
| 1195 InspectorStyleSheetBase* result = assertInspectorStyleSheetForId(&placeholde
r, styleSheetId); |
| 1196 if (result) |
| 1197 return result; |
| 1198 IdToInspectorStyleSheetForInlineStyle::iterator it = m_idToInspectorStyleShe
etForInlineStyle.find(styleSheetId); |
| 1199 if (it == m_idToInspectorStyleSheetForInlineStyle.end()) { |
| 1200 *errorString = "No style sheet with given id found"; |
| 1201 return 0; |
| 1202 } |
| 1203 return it->value.get(); |
| 1204 } |
| 1205 |
| 1187 TypeBuilder::CSS::StyleSheetOrigin::Enum InspectorCSSAgent::detectOrigin(CSSStyl
eSheet* pageStyleSheet, Document* ownerDocument) | 1206 TypeBuilder::CSS::StyleSheetOrigin::Enum InspectorCSSAgent::detectOrigin(CSSStyl
eSheet* pageStyleSheet, Document* ownerDocument) |
| 1188 { | 1207 { |
| 1189 if (m_creatingViaInspectorStyleSheet) | 1208 if (m_creatingViaInspectorStyleSheet) |
| 1190 return TypeBuilder::CSS::StyleSheetOrigin::Inspector; | 1209 return TypeBuilder::CSS::StyleSheetOrigin::Inspector; |
| 1191 | 1210 |
| 1192 TypeBuilder::CSS::StyleSheetOrigin::Enum origin = TypeBuilder::CSS::StyleShe
etOrigin::Regular; | 1211 TypeBuilder::CSS::StyleSheetOrigin::Enum origin = TypeBuilder::CSS::StyleShe
etOrigin::Regular; |
| 1193 if (pageStyleSheet && !pageStyleSheet->ownerNode() && pageStyleSheet->href()
.isEmpty()) | 1212 if (pageStyleSheet && !pageStyleSheet->ownerNode() && pageStyleSheet->href()
.isEmpty()) |
| 1194 origin = TypeBuilder::CSS::StyleSheetOrigin::User_agent; | 1213 origin = TypeBuilder::CSS::StyleSheetOrigin::User_agent; |
| 1195 else if (pageStyleSheet && pageStyleSheet->ownerNode() && pageStyleSheet->ow
nerNode()->isDocumentNode()) | 1214 else if (pageStyleSheet && pageStyleSheet->ownerNode() && pageStyleSheet->ow
nerNode()->isDocumentNode()) |
| 1196 origin = TypeBuilder::CSS::StyleSheetOrigin::User; | 1215 origin = TypeBuilder::CSS::StyleSheetOrigin::User; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 return; | 1310 return; |
| 1292 | 1311 |
| 1293 int nodeId = m_domAgent->boundNodeId(node); | 1312 int nodeId = m_domAgent->boundNodeId(node); |
| 1294 if (nodeId) | 1313 if (nodeId) |
| 1295 m_nodeIdToForcedPseudoState.remove(nodeId); | 1314 m_nodeIdToForcedPseudoState.remove(nodeId); |
| 1296 | 1315 |
| 1297 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(no
de); | 1316 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(no
de); |
| 1298 if (it == m_nodeToInspectorStyleSheet.end()) | 1317 if (it == m_nodeToInspectorStyleSheet.end()) |
| 1299 return; | 1318 return; |
| 1300 | 1319 |
| 1301 m_idToInspectorStyleSheet.remove(it->value->id()); | 1320 m_idToInspectorStyleSheetForInlineStyle.remove(it->value->id()); |
| 1302 m_nodeToInspectorStyleSheet.remove(node); | 1321 m_nodeToInspectorStyleSheet.remove(node); |
| 1303 } | 1322 } |
| 1304 | 1323 |
| 1305 void InspectorCSSAgent::didModifyDOMAttr(Element* element) | 1324 void InspectorCSSAgent::didModifyDOMAttr(Element* element) |
| 1306 { | 1325 { |
| 1307 if (!element) | 1326 if (!element) |
| 1308 return; | 1327 return; |
| 1309 | 1328 |
| 1310 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1329 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1311 if (it == m_nodeToInspectorStyleSheet.end()) | 1330 if (it == m_nodeToInspectorStyleSheet.end()) |
| 1312 return; | 1331 return; |
| 1313 | 1332 |
| 1314 it->value->didModifyElementAttribute(); | 1333 it->value->didModifyElementAttribute(); |
| 1315 } | 1334 } |
| 1316 | 1335 |
| 1317 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) | 1336 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheetBase* styleSheet) |
| 1318 { | 1337 { |
| 1319 flushPendingFrontendMessages(); | 1338 flushPendingFrontendMessages(); |
| 1320 m_frontend->styleSheetChanged(styleSheet->id()); | 1339 m_frontend->styleSheetChanged(styleSheet->id()); |
| 1321 } | 1340 } |
| 1322 | 1341 |
| 1323 void InspectorCSSAgent::willReparseStyleSheet() | 1342 void InspectorCSSAgent::willReparseStyleSheet() |
| 1324 { | 1343 { |
| 1325 ASSERT(!m_isSettingStyleSheetText); | 1344 ASSERT(!m_isSettingStyleSheetText); |
| 1326 m_isSettingStyleSheetText = true; | 1345 m_isSettingStyleSheetText = true; |
| 1327 } | 1346 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1341 documentsToChange.add(element->ownerDocument()); | 1360 documentsToChange.add(element->ownerDocument()); |
| 1342 } | 1361 } |
| 1343 | 1362 |
| 1344 m_nodeIdToForcedPseudoState.clear(); | 1363 m_nodeIdToForcedPseudoState.clear(); |
| 1345 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1364 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1346 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1365 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1347 } | 1366 } |
| 1348 | 1367 |
| 1349 } // namespace WebCore | 1368 } // namespace WebCore |
| 1350 | 1369 |
| OLD | NEW |