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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue Created 4 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 void RenderFrameImpl::SimulateImeSetComposition( 1318 void RenderFrameImpl::SimulateImeSetComposition(
1319 const base::string16& text, 1319 const base::string16& text,
1320 const std::vector<blink::WebCompositionUnderline>& underlines, 1320 const std::vector<blink::WebCompositionUnderline>& underlines,
1321 int selection_start, 1321 int selection_start,
1322 int selection_end) { 1322 int selection_end) {
1323 render_view_->OnImeSetComposition( 1323 render_view_->OnImeSetComposition(
1324 text, underlines, gfx::Range::InvalidRange(), 1324 text, underlines, gfx::Range::InvalidRange(),
1325 selection_start, selection_end); 1325 selection_start, selection_end);
1326 } 1326 }
1327 1327
1328 void RenderFrameImpl::SimulateImeConfirmComposition( 1328 void RenderFrameImpl::SimulateImeCommitText(
1329 const base::string16& text, 1329 const base::string16& text,
1330 const gfx::Range& replacement_range) { 1330 const gfx::Range& replacement_range) {
1331 render_view_->OnImeConfirmComposition(text, replacement_range, false); 1331 render_view_->OnImeCommitText(text, replacement_range, 0);
1332 }
1333
1334 void RenderFrameImpl::SimulateImeFinishComposingText(bool keep_selection) {
1335 render_view_->OnImeFinishComposingText(keep_selection);
1332 } 1336 }
1333 1337
1334 void RenderFrameImpl::OnImeSetComposition( 1338 void RenderFrameImpl::OnImeSetComposition(
1335 const base::string16& text, 1339 const base::string16& text,
1336 const std::vector<blink::WebCompositionUnderline>& underlines, 1340 const std::vector<blink::WebCompositionUnderline>& underlines,
1337 int selection_start, 1341 int selection_start,
1338 int selection_end) { 1342 int selection_end) {
1339 // When a PPAPI plugin has focus, we bypass WebKit. 1343 // When a PPAPI plugin has focus, we bypass WebKit.
1340 if (!IsPepperAcceptingCompositionEvents()) { 1344 if (!IsPepperAcceptingCompositionEvents()) {
1341 pepper_composition_text_ = text; 1345 pepper_composition_text_ = text;
(...skipping 13 matching lines...) Expand all
1355 } 1359 }
1356 pepper_composition_text_ = text; 1360 pepper_composition_text_ = text;
1357 // Nonempty: composition is ongoing. 1361 // Nonempty: composition is ongoing.
1358 if (!pepper_composition_text_.empty()) { 1362 if (!pepper_composition_text_.empty()) {
1359 focused_pepper_plugin_->HandleCompositionUpdate( 1363 focused_pepper_plugin_->HandleCompositionUpdate(
1360 pepper_composition_text_, underlines, selection_start, selection_end); 1364 pepper_composition_text_, underlines, selection_start, selection_end);
1361 } 1365 }
1362 } 1366 }
1363 } 1367 }
1364 1368
1365 void RenderFrameImpl::OnImeConfirmComposition( 1369 void RenderFrameImpl::OnImeCommitText(const base::string16& text,
1366 const base::string16& text, 1370 const gfx::Range& replacement_range,
1367 const gfx::Range& replacement_range, 1371 int relative_cursor_pos) {
1368 bool keep_selection) { 1372 if (text.empty())
1369 // When a PPAPI plugin has focus, we bypass WebKit.
1370 // Here, text.empty() has a special meaning. It means to commit the last
1371 // update of composition text (see
1372 // RenderWidgetHost::ImeConfirmComposition()).
1373 const base::string16& last_text = text.empty() ? pepper_composition_text_
1374 : text;
1375
1376 // last_text is empty only when both text and pepper_composition_text_ is.
1377 // Ignore it.
1378 if (last_text.empty())
1379 return; 1373 return;
1380 1374
1381 if (!IsPepperAcceptingCompositionEvents()) { 1375 if (!IsPepperAcceptingCompositionEvents()) {
1382 base::i18n::UTF16CharIterator iterator(&last_text); 1376 base::i18n::UTF16CharIterator iterator(&text);
1383 int32_t i = 0; 1377 int32_t i = 0;
1384 while (iterator.Advance()) { 1378 while (iterator.Advance()) {
1385 blink::WebKeyboardEvent char_event; 1379 blink::WebKeyboardEvent char_event;
1386 char_event.type = blink::WebInputEvent::Char; 1380 char_event.type = blink::WebInputEvent::Char;
1387 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); 1381 char_event.timeStampSeconds = base::Time::Now().ToDoubleT();
1388 char_event.modifiers = 0; 1382 char_event.modifiers = 0;
1389 char_event.windowsKeyCode = last_text[i]; 1383 char_event.windowsKeyCode = text[i];
1390 char_event.nativeKeyCode = last_text[i]; 1384 char_event.nativeKeyCode = text[i];
1391 1385
1392 const int32_t char_start = i; 1386 const int32_t char_start = i;
1393 for (; i < iterator.array_pos(); ++i) { 1387 for (; i < iterator.array_pos(); ++i) {
1394 char_event.text[i - char_start] = last_text[i]; 1388 char_event.text[i - char_start] = text[i];
1395 char_event.unmodifiedText[i - char_start] = last_text[i]; 1389 char_event.unmodifiedText[i - char_start] = text[i];
1396 } 1390 }
1397 1391
1398 if (GetRenderWidget()->webwidget()) 1392 if (GetRenderWidget()->webwidget())
1393 GetRenderWidget()->webwidget()->handleInputEvent(char_event);
1394 }
1395 } else {
1396 // Mimics the order of events sent by WebKit.
1397 // See WebCore::Editor::setComposition() for the corresponding code.
1398 focused_pepper_plugin_->HandleCompositionEnd(text);
1399 focused_pepper_plugin_->HandleTextInput(text);
1400 }
1401 pepper_composition_text_.clear();
1402 }
1403
1404 void RenderFrameImpl::OnImeFinishComposingText(bool keep_selection) {
1405 const base::string16& text = pepper_composition_text_;
1406
1407 if (text.empty())
1408 return;
1409
1410 if (!IsPepperAcceptingCompositionEvents()) {
1411 base::i18n::UTF16CharIterator iterator(&text);
1412 int32_t i = 0;
1413 while (iterator.Advance()) {
1414 blink::WebKeyboardEvent char_event;
1415 char_event.type = blink::WebInputEvent::Char;
1416 char_event.timeStampSeconds = base::Time::Now().ToDoubleT();
1417 char_event.modifiers = 0;
1418 char_event.windowsKeyCode = text[i];
1419 char_event.nativeKeyCode = text[i];
1420
1421 const int32_t char_start = i;
1422 for (; i < iterator.array_pos(); ++i) {
1423 char_event.text[i - char_start] = text[i];
1424 char_event.unmodifiedText[i - char_start] = text[i];
1425 }
1426
1427 if (GetRenderWidget()->webwidget())
1399 GetRenderWidget()->webwidget()->handleInputEvent(char_event); 1428 GetRenderWidget()->webwidget()->handleInputEvent(char_event);
1400 } 1429 }
1401 } else { 1430 } else {
1402 // Mimics the order of events sent by WebKit. 1431 // Mimics the order of events sent by WebKit.
1403 // See WebCore::Editor::setComposition() for the corresponding code. 1432 // See WebCore::Editor::setComposition() for the corresponding code.
1404 focused_pepper_plugin_->HandleCompositionEnd(last_text); 1433 focused_pepper_plugin_->HandleCompositionEnd(text);
1405 focused_pepper_plugin_->HandleTextInput(last_text); 1434 focused_pepper_plugin_->HandleTextInput(text);
1406 } 1435 }
1407 pepper_composition_text_.clear(); 1436 pepper_composition_text_.clear();
1408 } 1437 }
1409 #endif // defined(ENABLE_PLUGINS) 1438 #endif // defined(ENABLE_PLUGINS)
1410 1439
1411 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() { 1440 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() {
1412 if (!web_user_media_client_) 1441 if (!web_user_media_client_)
1413 InitializeUserMediaClient(); 1442 InitializeUserMediaClient();
1414 return web_user_media_client_ ? 1443 return web_user_media_client_ ?
1415 web_user_media_client_->media_stream_dispatcher() : NULL; 1444 web_user_media_client_->media_stream_dispatcher() : NULL;
(...skipping 4935 matching lines...) Expand 10 before | Expand all | Expand 10 after
6351 // event target. Potentially a Pepper plugin will receive the event. 6380 // event target. Potentially a Pepper plugin will receive the event.
6352 // In order to tell whether a plugin gets the last mouse event and which it 6381 // In order to tell whether a plugin gets the last mouse event and which it
6353 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6382 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6354 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6383 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6355 // |pepper_last_mouse_event_target_|. 6384 // |pepper_last_mouse_event_target_|.
6356 pepper_last_mouse_event_target_ = nullptr; 6385 pepper_last_mouse_event_target_ = nullptr;
6357 #endif 6386 #endif
6358 } 6387 }
6359 6388
6360 } // namespace content 6389 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698