| OLD | NEW |
| 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 Loading... |
| 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() && GetWebWidget()->isWebFrameWidget() && has_focus_; | 673 // TODO(ekaramad): We track page focus in all RenderViews on the page but the |
| 674 // RenderWidgets corresponding to OOPIFs do not get the update. For now, this |
| 675 // method returns true when the RenderWidget is for an OOPIF, i.e., IME events |
| 676 // will be processed regardless of page focus. We should revisit this after |
| 677 // page focus for OOPIFs has been fully resolved (https://crbug.com/689777). |
| 678 return GetWebWidget() && GetWebWidget()->isWebFrameWidget() && |
| 679 (has_focus_ || for_oopif_); |
| 674 } | 680 } |
| 675 | 681 |
| 676 void RenderWidget::SetWindowRectSynchronously( | 682 void RenderWidget::SetWindowRectSynchronously( |
| 677 const gfx::Rect& new_window_rect) { | 683 const gfx::Rect& new_window_rect) { |
| 678 ResizeParams params; | 684 ResizeParams params; |
| 679 params.screen_info = screen_info_; | 685 params.screen_info = screen_info_; |
| 680 params.new_size = new_window_rect.size(); | 686 params.new_size = new_window_rect.size(); |
| 681 params.physical_backing_size = | 687 params.physical_backing_size = |
| 682 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_); | 688 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_); |
| 683 params.visible_viewport_size = new_window_rect.size(); | 689 params.visible_viewport_size = new_window_rect.size(); |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 | 1604 |
| 1599 #if BUILDFLAG(ENABLE_PLUGINS) | 1605 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1600 if (focused_pepper_plugin_) { | 1606 if (focused_pepper_plugin_) { |
| 1601 focused_pepper_plugin_->render_frame()->OnImeCommitText( | 1607 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
| 1602 text, replacement_range, relative_cursor_pos); | 1608 text, replacement_range, relative_cursor_pos); |
| 1603 return; | 1609 return; |
| 1604 } | 1610 } |
| 1605 #endif | 1611 #endif |
| 1606 ImeEventGuard guard(this); | 1612 ImeEventGuard guard(this); |
| 1607 input_handler_->set_handling_input_event(true); | 1613 input_handler_->set_handling_input_event(true); |
| 1608 if (auto* controller = GetInputMethodController()) | 1614 if (auto* controller = GetInputMethodController()) { |
| 1609 controller->commitText( | 1615 controller->commitText( |
| 1610 WebString::fromUTF16(text), | 1616 WebString::fromUTF16(text), |
| 1611 WebVector<WebCompositionUnderline>(underlines), | 1617 WebVector<WebCompositionUnderline>(underlines), |
| 1612 replacement_range.IsValid() | 1618 replacement_range.IsValid() |
| 1613 ? WebRange(replacement_range.start(), replacement_range.length()) | 1619 ? WebRange(replacement_range.start(), replacement_range.length()) |
| 1614 : WebRange(), | 1620 : WebRange(), |
| 1615 relative_cursor_pos); | 1621 relative_cursor_pos); |
| 1622 } |
| 1616 input_handler_->set_handling_input_event(false); | 1623 input_handler_->set_handling_input_event(false); |
| 1617 UpdateCompositionInfo(false /* not an immediate request */); | 1624 UpdateCompositionInfo(false /* not an immediate request */); |
| 1618 } | 1625 } |
| 1619 | 1626 |
| 1620 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { | 1627 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
| 1621 if (!ShouldHandleImeEvents()) | 1628 if (!ShouldHandleImeEvents()) |
| 1622 return; | 1629 return; |
| 1623 | 1630 |
| 1624 #if BUILDFLAG(ENABLE_PLUGINS) | 1631 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1625 if (focused_pepper_plugin_) { | 1632 if (focused_pepper_plugin_) { |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 // browser side (https://crbug.com/669219). | 2309 // browser side (https://crbug.com/669219). |
| 2303 // If there is no WebFrameWidget, then there will be no | 2310 // If there is no WebFrameWidget, then there will be no |
| 2304 // InputMethodControllers for a WebLocalFrame. | 2311 // InputMethodControllers for a WebLocalFrame. |
| 2305 return nullptr; | 2312 return nullptr; |
| 2306 } | 2313 } |
| 2307 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2314 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| 2308 ->getActiveWebInputMethodController(); | 2315 ->getActiveWebInputMethodController(); |
| 2309 } | 2316 } |
| 2310 | 2317 |
| 2311 } // namespace content | 2318 } // namespace content |
| OLD | NEW |