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

Side by Side Diff: Source/core/editing/TypingCommand.cpp

Issue 1201423002: Use VisibleSelection::InDOMTree::equalSelections() instead of operator==() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-24T15:30:20 Rebase - exclude FrameSelection Created 5 years, 6 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, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 } 142 }
143 143
144 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply(); 144 TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)- >apply();
145 } 145 }
146 146
147 void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand * typingCommand, LocalFrame* frame) 147 void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand * typingCommand, LocalFrame* frame)
148 { 148 {
149 ASSERT(frame); 149 ASSERT(frame);
150 VisibleSelection currentSelection = frame->selection().selection(); 150 VisibleSelection currentSelection = frame->selection().selection();
151 if (currentSelection == typingCommand->endingSelection()) 151 if (VisibleSelection::InDOMTree::equalSelections(currentSelection, typingCom mand->endingSelection()))
152 return; 152 return;
153 153
154 typingCommand->setStartingSelection(currentSelection); 154 typingCommand->setStartingSelection(currentSelection);
155 typingCommand->setEndingSelection(currentSelection); 155 typingCommand->setEndingSelection(currentSelection);
156 } 156 }
157 157
158 void TypingCommand::insertText(Document& document, const String& text, Options o ptions, TextCompositionType composition) 158 void TypingCommand::insertText(Document& document, const String& text, Options o ptions, TextCompositionType composition)
159 { 159 {
160 LocalFrame* frame = document.frame(); 160 LocalFrame* frame = document.frame();
161 ASSERT(frame); 161 ASSERT(frame);
(...skipping 11 matching lines...) Expand all
173 ASSERT(frame); 173 ASSERT(frame);
174 174
175 VisibleSelection currentSelection = frame->selection().selection(); 175 VisibleSelection currentSelection = frame->selection().selection();
176 176
177 String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion , compositionType == TextCompositionUpdate); 177 String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion , compositionType == TextCompositionUpdate);
178 178
179 // Set the starting and ending selection appropriately if we are using a sel ection 179 // Set the starting and ending selection appropriately if we are using a sel ection
180 // that is different from the current selection. In the future, we should c hange EditCommand 180 // that is different from the current selection. In the future, we should c hange EditCommand
181 // to deal with custom selections in a general way that can be used by all o f the commands. 181 // to deal with custom selections in a general way that can be used by all o f the commands.
182 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(frame.get())) { 182 if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandI fStillOpenForTyping(frame.get())) {
183 if (lastTypingCommand->endingSelection() != selectionForInsertion) { 183 if (!VisibleSelection::InDOMTree::equalSelections(lastTypingCommand->end ingSelection(), selectionForInsertion)) {
184 lastTypingCommand->setStartingSelection(selectionForInsertion); 184 lastTypingCommand->setStartingSelection(selectionForInsertion);
185 lastTypingCommand->setEndingSelection(selectionForInsertion); 185 lastTypingCommand->setEndingSelection(selectionForInsertion);
186 } 186 }
187 187
188 lastTypingCommand->setCompositionType(compositionType); 188 lastTypingCommand->setCompositionType(compositionType);
189 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator); 189 lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & Reta inAutocorrectionIndicator);
190 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking); 190 lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellC hecking);
191 lastTypingCommand->insertText(newText, options & SelectInsertedText); 191 lastTypingCommand->insertText(newText, options & SelectInsertedText);
192 return; 192 return;
193 } 193 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 ASSERT_NOT_REACHED(); 624 ASSERT_NOT_REACHED();
625 m_preservesTypingStyle = false; 625 m_preservesTypingStyle = false;
626 } 626 }
627 627
628 bool TypingCommand::isTypingCommand() const 628 bool TypingCommand::isTypingCommand() const
629 { 629 {
630 return true; 630 return true;
631 } 631 }
632 632
633 } // namespace blink 633 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698