| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { | 122 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
| 123 WTF_MAKE_NONCOPYABLE(StyleSheetAction); | 123 WTF_MAKE_NONCOPYABLE(StyleSheetAction); |
| 124 public: | 124 public: |
| 125 StyleSheetAction(const String& name) | 125 StyleSheetAction(const String& name) |
| 126 : InspectorHistory::Action(name) | 126 : InspectorHistory::Action(name) |
| 127 { | 127 { |
| 128 } | 128 } |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 class InspectorCSSAgent::InspectorResourceContentLoaderCallback FINAL : public V
oidCallback { | 131 class InspectorCSSAgent::InspectorResourceContentLoaderCallback final : public V
oidCallback { |
| 132 public: | 132 public: |
| 133 InspectorResourceContentLoaderCallback(InspectorCSSAgent*, PassRefPtrWillBeR
awPtr<EnableCallback>); | 133 InspectorResourceContentLoaderCallback(InspectorCSSAgent*, PassRefPtrWillBeR
awPtr<EnableCallback>); |
| 134 virtual void trace(Visitor*) OVERRIDE; | 134 virtual void trace(Visitor*) override; |
| 135 virtual void handleEvent() OVERRIDE; | 135 virtual void handleEvent() override; |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; | 138 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; |
| 139 RefPtrWillBeMember<EnableCallback> m_callback; | 139 RefPtrWillBeMember<EnableCallback> m_callback; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 InspectorCSSAgent::InspectorResourceContentLoaderCallback::InspectorResourceCont
entLoaderCallback(InspectorCSSAgent* cssAgent, PassRefPtrWillBeRawPtr<EnableCall
back> callback) | 142 InspectorCSSAgent::InspectorResourceContentLoaderCallback::InspectorResourceCont
entLoaderCallback(InspectorCSSAgent* cssAgent, PassRefPtrWillBeRawPtr<EnableCall
back> callback) |
| 143 : m_cssAgent(cssAgent) | 143 : m_cssAgent(cssAgent) |
| 144 , m_callback(callback) | 144 , m_callback(callback) |
| 145 { | 145 { |
| 146 } | 146 } |
| 147 | 147 |
| 148 void InspectorCSSAgent::InspectorResourceContentLoaderCallback::trace(Visitor* v
isitor) | 148 void InspectorCSSAgent::InspectorResourceContentLoaderCallback::trace(Visitor* v
isitor) |
| 149 { | 149 { |
| 150 visitor->trace(m_cssAgent); | 150 visitor->trace(m_cssAgent); |
| 151 visitor->trace(m_callback); | 151 visitor->trace(m_callback); |
| 152 VoidCallback::trace(visitor); | 152 VoidCallback::trace(visitor); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void InspectorCSSAgent::InspectorResourceContentLoaderCallback::handleEvent() | 155 void InspectorCSSAgent::InspectorResourceContentLoaderCallback::handleEvent() |
| 156 { | 156 { |
| 157 // enable always succeeds. | 157 // enable always succeeds. |
| 158 if (!m_callback->isActive()) | 158 if (!m_callback->isActive()) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 m_cssAgent->wasEnabled(); | 161 m_cssAgent->wasEnabled(); |
| 162 m_callback->sendSuccess(); | 162 m_callback->sendSuccess(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 class InspectorCSSAgent::SetStyleSheetTextAction FINAL : public InspectorCSSAgen
t::StyleSheetAction { | 165 class InspectorCSSAgent::SetStyleSheetTextAction final : public InspectorCSSAgen
t::StyleSheetAction { |
| 166 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); | 166 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); |
| 167 public: | 167 public: |
| 168 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) | 168 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) |
| 169 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") | 169 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") |
| 170 , m_styleSheet(styleSheet) | 170 , m_styleSheet(styleSheet) |
| 171 , m_text(text) | 171 , m_text(text) |
| 172 { | 172 { |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 175 virtual bool perform(ExceptionState& exceptionState) override |
| 176 { | 176 { |
| 177 if (!m_styleSheet->getText(&m_oldText)) | 177 if (!m_styleSheet->getText(&m_oldText)) |
| 178 return false; | 178 return false; |
| 179 return redo(exceptionState); | 179 return redo(exceptionState); |
| 180 } | 180 } |
| 181 | 181 |
| 182 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 182 virtual bool undo(ExceptionState& exceptionState) override |
| 183 { | 183 { |
| 184 return m_styleSheet->setText(m_oldText, exceptionState); | 184 return m_styleSheet->setText(m_oldText, exceptionState); |
| 185 } | 185 } |
| 186 | 186 |
| 187 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 187 virtual bool redo(ExceptionState& exceptionState) override |
| 188 { | 188 { |
| 189 return m_styleSheet->setText(m_text, exceptionState); | 189 return m_styleSheet->setText(m_text, exceptionState); |
| 190 } | 190 } |
| 191 | 191 |
| 192 virtual String mergeId() OVERRIDE | 192 virtual String mergeId() override |
| 193 { | 193 { |
| 194 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); | 194 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 197 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override |
| 198 { | 198 { |
| 199 ASSERT(action->mergeId() == mergeId()); | 199 ASSERT(action->mergeId() == mergeId()); |
| 200 | 200 |
| 201 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 201 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
| 202 m_text = other->m_text; | 202 m_text = other->m_text; |
| 203 } | 203 } |
| 204 | 204 |
| 205 virtual void trace(Visitor* visitor) OVERRIDE | 205 virtual void trace(Visitor* visitor) override |
| 206 { | 206 { |
| 207 visitor->trace(m_styleSheet); | 207 visitor->trace(m_styleSheet); |
| 208 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 208 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 209 } | 209 } |
| 210 | 210 |
| 211 private: | 211 private: |
| 212 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; | 212 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 213 String m_text; | 213 String m_text; |
| 214 String m_oldText; | 214 String m_oldText; |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 class InspectorCSSAgent::SetPropertyTextAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 217 class InspectorCSSAgent::SetPropertyTextAction final : public InspectorCSSAgent:
:StyleSheetAction { |
| 218 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 218 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
| 219 public: | 219 public: |
| 220 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) | 220 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) |
| 221 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") | 221 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
| 222 , m_styleSheet(styleSheet) | 222 , m_styleSheet(styleSheet) |
| 223 , m_cssId(cssId) | 223 , m_cssId(cssId) |
| 224 , m_propertyIndex(propertyIndex) | 224 , m_propertyIndex(propertyIndex) |
| 225 , m_text(text) | 225 , m_text(text) |
| 226 , m_overwrite(overwrite) | 226 , m_overwrite(overwrite) |
| 227 { | 227 { |
| 228 } | 228 } |
| 229 | 229 |
| 230 virtual String toString() OVERRIDE | 230 virtual String toString() override |
| 231 { | 231 { |
| 232 return mergeId() + ": " + m_oldStyleText + " -> " + m_text; | 232 return mergeId() + ": " + m_oldStyleText + " -> " + m_text; |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 235 virtual bool perform(ExceptionState& exceptionState) override |
| 236 { | 236 { |
| 237 return redo(exceptionState); | 237 return redo(exceptionState); |
| 238 } | 238 } |
| 239 | 239 |
| 240 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 240 virtual bool undo(ExceptionState& exceptionState) override |
| 241 { | 241 { |
| 242 String placeholder; | 242 String placeholder; |
| 243 return m_styleSheet->setStyleText(m_cssId, m_oldStyleText); | 243 return m_styleSheet->setStyleText(m_cssId, m_oldStyleText); |
| 244 } | 244 } |
| 245 | 245 |
| 246 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 246 virtual bool redo(ExceptionState& exceptionState) override |
| 247 { | 247 { |
| 248 if (!m_styleSheet->getStyleText(m_cssId, &m_oldStyleText)) | 248 if (!m_styleSheet->getStyleText(m_cssId, &m_oldStyleText)) |
| 249 return false; | 249 return false; |
| 250 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); | 250 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); |
| 251 return result; | 251 return result; |
| 252 } | 252 } |
| 253 | 253 |
| 254 virtual String mergeId() OVERRIDE | 254 virtual String mergeId() override |
| 255 { | 255 { |
| 256 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); | 256 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); |
| 257 } | 257 } |
| 258 | 258 |
| 259 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) OVERRIDE | 259 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override |
| 260 { | 260 { |
| 261 ASSERT(action->mergeId() == mergeId()); | 261 ASSERT(action->mergeId() == mergeId()); |
| 262 | 262 |
| 263 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); | 263 SetPropertyTextAction* other = static_cast<SetPropertyTextAction*>(actio
n.get()); |
| 264 m_text = other->m_text; | 264 m_text = other->m_text; |
| 265 } | 265 } |
| 266 | 266 |
| 267 virtual void trace(Visitor* visitor) OVERRIDE | 267 virtual void trace(Visitor* visitor) override |
| 268 { | 268 { |
| 269 visitor->trace(m_styleSheet); | 269 visitor->trace(m_styleSheet); |
| 270 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 270 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 271 } | 271 } |
| 272 | 272 |
| 273 private: | 273 private: |
| 274 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; | 274 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 275 InspectorCSSId m_cssId; | 275 InspectorCSSId m_cssId; |
| 276 unsigned m_propertyIndex; | 276 unsigned m_propertyIndex; |
| 277 String m_text; | 277 String m_text; |
| 278 String m_oldStyleText; | 278 String m_oldStyleText; |
| 279 bool m_overwrite; | 279 bool m_overwrite; |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 class InspectorCSSAgent::SetRuleSelectorAction FINAL : public InspectorCSSAgent:
:StyleSheetAction { | 282 class InspectorCSSAgent::SetRuleSelectorAction final : public InspectorCSSAgent:
:StyleSheetAction { |
| 283 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 283 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
| 284 public: | 284 public: |
| 285 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, const String& selector) | 285 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, const String& selector) |
| 286 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector") | 286 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector") |
| 287 , m_styleSheet(styleSheet) | 287 , m_styleSheet(styleSheet) |
| 288 , m_cssId(cssId) | 288 , m_cssId(cssId) |
| 289 , m_selector(selector) | 289 , m_selector(selector) |
| 290 { | 290 { |
| 291 } | 291 } |
| 292 | 292 |
| 293 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 293 virtual bool perform(ExceptionState& exceptionState) override |
| 294 { | 294 { |
| 295 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState); | 295 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState); |
| 296 if (exceptionState.hadException()) | 296 if (exceptionState.hadException()) |
| 297 return false; | 297 return false; |
| 298 return redo(exceptionState); | 298 return redo(exceptionState); |
| 299 } | 299 } |
| 300 | 300 |
| 301 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 301 virtual bool undo(ExceptionState& exceptionState) override |
| 302 { | 302 { |
| 303 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 303 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); |
| 304 } | 304 } |
| 305 | 305 |
| 306 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 306 virtual bool redo(ExceptionState& exceptionState) override |
| 307 { | 307 { |
| 308 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 308 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); |
| 309 } | 309 } |
| 310 | 310 |
| 311 virtual void trace(Visitor* visitor) OVERRIDE | 311 virtual void trace(Visitor* visitor) override |
| 312 { | 312 { |
| 313 visitor->trace(m_styleSheet); | 313 visitor->trace(m_styleSheet); |
| 314 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 314 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 315 } | 315 } |
| 316 | 316 |
| 317 private: | 317 private: |
| 318 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 318 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 319 InspectorCSSId m_cssId; | 319 InspectorCSSId m_cssId; |
| 320 String m_selector; | 320 String m_selector; |
| 321 String m_oldSelector; | 321 String m_oldSelector; |
| 322 }; | 322 }; |
| 323 | 323 |
| 324 class InspectorCSSAgent::AddRuleAction FINAL : public InspectorCSSAgent::StyleSh
eetAction { | 324 class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSh
eetAction { |
| 325 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 325 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
| 326 public: | 326 public: |
| 327 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) | 327 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) |
| 328 : InspectorCSSAgent::StyleSheetAction("AddRule") | 328 : InspectorCSSAgent::StyleSheetAction("AddRule") |
| 329 , m_styleSheet(styleSheet) | 329 , m_styleSheet(styleSheet) |
| 330 , m_ruleText(ruleText) | 330 , m_ruleText(ruleText) |
| 331 , m_location(location) | 331 , m_location(location) |
| 332 { | 332 { |
| 333 } | 333 } |
| 334 | 334 |
| 335 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 335 virtual bool perform(ExceptionState& exceptionState) override |
| 336 { | 336 { |
| 337 return redo(exceptionState); | 337 return redo(exceptionState); |
| 338 } | 338 } |
| 339 | 339 |
| 340 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 340 virtual bool undo(ExceptionState& exceptionState) override |
| 341 { | 341 { |
| 342 return m_styleSheet->deleteRule(m_newId, m_oldText, exceptionState); | 342 return m_styleSheet->deleteRule(m_newId, m_oldText, exceptionState); |
| 343 } | 343 } |
| 344 | 344 |
| 345 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 345 virtual bool redo(ExceptionState& exceptionState) override |
| 346 { | 346 { |
| 347 if (!m_styleSheet->getText(&m_oldText)) | 347 if (!m_styleSheet->getText(&m_oldText)) |
| 348 return false; | 348 return false; |
| 349 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_ruleText, m_locatio
n, exceptionState); | 349 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_ruleText, m_locatio
n, exceptionState); |
| 350 if (exceptionState.hadException()) | 350 if (exceptionState.hadException()) |
| 351 return false; | 351 return false; |
| 352 m_newId = m_styleSheet->ruleId(cssStyleRule); | 352 m_newId = m_styleSheet->ruleId(cssStyleRule); |
| 353 return true; | 353 return true; |
| 354 } | 354 } |
| 355 | 355 |
| 356 InspectorCSSId newRuleId() { return m_newId; } | 356 InspectorCSSId newRuleId() { return m_newId; } |
| 357 | 357 |
| 358 virtual void trace(Visitor* visitor) OVERRIDE | 358 virtual void trace(Visitor* visitor) override |
| 359 { | 359 { |
| 360 visitor->trace(m_styleSheet); | 360 visitor->trace(m_styleSheet); |
| 361 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 361 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 362 } | 362 } |
| 363 | 363 |
| 364 private: | 364 private: |
| 365 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 365 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 366 InspectorCSSId m_newId; | 366 InspectorCSSId m_newId; |
| 367 String m_ruleText; | 367 String m_ruleText; |
| 368 String m_oldText; | 368 String m_oldText; |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 visitor->trace(m_invalidatedDocuments); | 1472 visitor->trace(m_invalidatedDocuments); |
| 1473 visitor->trace(m_nodeToInspectorStyleSheet); | 1473 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1474 visitor->trace(m_documentToViaInspectorStyleSheet); | 1474 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1475 #endif | 1475 #endif |
| 1476 visitor->trace(m_inspectorUserAgentStyleSheet); | 1476 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1477 InspectorBaseAgent::trace(visitor); | 1477 InspectorBaseAgent::trace(visitor); |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 } // namespace blink | 1480 } // namespace blink |
| 1481 | 1481 |
| OLD | NEW |