| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 class DOMEditor::RemoveChildAction : public InspectorHistory::Action { | 49 class DOMEditor::RemoveChildAction : public InspectorHistory::Action { |
| 50 WTF_MAKE_NONCOPYABLE(RemoveChildAction); | 50 WTF_MAKE_NONCOPYABLE(RemoveChildAction); |
| 51 public: | 51 public: |
| 52 RemoveChildAction(Node* parentNode, Node* node) | 52 RemoveChildAction(Node* parentNode, Node* node) |
| 53 : InspectorHistory::Action("RemoveChild") | 53 : InspectorHistory::Action("RemoveChild") |
| 54 , m_parentNode(parentNode) | 54 , m_parentNode(parentNode) |
| 55 , m_node(node) | 55 , m_node(node) |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual bool perform(ExceptionState& es) | 59 virtual bool perform(ExceptionState& exceptionState) |
| 60 { | 60 { |
| 61 m_anchorNode = m_node->nextSibling(); | 61 m_anchorNode = m_node->nextSibling(); |
| 62 return redo(es); | 62 return redo(exceptionState); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual bool undo(ExceptionState& es) | 65 virtual bool undo(ExceptionState& exceptionState) |
| 66 { | 66 { |
| 67 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), es); | 67 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); |
| 68 return !es.hadException(); | 68 return !exceptionState.hadException(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual bool redo(ExceptionState& es) | 71 virtual bool redo(ExceptionState& exceptionState) |
| 72 { | 72 { |
| 73 m_parentNode->removeChild(m_node.get(), es); | 73 m_parentNode->removeChild(m_node.get(), exceptionState); |
| 74 return !es.hadException(); | 74 return !exceptionState.hadException(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 RefPtr<Node> m_parentNode; | 78 RefPtr<Node> m_parentNode; |
| 79 RefPtr<Node> m_node; | 79 RefPtr<Node> m_node; |
| 80 RefPtr<Node> m_anchorNode; | 80 RefPtr<Node> m_anchorNode; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class DOMEditor::InsertBeforeAction : public InspectorHistory::Action { | 83 class DOMEditor::InsertBeforeAction : public InspectorHistory::Action { |
| 84 WTF_MAKE_NONCOPYABLE(InsertBeforeAction); | 84 WTF_MAKE_NONCOPYABLE(InsertBeforeAction); |
| 85 public: | 85 public: |
| 86 InsertBeforeAction(Node* parentNode, PassRefPtr<Node> node, Node* anchorNode
) | 86 InsertBeforeAction(Node* parentNode, PassRefPtr<Node> node, Node* anchorNode
) |
| 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& es) | 94 virtual bool perform(ExceptionState& exceptionState) |
| 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 = adoptPtr(new RemoveChildAction(m_node->parentN
ode(), m_node.get())); |
| 98 if (!m_removeChildAction->perform(es)) | 98 if (!m_removeChildAction->perform(exceptionState)) |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), es); | 101 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); |
| 102 return !es.hadException(); | 102 return !exceptionState.hadException(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual bool undo(ExceptionState& es) | 105 virtual bool undo(ExceptionState& exceptionState) |
| 106 { | 106 { |
| 107 m_parentNode->removeChild(m_node.get(), es); | 107 m_parentNode->removeChild(m_node.get(), exceptionState); |
| 108 if (es.hadException()) | 108 if (exceptionState.hadException()) |
| 109 return false; | 109 return false; |
| 110 if (m_removeChildAction) | 110 if (m_removeChildAction) |
| 111 return m_removeChildAction->undo(es); | 111 return m_removeChildAction->undo(exceptionState); |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual bool redo(ExceptionState& es) | 115 virtual bool redo(ExceptionState& exceptionState) |
| 116 { | 116 { |
| 117 if (m_removeChildAction && !m_removeChildAction->redo(es)) | 117 if (m_removeChildAction && !m_removeChildAction->redo(exceptionState)) |
| 118 return false; | 118 return false; |
| 119 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), es); | 119 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt
ate); |
| 120 return !es.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 OwnPtr<RemoveChildAction> m_removeChildAction; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 class DOMEditor::RemoveAttributeAction : public InspectorHistory::Action { | 130 class DOMEditor::RemoveAttributeAction : public InspectorHistory::Action { |
| 131 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction); | 131 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction); |
| 132 public: | 132 public: |
| 133 RemoveAttributeAction(Element* element, const String& name) | 133 RemoveAttributeAction(Element* element, const String& 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 { |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual bool perform(ExceptionState& es) | 140 virtual bool perform(ExceptionState& exceptionState) |
| 141 { | 141 { |
| 142 m_value = m_element->getAttribute(m_name); | 142 m_value = m_element->getAttribute(m_name); |
| 143 return redo(es); | 143 return redo(exceptionState); |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual bool undo(ExceptionState& es) | 146 virtual bool undo(ExceptionState& exceptionState) |
| 147 { | 147 { |
| 148 m_element->setAttribute(m_name, m_value, es); | 148 m_element->setAttribute(m_name, m_value, exceptionState); |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual bool redo(ExceptionState&) | 152 virtual bool redo(ExceptionState&) |
| 153 { | 153 { |
| 154 m_element->removeAttribute(m_name); | 154 m_element->removeAttribute(m_name); |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 RefPtr<Element> m_element; | 159 RefPtr<Element> m_element; |
| 160 String m_name; | 160 String m_name; |
| 161 String m_value; | 161 String m_value; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 class DOMEditor::SetAttributeAction : public InspectorHistory::Action { | 164 class DOMEditor::SetAttributeAction : public InspectorHistory::Action { |
| 165 WTF_MAKE_NONCOPYABLE(SetAttributeAction); | 165 WTF_MAKE_NONCOPYABLE(SetAttributeAction); |
| 166 public: | 166 public: |
| 167 SetAttributeAction(Element* element, const String& name, const String& value
) | 167 SetAttributeAction(Element* element, const String& name, const String& value
) |
| 168 : InspectorHistory::Action("SetAttribute") | 168 : InspectorHistory::Action("SetAttribute") |
| 169 , m_element(element) | 169 , m_element(element) |
| 170 , m_name(name) | 170 , m_name(name) |
| 171 , m_value(value) | 171 , m_value(value) |
| 172 , m_hadAttribute(false) | 172 , m_hadAttribute(false) |
| 173 { | 173 { |
| 174 } | 174 } |
| 175 | 175 |
| 176 virtual bool perform(ExceptionState& es) | 176 virtual bool perform(ExceptionState& exceptionState) |
| 177 { | 177 { |
| 178 m_hadAttribute = m_element->hasAttribute(m_name); | 178 m_hadAttribute = m_element->hasAttribute(m_name); |
| 179 if (m_hadAttribute) | 179 if (m_hadAttribute) |
| 180 m_oldValue = m_element->getAttribute(m_name); | 180 m_oldValue = m_element->getAttribute(m_name); |
| 181 return redo(es); | 181 return redo(exceptionState); |
| 182 } | 182 } |
| 183 | 183 |
| 184 virtual bool undo(ExceptionState& es) | 184 virtual bool undo(ExceptionState& exceptionState) |
| 185 { | 185 { |
| 186 if (m_hadAttribute) | 186 if (m_hadAttribute) |
| 187 m_element->setAttribute(m_name, m_oldValue, es); | 187 m_element->setAttribute(m_name, m_oldValue, exceptionState); |
| 188 else | 188 else |
| 189 m_element->removeAttribute(m_name); | 189 m_element->removeAttribute(m_name); |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 virtual bool redo(ExceptionState& es) | 193 virtual bool redo(ExceptionState& exceptionState) |
| 194 { | 194 { |
| 195 m_element->setAttribute(m_name, m_value, es); | 195 m_element->setAttribute(m_name, m_value, exceptionState); |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 RefPtr<Element> m_element; | 200 RefPtr<Element> m_element; |
| 201 String m_name; | 201 String m_name; |
| 202 String m_value; | 202 String m_value; |
| 203 bool m_hadAttribute; | 203 bool m_hadAttribute; |
| 204 String m_oldValue; | 204 String m_oldValue; |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 class DOMEditor::SetOuterHTMLAction : public InspectorHistory::Action { | 207 class DOMEditor::SetOuterHTMLAction : public InspectorHistory::Action { |
| 208 WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction); | 208 WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction); |
| 209 public: | 209 public: |
| 210 SetOuterHTMLAction(Node* node, const String& html) | 210 SetOuterHTMLAction(Node* node, const String& html) |
| 211 : InspectorHistory::Action("SetOuterHTML") | 211 : InspectorHistory::Action("SetOuterHTML") |
| 212 , m_node(node) | 212 , m_node(node) |
| 213 , m_nextSibling(node->nextSibling()) | 213 , m_nextSibling(node->nextSibling()) |
| 214 , m_html(html) | 214 , m_html(html) |
| 215 , m_newNode(0) | 215 , m_newNode(0) |
| 216 , m_history(adoptPtr(new InspectorHistory())) | 216 , m_history(adoptPtr(new InspectorHistory())) |
| 217 , m_domEditor(adoptPtr(new DOMEditor(m_history.get()))) | 217 , m_domEditor(adoptPtr(new DOMEditor(m_history.get()))) |
| 218 { | 218 { |
| 219 } | 219 } |
| 220 | 220 |
| 221 virtual bool perform(ExceptionState& es) | 221 virtual bool perform(ExceptionState& exceptionState) |
| 222 { | 222 { |
| 223 m_oldHTML = createMarkup(m_node.get()); | 223 m_oldHTML = createMarkup(m_node.get()); |
| 224 ASSERT(m_node->ownerDocument()); | 224 ASSERT(m_node->ownerDocument()); |
| 225 DOMPatchSupport domPatchSupport(m_domEditor.get(), *m_node->ownerDocumen
t()); | 225 DOMPatchSupport domPatchSupport(m_domEditor.get(), *m_node->ownerDocumen
t()); |
| 226 m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, es); | 226 m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, exceptionSta
te); |
| 227 return !es.hadException(); | 227 return !exceptionState.hadException(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 virtual bool undo(ExceptionState& es) | 230 virtual bool undo(ExceptionState& exceptionState) |
| 231 { | 231 { |
| 232 return m_history->undo(es); | 232 return m_history->undo(exceptionState); |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual bool redo(ExceptionState& es) | 235 virtual bool redo(ExceptionState& exceptionState) |
| 236 { | 236 { |
| 237 return m_history->redo(es); | 237 return m_history->redo(exceptionState); |
| 238 } | 238 } |
| 239 | 239 |
| 240 Node* newNode() | 240 Node* newNode() |
| 241 { | 241 { |
| 242 return m_newNode; | 242 return m_newNode; |
| 243 } | 243 } |
| 244 | 244 |
| 245 private: | 245 private: |
| 246 RefPtr<Node> m_node; | 246 RefPtr<Node> m_node; |
| 247 RefPtr<Node> m_nextSibling; | 247 RefPtr<Node> m_nextSibling; |
| 248 String m_html; | 248 String m_html; |
| 249 String m_oldHTML; | 249 String m_oldHTML; |
| 250 Node* m_newNode; | 250 Node* m_newNode; |
| 251 OwnPtr<InspectorHistory> m_history; | 251 OwnPtr<InspectorHistory> m_history; |
| 252 OwnPtr<DOMEditor> m_domEditor; | 252 OwnPtr<DOMEditor> m_domEditor; |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 class DOMEditor::ReplaceWholeTextAction : public InspectorHistory::Action { | 255 class DOMEditor::ReplaceWholeTextAction : public InspectorHistory::Action { |
| 256 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction); | 256 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction); |
| 257 public: | 257 public: |
| 258 ReplaceWholeTextAction(Text* textNode, const String& text) | 258 ReplaceWholeTextAction(Text* textNode, const String& text) |
| 259 : InspectorHistory::Action("ReplaceWholeText") | 259 : InspectorHistory::Action("ReplaceWholeText") |
| 260 , m_textNode(textNode) | 260 , m_textNode(textNode) |
| 261 , m_text(text) | 261 , m_text(text) |
| 262 { | 262 { |
| 263 } | 263 } |
| 264 | 264 |
| 265 virtual bool perform(ExceptionState& es) | 265 virtual bool perform(ExceptionState& exceptionState) |
| 266 { | 266 { |
| 267 m_oldText = m_textNode->wholeText(); | 267 m_oldText = m_textNode->wholeText(); |
| 268 return redo(es); | 268 return redo(exceptionState); |
| 269 } | 269 } |
| 270 | 270 |
| 271 virtual bool undo(ExceptionState&) | 271 virtual bool undo(ExceptionState&) |
| 272 { | 272 { |
| 273 m_textNode->replaceWholeText(m_oldText); | 273 m_textNode->replaceWholeText(m_oldText); |
| 274 return true; | 274 return true; |
| 275 } | 275 } |
| 276 | 276 |
| 277 virtual bool redo(ExceptionState&) | 277 virtual bool redo(ExceptionState&) |
| 278 { | 278 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 290 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction); | 290 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction); |
| 291 public: | 291 public: |
| 292 ReplaceChildNodeAction(Node* parentNode, PassRefPtr<Node> newNode, Node* old
Node) | 292 ReplaceChildNodeAction(Node* parentNode, PassRefPtr<Node> newNode, Node* old
Node) |
| 293 : InspectorHistory::Action("ReplaceChildNode") | 293 : InspectorHistory::Action("ReplaceChildNode") |
| 294 , m_parentNode(parentNode) | 294 , m_parentNode(parentNode) |
| 295 , m_newNode(newNode) | 295 , m_newNode(newNode) |
| 296 , m_oldNode(oldNode) | 296 , m_oldNode(oldNode) |
| 297 { | 297 { |
| 298 } | 298 } |
| 299 | 299 |
| 300 virtual bool perform(ExceptionState& es) | 300 virtual bool perform(ExceptionState& exceptionState) |
| 301 { | 301 { |
| 302 return redo(es); | 302 return redo(exceptionState); |
| 303 } | 303 } |
| 304 | 304 |
| 305 virtual bool undo(ExceptionState& es) | 305 virtual bool undo(ExceptionState& exceptionState) |
| 306 { | 306 { |
| 307 m_parentNode->replaceChild(m_oldNode, m_newNode.get(), es); | 307 m_parentNode->replaceChild(m_oldNode, m_newNode.get(), exceptionState); |
| 308 return !es.hadException(); | 308 return !exceptionState.hadException(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 virtual bool redo(ExceptionState& es) | 311 virtual bool redo(ExceptionState& exceptionState) |
| 312 { | 312 { |
| 313 m_parentNode->replaceChild(m_newNode, m_oldNode.get(), es); | 313 m_parentNode->replaceChild(m_newNode, m_oldNode.get(), exceptionState); |
| 314 return !es.hadException(); | 314 return !exceptionState.hadException(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 private: | 317 private: |
| 318 RefPtr<Node> m_parentNode; | 318 RefPtr<Node> m_parentNode; |
| 319 RefPtr<Node> m_newNode; | 319 RefPtr<Node> m_newNode; |
| 320 RefPtr<Node> m_oldNode; | 320 RefPtr<Node> m_oldNode; |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 class DOMEditor::SetNodeValueAction : public InspectorHistory::Action { | 323 class DOMEditor::SetNodeValueAction : public InspectorHistory::Action { |
| 324 WTF_MAKE_NONCOPYABLE(SetNodeValueAction); | 324 WTF_MAKE_NONCOPYABLE(SetNodeValueAction); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 351 private: | 351 private: |
| 352 RefPtr<Node> m_node; | 352 RefPtr<Node> m_node; |
| 353 String m_value; | 353 String m_value; |
| 354 String m_oldValue; | 354 String m_oldValue; |
| 355 }; | 355 }; |
| 356 | 356 |
| 357 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } | 357 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } |
| 358 | 358 |
| 359 DOMEditor::~DOMEditor() { } | 359 DOMEditor::~DOMEditor() { } |
| 360 | 360 |
| 361 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ExceptionState& es) | 361 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ExceptionState& exceptionState) |
| 362 { | 362 { |
| 363 return m_history->perform(adoptPtr(new InsertBeforeAction(parentNode, node,
anchorNode)), es); | 363 return m_history->perform(adoptPtr(new InsertBeforeAction(parentNode, node,
anchorNode)), exceptionState); |
| 364 } | 364 } |
| 365 | 365 |
| 366 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& es) | 366 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& except
ionState) |
| 367 { | 367 { |
| 368 return m_history->perform(adoptPtr(new RemoveChildAction(parentNode, node)),
es); | 368 return m_history->perform(adoptPtr(new RemoveChildAction(parentNode, node)),
exceptionState); |
| 369 } | 369 } |
| 370 | 370 |
| 371 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& es) | 371 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& exceptionState) |
| 372 { | 372 { |
| 373 return m_history->perform(adoptPtr(new SetAttributeAction(element, name, val
ue)), es); | 373 return m_history->perform(adoptPtr(new SetAttributeAction(element, name, val
ue)), exceptionState); |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionS
tate& es) | 376 bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionS
tate& exceptionState) |
| 377 { | 377 { |
| 378 return m_history->perform(adoptPtr(new RemoveAttributeAction(element, name))
, es); | 378 return m_history->perform(adoptPtr(new RemoveAttributeAction(element, name))
, exceptionState); |
| 379 } | 379 } |
| 380 | 380 |
| 381 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Exc
eptionState& es) | 381 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Exc
eptionState& exceptionState) |
| 382 { | 382 { |
| 383 OwnPtr<SetOuterHTMLAction> action = adoptPtr(new SetOuterHTMLAction(node, ht
ml)); | 383 OwnPtr<SetOuterHTMLAction> action = adoptPtr(new SetOuterHTMLAction(node, ht
ml)); |
| 384 SetOuterHTMLAction* rawAction = action.get(); | 384 SetOuterHTMLAction* rawAction = action.get(); |
| 385 bool result = m_history->perform(action.release(), es); | 385 bool result = m_history->perform(action.release(), exceptionState); |
| 386 if (result) | 386 if (result) |
| 387 *newNode = rawAction->newNode(); | 387 *newNode = rawAction->newNode(); |
| 388 return result; | 388 return result; |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& es) | 391 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& exceptionState) |
| 392 { | 392 { |
| 393 return m_history->perform(adoptPtr(new ReplaceWholeTextAction(textNode, text
)), es); | 393 return m_history->perform(adoptPtr(new ReplaceWholeTextAction(textNode, text
)), exceptionState); |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* o
ldNode, ExceptionState& es) | 396 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* o
ldNode, ExceptionState& exceptionState) |
| 397 { | 397 { |
| 398 return m_history->perform(adoptPtr(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), es); | 398 return m_history->perform(adoptPtr(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), exceptionState); |
| 399 } | 399 } |
| 400 | 400 |
| 401 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& es
) | 401 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& ex
ceptionState) |
| 402 { | 402 { |
| 403 return m_history->perform(adoptPtr(new SetNodeValueAction(node, value)), es)
; | 403 return m_history->perform(adoptPtr(new SetNodeValueAction(node, value)), exc
eptionState); |
| 404 } | 404 } |
| 405 | 405 |
| 406 static void populateErrorString(ExceptionState& es, ErrorString* errorString) | 406 static void populateErrorString(ExceptionState& exceptionState, ErrorString* err
orString) |
| 407 { | 407 { |
| 408 if (es.hadException()) | 408 if (exceptionState.hadException()) |
| 409 *errorString = DOMException::getErrorName(es.code()); | 409 *errorString = DOMException::getErrorName(exceptionState.code()); |
| 410 } | 410 } |
| 411 | 411 |
| 412 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) |
| 413 { | 413 { |
| 414 TrackExceptionState es; | 414 TrackExceptionState exceptionState; |
| 415 bool result = insertBefore(parentNode, node, anchorNode, es); | 415 bool result = insertBefore(parentNode, node, anchorNode, exceptionState); |
| 416 populateErrorString(es, errorString); | 416 populateErrorString(exceptionState, errorString); |
| 417 return result; | 417 return result; |
| 418 } | 418 } |
| 419 | 419 |
| 420 bool DOMEditor::removeChild(Node* parentNode, Node* node, ErrorString* errorStri
ng) | 420 bool DOMEditor::removeChild(Node* parentNode, Node* node, ErrorString* errorStri
ng) |
| 421 { | 421 { |
| 422 TrackExceptionState es; | 422 TrackExceptionState exceptionState; |
| 423 bool result = removeChild(parentNode, node, es); | 423 bool result = removeChild(parentNode, node, exceptionState); |
| 424 populateErrorString(es, errorString); | 424 populateErrorString(exceptionState, errorString); |
| 425 return result; | 425 return result; |
| 426 } | 426 } |
| 427 | 427 |
| 428 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ErrorString* errorString) | 428 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ErrorString* errorString) |
| 429 { | 429 { |
| 430 TrackExceptionState es; | 430 TrackExceptionState exceptionState; |
| 431 bool result = setAttribute(element, name, value, es); | 431 bool result = setAttribute(element, name, value, exceptionState); |
| 432 populateErrorString(es, errorString); | 432 populateErrorString(exceptionState, errorString); |
| 433 return result; | 433 return result; |
| 434 } | 434 } |
| 435 | 435 |
| 436 bool DOMEditor::removeAttribute(Element* element, const String& name, ErrorStrin
g* errorString) | 436 bool DOMEditor::removeAttribute(Element* element, const String& name, ErrorStrin
g* errorString) |
| 437 { | 437 { |
| 438 TrackExceptionState es; | 438 TrackExceptionState exceptionState; |
| 439 bool result = removeAttribute(element, name, es); | 439 bool result = removeAttribute(element, name, exceptionState); |
| 440 populateErrorString(es, errorString); | 440 populateErrorString(exceptionState, errorString); |
| 441 return result; | 441 return result; |
| 442 } | 442 } |
| 443 | 443 |
| 444 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Err
orString* errorString) | 444 bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, Err
orString* errorString) |
| 445 { | 445 { |
| 446 TrackExceptionState es; | 446 TrackExceptionState exceptionState; |
| 447 bool result = setOuterHTML(node, html, newNode, es); | 447 bool result = setOuterHTML(node, html, newNode, exceptionState); |
| 448 populateErrorString(es, errorString); | 448 populateErrorString(exceptionState, errorString); |
| 449 return result; | 449 return result; |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) | 452 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) |
| 453 { | 453 { |
| 454 TrackExceptionState es; | 454 TrackExceptionState exceptionState; |
| 455 bool result = replaceWholeText(textNode, text, es); | 455 bool result = replaceWholeText(textNode, text, exceptionState); |
| 456 populateErrorString(es, errorString); | 456 populateErrorString(exceptionState, errorString); |
| 457 return result; | 457 return result; |
| 458 } | 458 } |
| 459 | 459 |
| 460 } // namespace WebCore | 460 } // namespace WebCore |
| 461 | 461 |
| OLD | NEW |