Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: Source/core/inspector/DOMEditor.cpp

Issue 1232333002: Fix virtual/override/final usage in the rest of Source/core/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/AsyncCallTracker.cpp ('k') | Source/core/inspector/DevToolsHost.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class DOMEditor::RemoveChildAction final : public InspectorHistory::Action { 47 class DOMEditor::RemoveChildAction final : public InspectorHistory::Action {
48 WTF_MAKE_NONCOPYABLE(RemoveChildAction); 48 WTF_MAKE_NONCOPYABLE(RemoveChildAction);
49 public: 49 public:
50 RemoveChildAction(ContainerNode* parentNode, Node* node) 50 RemoveChildAction(ContainerNode* parentNode, Node* node)
51 : InspectorHistory::Action("RemoveChild") 51 : InspectorHistory::Action("RemoveChild")
52 , m_parentNode(parentNode) 52 , m_parentNode(parentNode)
53 , m_node(node) 53 , m_node(node)
54 { 54 {
55 } 55 }
56 56
57 virtual bool perform(ExceptionState& exceptionState) override 57 bool perform(ExceptionState& exceptionState) override
58 { 58 {
59 m_anchorNode = m_node->nextSibling(); 59 m_anchorNode = m_node->nextSibling();
60 return redo(exceptionState); 60 return redo(exceptionState);
61 } 61 }
62 62
63 virtual bool undo(ExceptionState& exceptionState) override 63 bool undo(ExceptionState& exceptionState) override
64 { 64 {
65 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate); 65 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate);
66 return !exceptionState.hadException(); 66 return !exceptionState.hadException();
67 } 67 }
68 68
69 virtual bool redo(ExceptionState& exceptionState) override 69 bool redo(ExceptionState& exceptionState) override
70 { 70 {
71 m_parentNode->removeChild(m_node.get(), exceptionState); 71 m_parentNode->removeChild(m_node.get(), exceptionState);
72 return !exceptionState.hadException(); 72 return !exceptionState.hadException();
73 } 73 }
74 74
75 DEFINE_INLINE_VIRTUAL_TRACE() 75 DEFINE_INLINE_VIRTUAL_TRACE()
76 { 76 {
77 visitor->trace(m_parentNode); 77 visitor->trace(m_parentNode);
78 visitor->trace(m_node); 78 visitor->trace(m_node);
79 visitor->trace(m_anchorNode); 79 visitor->trace(m_anchorNode);
(...skipping 10 matching lines...) Expand all
90 WTF_MAKE_NONCOPYABLE(InsertBeforeAction); 90 WTF_MAKE_NONCOPYABLE(InsertBeforeAction);
91 public: 91 public:
92 InsertBeforeAction(ContainerNode* parentNode, PassRefPtrWillBeRawPtr<Node> n ode, Node* anchorNode) 92 InsertBeforeAction(ContainerNode* parentNode, PassRefPtrWillBeRawPtr<Node> n ode, Node* anchorNode)
93 : InspectorHistory::Action("InsertBefore") 93 : InspectorHistory::Action("InsertBefore")
94 , m_parentNode(parentNode) 94 , m_parentNode(parentNode)
95 , m_node(node) 95 , m_node(node)
96 , m_anchorNode(anchorNode) 96 , m_anchorNode(anchorNode)
97 { 97 {
98 } 98 }
99 99
100 virtual bool perform(ExceptionState& exceptionState) override 100 bool perform(ExceptionState& exceptionState) override
101 { 101 {
102 if (m_node->parentNode()) { 102 if (m_node->parentNode()) {
103 m_removeChildAction = adoptRefWillBeNoop(new RemoveChildAction(m_nod e->parentNode(), m_node.get())); 103 m_removeChildAction = adoptRefWillBeNoop(new RemoveChildAction(m_nod e->parentNode(), m_node.get()));
104 if (!m_removeChildAction->perform(exceptionState)) 104 if (!m_removeChildAction->perform(exceptionState))
105 return false; 105 return false;
106 } 106 }
107 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate); 107 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate);
108 return !exceptionState.hadException(); 108 return !exceptionState.hadException();
109 } 109 }
110 110
111 virtual bool undo(ExceptionState& exceptionState) override 111 bool undo(ExceptionState& exceptionState) override
112 { 112 {
113 m_parentNode->removeChild(m_node.get(), exceptionState); 113 m_parentNode->removeChild(m_node.get(), exceptionState);
114 if (exceptionState.hadException()) 114 if (exceptionState.hadException())
115 return false; 115 return false;
116 if (m_removeChildAction) 116 if (m_removeChildAction)
117 return m_removeChildAction->undo(exceptionState); 117 return m_removeChildAction->undo(exceptionState);
118 return true; 118 return true;
119 } 119 }
120 120
121 virtual bool redo(ExceptionState& exceptionState) override 121 bool redo(ExceptionState& exceptionState) override
122 { 122 {
123 if (m_removeChildAction && !m_removeChildAction->redo(exceptionState)) 123 if (m_removeChildAction && !m_removeChildAction->redo(exceptionState))
124 return false; 124 return false;
125 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate); 125 m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), exceptionSt ate);
126 return !exceptionState.hadException(); 126 return !exceptionState.hadException();
127 } 127 }
128 128
129 DEFINE_INLINE_VIRTUAL_TRACE() 129 DEFINE_INLINE_VIRTUAL_TRACE()
130 { 130 {
131 visitor->trace(m_parentNode); 131 visitor->trace(m_parentNode);
(...skipping 13 matching lines...) Expand all
145 class DOMEditor::RemoveAttributeAction final : public InspectorHistory::Action { 145 class DOMEditor::RemoveAttributeAction final : public InspectorHistory::Action {
146 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction); 146 WTF_MAKE_NONCOPYABLE(RemoveAttributeAction);
147 public: 147 public:
148 RemoveAttributeAction(Element* element, const AtomicString& name) 148 RemoveAttributeAction(Element* element, const AtomicString& name)
149 : InspectorHistory::Action("RemoveAttribute") 149 : InspectorHistory::Action("RemoveAttribute")
150 , m_element(element) 150 , m_element(element)
151 , m_name(name) 151 , m_name(name)
152 { 152 {
153 } 153 }
154 154
155 virtual bool perform(ExceptionState& exceptionState) override 155 bool perform(ExceptionState& exceptionState) override
156 { 156 {
157 m_value = m_element->getAttribute(m_name); 157 m_value = m_element->getAttribute(m_name);
158 return redo(exceptionState); 158 return redo(exceptionState);
159 } 159 }
160 160
161 virtual bool undo(ExceptionState& exceptionState) override 161 bool undo(ExceptionState& exceptionState) override
162 { 162 {
163 m_element->setAttribute(m_name, m_value, exceptionState); 163 m_element->setAttribute(m_name, m_value, exceptionState);
164 return true; 164 return true;
165 } 165 }
166 166
167 virtual bool redo(ExceptionState&) override 167 bool redo(ExceptionState&) override
168 { 168 {
169 m_element->removeAttribute(m_name); 169 m_element->removeAttribute(m_name);
170 return true; 170 return true;
171 } 171 }
172 172
173 DEFINE_INLINE_VIRTUAL_TRACE() 173 DEFINE_INLINE_VIRTUAL_TRACE()
174 { 174 {
175 visitor->trace(m_element); 175 visitor->trace(m_element);
176 InspectorHistory::Action::trace(visitor); 176 InspectorHistory::Action::trace(visitor);
177 } 177 }
178 178
179 private: 179 private:
180 RefPtrWillBeMember<Element> m_element; 180 RefPtrWillBeMember<Element> m_element;
181 AtomicString m_name; 181 AtomicString m_name;
182 AtomicString m_value; 182 AtomicString m_value;
183 }; 183 };
184 184
185 class DOMEditor::SetAttributeAction final : public InspectorHistory::Action { 185 class DOMEditor::SetAttributeAction final : public InspectorHistory::Action {
186 WTF_MAKE_NONCOPYABLE(SetAttributeAction); 186 WTF_MAKE_NONCOPYABLE(SetAttributeAction);
187 public: 187 public:
188 SetAttributeAction(Element* element, const AtomicString& name, const AtomicS tring& value) 188 SetAttributeAction(Element* element, const AtomicString& name, const AtomicS tring& value)
189 : InspectorHistory::Action("SetAttribute") 189 : InspectorHistory::Action("SetAttribute")
190 , m_element(element) 190 , m_element(element)
191 , m_name(name) 191 , m_name(name)
192 , m_value(value) 192 , m_value(value)
193 , m_hadAttribute(false) 193 , m_hadAttribute(false)
194 { 194 {
195 } 195 }
196 196
197 virtual bool perform(ExceptionState& exceptionState) override 197 bool perform(ExceptionState& exceptionState) override
198 { 198 {
199 const AtomicString& value = m_element->getAttribute(m_name); 199 const AtomicString& value = m_element->getAttribute(m_name);
200 m_hadAttribute = !value.isNull(); 200 m_hadAttribute = !value.isNull();
201 if (m_hadAttribute) 201 if (m_hadAttribute)
202 m_oldValue = value; 202 m_oldValue = value;
203 return redo(exceptionState); 203 return redo(exceptionState);
204 } 204 }
205 205
206 virtual bool undo(ExceptionState& exceptionState) override 206 bool undo(ExceptionState& exceptionState) override
207 { 207 {
208 if (m_hadAttribute) 208 if (m_hadAttribute)
209 m_element->setAttribute(m_name, m_oldValue, exceptionState); 209 m_element->setAttribute(m_name, m_oldValue, exceptionState);
210 else 210 else
211 m_element->removeAttribute(m_name); 211 m_element->removeAttribute(m_name);
212 return true; 212 return true;
213 } 213 }
214 214
215 virtual bool redo(ExceptionState& exceptionState) override 215 bool redo(ExceptionState& exceptionState) override
216 { 216 {
217 m_element->setAttribute(m_name, m_value, exceptionState); 217 m_element->setAttribute(m_name, m_value, exceptionState);
218 return true; 218 return true;
219 } 219 }
220 220
221 DEFINE_INLINE_VIRTUAL_TRACE() 221 DEFINE_INLINE_VIRTUAL_TRACE()
222 { 222 {
223 visitor->trace(m_element); 223 visitor->trace(m_element);
224 InspectorHistory::Action::trace(visitor); 224 InspectorHistory::Action::trace(visitor);
225 } 225 }
(...skipping 13 matching lines...) Expand all
239 : InspectorHistory::Action("SetOuterHTML") 239 : InspectorHistory::Action("SetOuterHTML")
240 , m_node(node) 240 , m_node(node)
241 , m_nextSibling(node->nextSibling()) 241 , m_nextSibling(node->nextSibling())
242 , m_html(html) 242 , m_html(html)
243 , m_newNode(nullptr) 243 , m_newNode(nullptr)
244 , m_history(adoptPtrWillBeNoop(new InspectorHistory())) 244 , m_history(adoptPtrWillBeNoop(new InspectorHistory()))
245 , m_domEditor(adoptPtrWillBeNoop(new DOMEditor(m_history.get()))) 245 , m_domEditor(adoptPtrWillBeNoop(new DOMEditor(m_history.get())))
246 { 246 {
247 } 247 }
248 248
249 virtual bool perform(ExceptionState& exceptionState) override 249 bool perform(ExceptionState& exceptionState) override
250 { 250 {
251 m_oldHTML = createMarkup(m_node.get()); 251 m_oldHTML = createMarkup(m_node.get());
252 ASSERT(m_node->ownerDocument()); 252 ASSERT(m_node->ownerDocument());
253 DOMPatchSupport domPatchSupport(m_domEditor.get(), *m_node->ownerDocumen t()); 253 DOMPatchSupport domPatchSupport(m_domEditor.get(), *m_node->ownerDocumen t());
254 m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, exceptionSta te); 254 m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, exceptionSta te);
255 return !exceptionState.hadException(); 255 return !exceptionState.hadException();
256 } 256 }
257 257
258 virtual bool undo(ExceptionState& exceptionState) override 258 bool undo(ExceptionState& exceptionState) override
259 { 259 {
260 return m_history->undo(exceptionState); 260 return m_history->undo(exceptionState);
261 } 261 }
262 262
263 virtual bool redo(ExceptionState& exceptionState) override 263 bool redo(ExceptionState& exceptionState) override
264 { 264 {
265 return m_history->redo(exceptionState); 265 return m_history->redo(exceptionState);
266 } 266 }
267 267
268 Node* newNode() 268 Node* newNode()
269 { 269 {
270 return m_newNode; 270 return m_newNode;
271 } 271 }
272 272
273 DEFINE_INLINE_VIRTUAL_TRACE() 273 DEFINE_INLINE_VIRTUAL_TRACE()
(...skipping 19 matching lines...) Expand all
293 class DOMEditor::ReplaceWholeTextAction final : public InspectorHistory::Action { 293 class DOMEditor::ReplaceWholeTextAction final : public InspectorHistory::Action {
294 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction); 294 WTF_MAKE_NONCOPYABLE(ReplaceWholeTextAction);
295 public: 295 public:
296 ReplaceWholeTextAction(Text* textNode, const String& text) 296 ReplaceWholeTextAction(Text* textNode, const String& text)
297 : InspectorHistory::Action("ReplaceWholeText") 297 : InspectorHistory::Action("ReplaceWholeText")
298 , m_textNode(textNode) 298 , m_textNode(textNode)
299 , m_text(text) 299 , m_text(text)
300 { 300 {
301 } 301 }
302 302
303 virtual bool perform(ExceptionState& exceptionState) override 303 bool perform(ExceptionState& exceptionState) override
304 { 304 {
305 m_oldText = m_textNode->wholeText(); 305 m_oldText = m_textNode->wholeText();
306 return redo(exceptionState); 306 return redo(exceptionState);
307 } 307 }
308 308
309 virtual bool undo(ExceptionState&) override 309 bool undo(ExceptionState&) override
310 { 310 {
311 m_textNode->replaceWholeText(m_oldText); 311 m_textNode->replaceWholeText(m_oldText);
312 return true; 312 return true;
313 } 313 }
314 314
315 virtual bool redo(ExceptionState&) override 315 bool redo(ExceptionState&) override
316 { 316 {
317 m_textNode->replaceWholeText(m_text); 317 m_textNode->replaceWholeText(m_text);
318 return true; 318 return true;
319 } 319 }
320 320
321 DEFINE_INLINE_VIRTUAL_TRACE() 321 DEFINE_INLINE_VIRTUAL_TRACE()
322 { 322 {
323 visitor->trace(m_textNode); 323 visitor->trace(m_textNode);
324 InspectorHistory::Action::trace(visitor); 324 InspectorHistory::Action::trace(visitor);
325 } 325 }
326 326
327 private: 327 private:
328 RefPtrWillBeMember<Text> m_textNode; 328 RefPtrWillBeMember<Text> m_textNode;
329 String m_text; 329 String m_text;
330 String m_oldText; 330 String m_oldText;
331 }; 331 };
332 332
333 class DOMEditor::ReplaceChildNodeAction final : public InspectorHistory::Action { 333 class DOMEditor::ReplaceChildNodeAction final : public InspectorHistory::Action {
334 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction); 334 WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction);
335 public: 335 public:
336 ReplaceChildNodeAction(ContainerNode* parentNode, PassRefPtrWillBeRawPtr<Nod e> newNode, Node* oldNode) 336 ReplaceChildNodeAction(ContainerNode* parentNode, PassRefPtrWillBeRawPtr<Nod e> newNode, Node* oldNode)
337 : InspectorHistory::Action("ReplaceChildNode") 337 : InspectorHistory::Action("ReplaceChildNode")
338 , m_parentNode(parentNode) 338 , m_parentNode(parentNode)
339 , m_newNode(newNode) 339 , m_newNode(newNode)
340 , m_oldNode(oldNode) 340 , m_oldNode(oldNode)
341 { 341 {
342 } 342 }
343 343
344 virtual bool perform(ExceptionState& exceptionState) override 344 bool perform(ExceptionState& exceptionState) override
345 { 345 {
346 return redo(exceptionState); 346 return redo(exceptionState);
347 } 347 }
348 348
349 virtual bool undo(ExceptionState& exceptionState) override 349 bool undo(ExceptionState& exceptionState) override
350 { 350 {
351 m_parentNode->replaceChild(m_oldNode, m_newNode.get(), exceptionState); 351 m_parentNode->replaceChild(m_oldNode, m_newNode.get(), exceptionState);
352 return !exceptionState.hadException(); 352 return !exceptionState.hadException();
353 } 353 }
354 354
355 virtual bool redo(ExceptionState& exceptionState) override 355 bool redo(ExceptionState& exceptionState) override
356 { 356 {
357 m_parentNode->replaceChild(m_newNode, m_oldNode.get(), exceptionState); 357 m_parentNode->replaceChild(m_newNode, m_oldNode.get(), exceptionState);
358 return !exceptionState.hadException(); 358 return !exceptionState.hadException();
359 } 359 }
360 360
361 DEFINE_INLINE_VIRTUAL_TRACE() 361 DEFINE_INLINE_VIRTUAL_TRACE()
362 { 362 {
363 visitor->trace(m_parentNode); 363 visitor->trace(m_parentNode);
364 visitor->trace(m_newNode); 364 visitor->trace(m_newNode);
365 visitor->trace(m_oldNode); 365 visitor->trace(m_oldNode);
366 InspectorHistory::Action::trace(visitor); 366 InspectorHistory::Action::trace(visitor);
367 } 367 }
368 368
369 private: 369 private:
370 RefPtrWillBeMember<ContainerNode> m_parentNode; 370 RefPtrWillBeMember<ContainerNode> m_parentNode;
371 RefPtrWillBeMember<Node> m_newNode; 371 RefPtrWillBeMember<Node> m_newNode;
372 RefPtrWillBeMember<Node> m_oldNode; 372 RefPtrWillBeMember<Node> m_oldNode;
373 }; 373 };
374 374
375 class DOMEditor::SetNodeValueAction final : public InspectorHistory::Action { 375 class DOMEditor::SetNodeValueAction final : public InspectorHistory::Action {
376 WTF_MAKE_NONCOPYABLE(SetNodeValueAction); 376 WTF_MAKE_NONCOPYABLE(SetNodeValueAction);
377 public: 377 public:
378 SetNodeValueAction(Node* node, const String& value) 378 SetNodeValueAction(Node* node, const String& value)
379 : InspectorHistory::Action("SetNodeValue") 379 : InspectorHistory::Action("SetNodeValue")
380 , m_node(node) 380 , m_node(node)
381 , m_value(value) 381 , m_value(value)
382 { 382 {
383 } 383 }
384 384
385 virtual bool perform(ExceptionState&) override 385 bool perform(ExceptionState&) override
386 { 386 {
387 m_oldValue = m_node->nodeValue(); 387 m_oldValue = m_node->nodeValue();
388 return redo(IGNORE_EXCEPTION); 388 return redo(IGNORE_EXCEPTION);
389 } 389 }
390 390
391 virtual bool undo(ExceptionState&) override 391 bool undo(ExceptionState&) override
392 { 392 {
393 m_node->setNodeValue(m_oldValue); 393 m_node->setNodeValue(m_oldValue);
394 return true; 394 return true;
395 } 395 }
396 396
397 virtual bool redo(ExceptionState&) override 397 bool redo(ExceptionState&) override
398 { 398 {
399 m_node->setNodeValue(m_value); 399 m_node->setNodeValue(m_value);
400 return true; 400 return true;
401 } 401 }
402 402
403 DEFINE_INLINE_VIRTUAL_TRACE() 403 DEFINE_INLINE_VIRTUAL_TRACE()
404 { 404 {
405 visitor->trace(m_node); 405 visitor->trace(m_node);
406 InspectorHistory::Action::trace(visitor); 406 InspectorHistory::Action::trace(visitor);
407 } 407 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return result; 512 return result;
513 } 513 }
514 514
515 DEFINE_TRACE(DOMEditor) 515 DEFINE_TRACE(DOMEditor)
516 { 516 {
517 visitor->trace(m_history); 517 visitor->trace(m_history);
518 } 518 }
519 519
520 } // namespace blink 520 } // namespace blink
521 521
OLDNEW
« no previous file with comments | « Source/core/inspector/AsyncCallTracker.cpp ('k') | Source/core/inspector/DevToolsHost.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698