| Index: third_party/WebKit/Source/web/WebViewImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
|
| index 9d68a6777ef6392c804aad67173f0ca12cef93b4..29e32c03b4b5b12b2686e58cb7a2af56eb4b1132 100644
|
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
|
| @@ -356,7 +356,6 @@ WebViewImpl::WebViewImpl(WebViewClient* client,
|
| fake_page_scale_animation_use_anchor_(false),
|
| compositor_device_scale_factor_override_(0),
|
| suppress_next_keypress_event_(false),
|
| - ime_accept_events_(true),
|
| dev_tools_emulator_(nullptr),
|
| tabs_to_links_(false),
|
| layer_tree_view_(nullptr),
|
| @@ -2289,9 +2288,9 @@ void WebViewImpl::MouseCaptureLost() {
|
|
|
| void WebViewImpl::SetFocus(bool enable) {
|
| page_->GetFocusController().SetFocused(enable);
|
| + LocalFrame* focused_frame = page_->GetFocusController().FocusedFrame();
|
| if (enable) {
|
| page_->GetFocusController().SetActive(true);
|
| - LocalFrame* focused_frame = page_->GetFocusController().FocusedFrame();
|
| if (focused_frame) {
|
| Element* element = focused_frame->GetDocument()->FocusedElement();
|
| if (element && focused_frame->Selection()
|
| @@ -2313,36 +2312,37 @@ void WebViewImpl::SetFocus(bool enable) {
|
| SelectionInDOMTree::Builder().Collapse(position).Build());
|
| }
|
| }
|
| + // TODO(ekaramad): We need to figure out the right way to propagate page
|
| + // focus to OOPIFs. Right now WebFrameWidgetImpl::SetFocus never gets
|
| + // called (https://crbug.com/689777).
|
| + WebLocalFrameBase::FromFrame(focused_frame->LocalFrameRoot())
|
| + ->FrameWidget()
|
| + ->ime_accept_events_ = true;
|
| }
|
| - ime_accept_events_ = true;
|
| } else {
|
| HidePopups();
|
|
|
| // Clear focus on the currently focused frame if any.
|
| - if (!page_)
|
| + if (!page_ || !focused_frame)
|
| return;
|
|
|
| - LocalFrame* frame = page_->MainFrame() && page_->MainFrame()->IsLocalFrame()
|
| - ? page_->DeprecatedLocalMainFrame()
|
| - : nullptr;
|
| - if (!frame)
|
| - return;
|
| + // Finish an ongoing composition to delete the composition node.
|
| + if (focused_frame->GetInputMethodController().HasComposition()) {
|
| + // TODO(editing-dev): The use of
|
| + // updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
|
| + // See http://crbug.com/590369 for more details.
|
| + focused_frame->GetDocument()
|
| + ->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| - LocalFrame* focused_frame = FocusedLocalFrameInWidget();
|
| - if (focused_frame) {
|
| - // Finish an ongoing composition to delete the composition node.
|
| - if (focused_frame->GetInputMethodController().HasComposition()) {
|
| - // TODO(editing-dev): The use of
|
| - // updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
|
| - // See http://crbug.com/590369 for more details.
|
| - focused_frame->GetDocument()
|
| - ->UpdateStyleAndLayoutIgnorePendingStylesheets();
|
| -
|
| - focused_frame->GetInputMethodController().FinishComposingText(
|
| - InputMethodController::kKeepSelection);
|
| + focused_frame->GetInputMethodController().FinishComposingText(
|
| + InputMethodController::kKeepSelection);
|
| }
|
| - ime_accept_events_ = false;
|
| - }
|
| + // TODO(ekaramad): We need to figure out the right way to propagate page
|
| + // focus to OOPIFs. Right now WebFrameWidgetImpl::SetFocus never gets
|
| + // called (https://crbug.com/689777).
|
| + WebLocalFrameBase::FromFrame(focused_frame->LocalFrameRoot())
|
| + ->FrameWidget()
|
| + ->ime_accept_events_ = false;
|
| }
|
| }
|
|
|
| @@ -4141,17 +4141,15 @@ float WebViewImpl::DeviceScaleFactor() const {
|
| }
|
|
|
| LocalFrame* WebViewImpl::FocusedLocalFrameInWidget() const {
|
| - if (!MainFrameImpl())
|
| - return nullptr;
|
| -
|
| - LocalFrame* focused_frame = ToLocalFrame(FocusedCoreFrame());
|
| - if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame())
|
| - return nullptr;
|
| - return focused_frame;
|
| + if (auto* frame = MainFrameImpl())
|
| + return frame->FrameWidget()->FocusedLocalFrameInWidget();
|
| + return nullptr;
|
| }
|
|
|
| LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const {
|
| - return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr;
|
| + if (auto* frame = MainFrameImpl())
|
| + return frame->FrameWidget()->FocusedLocalFrameAvailableForIme();
|
| + return nullptr;
|
| }
|
|
|
| } // namespace blink
|
|
|