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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return !exceptionState.hadException(); | 68 return !exceptionState.hadException(); |
69 } | 69 } |
70 | 70 |
71 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 71 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
72 { | 72 { |
73 m_parentNode->removeChild(m_node.get(), exceptionState); | 73 m_parentNode->removeChild(m_node.get(), exceptionState); |
74 return !exceptionState.hadException(); | 74 return !exceptionState.hadException(); |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 RefPtr<Node> m_parentNode; | 78 RefPtrWillBePersistent<Node> m_parentNode; |
79 RefPtr<Node> m_node; | 79 RefPtrWillBePersistent<Node> m_node; |
80 RefPtr<Node> m_anchorNode; | 80 RefPtrWillBePersistent<Node> m_anchorNode; |
81 }; | 81 }; |
82 | 82 |
83 class DOMEditor::InsertBeforeAction FINAL : public InspectorHistory::Action { | 83 class DOMEditor::InsertBeforeAction FINAL : 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, PassRefPtrWillBeRawPtr<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& exceptionState) OVERRIDE | 94 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
95 { | 95 { |
96 if (m_node->parentNode()) { | 96 if (m_node->parentNode()) { |
(...skipping 17 matching lines...) Expand all Loading... |
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 RefPtrWillBePersistent<Node> m_parentNode; |
125 RefPtr<Node> m_node; | 125 RefPtrWillBePersistent<Node> m_node; |
126 RefPtr<Node> m_anchorNode; | 126 RefPtrWillBePersistent<Node> m_anchorNode; |
127 RefPtr<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) |
(...skipping 12 matching lines...) Expand all Loading... |
149 return true; | 149 return true; |
150 } | 150 } |
151 | 151 |
152 virtual bool redo(ExceptionState&) OVERRIDE | 152 virtual bool redo(ExceptionState&) OVERRIDE |
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 RefPtrWillBePersistent<Element> m_element; |
160 AtomicString m_name; | 160 AtomicString m_name; |
161 AtomicString m_value; | 161 AtomicString m_value; |
162 }; | 162 }; |
163 | 163 |
164 class DOMEditor::SetAttributeAction FINAL : public InspectorHistory::Action { | 164 class DOMEditor::SetAttributeAction FINAL : public InspectorHistory::Action { |
165 WTF_MAKE_NONCOPYABLE(SetAttributeAction); | 165 WTF_MAKE_NONCOPYABLE(SetAttributeAction); |
166 public: | 166 public: |
167 SetAttributeAction(Element* element, const AtomicString& name, const AtomicS
tring& value) | 167 SetAttributeAction(Element* element, const AtomicString& name, const AtomicS
tring& value) |
168 : InspectorHistory::Action("SetAttribute") | 168 : InspectorHistory::Action("SetAttribute") |
169 , m_element(element) | 169 , m_element(element) |
(...skipping 21 matching lines...) Expand all Loading... |
191 return true; | 191 return true; |
192 } | 192 } |
193 | 193 |
194 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 194 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
195 { | 195 { |
196 m_element->setAttribute(m_name, m_value, exceptionState); | 196 m_element->setAttribute(m_name, m_value, exceptionState); |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 private: | 200 private: |
201 RefPtr<Element> m_element; | 201 RefPtrWillBePersistent<Element> m_element; |
202 AtomicString m_name; | 202 AtomicString m_name; |
203 AtomicString m_value; | 203 AtomicString m_value; |
204 bool m_hadAttribute; | 204 bool m_hadAttribute; |
205 AtomicString m_oldValue; | 205 AtomicString m_oldValue; |
206 }; | 206 }; |
207 | 207 |
208 class DOMEditor::SetOuterHTMLAction FINAL : public InspectorHistory::Action { | 208 class DOMEditor::SetOuterHTMLAction FINAL : public InspectorHistory::Action { |
209 WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction); | 209 WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction); |
210 public: | 210 public: |
211 SetOuterHTMLAction(Node* node, const String& html) | 211 SetOuterHTMLAction(Node* node, const String& html) |
(...skipping 25 matching lines...) Expand all Loading... |
237 { | 237 { |
238 return m_history->redo(exceptionState); | 238 return m_history->redo(exceptionState); |
239 } | 239 } |
240 | 240 |
241 Node* newNode() | 241 Node* newNode() |
242 { | 242 { |
243 return m_newNode; | 243 return m_newNode; |
244 } | 244 } |
245 | 245 |
246 private: | 246 private: |
247 RefPtr<Node> m_node; | 247 RefPtrWillBePersistent<Node> m_node; |
248 RefPtr<Node> m_nextSibling; | 248 RefPtrWillBePersistent<Node> m_nextSibling; |
249 String m_html; | 249 String m_html; |
250 String m_oldHTML; | 250 String m_oldHTML; |
251 Node* m_newNode; | 251 Node* m_newNode; |
252 OwnPtr<InspectorHistory> m_history; | 252 OwnPtr<InspectorHistory> m_history; |
253 OwnPtr<DOMEditor> m_domEditor; | 253 OwnPtr<DOMEditor> m_domEditor; |
254 }; | 254 }; |
255 | 255 |
256 class DOMEditor::ReplaceWholeTextAction FINAL : public InspectorHistory::Action
{ | 256 class DOMEditor::ReplaceWholeTextAction FINAL : public InspectorHistory::Action
{ |
257 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction); | 257 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction); |
258 public: | 258 public: |
(...skipping 24 matching lines...) Expand all Loading... |
283 | 283 |
284 private: | 284 private: |
285 RefPtrWillBePersistent<Text> m_textNode; | 285 RefPtrWillBePersistent<Text> m_textNode; |
286 String m_text; | 286 String m_text; |
287 String m_oldText; | 287 String m_oldText; |
288 }; | 288 }; |
289 | 289 |
290 class DOMEditor::ReplaceChildNodeAction FINAL : public InspectorHistory::Action
{ | 290 class DOMEditor::ReplaceChildNodeAction FINAL : public InspectorHistory::Action
{ |
291 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction); | 291 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction); |
292 public: | 292 public: |
293 ReplaceChildNodeAction(Node* parentNode, PassRefPtr<Node> newNode, Node* old
Node) | 293 ReplaceChildNodeAction(Node* parentNode, PassRefPtrWillBeRawPtr<Node> newNod
e, Node* oldNode) |
294 : InspectorHistory::Action("ReplaceChildNode") | 294 : InspectorHistory::Action("ReplaceChildNode") |
295 , m_parentNode(parentNode) | 295 , m_parentNode(parentNode) |
296 , m_newNode(newNode) | 296 , m_newNode(newNode) |
297 , m_oldNode(oldNode) | 297 , m_oldNode(oldNode) |
298 { | 298 { |
299 } | 299 } |
300 | 300 |
301 virtual bool perform(ExceptionState& exceptionState) OVERRIDE | 301 virtual bool perform(ExceptionState& exceptionState) OVERRIDE |
302 { | 302 { |
303 return redo(exceptionState); | 303 return redo(exceptionState); |
304 } | 304 } |
305 | 305 |
306 virtual bool undo(ExceptionState& exceptionState) OVERRIDE | 306 virtual bool undo(ExceptionState& exceptionState) OVERRIDE |
307 { | 307 { |
308 // FIXME: Oilpan: The first .get() is unnecessary if m_oldNode is a | 308 // FIXME: Oilpan: The first .get() is unnecessary if m_oldNode is a |
309 // Persistent or a Member. | 309 // Persistent or a Member. |
310 m_parentNode->replaceChild(m_oldNode.get(), m_newNode.get(), exceptionSt
ate); | 310 m_parentNode->replaceChild(m_oldNode.get(), m_newNode.get(), exceptionSt
ate); |
311 return !exceptionState.hadException(); | 311 return !exceptionState.hadException(); |
312 } | 312 } |
313 | 313 |
314 virtual bool redo(ExceptionState& exceptionState) OVERRIDE | 314 virtual bool redo(ExceptionState& exceptionState) OVERRIDE |
315 { | 315 { |
316 // FIXME: Oilpan: The first .get() is unnecessary if m_newNode is a | 316 // FIXME: Oilpan: The first .get() is unnecessary if m_newNode is a |
317 // Persistent or a Member. | 317 // Persistent or a Member. |
318 m_parentNode->replaceChild(m_newNode.get(), m_oldNode.get(), exceptionSt
ate); | 318 m_parentNode->replaceChild(m_newNode.get(), m_oldNode.get(), exceptionSt
ate); |
319 return !exceptionState.hadException(); | 319 return !exceptionState.hadException(); |
320 } | 320 } |
321 | 321 |
322 private: | 322 private: |
323 RefPtr<Node> m_parentNode; | 323 RefPtrWillBePersistent<Node> m_parentNode; |
324 RefPtr<Node> m_newNode; | 324 RefPtrWillBePersistent<Node> m_newNode; |
325 RefPtr<Node> m_oldNode; | 325 RefPtrWillBePersistent<Node> m_oldNode; |
326 }; | 326 }; |
327 | 327 |
328 class DOMEditor::SetNodeValueAction FINAL : public InspectorHistory::Action { | 328 class DOMEditor::SetNodeValueAction FINAL : public InspectorHistory::Action { |
329 WTF_MAKE_NONCOPYABLE(SetNodeValueAction); | 329 WTF_MAKE_NONCOPYABLE(SetNodeValueAction); |
330 public: | 330 public: |
331 SetNodeValueAction(Node* node, const String& value) | 331 SetNodeValueAction(Node* node, const String& value) |
332 : InspectorHistory::Action("SetNodeValue") | 332 : InspectorHistory::Action("SetNodeValue") |
333 , m_node(node) | 333 , m_node(node) |
334 , m_value(value) | 334 , m_value(value) |
335 { | 335 { |
(...skipping 11 matching lines...) Expand all Loading... |
347 return true; | 347 return true; |
348 } | 348 } |
349 | 349 |
350 virtual bool redo(ExceptionState&) OVERRIDE | 350 virtual bool redo(ExceptionState&) OVERRIDE |
351 { | 351 { |
352 m_node->setNodeValue(m_value); | 352 m_node->setNodeValue(m_value); |
353 return true; | 353 return true; |
354 } | 354 } |
355 | 355 |
356 private: | 356 private: |
357 RefPtr<Node> m_node; | 357 RefPtrWillBePersistent<Node> m_node; |
358 String m_value; | 358 String m_value; |
359 String m_oldValue; | 359 String m_oldValue; |
360 }; | 360 }; |
361 | 361 |
362 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } | 362 DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { } |
363 | 363 |
364 DOMEditor::~DOMEditor() { } | 364 DOMEditor::~DOMEditor() { } |
365 | 365 |
366 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ExceptionState& exceptionState) | 366 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtrWillBeRawPtr<Node> node
, Node* anchorNode, ExceptionState& exceptionState) |
367 { | 367 { |
368 return m_history->perform(adoptRef(new InsertBeforeAction(parentNode, node,
anchorNode)), exceptionState); | 368 return m_history->perform(adoptRef(new InsertBeforeAction(parentNode, node,
anchorNode)), exceptionState); |
369 } | 369 } |
370 | 370 |
371 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& except
ionState) | 371 bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionState& except
ionState) |
372 { | 372 { |
373 return m_history->perform(adoptRef(new RemoveChildAction(parentNode, node)),
exceptionState); | 373 return m_history->perform(adoptRef(new RemoveChildAction(parentNode, node)),
exceptionState); |
374 } | 374 } |
375 | 375 |
376 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& exceptionState) | 376 bool DOMEditor::setAttribute(Element* element, const String& name, const String&
value, ExceptionState& exceptionState) |
(...skipping 13 matching lines...) Expand all Loading... |
390 if (result) | 390 if (result) |
391 *newNode = action->newNode(); | 391 *newNode = action->newNode(); |
392 return result; | 392 return result; |
393 } | 393 } |
394 | 394 |
395 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& exceptionState) | 395 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionSt
ate& exceptionState) |
396 { | 396 { |
397 return m_history->perform(adoptRef(new ReplaceWholeTextAction(textNode, text
)), exceptionState); | 397 return m_history->perform(adoptRef(new ReplaceWholeTextAction(textNode, text
)), exceptionState); |
398 } | 398 } |
399 | 399 |
400 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* o
ldNode, ExceptionState& exceptionState) | 400 bool DOMEditor::replaceChild(Node* parentNode, PassRefPtrWillBeRawPtr<Node> newN
ode, Node* oldNode, ExceptionState& exceptionState) |
401 { | 401 { |
402 return m_history->perform(adoptRef(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), exceptionState); | 402 return m_history->perform(adoptRef(new ReplaceChildNodeAction(parentNode, ne
wNode, oldNode)), exceptionState); |
403 } | 403 } |
404 | 404 |
405 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& ex
ceptionState) | 405 bool DOMEditor::setNodeValue(Node* node, const String& value, ExceptionState& ex
ceptionState) |
406 { | 406 { |
407 return m_history->perform(adoptRef(new SetNodeValueAction(node, value)), exc
eptionState); | 407 return m_history->perform(adoptRef(new SetNodeValueAction(node, value)), exc
eptionState); |
408 } | 408 } |
409 | 409 |
410 static void populateErrorString(ExceptionState& exceptionState, ErrorString* err
orString) | 410 static void populateErrorString(ExceptionState& exceptionState, ErrorString* err
orString) |
411 { | 411 { |
412 if (exceptionState.hadException()) | 412 if (exceptionState.hadException()) |
413 *errorString = DOMException::getErrorName(exceptionState.code()); | 413 *errorString = DOMException::getErrorName(exceptionState.code()); |
414 } | 414 } |
415 | 415 |
416 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anch
orNode, ErrorString* errorString) | 416 bool DOMEditor::insertBefore(Node* parentNode, PassRefPtrWillBeRawPtr<Node> node
, Node* anchorNode, ErrorString* errorString) |
417 { | 417 { |
418 TrackExceptionState exceptionState; | 418 TrackExceptionState exceptionState; |
419 bool result = insertBefore(parentNode, node, anchorNode, exceptionState); | 419 bool result = insertBefore(parentNode, node, anchorNode, exceptionState); |
420 populateErrorString(exceptionState, errorString); | 420 populateErrorString(exceptionState, errorString); |
421 return result; | 421 return result; |
422 } | 422 } |
423 | 423 |
424 bool DOMEditor::removeChild(Node* parentNode, Node* node, ErrorString* errorStri
ng) | 424 bool DOMEditor::removeChild(Node* parentNode, Node* node, ErrorString* errorStri
ng) |
425 { | 425 { |
426 TrackExceptionState exceptionState; | 426 TrackExceptionState exceptionState; |
(...skipping 29 matching lines...) Expand all Loading... |
456 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) | 456 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString
* errorString) |
457 { | 457 { |
458 TrackExceptionState exceptionState; | 458 TrackExceptionState exceptionState; |
459 bool result = replaceWholeText(textNode, text, exceptionState); | 459 bool result = replaceWholeText(textNode, text, exceptionState); |
460 populateErrorString(exceptionState, errorString); | 460 populateErrorString(exceptionState, errorString); |
461 return result; | 461 return result; |
462 } | 462 } |
463 | 463 |
464 } // namespace WebCore | 464 } // namespace WebCore |
465 | 465 |
OLD | NEW |