| 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 6f75a156113a454ed6709f14b16412825f297e50..cdbdcfd30c06111a66f19c9411c26796ea5080ca 100644
|
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
|
| @@ -350,7 +350,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),
|
| @@ -2266,9 +2265,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()
|
| @@ -2290,43 +2289,47 @@ 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;
|
| }
|
| }
|
|
|
| // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as
|
| // well. This code needs to be refactored (http://crbug.com/629721).
|
| WebRange WebViewImpl::CompositionRange() {
|
| - LocalFrame* focused = FocusedLocalFrameAvailableForIme();
|
| + if (!MainFrameImpl() || !MainFrameImpl()->FrameWidget()->ime_accept_events_)
|
| + return WebRange();
|
| +
|
| + LocalFrame* focused = FocusedLocalFrameInWidget();
|
| if (!focused)
|
| return WebRange();
|
|
|
| @@ -4113,17 +4116,9 @@ 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;
|
| -}
|
| -
|
| -LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const {
|
| - return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr;
|
| + if (auto* frame = MainFrameImpl())
|
| + return frame->FrameWidget()->FocusedLocalFrame();
|
| + return nullptr;
|
| }
|
|
|
| } // namespace blink
|
|
|