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

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

Issue 2903833002: Reland: Update TextSelection for non-user initiated events
Patch Set: Suppress superfluous non-user initiated text selection events Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 return; 1622 return;
1623 1623
1624 #if BUILDFLAG(ENABLE_PLUGINS) 1624 #if BUILDFLAG(ENABLE_PLUGINS)
1625 if (focused_pepper_plugin_) { 1625 if (focused_pepper_plugin_) {
1626 focused_pepper_plugin_->render_frame()->OnImeSetComposition( 1626 focused_pepper_plugin_->render_frame()->OnImeSetComposition(
1627 text, underlines, selection_start, selection_end); 1627 text, underlines, selection_start, selection_end);
1628 return; 1628 return;
1629 } 1629 }
1630 #endif 1630 #endif
1631 ImeEventGuard guard(this); 1631 ImeEventGuard guard(this);
1632 input_handler_->set_ime_composition_replacement(replacement_range.IsValid());
1632 blink::WebInputMethodController* controller = GetInputMethodController(); 1633 blink::WebInputMethodController* controller = GetInputMethodController();
1633 if (!controller || 1634 if (!controller ||
1634 !controller->SetComposition( 1635 !controller->SetComposition(
1635 WebString::FromUTF16(text), 1636 WebString::FromUTF16(text),
1636 WebVector<WebCompositionUnderline>(underlines), 1637 WebVector<WebCompositionUnderline>(underlines),
1637 replacement_range.IsValid() 1638 replacement_range.IsValid()
1638 ? WebRange(replacement_range.start(), replacement_range.length()) 1639 ? WebRange(replacement_range.start(), replacement_range.length())
1639 : WebRange(), 1640 : WebRange(),
1640 selection_start, selection_end)) { 1641 selection_start, selection_end)) {
1641 // If we failed to set the composition text, then we need to let the browser 1642 // If we failed to set the composition text, then we need to let the browser
1642 // process to cancel the input method's ongoing composition session, to make 1643 // process to cancel the input method's ongoing composition session, to make
1643 // sure we are in a consistent state. 1644 // sure we are in a consistent state.
1644 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1645 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1645 } 1646 }
1647 input_handler_->set_ime_composition_replacement(false);
1646 UpdateCompositionInfo(false /* not an immediate request */); 1648 UpdateCompositionInfo(false /* not an immediate request */);
1647 } 1649 }
1648 1650
1649 void RenderWidget::OnImeCommitText( 1651 void RenderWidget::OnImeCommitText(
1650 const base::string16& text, 1652 const base::string16& text,
1651 const std::vector<WebCompositionUnderline>& underlines, 1653 const std::vector<WebCompositionUnderline>& underlines,
1652 const gfx::Range& replacement_range, 1654 const gfx::Range& replacement_range,
1653 int relative_cursor_pos) { 1655 int relative_cursor_pos) {
1654 if (!ShouldHandleImeEvents()) 1656 if (!ShouldHandleImeEvents())
1655 return; 1657 return;
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 // browser side (https://crbug.com/669219). 2381 // browser side (https://crbug.com/669219).
2380 // If there is no WebFrameWidget, then there will be no 2382 // If there is no WebFrameWidget, then there will be no
2381 // InputMethodControllers for a WebLocalFrame. 2383 // InputMethodControllers for a WebLocalFrame.
2382 return nullptr; 2384 return nullptr;
2383 } 2385 }
2384 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) 2386 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2385 ->GetActiveWebInputMethodController(); 2387 ->GetActiveWebInputMethodController();
2386 } 2388 }
2387 2389
2388 } // namespace content 2390 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698