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

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

Issue 2574793002: [Editing] Store |CommandSource| in |CompositeEditCommand| (Closed)
Patch Set: Created 4 years 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, 2006, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2009 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (anchorNode->isCharacterDataNode()) 118 if (anchorNode->isCharacterDataNode())
119 return offset < anchorNode->maxCharacterOffset(); 119 return offset < anchorNode->maxCharacterOffset();
120 int currentOffset = 0; 120 int currentOffset = 0;
121 for (Node* node = NodeTraversal::firstChild(*anchorNode); 121 for (Node* node = NodeTraversal::firstChild(*anchorNode);
122 node && currentOffset < offset; node = NodeTraversal::nextSibling(*node)) 122 node && currentOffset < offset; node = NodeTraversal::nextSibling(*node))
123 currentOffset++; 123 currentOffset++;
124 return offset < currentOffset; 124 return offset < currentOffset;
125 } 125 }
126 126
127 ApplyStyleCommand::ApplyStyleCommand(Document& document, 127 ApplyStyleCommand::ApplyStyleCommand(Document& document,
128 CommandSource source,
128 const EditingStyle* style, 129 const EditingStyle* style,
129 InputEvent::InputType inputType, 130 InputEvent::InputType inputType,
130 EPropertyLevel propertyLevel) 131 EPropertyLevel propertyLevel)
131 : CompositeEditCommand(document), 132 : CompositeEditCommand(document, source),
132 m_style(style->copy()), 133 m_style(style->copy()),
133 m_inputType(inputType), 134 m_inputType(inputType),
134 m_propertyLevel(propertyLevel), 135 m_propertyLevel(propertyLevel),
135 m_start(mostForwardCaretPosition(endingSelection().start())), 136 m_start(mostForwardCaretPosition(endingSelection().start())),
136 m_end(mostBackwardCaretPosition(endingSelection().end())), 137 m_end(mostBackwardCaretPosition(endingSelection().end())),
137 m_useEndingSelection(true), 138 m_useEndingSelection(true),
138 m_styledInlineElement(nullptr), 139 m_styledInlineElement(nullptr),
139 m_removeOnly(false), 140 m_removeOnly(false),
140 m_isInlineElementToRemoveFunction(0) {} 141 m_isInlineElementToRemoveFunction(0) {}
141 142
142 ApplyStyleCommand::ApplyStyleCommand(Document& document, 143 ApplyStyleCommand::ApplyStyleCommand(Document& document,
144 CommandSource source,
143 const EditingStyle* style, 145 const EditingStyle* style,
144 const Position& start, 146 const Position& start,
145 const Position& end) 147 const Position& end)
146 : CompositeEditCommand(document), 148 : CompositeEditCommand(document, source),
147 m_style(style->copy()), 149 m_style(style->copy()),
148 m_inputType(InputEvent::InputType::None), 150 m_inputType(InputEvent::InputType::None),
149 m_propertyLevel(PropertyDefault), 151 m_propertyLevel(PropertyDefault),
150 m_start(start), 152 m_start(start),
151 m_end(end), 153 m_end(end),
152 m_useEndingSelection(false), 154 m_useEndingSelection(false),
153 m_styledInlineElement(nullptr), 155 m_styledInlineElement(nullptr),
154 m_removeOnly(false), 156 m_removeOnly(false),
155 m_isInlineElementToRemoveFunction(0) {} 157 m_isInlineElementToRemoveFunction(0) {}
156 158
157 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool removeOnly) 159 ApplyStyleCommand::ApplyStyleCommand(CommandSource source,
158 : CompositeEditCommand(element->document()), 160 Element* element,
161 bool removeOnly)
162 : CompositeEditCommand(element->document(), source),
159 m_style(EditingStyle::create()), 163 m_style(EditingStyle::create()),
160 m_inputType(InputEvent::InputType::None), 164 m_inputType(InputEvent::InputType::None),
161 m_propertyLevel(PropertyDefault), 165 m_propertyLevel(PropertyDefault),
162 m_start(mostForwardCaretPosition(endingSelection().start())), 166 m_start(mostForwardCaretPosition(endingSelection().start())),
163 m_end(mostBackwardCaretPosition(endingSelection().end())), 167 m_end(mostBackwardCaretPosition(endingSelection().end())),
164 m_useEndingSelection(true), 168 m_useEndingSelection(true),
165 m_styledInlineElement(element), 169 m_styledInlineElement(element),
166 m_removeOnly(removeOnly), 170 m_removeOnly(removeOnly),
167 m_isInlineElementToRemoveFunction(0) {} 171 m_isInlineElementToRemoveFunction(0) {}
168 172
169 ApplyStyleCommand::ApplyStyleCommand( 173 ApplyStyleCommand::ApplyStyleCommand(
170 Document& document, 174 Document& document,
175 CommandSource source,
171 const EditingStyle* style, 176 const EditingStyle* style,
172 IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, 177 IsInlineElementToRemoveFunction isInlineElementToRemoveFunction,
173 InputEvent::InputType inputType) 178 InputEvent::InputType inputType)
174 : CompositeEditCommand(document), 179 : CompositeEditCommand(document, source),
175 m_style(style->copy()), 180 m_style(style->copy()),
176 m_inputType(inputType), 181 m_inputType(inputType),
177 m_propertyLevel(PropertyDefault), 182 m_propertyLevel(PropertyDefault),
178 m_start(mostForwardCaretPosition(endingSelection().start())), 183 m_start(mostForwardCaretPosition(endingSelection().start())),
179 m_end(mostBackwardCaretPosition(endingSelection().end())), 184 m_end(mostBackwardCaretPosition(endingSelection().end())),
180 m_useEndingSelection(true), 185 m_useEndingSelection(true),
181 m_styledInlineElement(nullptr), 186 m_styledInlineElement(nullptr),
182 m_removeOnly(true), 187 m_removeOnly(true),
183 m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction) {} 188 m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction) {}
184 189
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 2034
2030 DEFINE_TRACE(ApplyStyleCommand) { 2035 DEFINE_TRACE(ApplyStyleCommand) {
2031 visitor->trace(m_style); 2036 visitor->trace(m_style);
2032 visitor->trace(m_start); 2037 visitor->trace(m_start);
2033 visitor->trace(m_end); 2038 visitor->trace(m_end);
2034 visitor->trace(m_styledInlineElement); 2039 visitor->trace(m_styledInlineElement);
2035 CompositeEditCommand::trace(visitor); 2040 CompositeEditCommand::trace(visitor);
2036 } 2041 }
2037 2042
2038 } // namespace blink 2043 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698