| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 : InspectorHistory::Action("InsertBefore") | 87 : InspectorHistory::Action("InsertBefore") |
| 88 , m_parentNode(parentNode) | 88 , m_parentNode(parentNode) |
| 89 , m_node(node) | 89 , m_node(node) |
| 90 , m_anchorNode(anchorNode) | 90 , m_anchorNode(anchorNode) |
| 91 { | 91 { |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 94 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
| 95 { | 95 { |
| 96 if (m_node->parentNode()) { | 96 if (m_node->parentNode()) { |
| 97 m_removeChildAction = adoptPtr(new RemoveChildAction(m_node->parentN
ode(), m_node.get())); | 97 m_removeChildAction = adoptRef(new RemoveChildAction(m_node->parentN
ode(), m_node.get())); |
| 98 if (!m_removeChildAction->perform(exceptionState)) | 98 if (!m_removeChildAction->perform(exceptionState)) |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); | 101 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); |
| 102 return !exceptionState.hadException(); | 102 return !exceptionState.hadException(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 105 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
| 106 { | 106 { |
| 107 m_parentNode->removeChild(m_node.get(), exceptionState); | 107 m_parentNode->removeChild(m_node.get(), exceptionState); |
| 108 if (exceptionState.hadException()) | 108 if (exceptionState.hadException()) |
| 109 return false; | 109 return false; |
| 110 if (m_removeChildAction) | 110 if (m_removeChildAction) |
| 111 return m_removeChildAction->undo(exceptionState); | 111 return m_removeChildAction->undo(exceptionState); |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 115 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
| 116 { | 116 { |
| 117 if (m_removeChildAction && !m_removeChildAction->redo(exceptionState)) | 117 if (m_removeChildAction && !m_removeChildAction->redo(exceptionState)) |
| 118 return false; | 118 return false; |
| 119 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); | 119 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); |
| 120 return !exceptionState.hadException(); | 120 return !exceptionState.hadException(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 RefPtr<Node> m_parentNode; | 124 RefPtr<Node> m_parentNode; |
| 125 RefPtr<Node> m_node; | 125 RefPtr<Node> m_node; |
| 126 RefPtr<Node> m_anchorNode; | 126 RefPtr<Node> m_anchorNode; |
| 127 OwnPtr<RemoveChildAction> m_removeChildAction; | 127 RefPtr<RemoveChildAction> m_removeChildAction; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 class DOMEditor::RemoveAttributeAction FINAL : public InspectorHistory::Action { | 130 class DOMEditor::RemoveAttributeAction FINAL : public InspectorHistory::Action { |
| 131 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction); | 131 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction); |
| 132 public: | 132 public: |
| 133 RemoveAttributeAction(Element* element, const AtomicString& name) | 133 RemoveAttributeAction(Element* element, const AtomicString& name) |
| 134 : InspectorHistory::Action("RemoveAttribute") | 134 : InspectorHistory::Action("RemoveAttribute") |
| 135 , m_element(element) | 135 , m_element(element) |
| 136 , m_name(name) | 136 , m_name(name) |
| 137 { | 137 { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 String m_value; | 354 String m_value; |
| 355 String m_oldValue; | 355 String m_oldValue; |
| 356 }; | 356 }; |
| 357 | 357 |
| 358 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } | 358 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } |
| 359 | 359 |
| 360 DOMEditor::~DOMEditor() { } | 360 DOMEditor::~DOMEditor() { } |
| 361 | 361 |
| 362 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ExceptionState& exceptionState) | 362 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ExceptionState& exceptionState) |
| 363 { | 363 { |
| 364 return m_history->perform(adoptPtr(new InsertBeforeAction(parentNode, node,
anchorNode)), exceptionState); | 364 return m_history->perform(adoptRef(new InsertBeforeAction(parentNode, node,
anchorNode)), exceptionState); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& except
ionState) | 367 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& except
ionState) |
| 368 { | 368 { |
| 369 return m_history->perform(adoptPtr(new RemoveChildAction(parentNode, node)),
exceptionState); | 369 return m_history->perform(adoptRef(new RemoveChildAction(parentNode, node)),
exceptionState); |
| 370 } | 370 } |
| 371 | 371 |
| 372 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& exceptionState) | 372 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& exceptionState) |
| 373 { | 373 { |
| 374 return m_history->perform(adoptPtr(new SetAttributeAction(element, AtomicStr
ing(name), AtomicString(value))), exceptionState); | 374 return m_history->perform(adoptRef(new SetAttributeAction(element, AtomicStr
ing(name), AtomicString(value))), exceptionState); |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionS
tate& exceptionState) | 377 bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionS
tate& exceptionState) |
| 378 { | 378 { |
| 379 return m_history->perform(adoptPtr(new RemoveAttributeAction(element, Atomic
String(name))), exceptionState); | 379 return m_history->perform(adoptRef(new RemoveAttributeAction(element, Atomic
String(name))), exceptionState); |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Exc
eptionState& exceptionState) | 382 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Exc
eptionState& exceptionState) |
| 383 { | 383 { |
| 384 OwnPtr<SetOuterHTMLAction> action = adoptPtr(new SetOuterHTMLAction(node, ht
ml)); | 384 RefPtr<SetOuterHTMLAction> action = adoptRef(new SetOuterHTMLAction(node, ht
ml)); |
| 385 SetOuterHTMLAction* rawAction = action.get(); | 385 bool result = m_history->perform(action, exceptionState); |
| 386 bool result = m_history->perform(action.release(), exceptionState); | |
| 387 if (result) | 386 if (result) |
| 388 *newNode = rawAction->newNode(); | 387 *newNode = action->newNode(); |
| 389 return result; | 388 return result; |
| 390 } | 389 } |
| 391 | 390 |
| 392 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& exceptionState) | 391 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& exceptionState) |
| 393 { | 392 { |
| 394 return m_history->perform(adoptPtr(new ReplaceWholeTextAction(textNode, text
)), exceptionState); | 393 return m_history->perform(adoptRef(new ReplaceWholeTextAction(textNode, text
)), exceptionState); |
| 395 } | 394 } |
| 396 | 395 |
| 397 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* o
ldNode, ExceptionState& exceptionState) | 396 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* o
ldNode, ExceptionState& exceptionState) |
| 398 { | 397 { |
| 399 return m_history->perform(adoptPtr(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), exceptionState); | 398 return m_history->perform(adoptRef(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), exceptionState); |
| 400 } | 399 } |
| 401 | 400 |
| 402 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& ex
ceptionState) | 401 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& ex
ceptionState) |
| 403 { | 402 { |
| 404 return m_history->perform(adoptPtr(new SetNodeValueAction(node, value)), exc
eptionState); | 403 return m_history->perform(adoptRef(new SetNodeValueAction(node, value)), exc
eptionState); |
| 405 } | 404 } |
| 406 | 405 |
| 407 static void populateErrorString(ExceptionState& exceptionState, ErrorString* err
orString) | 406 static void populateErrorString(ExceptionState& exceptionState, ErrorString* err
orString) |
| 408 { | 407 { |
| 409 if (exceptionState.hadException()) | 408 if (exceptionState.hadException()) |
| 410 *errorString = DOMException::getErrorName(exceptionState.code()); | 409 *errorString = DOMException::getErrorName(exceptionState.code()); |
| 411 } | 410 } |
| 412 | 411 |
| 413 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ErrorString* errorString) | 412 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ErrorString* errorString) |
| 414 { | 413 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) | 452 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) |
| 454 { | 453 { |
| 455 TrackExceptionState exceptionState; | 454 TrackExceptionState exceptionState; |
| 456 bool result = replaceWholeText(textNode, text, exceptionState); | 455 bool result = replaceWholeText(textNode, text, exceptionState); |
| 457 populateErrorString(exceptionState, errorString); | 456 populateErrorString(exceptionState, errorString); |
| 458 return result; | 457 return result; |
| 459 } | 458 } |
| 460 | 459 |
| 461 } // namespace WebCore | 460 } // namespace WebCore |
| 462 | 461 |
| OLD | NEW |