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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 StyleSheetAction(const String& name) | 146 StyleSheetAction(const String& name) |
147 : InspectorHistory::Action(name) | 147 : InspectorHistory::Action(name) |
148 { | 148 { |
149 } | 149 } |
150 }; | 150 }; |
151 | 151 |
152 class InspectorCSSAgent::InspectorResourceContentLoaderCallback final : public V
oidCallback { | 152 class InspectorCSSAgent::InspectorResourceContentLoaderCallback final : public V
oidCallback { |
153 public: | 153 public: |
154 InspectorResourceContentLoaderCallback(InspectorCSSAgent*, PassRefPtrWillBeR
awPtr<EnableCallback>); | 154 InspectorResourceContentLoaderCallback(InspectorCSSAgent*, PassRefPtrWillBeR
awPtr<EnableCallback>); |
155 DECLARE_VIRTUAL_TRACE(); | 155 DECLARE_VIRTUAL_TRACE(); |
156 virtual void handleEvent() override; | 156 void handleEvent() override; |
157 | 157 |
158 private: | 158 private: |
159 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; | 159 RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; |
160 RefPtrWillBeMember<EnableCallback> m_callback; | 160 RefPtrWillBeMember<EnableCallback> m_callback; |
161 }; | 161 }; |
162 | 162 |
163 InspectorCSSAgent::InspectorResourceContentLoaderCallback::InspectorResourceCont
entLoaderCallback(InspectorCSSAgent* cssAgent, PassRefPtrWillBeRawPtr<EnableCall
back> callback) | 163 InspectorCSSAgent::InspectorResourceContentLoaderCallback::InspectorResourceCont
entLoaderCallback(InspectorCSSAgent* cssAgent, PassRefPtrWillBeRawPtr<EnableCall
back> callback) |
164 : m_cssAgent(cssAgent) | 164 : m_cssAgent(cssAgent) |
165 , m_callback(callback) | 165 , m_callback(callback) |
166 { | 166 { |
(...skipping 19 matching lines...) Expand all Loading... |
186 class InspectorCSSAgent::SetStyleSheetTextAction final : public InspectorCSSAgen
t::StyleSheetAction { | 186 class InspectorCSSAgent::SetStyleSheetTextAction final : public InspectorCSSAgen
t::StyleSheetAction { |
187 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); | 187 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); |
188 public: | 188 public: |
189 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) | 189 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) |
190 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") | 190 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") |
191 , m_styleSheet(styleSheet) | 191 , m_styleSheet(styleSheet) |
192 , m_text(text) | 192 , m_text(text) |
193 { | 193 { |
194 } | 194 } |
195 | 195 |
196 virtual bool perform(ExceptionState& exceptionState) override | 196 bool perform(ExceptionState& exceptionState) override |
197 { | 197 { |
198 if (!m_styleSheet->getText(&m_oldText)) | 198 if (!m_styleSheet->getText(&m_oldText)) |
199 return false; | 199 return false; |
200 return redo(exceptionState); | 200 return redo(exceptionState); |
201 } | 201 } |
202 | 202 |
203 virtual bool undo(ExceptionState& exceptionState) override | 203 bool undo(ExceptionState& exceptionState) override |
204 { | 204 { |
205 return m_styleSheet->setText(m_oldText, exceptionState); | 205 return m_styleSheet->setText(m_oldText, exceptionState); |
206 } | 206 } |
207 | 207 |
208 virtual bool redo(ExceptionState& exceptionState) override | 208 bool redo(ExceptionState& exceptionState) override |
209 { | 209 { |
210 return m_styleSheet->setText(m_text, exceptionState); | 210 return m_styleSheet->setText(m_text, exceptionState); |
211 } | 211 } |
212 | 212 |
213 virtual String mergeId() override | 213 String mergeId() override |
214 { | 214 { |
215 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); | 215 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().
data()); |
216 } | 216 } |
217 | 217 |
218 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override | 218 void merge(PassRefPtrWillBeRawPtr<Action> action) override |
219 { | 219 { |
220 ASSERT(action->mergeId() == mergeId()); | 220 ASSERT(action->mergeId() == mergeId()); |
221 | 221 |
222 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); | 222 SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(a
ction.get()); |
223 m_text = other->m_text; | 223 m_text = other->m_text; |
224 } | 224 } |
225 | 225 |
226 DEFINE_INLINE_VIRTUAL_TRACE() | 226 DEFINE_INLINE_VIRTUAL_TRACE() |
227 { | 227 { |
228 visitor->trace(m_styleSheet); | 228 visitor->trace(m_styleSheet); |
(...skipping 18 matching lines...) Expand all Loading... |
247 ModifyRuleAction(Type type, InspectorStyleSheet* styleSheet, const SourceRan
ge& range, const String& text) | 247 ModifyRuleAction(Type type, InspectorStyleSheet* styleSheet, const SourceRan
ge& range, const String& text) |
248 : InspectorCSSAgent::StyleSheetAction("ModifyRuleAction") | 248 : InspectorCSSAgent::StyleSheetAction("ModifyRuleAction") |
249 , m_styleSheet(styleSheet) | 249 , m_styleSheet(styleSheet) |
250 , m_type(type) | 250 , m_type(type) |
251 , m_newText(text) | 251 , m_newText(text) |
252 , m_oldRange(range) | 252 , m_oldRange(range) |
253 , m_cssRule(nullptr) | 253 , m_cssRule(nullptr) |
254 { | 254 { |
255 } | 255 } |
256 | 256 |
257 virtual bool perform(ExceptionState& exceptionState) override | 257 bool perform(ExceptionState& exceptionState) override |
258 { | 258 { |
259 return redo(exceptionState); | 259 return redo(exceptionState); |
260 } | 260 } |
261 | 261 |
262 virtual bool undo(ExceptionState& exceptionState) override | 262 bool undo(ExceptionState& exceptionState) override |
263 { | 263 { |
264 switch (m_type) { | 264 switch (m_type) { |
265 case SetRuleSelector: | 265 case SetRuleSelector: |
266 return m_styleSheet->setRuleSelector(m_newRange, m_oldText, nullptr,
nullptr, exceptionState); | 266 return m_styleSheet->setRuleSelector(m_newRange, m_oldText, nullptr,
nullptr, exceptionState); |
267 case SetStyleText: | 267 case SetStyleText: |
268 return m_styleSheet->setStyleText(m_newRange, m_oldText, nullptr, nu
llptr, exceptionState); | 268 return m_styleSheet->setStyleText(m_newRange, m_oldText, nullptr, nu
llptr, exceptionState); |
269 case SetMediaRuleText: | 269 case SetMediaRuleText: |
270 return m_styleSheet->setMediaRuleText(m_newRange, m_oldText, nullptr
, nullptr, exceptionState); | 270 return m_styleSheet->setMediaRuleText(m_newRange, m_oldText, nullptr
, nullptr, exceptionState); |
271 default: | 271 default: |
272 ASSERT_NOT_REACHED(); | 272 ASSERT_NOT_REACHED(); |
273 } | 273 } |
274 return false; | 274 return false; |
275 } | 275 } |
276 | 276 |
277 virtual bool redo(ExceptionState& exceptionState) override | 277 bool redo(ExceptionState& exceptionState) override |
278 { | 278 { |
279 switch (m_type) { | 279 switch (m_type) { |
280 case SetRuleSelector: | 280 case SetRuleSelector: |
281 m_cssRule = m_styleSheet->setRuleSelector(m_oldRange, m_newText, &m_
newRange, &m_oldText, exceptionState); | 281 m_cssRule = m_styleSheet->setRuleSelector(m_oldRange, m_newText, &m_
newRange, &m_oldText, exceptionState); |
282 break; | 282 break; |
283 case SetStyleText: | 283 case SetStyleText: |
284 m_cssRule = m_styleSheet->setStyleText(m_oldRange, m_newText, &m_new
Range, &m_oldText, exceptionState); | 284 m_cssRule = m_styleSheet->setStyleText(m_oldRange, m_newText, &m_new
Range, &m_oldText, exceptionState); |
285 break; | 285 break; |
286 case SetMediaRuleText: | 286 case SetMediaRuleText: |
287 m_cssRule = m_styleSheet->setMediaRuleText(m_oldRange, m_newText, &m
_newRange, &m_oldText, exceptionState); | 287 m_cssRule = m_styleSheet->setMediaRuleText(m_oldRange, m_newText, &m
_newRange, &m_oldText, exceptionState); |
(...skipping 11 matching lines...) Expand all Loading... |
299 return result; | 299 return result; |
300 } | 300 } |
301 | 301 |
302 DEFINE_INLINE_VIRTUAL_TRACE() | 302 DEFINE_INLINE_VIRTUAL_TRACE() |
303 { | 303 { |
304 visitor->trace(m_styleSheet); | 304 visitor->trace(m_styleSheet); |
305 visitor->trace(m_cssRule); | 305 visitor->trace(m_cssRule); |
306 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 306 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
307 } | 307 } |
308 | 308 |
309 virtual String mergeId() override | 309 String mergeId() override |
310 { | 310 { |
311 return String::format("ModifyRuleAction:%d %s:%d", m_type, m_styleSheet-
>id().utf8().data(), m_oldRange.start); | 311 return String::format("ModifyRuleAction:%d %s:%d", m_type, m_styleSheet-
>id().utf8().data(), m_oldRange.start); |
312 } | 312 } |
313 | 313 |
314 virtual bool isNoop() override | 314 bool isNoop() override |
315 { | 315 { |
316 return m_oldText == m_newText; | 316 return m_oldText == m_newText; |
317 } | 317 } |
318 | 318 |
319 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override | 319 void merge(PassRefPtrWillBeRawPtr<Action> action) override |
320 { | 320 { |
321 ASSERT(action->mergeId() == mergeId()); | 321 ASSERT(action->mergeId() == mergeId()); |
322 | 322 |
323 ModifyRuleAction* other = static_cast<ModifyRuleAction*>(action.get()); | 323 ModifyRuleAction* other = static_cast<ModifyRuleAction*>(action.get()); |
324 m_newText = other->m_newText; | 324 m_newText = other->m_newText; |
325 m_newRange = other->m_newRange; | 325 m_newRange = other->m_newRange; |
326 } | 326 } |
327 | 327 |
328 private: | 328 private: |
329 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 329 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
330 Type m_type; | 330 Type m_type; |
331 String m_oldText; | 331 String m_oldText; |
332 String m_newText; | 332 String m_newText; |
333 SourceRange m_oldRange; | 333 SourceRange m_oldRange; |
334 SourceRange m_newRange; | 334 SourceRange m_newRange; |
335 RefPtrWillBeMember<CSSRule> m_cssRule; | 335 RefPtrWillBeMember<CSSRule> m_cssRule; |
336 }; | 336 }; |
337 | 337 |
338 class InspectorCSSAgent::SetElementStyleAction final : public InspectorCSSAgent:
:StyleSheetAction { | 338 class InspectorCSSAgent::SetElementStyleAction final : public InspectorCSSAgent:
:StyleSheetAction { |
339 WTF_MAKE_NONCOPYABLE(SetElementStyleAction); | 339 WTF_MAKE_NONCOPYABLE(SetElementStyleAction); |
340 public: | 340 public: |
341 SetElementStyleAction(InspectorStyleSheetForInlineStyle* styleSheet, const S
tring& text) | 341 SetElementStyleAction(InspectorStyleSheetForInlineStyle* styleSheet, const S
tring& text) |
342 : InspectorCSSAgent::StyleSheetAction("SetElementStyleAction") | 342 : InspectorCSSAgent::StyleSheetAction("SetElementStyleAction") |
343 , m_styleSheet(styleSheet) | 343 , m_styleSheet(styleSheet) |
344 , m_text(text) | 344 , m_text(text) |
345 { | 345 { |
346 } | 346 } |
347 | 347 |
348 virtual bool perform(ExceptionState& exceptionState) override | 348 bool perform(ExceptionState& exceptionState) override |
349 { | 349 { |
350 return redo(exceptionState); | 350 return redo(exceptionState); |
351 } | 351 } |
352 | 352 |
353 virtual bool undo(ExceptionState& exceptionState) override | 353 bool undo(ExceptionState& exceptionState) override |
354 { | 354 { |
355 return m_styleSheet->setText(m_oldText, exceptionState); | 355 return m_styleSheet->setText(m_oldText, exceptionState); |
356 } | 356 } |
357 | 357 |
358 virtual bool redo(ExceptionState& exceptionState) override | 358 bool redo(ExceptionState& exceptionState) override |
359 { | 359 { |
360 if (!m_styleSheet->getText(&m_oldText)) | 360 if (!m_styleSheet->getText(&m_oldText)) |
361 return false; | 361 return false; |
362 return m_styleSheet->setText(m_text, exceptionState); | 362 return m_styleSheet->setText(m_text, exceptionState); |
363 } | 363 } |
364 | 364 |
365 DEFINE_INLINE_VIRTUAL_TRACE() | 365 DEFINE_INLINE_VIRTUAL_TRACE() |
366 { | 366 { |
367 visitor->trace(m_styleSheet); | 367 visitor->trace(m_styleSheet); |
368 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 368 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
369 } | 369 } |
370 | 370 |
371 virtual String mergeId() override | 371 String mergeId() override |
372 { | 372 { |
373 return String::format("SetElementStyleAction:%s", m_styleSheet->id().utf
8().data()); | 373 return String::format("SetElementStyleAction:%s", m_styleSheet->id().utf
8().data()); |
374 } | 374 } |
375 | 375 |
376 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override | 376 void merge(PassRefPtrWillBeRawPtr<Action> action) override |
377 { | 377 { |
378 ASSERT(action->mergeId() == mergeId()); | 378 ASSERT(action->mergeId() == mergeId()); |
379 | 379 |
380 SetElementStyleAction* other = static_cast<SetElementStyleAction*>(actio
n.get()); | 380 SetElementStyleAction* other = static_cast<SetElementStyleAction*>(actio
n.get()); |
381 m_text = other->m_text; | 381 m_text = other->m_text; |
382 } | 382 } |
383 | 383 |
384 private: | 384 private: |
385 RefPtrWillBeMember<InspectorStyleSheetForInlineStyle> m_styleSheet; | 385 RefPtrWillBeMember<InspectorStyleSheetForInlineStyle> m_styleSheet; |
386 String m_text; | 386 String m_text; |
387 String m_oldText; | 387 String m_oldText; |
388 }; | 388 }; |
389 | 389 |
390 class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSh
eetAction { | 390 class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSh
eetAction { |
391 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 391 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
392 public: | 392 public: |
393 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) | 393 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) |
394 : InspectorCSSAgent::StyleSheetAction("AddRule") | 394 : InspectorCSSAgent::StyleSheetAction("AddRule") |
395 , m_styleSheet(styleSheet) | 395 , m_styleSheet(styleSheet) |
396 , m_ruleText(ruleText) | 396 , m_ruleText(ruleText) |
397 , m_location(location) | 397 , m_location(location) |
398 { | 398 { |
399 } | 399 } |
400 | 400 |
401 virtual bool perform(ExceptionState& exceptionState) override | 401 bool perform(ExceptionState& exceptionState) override |
402 { | 402 { |
403 return redo(exceptionState); | 403 return redo(exceptionState); |
404 } | 404 } |
405 | 405 |
406 virtual bool undo(ExceptionState& exceptionState) override | 406 bool undo(ExceptionState& exceptionState) override |
407 { | 407 { |
408 return m_styleSheet->deleteRule(m_addedRange, exceptionState); | 408 return m_styleSheet->deleteRule(m_addedRange, exceptionState); |
409 } | 409 } |
410 | 410 |
411 virtual bool redo(ExceptionState& exceptionState) override | 411 bool redo(ExceptionState& exceptionState) override |
412 { | 412 { |
413 m_cssRule = m_styleSheet->addRule(m_ruleText, m_location, &m_addedRange,
exceptionState); | 413 m_cssRule = m_styleSheet->addRule(m_ruleText, m_location, &m_addedRange,
exceptionState); |
414 if (exceptionState.hadException()) | 414 if (exceptionState.hadException()) |
415 return false; | 415 return false; |
416 return true; | 416 return true; |
417 } | 417 } |
418 | 418 |
419 RefPtrWillBeRawPtr<CSSStyleRule> takeRule() | 419 RefPtrWillBeRawPtr<CSSStyleRule> takeRule() |
420 { | 420 { |
421 RefPtrWillBeRawPtr<CSSStyleRule> result = m_cssRule; | 421 RefPtrWillBeRawPtr<CSSStyleRule> result = m_cssRule; |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 visitor->trace(m_documentToCSSStyleSheets); | 1692 visitor->trace(m_documentToCSSStyleSheets); |
1693 visitor->trace(m_invalidatedDocuments); | 1693 visitor->trace(m_invalidatedDocuments); |
1694 visitor->trace(m_nodeToInspectorStyleSheet); | 1694 visitor->trace(m_nodeToInspectorStyleSheet); |
1695 visitor->trace(m_documentToViaInspectorStyleSheet); | 1695 visitor->trace(m_documentToViaInspectorStyleSheet); |
1696 #endif | 1696 #endif |
1697 visitor->trace(m_inspectorUserAgentStyleSheet); | 1697 visitor->trace(m_inspectorUserAgentStyleSheet); |
1698 InspectorBaseAgent::trace(visitor); | 1698 InspectorBaseAgent::trace(visitor); |
1699 } | 1699 } |
1700 | 1700 |
1701 } // namespace blink | 1701 } // namespace blink |
OLD | NEW |