OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2010 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 VisiblePosition visibleStartOfSelection = selection.visibleStart(); | 177 VisiblePosition visibleStartOfSelection = selection.visibleStart(); |
178 VisiblePosition visibleEndOfSelection = selection.visibleEnd(); | 178 VisiblePosition visibleEndOfSelection = selection.visibleEnd(); |
179 PositionWithAffinity startOfSelection = | 179 PositionWithAffinity startOfSelection = |
180 visibleStartOfSelection.toPositionWithAffinity(); | 180 visibleStartOfSelection.toPositionWithAffinity(); |
181 PositionWithAffinity endOfSelection = | 181 PositionWithAffinity endOfSelection = |
182 visibleEndOfSelection.toPositionWithAffinity(); | 182 visibleEndOfSelection.toPositionWithAffinity(); |
183 Position startOfLastParagraph = | 183 Position startOfLastParagraph = |
184 startOfParagraph(visibleEndOfSelection, CanSkipOverEditingBoundary) | 184 startOfParagraph(visibleEndOfSelection, CanSkipOverEditingBoundary) |
185 .deepEquivalent(); | 185 .deepEquivalent(); |
186 | 186 |
187 Range* currentSelection = firstRangeOf(endingSelection()); | 187 Range* currentSelection = |
188 createRange(firstEphemeralRangeOf(endingSelection())); | |
188 ContainerNode* scopeForStartOfSelection = nullptr; | 189 ContainerNode* scopeForStartOfSelection = nullptr; |
189 ContainerNode* scopeForEndOfSelection = nullptr; | 190 ContainerNode* scopeForEndOfSelection = nullptr; |
190 // FIXME: This is an inefficient way to keep selection alive because | 191 // FIXME: This is an inefficient way to keep selection alive because |
191 // indexForVisiblePosition walks from the beginning of the document to the | 192 // indexForVisiblePosition walks from the beginning of the document to the |
192 // visibleEndOfSelection everytime this code is executed. But not using | 193 // visibleEndOfSelection everytime this code is executed. But not using |
193 // index is hard because there are so many ways we can lose selection inside | 194 // index is hard because there are so many ways we can lose selection inside |
194 // doApplyForSingleParagraph. | 195 // doApplyForSingleParagraph. |
195 int indexForStartOfSelection = indexForVisiblePosition( | 196 int indexForStartOfSelection = indexForVisiblePosition( |
196 visibleStartOfSelection, scopeForStartOfSelection); | 197 visibleStartOfSelection, scopeForStartOfSelection); |
197 int indexForEndOfSelection = | 198 int indexForEndOfSelection = |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 setEndingSelection(SelectionInDOMTree::Builder() | 290 setEndingSelection(SelectionInDOMTree::Builder() |
290 .setAffinity(visibleStartOfSelection.affinity()) | 291 .setAffinity(visibleStartOfSelection.affinity()) |
291 .setBaseAndExtentDeprecated( | 292 .setBaseAndExtentDeprecated( |
292 visibleStartOfSelection.deepEquivalent(), | 293 visibleStartOfSelection.deepEquivalent(), |
293 visibleEndOfSelection.deepEquivalent()) | 294 visibleEndOfSelection.deepEquivalent()) |
294 .setIsDirectional(endingSelection().isDirectional()) | 295 .setIsDirectional(endingSelection().isDirectional()) |
295 .build()); | 296 .build()); |
296 return; | 297 return; |
297 } | 298 } |
298 | 299 |
299 DCHECK(firstRangeOf(endingSelection())); | 300 Range* const range = createRange(firstEphemeralRangeOf(endingSelection())); |
300 doApplyForSingleParagraph(false, listTag, *firstRangeOf(endingSelection()), | 301 DCHECK(!range); |
Xiaocheng
2017/03/02 20:14:29
Remove '!'
yosin_UTC9
2017/03/03 04:22:35
Done.
(my brain is still damaged...)
| |
301 editingState); | 302 doApplyForSingleParagraph(false, listTag, *range, editingState); |
302 } | 303 } |
303 | 304 |
304 InputEvent::InputType InsertListCommand::inputType() const { | 305 InputEvent::InputType InsertListCommand::inputType() const { |
305 return m_type == OrderedList ? InputEvent::InputType::InsertOrderedList | 306 return m_type == OrderedList ? InputEvent::InputType::InsertOrderedList |
306 : InputEvent::InputType::InsertUnorderedList; | 307 : InputEvent::InputType::InsertUnorderedList; |
307 } | 308 } |
308 | 309 |
309 bool InsertListCommand::doApplyForSingleParagraph( | 310 bool InsertListCommand::doApplyForSingleParagraph( |
310 bool forceCreateList, | 311 bool forceCreateList, |
311 const HTMLQualifiedName& listTag, | 312 const HTMLQualifiedName& listTag, |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 endOfParagraph(validPos, CanSkipOverEditingBoundary); | 660 endOfParagraph(validPos, CanSkipOverEditingBoundary); |
660 moveParagraph(start, end, VisiblePosition::beforeNode(placeholder), | 661 moveParagraph(start, end, VisiblePosition::beforeNode(placeholder), |
661 editingState, PreserveSelection); | 662 editingState, PreserveSelection); |
662 } | 663 } |
663 | 664 |
664 DEFINE_TRACE(InsertListCommand) { | 665 DEFINE_TRACE(InsertListCommand) { |
665 CompositeEditCommand::trace(visitor); | 666 CompositeEditCommand::trace(visitor); |
666 } | 667 } |
667 | 668 |
668 } // namespace blink | 669 } // namespace blink |
OLD | NEW |