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

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

Issue 18041002: compositionstart event's data should contain text to replace. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a testcase for selection. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/events/ime-composition-events-001-expected.txt ('k') | no next file » | 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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 // Send a compositionupdate event when this function updates the exis ting composition 1240 // Send a compositionupdate event when this function updates the exis ting composition
1241 // node, i.e. m_compositionNode != 0 && !text.isEmpty(). 1241 // node, i.e. m_compositionNode != 0 && !text.isEmpty().
1242 // 3. Canceling the ongoing composition. 1242 // 3. Canceling the ongoing composition.
1243 // Send a compositionend event when function deletes the existing com position node, i.e. 1243 // Send a compositionend event when function deletes the existing com position node, i.e.
1244 // m_compositionNode != 0 && test.isEmpty(). 1244 // m_compositionNode != 0 && test.isEmpty().
1245 RefPtr<CompositionEvent> event; 1245 RefPtr<CompositionEvent> event;
1246 if (!m_compositionNode) { 1246 if (!m_compositionNode) {
1247 // We should send a compositionstart event only when the given text is not empty because this 1247 // We should send a compositionstart event only when the given text is not empty because this
1248 // function doesn't create a composition node when the text is empty . 1248 // function doesn't create a composition node when the text is empty .
1249 if (!text.isEmpty()) { 1249 if (!text.isEmpty()) {
1250 target->dispatchEvent(CompositionEvent::create(eventNames().comp ositionstartEvent, m_frame->document()->domWindow(), text)); 1250 FrameSelection* selection = m_frame->selection();
1251 String selectionText;
1252 if (selection->isRange()) {
1253 RefPtr<Range> range = selection->toNormalizedRange();
1254 selectionText = plainText(range.get());
1255 }
1256 target->dispatchEvent(CompositionEvent::create(eventNames().comp ositionstartEvent, m_frame->document()->domWindow(), selectionText));
rniwa-cr 2013/07/15 21:46:52 You could have simply called selectedText() here a
kochi 2013/07/16 09:50:41 Done.
1251 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->document()->domWindow(), text); 1257 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->document()->domWindow(), text);
1252 } 1258 }
1253 } else { 1259 } else {
1254 if (!text.isEmpty()) 1260 if (!text.isEmpty())
1255 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->document()->domWindow(), text); 1261 event = CompositionEvent::create(eventNames().compositionupdateE vent, m_frame->document()->domWindow(), text);
1256 else 1262 else
1257 event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text); 1263 event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
1258 } 1264 }
1259 if (event.get()) 1265 if (event.get())
1260 target->dispatchEvent(event, IGNORE_EXCEPTION); 1266 target->dispatchEvent(event, IGNORE_EXCEPTION);
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 return WebCore::unifiedTextCheckerEnabled(m_frame); 2349 return WebCore::unifiedTextCheckerEnabled(m_frame);
2344 } 2350 }
2345 2351
2346 void Editor::toggleOverwriteModeEnabled() 2352 void Editor::toggleOverwriteModeEnabled()
2347 { 2353 {
2348 m_overwriteModeEnabled = !m_overwriteModeEnabled; 2354 m_overwriteModeEnabled = !m_overwriteModeEnabled;
2349 frame()->selection()->setShouldShowBlockCursor(m_overwriteModeEnabled); 2355 frame()->selection()->setShouldShowBlockCursor(m_overwriteModeEnabled);
2350 }; 2356 };
2351 2357
2352 } // namespace WebCore 2358 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/ime-composition-events-001-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698