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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/SplitElementCommand.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2008 Apple 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 15 matching lines...) Expand all
26 #include "core/editing/commands/SplitElementCommand.h" 26 #include "core/editing/commands/SplitElementCommand.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
30 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
31 #include "core/dom/Element.h" 31 #include "core/dom/Element.h"
32 #include "wtf/Assertions.h" 32 #include "wtf/Assertions.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 SplitElementCommand::SplitElementCommand(PassRefPtrWillBeRawPtr<Element> element , PassRefPtrWillBeRawPtr<Node> atChild) 36 SplitElementCommand::SplitElementCommand(RawPtr<Element> element, RawPtr<Node> a tChild)
37 : SimpleEditCommand(element->document()) 37 : SimpleEditCommand(element->document())
38 , m_element2(element) 38 , m_element2(element)
39 , m_atChild(atChild) 39 , m_atChild(atChild)
40 { 40 {
41 ASSERT(m_element2); 41 ASSERT(m_element2);
42 ASSERT(m_atChild); 42 ASSERT(m_atChild);
43 ASSERT(m_atChild->parentNode() == m_element2); 43 ASSERT(m_atChild->parentNode() == m_element2);
44 } 44 }
45 45
46 void SplitElementCommand::executeApply() 46 void SplitElementCommand::executeApply()
47 { 47 {
48 if (m_atChild->parentNode() != m_element2) 48 if (m_atChild->parentNode() != m_element2)
49 return; 49 return;
50 50
51 WillBeHeapVector<RefPtrWillBeMember<Node>> children; 51 HeapVector<Member<Node>> children;
52 for (Node* node = m_element2->firstChild(); node != m_atChild; node = node-> nextSibling()) 52 for (Node* node = m_element2->firstChild(); node != m_atChild; node = node-> nextSibling())
53 children.append(node); 53 children.append(node);
54 54
55 TrackExceptionState exceptionState; 55 TrackExceptionState exceptionState;
56 56
57 ContainerNode* parent = m_element2->parentNode(); 57 ContainerNode* parent = m_element2->parentNode();
58 if (!parent || !parent->hasEditableStyle()) 58 if (!parent || !parent->hasEditableStyle())
59 return; 59 return;
60 parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState); 60 parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState);
61 if (exceptionState.hadException()) 61 if (exceptionState.hadException())
(...skipping 14 matching lines...) Expand all
76 } 76 }
77 77
78 void SplitElementCommand::doUnapply() 78 void SplitElementCommand::doUnapply()
79 { 79 {
80 if (!m_element1 || !m_element1->hasEditableStyle() || !m_element2->hasEditab leStyle()) 80 if (!m_element1 || !m_element1->hasEditableStyle() || !m_element2->hasEditab leStyle())
81 return; 81 return;
82 82
83 NodeVector children; 83 NodeVector children;
84 getChildNodes(*m_element1, children); 84 getChildNodes(*m_element1, children);
85 85
86 RefPtrWillBeRawPtr<Node> refChild = m_element2->firstChild(); 86 RawPtr<Node> refChild = m_element2->firstChild();
87 87
88 for (const auto& child : children) 88 for (const auto& child : children)
89 m_element2->insertBefore(child.get(), refChild.get(), IGNORE_EXCEPTION); 89 m_element2->insertBefore(child.get(), refChild.get(), IGNORE_EXCEPTION);
90 90
91 // Recover the id attribute of the original element. 91 // Recover the id attribute of the original element.
92 const AtomicString& id = m_element1->getAttribute(HTMLNames::idAttr); 92 const AtomicString& id = m_element1->getAttribute(HTMLNames::idAttr);
93 if (!id.isNull()) 93 if (!id.isNull())
94 m_element2->setAttribute(HTMLNames::idAttr, id); 94 m_element2->setAttribute(HTMLNames::idAttr, id);
95 95
96 m_element1->remove(IGNORE_EXCEPTION); 96 m_element1->remove(IGNORE_EXCEPTION);
97 } 97 }
98 98
99 void SplitElementCommand::doReapply() 99 void SplitElementCommand::doReapply()
100 { 100 {
101 if (!m_element1) 101 if (!m_element1)
102 return; 102 return;
103 103
104 executeApply(); 104 executeApply();
105 } 105 }
106 106
107 DEFINE_TRACE(SplitElementCommand) 107 DEFINE_TRACE(SplitElementCommand)
108 { 108 {
109 visitor->trace(m_element1); 109 visitor->trace(m_element1);
110 visitor->trace(m_element2); 110 visitor->trace(m_element2);
111 visitor->trace(m_atChild); 111 visitor->trace(m_atChild);
112 SimpleEditCommand::trace(visitor); 112 SimpleEditCommand::trace(visitor);
113 } 113 }
114 114
115 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698