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

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

Issue 2151353002: [InputEvent] Replace |EditAction| with |InputType| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inputevent-text-styling
Patch Set: Replaced |EditAction| with |InputType| Created 4 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
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 static bool offsetIsBeforeLastNodeOffset(int offset, Node* anchorNode) 115 static bool offsetIsBeforeLastNodeOffset(int offset, Node* anchorNode)
116 { 116 {
117 if (anchorNode->offsetInCharacters()) 117 if (anchorNode->offsetInCharacters())
118 return offset < anchorNode->maxCharacterOffset(); 118 return offset < anchorNode->maxCharacterOffset();
119 int currentOffset = 0; 119 int currentOffset = 0;
120 for (Node* node = NodeTraversal::firstChild(*anchorNode); node && currentOff set < offset; node = NodeTraversal::nextSibling(*node)) 120 for (Node* node = NodeTraversal::firstChild(*anchorNode); node && currentOff set < offset; node = NodeTraversal::nextSibling(*node))
121 currentOffset++; 121 currentOffset++;
122 return offset < currentOffset; 122 return offset < currentOffset;
123 } 123 }
124 124
125 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, EditAction editingAction, EPropertyLevel propertyLevel) 125 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, InputEvent::InputType inputType, EPropertyLevel propertyLevel)
126 : CompositeEditCommand(document) 126 : CompositeEditCommand(document)
127 , m_style(style->copy()) 127 , m_style(style->copy())
128 , m_editingAction(editingAction) 128 , m_inputType(inputType)
129 , m_propertyLevel(propertyLevel) 129 , m_propertyLevel(propertyLevel)
130 , m_start(mostForwardCaretPosition(endingSelection().start())) 130 , m_start(mostForwardCaretPosition(endingSelection().start()))
131 , m_end(mostBackwardCaretPosition(endingSelection().end())) 131 , m_end(mostBackwardCaretPosition(endingSelection().end()))
132 , m_useEndingSelection(true) 132 , m_useEndingSelection(true)
133 , m_styledInlineElement(nullptr) 133 , m_styledInlineElement(nullptr)
134 , m_removeOnly(false) 134 , m_removeOnly(false)
135 , m_isInlineElementToRemoveFunction(0) 135 , m_isInlineElementToRemoveFunction(0)
136 { 136 {
137 } 137 }
138 138
139 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, const Position& start, const Position& end) 139 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, const Position& start, const Position& end)
140 : CompositeEditCommand(document) 140 : CompositeEditCommand(document)
141 , m_style(style->copy()) 141 , m_style(style->copy())
142 , m_editingAction(EditActionChangeAttributes) 142 , m_inputType(InputEvent::InputType::ChangeAttributes)
143 , m_propertyLevel(PropertyDefault) 143 , m_propertyLevel(PropertyDefault)
144 , m_start(start) 144 , m_start(start)
145 , m_end(end) 145 , m_end(end)
146 , m_useEndingSelection(false) 146 , m_useEndingSelection(false)
147 , m_styledInlineElement(nullptr) 147 , m_styledInlineElement(nullptr)
148 , m_removeOnly(false) 148 , m_removeOnly(false)
149 , m_isInlineElementToRemoveFunction(0) 149 , m_isInlineElementToRemoveFunction(0)
150 { 150 {
151 } 151 }
152 152
153 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool removeOnly) 153 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool removeOnly)
154 : CompositeEditCommand(element->document()) 154 : CompositeEditCommand(element->document())
155 , m_style(EditingStyle::create()) 155 , m_style(EditingStyle::create())
156 , m_editingAction(EditActionChangeAttributes) 156 , m_inputType(InputEvent::InputType::ChangeAttributes)
157 , m_propertyLevel(PropertyDefault) 157 , m_propertyLevel(PropertyDefault)
158 , m_start(mostForwardCaretPosition(endingSelection().start())) 158 , m_start(mostForwardCaretPosition(endingSelection().start()))
159 , m_end(mostBackwardCaretPosition(endingSelection().end())) 159 , m_end(mostBackwardCaretPosition(endingSelection().end()))
160 , m_useEndingSelection(true) 160 , m_useEndingSelection(true)
161 , m_styledInlineElement(element) 161 , m_styledInlineElement(element)
162 , m_removeOnly(removeOnly) 162 , m_removeOnly(removeOnly)
163 , m_isInlineElementToRemoveFunction(0) 163 , m_isInlineElementToRemoveFunction(0)
164 { 164 {
165 } 165 }
166 166
167 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, EditAction editingAction) 167 ApplyStyleCommand::ApplyStyleCommand(Document& document, const EditingStyle* sty le, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, InputEvent: :InputType inputType)
168 : CompositeEditCommand(document) 168 : CompositeEditCommand(document)
169 , m_style(style->copy()) 169 , m_style(style->copy())
170 , m_editingAction(editingAction) 170 , m_inputType(inputType)
171 , m_propertyLevel(PropertyDefault) 171 , m_propertyLevel(PropertyDefault)
172 , m_start(mostForwardCaretPosition(endingSelection().start())) 172 , m_start(mostForwardCaretPosition(endingSelection().start()))
173 , m_end(mostBackwardCaretPosition(endingSelection().end())) 173 , m_end(mostBackwardCaretPosition(endingSelection().end()))
174 , m_useEndingSelection(true) 174 , m_useEndingSelection(true)
175 , m_styledInlineElement(nullptr) 175 , m_styledInlineElement(nullptr)
176 , m_removeOnly(true) 176 , m_removeOnly(true)
177 , m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction) 177 , m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction)
178 { 178 {
179 } 179 }
180 180
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 break; 229 break;
230 } 230 }
231 case ForceBlockProperties: 231 case ForceBlockProperties:
232 // Force all properties to be applied as block styles. 232 // Force all properties to be applied as block styles.
233 applyBlockStyle(m_style.get(), editingState); 233 applyBlockStyle(m_style.get(), editingState);
234 break; 234 break;
235 } 235 }
236 } 236 }
237 237
238 EditAction ApplyStyleCommand::editingAction() const 238 InputEvent::InputType ApplyStyleCommand::inputType() const
239 { 239 {
240 return m_editingAction; 240 return m_inputType;
241 } 241 }
242 242
243 void ApplyStyleCommand::applyBlockStyle(EditingStyle *style, EditingState* editi ngState) 243 void ApplyStyleCommand::applyBlockStyle(EditingStyle *style, EditingState* editi ngState)
244 { 244 {
245 // update document layout once before removing styles 245 // update document layout once before removing styles
246 // so that we avoid the expense of updating before each and every call 246 // so that we avoid the expense of updating before each and every call
247 // to check a computed style 247 // to check a computed style
248 document().updateStyleAndLayoutIgnorePendingStylesheets(); 248 document().updateStyleAndLayoutIgnorePendingStylesheets();
249 249
250 // get positions we want to use for applying style 250 // get positions we want to use for applying style
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 DEFINE_TRACE(ApplyStyleCommand) 1731 DEFINE_TRACE(ApplyStyleCommand)
1732 { 1732 {
1733 visitor->trace(m_style); 1733 visitor->trace(m_style);
1734 visitor->trace(m_start); 1734 visitor->trace(m_start);
1735 visitor->trace(m_end); 1735 visitor->trace(m_end);
1736 visitor->trace(m_styledInlineElement); 1736 visitor->trace(m_styledInlineElement);
1737 CompositeEditCommand::trace(visitor); 1737 CompositeEditCommand::trace(visitor);
1738 } 1738 }
1739 1739
1740 } // namespace blink 1740 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698