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

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

Issue 2674253004: [refactor] Remove WebWidget::applyReplacementRange (Closed)
Patch Set: Rebased Created 3 years, 10 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 663
664 return RenderThread::Get()->Send(message); 664 return RenderThread::Get()->Send(message);
665 } 665 }
666 666
667 void RenderWidget::SendOrCrash(IPC::Message* message) { 667 void RenderWidget::SendOrCrash(IPC::Message* message) {
668 bool result = Send(message); 668 bool result = Send(message);
669 CHECK(closing_ || result) << "Failed to send message"; 669 CHECK(closing_ || result) << "Failed to send message";
670 } 670 }
671 671
672 bool RenderWidget::ShouldHandleImeEvents() const { 672 bool RenderWidget::ShouldHandleImeEvents() const {
673 return GetWebWidget()->isWebFrameWidget() && has_focus_; 673 return GetWebWidget() && GetWebWidget()->isWebFrameWidget() && has_focus_;
674 } 674 }
675 675
676 void RenderWidget::SetWindowRectSynchronously( 676 void RenderWidget::SetWindowRectSynchronously(
677 const gfx::Rect& new_window_rect) { 677 const gfx::Rect& new_window_rect) {
678 ResizeParams params; 678 ResizeParams params;
679 params.screen_info = screen_info_; 679 params.screen_info = screen_info_;
680 params.new_size = new_window_rect.size(); 680 params.new_size = new_window_rect.size();
681 params.physical_backing_size = 681 params.physical_backing_size =
682 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_); 682 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_);
683 params.visible_viewport_size = new_window_rect.size(); 683 params.visible_viewport_size = new_window_rect.size();
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 if (!ShouldHandleImeEvents()) 1563 if (!ShouldHandleImeEvents())
1564 return; 1564 return;
1565 1565
1566 #if BUILDFLAG(ENABLE_PLUGINS) 1566 #if BUILDFLAG(ENABLE_PLUGINS)
1567 if (focused_pepper_plugin_) { 1567 if (focused_pepper_plugin_) {
1568 focused_pepper_plugin_->render_frame()->OnImeSetComposition( 1568 focused_pepper_plugin_->render_frame()->OnImeSetComposition(
1569 text, underlines, selection_start, selection_end); 1569 text, underlines, selection_start, selection_end);
1570 return; 1570 return;
1571 } 1571 }
1572 #endif 1572 #endif
1573 if (replacement_range.IsValid()) {
1574 GetWebWidget()->applyReplacementRange(
1575 WebRange(replacement_range.start(), replacement_range.length()));
1576 }
1577
1578 if (!GetWebWidget())
1579 return;
1580 ImeEventGuard guard(this); 1573 ImeEventGuard guard(this);
1581 blink::WebInputMethodController* controller = GetInputMethodController(); 1574 blink::WebInputMethodController* controller = GetInputMethodController();
1582 if (!controller || 1575 if (!controller ||
1583 !controller->setComposition( 1576 !controller->setComposition(
1584 WebString::fromUTF16(text), 1577 WebString::fromUTF16(text),
1585 WebVector<WebCompositionUnderline>(underlines), selection_start, 1578 WebVector<WebCompositionUnderline>(underlines),
1586 selection_end)) { 1579 replacement_range.IsValid()
1580 ? WebRange(replacement_range.start(), replacement_range.length())
1581 : WebRange(),
1582 selection_start, selection_end)) {
1587 // If we failed to set the composition text, then we need to let the browser 1583 // If we failed to set the composition text, then we need to let the browser
1588 // process to cancel the input method's ongoing composition session, to make 1584 // process to cancel the input method's ongoing composition session, to make
1589 // sure we are in a consistent state. 1585 // sure we are in a consistent state.
1590 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1586 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1591 } 1587 }
1592 UpdateCompositionInfo(false /* not an immediate request */); 1588 UpdateCompositionInfo(false /* not an immediate request */);
1593 } 1589 }
1594 1590
1595 void RenderWidget::OnImeCommitText( 1591 void RenderWidget::OnImeCommitText(
1596 const base::string16& text, 1592 const base::string16& text,
1597 const std::vector<WebCompositionUnderline>& underlines, 1593 const std::vector<WebCompositionUnderline>& underlines,
1598 const gfx::Range& replacement_range, 1594 const gfx::Range& replacement_range,
1599 int relative_cursor_pos) { 1595 int relative_cursor_pos) {
1600 if (!ShouldHandleImeEvents()) 1596 if (!ShouldHandleImeEvents())
1601 return; 1597 return;
1602 1598
1603 #if BUILDFLAG(ENABLE_PLUGINS) 1599 #if BUILDFLAG(ENABLE_PLUGINS)
1604 if (focused_pepper_plugin_) { 1600 if (focused_pepper_plugin_) {
1605 focused_pepper_plugin_->render_frame()->OnImeCommitText( 1601 focused_pepper_plugin_->render_frame()->OnImeCommitText(
1606 text, replacement_range, relative_cursor_pos); 1602 text, replacement_range, relative_cursor_pos);
1607 return; 1603 return;
1608 } 1604 }
1609 #endif 1605 #endif
1610 if (replacement_range.IsValid()) {
1611 GetWebWidget()->applyReplacementRange(
1612 WebRange(replacement_range.start(), replacement_range.length()));
1613 }
1614
1615 if (!GetWebWidget())
1616 return;
1617 ImeEventGuard guard(this); 1606 ImeEventGuard guard(this);
1618 input_handler_->set_handling_input_event(true); 1607 input_handler_->set_handling_input_event(true);
1619 if (auto* controller = GetInputMethodController()) 1608 if (auto* controller = GetInputMethodController())
1620 controller->commitText(WebString::fromUTF16(text), 1609 controller->commitText(
1621 WebVector<WebCompositionUnderline>(underlines), 1610 WebString::fromUTF16(text),
1622 relative_cursor_pos); 1611 WebVector<WebCompositionUnderline>(underlines),
1612 replacement_range.IsValid()
1613 ? WebRange(replacement_range.start(), replacement_range.length())
1614 : WebRange(),
1615 relative_cursor_pos);
1623 input_handler_->set_handling_input_event(false); 1616 input_handler_->set_handling_input_event(false);
1624 UpdateCompositionInfo(false /* not an immediate request */); 1617 UpdateCompositionInfo(false /* not an immediate request */);
1625 } 1618 }
1626 1619
1627 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { 1620 void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
1628 if (!ShouldHandleImeEvents()) 1621 if (!ShouldHandleImeEvents())
1629 return; 1622 return;
1630 1623
1631 #if BUILDFLAG(ENABLE_PLUGINS) 1624 #if BUILDFLAG(ENABLE_PLUGINS)
1632 if (focused_pepper_plugin_) { 1625 if (focused_pepper_plugin_) {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 // browser side (https://crbug.com/669219). 2302 // browser side (https://crbug.com/669219).
2310 // If there is no WebFrameWidget, then there will be no 2303 // If there is no WebFrameWidget, then there will be no
2311 // InputMethodControllers for a WebLocalFrame. 2304 // InputMethodControllers for a WebLocalFrame.
2312 return nullptr; 2305 return nullptr;
2313 } 2306 }
2314 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) 2307 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2315 ->getActiveWebInputMethodController(); 2308 ->getActiveWebInputMethodController();
2316 } 2309 }
2317 2310
2318 } // namespace content 2311 } // namespace content
OLDNEW
« no previous file with comments | « components/test_runner/text_input_controller.cc ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698