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

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

Issue 311053008: CANCEL: Make "compositionstart" event cancelable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2014-06-18T10:53:48 Created 6 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // Send a compositionupdate event when this function updates the exis ting composition 252 // Send a compositionupdate event when this function updates the exis ting composition
253 // node, i.e. m_compositionNode != 0 && !text.isEmpty(). 253 // node, i.e. m_compositionNode != 0 && !text.isEmpty().
254 // 3. Canceling the ongoing composition. 254 // 3. Canceling the ongoing composition.
255 // Send a compositionend event when function deletes the existing com position node, i.e. 255 // Send a compositionend event when function deletes the existing com position node, i.e.
256 // m_compositionNode != 0 && test.isEmpty(). 256 // m_compositionNode != 0 && test.isEmpty().
257 RefPtrWillBeRawPtr<CompositionEvent> event = nullptr; 257 RefPtrWillBeRawPtr<CompositionEvent> event = nullptr;
258 if (!hasComposition()) { 258 if (!hasComposition()) {
259 // We should send a compositionstart event only when the given text is not empty because this 259 // We should send a compositionstart event only when the given text is not empty because this
260 // function doesn't create a composition node when the text is empty . 260 // function doesn't create a composition node when the text is empty .
261 if (!text.isEmpty()) { 261 if (!text.isEmpty()) {
262 target->dispatchEvent(CompositionEvent::create(EventTypeNames::c ompositionstart, m_frame.domWindow(), m_frame.selectedText(), underlines)); 262 RefPtrWillBeRawPtr<CompositionEvent> compositionStartEvent = Com positionEvent::create(EventTypeNames::compositionstart, m_frame.domWindow(), m_f rame.selectedText(), underlines);
263 if (!target->dispatchEvent(compositionStartEvent)) {
264 RefPtrWillBeRawPtr<CompositionEvent> compositionEndEvent = C ompositionEvent::create(EventTypeNames::compositionend, m_frame.domWindow(), emp tyString(), Vector<CompositionUnderline>());
265 target->dispatchEvent(compositionEndEvent, IGNORE_EXCEPTION) ;
266 return;
267 }
263 event = CompositionEvent::create(EventTypeNames::compositionupda te, m_frame.domWindow(), text, underlines); 268 event = CompositionEvent::create(EventTypeNames::compositionupda te, m_frame.domWindow(), text, underlines);
264 } 269 }
265 } else { 270 } else {
266 if (!text.isEmpty()) 271 if (!text.isEmpty())
267 event = CompositionEvent::create(EventTypeNames::compositionupda te, m_frame.domWindow(), text, underlines); 272 event = CompositionEvent::create(EventTypeNames::compositionupda te, m_frame.domWindow(), text, underlines);
268 else 273 else
269 event = CompositionEvent::create(EventTypeNames::compositionend, m_frame.domWindow(), text, underlines); 274 event = CompositionEvent::create(EventTypeNames::compositionend, m_frame.domWindow(), text, underlines);
270 } 275 }
271 if (event.get()) 276 if (event.get())
272 target->dispatchEvent(event, IGNORE_EXCEPTION); 277 target->dispatchEvent(event, IGNORE_EXCEPTION);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (!editor().canEdit()) 403 if (!editor().canEdit())
399 return; 404 return;
400 PlainTextRange selectionOffsets(getSelectionOffsets()); 405 PlainTextRange selectionOffsets(getSelectionOffsets());
401 if (selectionOffsets.isNull()) 406 if (selectionOffsets.isNull())
402 return; 407 return;
403 setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(selectionOffset s.start()) - before, 0), selectionOffsets.end() + after)); 408 setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(selectionOffset s.start()) - before, 0), selectionOffsets.end() + after));
404 TypingCommand::deleteSelection(*m_frame.document()); 409 TypingCommand::deleteSelection(*m_frame.document());
405 } 410 }
406 411
407 } // namespace WebCore 412 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698