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

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

Issue 23822003: Have EditCommand classes deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Dispatch a compositionend event to the focused node. 198 // Dispatch a compositionend event to the focused node.
199 // We should send this event before sending a TextEvent as written in Sectio n 6.2.2 and 6.2.3 of 199 // We should send this event before sending a TextEvent as written in Sectio n 6.2.2 and 6.2.3 of
200 // the DOM Event specification. 200 // the DOM Event specification.
201 if (Element* target = m_frame->document()->focusedElement()) { 201 if (Element* target = m_frame->document()->focusedElement()) {
202 RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().c ompositionendEvent, m_frame->domWindow(), text); 202 RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().c ompositionendEvent, m_frame->domWindow(), text);
203 target->dispatchEvent(event, IGNORE_EXCEPTION); 203 target->dispatchEvent(event, IGNORE_EXCEPTION);
204 } 204 }
205 205
206 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input 206 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input
207 // will delete the old composition with an optimized replace operation. 207 // will delete the old composition with an optimized replace operation.
208 if (text.isEmpty() && mode != CancelComposition) 208 if (text.isEmpty() && mode != CancelComposition) {
209 TypingCommand::deleteSelection(m_frame->document(), 0); 209 ASSERT(m_frame->document());
210 TypingCommand::deleteSelection(*m_frame->document(), 0);
211 }
210 212
211 m_compositionNode = 0; 213 m_compositionNode = 0;
212 m_customCompositionUnderlines.clear(); 214 m_customCompositionUnderlines.clear();
213 215
214 insertTextForConfirmedComposition(text); 216 insertTextForConfirmedComposition(text);
215 217
216 if (mode == CancelComposition) { 218 if (mode == CancelComposition) {
217 // An open typing command that disagrees about current selection would c ause issues with typing later on. 219 // An open typing command that disagrees about current selection would c ause issues with typing later on.
218 TypingCommand::closeTyping(m_frame); 220 TypingCommand::closeTyping(m_frame);
219 } 221 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->domWindow(), text); 266 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->domWindow(), text);
265 else 267 else
266 event = CompositionEvent::create(eventNames().compositionendEven t, m_frame->domWindow(), text); 268 event = CompositionEvent::create(eventNames().compositionendEven t, m_frame->domWindow(), text);
267 } 269 }
268 if (event.get()) 270 if (event.get())
269 target->dispatchEvent(event, IGNORE_EXCEPTION); 271 target->dispatchEvent(event, IGNORE_EXCEPTION);
270 } 272 }
271 273
272 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input 274 // If text is empty, then delete the old composition here. If text is non-em pty, InsertTextCommand::input
273 // will delete the old composition with an optimized replace operation. 275 // will delete the old composition with an optimized replace operation.
274 if (text.isEmpty()) 276 if (text.isEmpty()) {
275 TypingCommand::deleteSelection(m_frame->document(), TypingCommand::Preve ntSpellChecking); 277 ASSERT(m_frame->document());
278 TypingCommand::deleteSelection(*m_frame->document(), TypingCommand::Prev entSpellChecking);
279 }
276 280
277 m_compositionNode = 0; 281 m_compositionNode = 0;
278 m_customCompositionUnderlines.clear(); 282 m_customCompositionUnderlines.clear();
279 283
280 if (!text.isEmpty()) { 284 if (!text.isEmpty()) {
281 TypingCommand::insertText(m_frame->document(), text, TypingCommand::Sele ctInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposi tionUpdate); 285 ASSERT(m_frame->document());
286 TypingCommand::insertText(*m_frame->document(), text, TypingCommand::Sel ectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompos itionUpdate);
282 287
283 // Find out what node has the composition now. 288 // Find out what node has the composition now.
284 Position base = m_frame->selection()->base().downstream(); 289 Position base = m_frame->selection()->base().downstream();
285 Position extent = m_frame->selection()->extent(); 290 Position extent = m_frame->selection()->extent();
286 Node* baseNode = base.deprecatedNode(); 291 Node* baseNode = base.deprecatedNode();
287 unsigned baseOffset = base.deprecatedEditingOffset(); 292 unsigned baseOffset = base.deprecatedEditingOffset();
288 Node* extentNode = extent.deprecatedNode(); 293 Node* extentNode = extent.deprecatedNode();
289 unsigned extentOffset = extent.deprecatedEditingOffset(); 294 unsigned extentOffset = extent.deprecatedEditingOffset();
290 295
291 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base Offset + text.length() == extentOffset) { 296 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base Offset + text.length() == extentOffset) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 375
371 bool InputMethodController::setSelectionOffsets(const PlainTextOffsets& selectio nOffsets) 376 bool InputMethodController::setSelectionOffsets(const PlainTextOffsets& selectio nOffsets)
372 { 377 {
373 if (selectionOffsets.isNull()) 378 if (selectionOffsets.isNull())
374 return false; 379 return false;
375 // FIXME: We should move Editor::setSelectionOffsets() into InputMethodContr oller class. 380 // FIXME: We should move Editor::setSelectionOffsets() into InputMethodContr oller class.
376 return editor().setSelectionOffsets(selectionOffsets.start(), selectionOffse ts.end()); 381 return editor().setSelectionOffsets(selectionOffsets.start(), selectionOffse ts.end());
377 } 382 }
378 383
379 } // namespace WebCore 384 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/IndentOutdentCommand.cpp ('k') | Source/core/editing/InsertIntoTextNodeCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698