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

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

Issue 2522353002: Remove the CHECK in RenderWidget::GetInputMethodController (Closed)
Patch Set: Addressing creis@'s comments + Removing unused forward dec. Created 4 years 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 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 } 1528 }
1529 #endif 1529 #endif
1530 if (replacement_range.IsValid()) { 1530 if (replacement_range.IsValid()) {
1531 GetWebWidget()->applyReplacementRange( 1531 GetWebWidget()->applyReplacementRange(
1532 WebRange(replacement_range.start(), replacement_range.length())); 1532 WebRange(replacement_range.start(), replacement_range.length()));
1533 } 1533 }
1534 1534
1535 if (!ShouldHandleImeEvent()) 1535 if (!ShouldHandleImeEvent())
1536 return; 1536 return;
1537 ImeEventGuard guard(this); 1537 ImeEventGuard guard(this);
1538 blink::WebInputMethodController* controller = GetInputMethodController(); 1538 blink::WebInputMethodController* controller =
1539 GetWebWidget()->getActiveInputMethodController();
1539 DCHECK(controller); 1540 DCHECK(controller);
1540 if (!controller || 1541 if (!controller ||
1541 !controller->setComposition( 1542 !controller->setComposition(
1542 text, WebVector<WebCompositionUnderline>(underlines), selection_start, 1543 text, WebVector<WebCompositionUnderline>(underlines), selection_start,
1543 selection_end)) { 1544 selection_end)) {
1544 // If we failed to set the composition text, then we need to let the browser 1545 // If we failed to set the composition text, then we need to let the browser
1545 // process to cancel the input method's ongoing composition session, to make 1546 // process to cancel the input method's ongoing composition session, to make
1546 // sure we are in a consistent state. 1547 // sure we are in a consistent state.
1547 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1548 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1548 } 1549 }
(...skipping 12 matching lines...) Expand all
1561 #endif 1562 #endif
1562 if (replacement_range.IsValid()) { 1563 if (replacement_range.IsValid()) {
1563 GetWebWidget()->applyReplacementRange( 1564 GetWebWidget()->applyReplacementRange(
1564 WebRange(replacement_range.start(), replacement_range.length())); 1565 WebRange(replacement_range.start(), replacement_range.length()));
1565 } 1566 }
1566 1567
1567 if (!ShouldHandleImeEvent()) 1568 if (!ShouldHandleImeEvent())
1568 return; 1569 return;
1569 ImeEventGuard guard(this); 1570 ImeEventGuard guard(this);
1570 input_handler_->set_handling_input_event(true); 1571 input_handler_->set_handling_input_event(true);
1571 if (auto* controller = GetInputMethodController()) 1572 if (auto* controller = GetWebWidget()->getActiveInputMethodController())
1572 controller->commitText(text, relative_cursor_pos); 1573 controller->commitText(text, relative_cursor_pos);
1573 input_handler_->set_handling_input_event(false); 1574 input_handler_->set_handling_input_event(false);
1574 UpdateCompositionInfo(false /* not an immediate request */); 1575 UpdateCompositionInfo(false /* not an immediate request */);
1575 } 1576 }
1576 1577
1577 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { 1578 void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
1578 #if BUILDFLAG(ENABLE_PLUGINS) 1579 #if BUILDFLAG(ENABLE_PLUGINS)
1579 if (focused_pepper_plugin_) { 1580 if (focused_pepper_plugin_) {
1580 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( 1581 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText(
1581 keep_selection); 1582 keep_selection);
1582 return; 1583 return;
1583 } 1584 }
1584 #endif 1585 #endif
1585 1586
1586 if (!ShouldHandleImeEvent()) 1587 if (!ShouldHandleImeEvent())
1587 return; 1588 return;
1588 ImeEventGuard guard(this); 1589 ImeEventGuard guard(this);
1589 input_handler_->set_handling_input_event(true); 1590 input_handler_->set_handling_input_event(true);
1590 if (auto* controller = GetInputMethodController()) { 1591 if (auto* controller = GetWebWidget()->getActiveInputMethodController()) {
1591 controller->finishComposingText( 1592 controller->finishComposingText(
1592 keep_selection ? WebInputMethodController::KeepSelection 1593 keep_selection ? WebInputMethodController::KeepSelection
1593 : WebInputMethodController::DoNotKeepSelection); 1594 : WebInputMethodController::DoNotKeepSelection);
1594 } 1595 }
1595 input_handler_->set_handling_input_event(false); 1596 input_handler_->set_handling_input_event(false);
1596 UpdateCompositionInfo(false /* not an immediate request */); 1597 UpdateCompositionInfo(false /* not an immediate request */);
1597 } 1598 }
1598 1599
1599 void RenderWidget::OnDeviceScaleFactorChanged() { 1600 void RenderWidget::OnDeviceScaleFactorChanged() {
1600 if (!compositor_) 1601 if (!compositor_)
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 return web_screen_info; 2134 return web_screen_info;
2134 } 2135 }
2135 2136
2136 void RenderWidget::resetInputMethod() { 2137 void RenderWidget::resetInputMethod() {
2137 ImeEventGuard guard(this); 2138 ImeEventGuard guard(this);
2138 // If the last text input type is not None, then we should finish any 2139 // If the last text input type is not None, then we should finish any
2139 // ongoing composition regardless of the new text input type. 2140 // ongoing composition regardless of the new text input type.
2140 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { 2141 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
2141 // If a composition text exists, then we need to let the browser process 2142 // If a composition text exists, then we need to let the browser process
2142 // to cancel the input method's ongoing composition session. 2143 // to cancel the input method's ongoing composition session.
2143 blink::WebInputMethodController* controller = GetInputMethodController(); 2144 blink::WebInputMethodController* controller =
2145 GetWebWidget()->getActiveInputMethodController();
2144 if (controller && 2146 if (controller &&
2145 controller->finishComposingText( 2147 controller->finishComposingText(
2146 WebInputMethodController::DoNotKeepSelection)) 2148 WebInputMethodController::DoNotKeepSelection))
2147 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 2149 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
2148 } 2150 }
2149 2151
2150 UpdateCompositionInfo(false /* not an immediate request */); 2152 UpdateCompositionInfo(false /* not an immediate request */);
2151 } 2153 }
2152 2154
2153 #if defined(OS_ANDROID) 2155 #if defined(OS_ANDROID)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); 2301 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y);
2300 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask, 2302 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask,
2301 image.getSkBitmap(), imageOffset, 2303 image.getSkBitmap(), imageOffset,
2302 possible_drag_event_info_)); 2304 possible_drag_event_info_));
2303 } 2305 }
2304 2306
2305 blink::WebWidget* RenderWidget::GetWebWidget() const { 2307 blink::WebWidget* RenderWidget::GetWebWidget() const {
2306 return webwidget_internal_; 2308 return webwidget_internal_;
2307 } 2309 }
2308 2310
2309 blink::WebInputMethodController* RenderWidget::GetInputMethodController()
2310 const {
2311 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is
2312 // always a WebFrameWidget.
2313 CHECK(GetWebWidget()->isWebFrameWidget());
2314 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2315 ->getActiveWebInputMethodController();
2316 }
2317
2318 } // namespace content 2311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698