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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2451143003: <webview>: Correctly shift focus between WebContents. (Closed)
Patch Set: forgot rebase Created 4 years, 1 month 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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 void RenderWidgetHostImpl::GotFocus() { 680 void RenderWidgetHostImpl::GotFocus() {
681 Focus(); 681 Focus();
682 if (owner_delegate_) 682 if (owner_delegate_)
683 owner_delegate_->RenderWidgetGotFocus(); 683 owner_delegate_->RenderWidgetGotFocus();
684 if (delegate_) 684 if (delegate_)
685 delegate_->RenderWidgetGotFocus(this); 685 delegate_->RenderWidgetGotFocus(this);
686 } 686 }
687 687
688 void RenderWidgetHostImpl::Focus() { 688 void RenderWidgetHostImpl::Focus() {
689 is_focused_ = true; 689 RenderWidgetHostImpl* focused_widget =
690 delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr;
690 691
691 Send(new InputMsg_SetFocus(routing_id_, true)); 692 (focused_widget ? focused_widget : this)->SetPageFocus(true);
693 }
694
695 void RenderWidgetHostImpl::Blur() {
696 RenderWidgetHostImpl* focused_widget =
697 delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr;
698
699 (focused_widget ? focused_widget : this)->SetPageFocus(false);
700 }
701
702 void RenderWidgetHostImpl::SetPageFocus(bool focused) {
703 is_focused_ = focused;
704
705 if (!focused) {
706 // If there is a pending mouse lock request, we don't want to reject it at
707 // this point. The user can switch focus back to this view and approve the
708 // request later.
709 if (IsMouseLocked())
710 view_->UnlockMouse();
711
712 if (touch_emulator_)
713 touch_emulator_->CancelTouch();
714 }
715
716 Send(new InputMsg_SetFocus(routing_id_, focused));
692 717
693 // Also send page-level focus state to other SiteInstances involved in 718 // Also send page-level focus state to other SiteInstances involved in
694 // rendering the current FrameTree. 719 // rendering the current FrameTree.
695 if (RenderViewHost::From(this) && delegate_) 720 if (RenderViewHost::From(this) && delegate_)
696 delegate_->ReplicatePageFocus(true); 721 delegate_->ReplicatePageFocus(focused);
697 }
698
699 void RenderWidgetHostImpl::Blur() {
700 is_focused_ = false;
701
702 // If there is a pending mouse lock request, we don't want to reject it at
703 // this point. The user can switch focus back to this view and approve the
704 // request later.
705 if (IsMouseLocked())
706 view_->UnlockMouse();
707
708 if (touch_emulator_)
709 touch_emulator_->CancelTouch();
710
711 Send(new InputMsg_SetFocus(routing_id_, false));
712
713 // Also send page-level focus state to other SiteInstances involved in
714 // rendering the current FrameTree.
715 if (RenderViewHost::From(this) && delegate_)
716 delegate_->ReplicatePageFocus(false);
717 } 722 }
718 723
719 void RenderWidgetHostImpl::LostCapture() { 724 void RenderWidgetHostImpl::LostCapture() {
720 if (touch_emulator_) 725 if (touch_emulator_)
721 touch_emulator_->CancelTouch(); 726 touch_emulator_->CancelTouch();
722 727
723 Send(new InputMsg_MouseCaptureLost(routing_id_)); 728 Send(new InputMsg_MouseCaptureLost(routing_id_));
724 729
725 if (delegate_) 730 if (delegate_)
726 delegate_->LostCapture(this); 731 delegate_->LostCapture(this);
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { 1883 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) {
1879 // Don't ignore touch cancel events, since they may be sent while input 1884 // Don't ignore touch cancel events, since they may be sent while input
1880 // events are being ignored in order to keep the renderer from getting 1885 // events are being ignored in order to keep the renderer from getting
1881 // confused about how many touches are active. 1886 // confused about how many touches are active.
1882 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) 1887 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel)
1883 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 1888 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
1884 1889
1885 if (!process_->HasConnection()) 1890 if (!process_->HasConnection())
1886 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1891 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1887 1892
1888 if (delegate_ && (event.type == WebInputEvent::MouseDown || 1893 if (delegate_) {
1889 event.type == WebInputEvent::GestureScrollBegin || 1894 if (event.type == WebInputEvent::MouseDown ||
1890 event.type == WebInputEvent::TouchStart || 1895 event.type == WebInputEvent::TouchStart) {
1891 event.type == WebInputEvent::RawKeyDown)) { 1896 delegate_->EnsureOwningContentsIsFocused(this);
1892 delegate_->OnUserInteraction(this, event.type); 1897 }
1898 if (event.type == WebInputEvent::MouseDown ||
1899 event.type == WebInputEvent::GestureScrollBegin ||
1900 event.type == WebInputEvent::TouchStart ||
1901 event.type == WebInputEvent::RawKeyDown) {
1902 delegate_->OnUserInteraction(this, event.type);
1903 }
1893 } 1904 }
1894 1905
1895 return view_ ? view_->FilterInputEvent(event) 1906 return view_ ? view_->FilterInputEvent(event)
1896 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1907 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1897 } 1908 }
1898 1909
1899 void RenderWidgetHostImpl::IncrementInFlightEventCount( 1910 void RenderWidgetHostImpl::IncrementInFlightEventCount(
1900 blink::WebInputEvent::Type event_type) { 1911 blink::WebInputEvent::Type event_type) {
1901 increment_in_flight_event_count(); 1912 increment_in_flight_event_count();
1902 if (!is_hidden_) { 1913 if (!is_hidden_) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2226 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2216 } 2227 }
2217 2228
2218 BrowserAccessibilityManager* 2229 BrowserAccessibilityManager*
2219 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2230 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2220 return delegate_ ? 2231 return delegate_ ?
2221 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2232 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2222 } 2233 }
2223 2234
2224 } // namespace content 2235 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698