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

Unified Diff: content/renderer/render_widget.cc

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Add early out to accommodate null frameWidget in webkit_unit_tests. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 8f6ffdb2189c598c6079f455a214ab1456329318..3c4d2ade9233ee38b8198b198fb75fadca29d7e6 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -87,6 +87,7 @@
#if defined(OS_ANDROID)
#include <android/keycodes.h>
+#include "base/time/time.h"
#endif
#if defined(OS_POSIX)
@@ -205,6 +206,13 @@ ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) {
namespace content {
+#if defined(OS_ANDROID)
+// Delay between tapping in content and launching the associated android intent.
+// Used to allow users see what has been recognized as content.
+constexpr base::TimeDelta kContentIntentDelay =
+ base::TimeDelta::FromMilliseconds(700);
+#endif
+
// RenderWidget ---------------------------------------------------------------
RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
@@ -248,11 +256,13 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
frame_swap_message_queue_(new FrameSwapMessageQueue()),
resizing_mode_selector_(new ResizingModeSelector()),
has_host_context_menu_location_(false),
+ has_added_input_handler_(false),
has_focus_(false),
#if defined(OS_MACOSX)
text_input_client_observer_(new TextInputClientObserver(this)),
#endif
- focused_pepper_plugin_(nullptr) {
+ focused_pepper_plugin_(nullptr),
+ weak_ptr_factory_(this) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
DCHECK(RenderThread::Get());
@@ -1130,6 +1140,30 @@ void RenderWidget::initializeLayerTreeView() {
DCHECK_NE(MSG_ROUTING_NONE, routing_id_);
compositor_->SetFrameSinkId(
cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_));
+
+ bool use_threaded_event_handling = true;
+#if defined(OS_MACOSX)
+ // Disable threaded event handling if content is not handling the elastic
+ // overscroll effect. This includes the cases where the elastic overscroll
+ // effect is being handled by Blink (because of command line flags) and older
+ // operating system versions which do not have an elastic overscroll effect
+ // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
+ use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
+#endif
+ if (!use_threaded_event_handling)
+ return;
+
+ RenderThreadImpl* render_thread = RenderThreadImpl::current();
+ // render_thread may be NULL in tests.
+ InputHandlerManager* input_handler_manager =
+ render_thread ? render_thread->input_handler_manager() : NULL;
+ if (input_handler_manager) {
+ input_handler_manager->AddInputHandler(
+ routing_id_, compositor()->GetInputHandler(),
+ weak_ptr_factory_.GetWeakPtr(),
+ compositor_deps_->IsScrollAnimatorEnabled());
+ has_added_input_handler_ = true;
+ }
}
void RenderWidget::WillCloseLayerTreeView() {
@@ -1615,6 +1649,18 @@ void RenderWidget::OnRequestTextInputStateUpdate() {
UpdateSelectionBounds();
UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
}
+
+void RenderWidget::scheduleContentIntentForRenderView(
+ const blink::WebURL& intent,
+ bool is_main_frame,
+ size_t expected_content_intent_id) {
+ // Introduce a short delay so that the user can notice the content.
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE, base::Bind(&RenderWidget::LaunchAndroidContentIntent,
+ weak_ptr_factory_.GetWeakPtr(), intent,
+ expected_content_intent_id, is_main_frame),
+ kContentIntentDelay);
+}
#endif
void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,

Powered by Google App Engine
This is Rietveld 408576698