summaryrefslogtreecommitdiffstats
path: root/chromium/content/renderer/render_widget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/renderer/render_widget.cc')
-rw-r--r--chromium/content/renderer/render_widget.cc835
1 files changed, 554 insertions, 281 deletions
diff --git a/chromium/content/renderer/render_widget.cc b/chromium/content/renderer/render_widget.cc
index dc4a9025a13..852e94e1c8b 100644
--- a/chromium/content/renderer/render_widget.cc
+++ b/chromium/content/renderer/render_widget.cc
@@ -16,44 +16,49 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
+#include "cc/debug/benchmark_instrumentation.h"
#include "cc/output/output_surface.h"
#include "cc/trees/layer_tree_host.h"
#include "content/child/npapi/webplugin.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
+#include "content/common/gpu/gpu_process_launch_causes.h"
+#include "content/common/input/synthetic_gesture_packet.h"
+#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/cursor_utils.h"
+#include "content/renderer/external_popup_menu.h"
#include "content/renderer/gpu/compositor_output_surface.h"
#include "content/renderer/gpu/compositor_software_output_device.h"
#include "content/renderer/gpu/delegated_compositor_output_surface.h"
-#include "content/renderer/gpu/input_handler_manager.h"
#include "content/renderer/gpu/mailbox_output_surface.h"
#include "content/renderer/gpu/render_widget_compositor.h"
#include "content/renderer/ime_event_guard.h"
+#include "content/renderer/input/input_handler_manager.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/render_process.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_webkitplatformsupport_impl.h"
+#include "content/renderer/resizing_mode_selector.h"
#include "ipc/ipc_sync_message.h"
#include "skia/ext/platform_canvas.h"
+#include "third_party/WebKit/public/platform/WebCursorInfo.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
-#include "third_party/WebKit/public/platform/WebPoint.h"
#include "third_party/WebKit/public/platform/WebRect.h"
+#include "third_party/WebKit/public/platform/WebScreenInfo.h"
#include "third_party/WebKit/public/platform/WebSize.h"
#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/web/WebCursorInfo.h"
#include "third_party/WebKit/public/web/WebHelperPlugin.h"
#include "third_party/WebKit/public/web/WebPagePopup.h"
#include "third_party/WebKit/public/web/WebPopupMenu.h"
#include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
#include "third_party/WebKit/public/web/WebRange.h"
-#include "third_party/WebKit/public/web/WebScreenInfo.h"
#include "third_party/skia/include/core/SkShader.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/gfx/point.h"
+#include "ui/gfx/frame_time.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/skia_util.h"
@@ -74,72 +79,29 @@
#include "third_party/WebKit/public/web/WebWidget.h"
-using WebKit::WebCompositionUnderline;
-using WebKit::WebCursorInfo;
-using WebKit::WebGestureEvent;
-using WebKit::WebInputEvent;
-using WebKit::WebKeyboardEvent;
-using WebKit::WebMouseEvent;
-using WebKit::WebNavigationPolicy;
-using WebKit::WebPagePopup;
-using WebKit::WebPoint;
-using WebKit::WebPopupMenu;
-using WebKit::WebPopupMenuInfo;
-using WebKit::WebPopupType;
-using WebKit::WebRange;
-using WebKit::WebRect;
-using WebKit::WebScreenInfo;
-using WebKit::WebSize;
-using WebKit::WebTextDirection;
-using WebKit::WebTouchEvent;
-using WebKit::WebVector;
-using WebKit::WebWidget;
+using blink::WebCompositionUnderline;
+using blink::WebCursorInfo;
+using blink::WebGestureEvent;
+using blink::WebInputEvent;
+using blink::WebKeyboardEvent;
+using blink::WebMouseEvent;
+using blink::WebMouseWheelEvent;
+using blink::WebNavigationPolicy;
+using blink::WebPagePopup;
+using blink::WebPopupMenu;
+using blink::WebPopupMenuInfo;
+using blink::WebPopupType;
+using blink::WebRange;
+using blink::WebRect;
+using blink::WebScreenInfo;
+using blink::WebSize;
+using blink::WebTextDirection;
+using blink::WebTouchEvent;
+using blink::WebTouchPoint;
+using blink::WebVector;
+using blink::WebWidget;
namespace {
-const char* GetEventName(WebInputEvent::Type type) {
-#define CASE_TYPE(t) case WebInputEvent::t: return #t
- switch(type) {
- CASE_TYPE(Undefined);
- CASE_TYPE(MouseDown);
- CASE_TYPE(MouseUp);
- CASE_TYPE(MouseMove);
- CASE_TYPE(MouseEnter);
- CASE_TYPE(MouseLeave);
- CASE_TYPE(ContextMenu);
- CASE_TYPE(MouseWheel);
- CASE_TYPE(RawKeyDown);
- CASE_TYPE(KeyDown);
- CASE_TYPE(KeyUp);
- CASE_TYPE(Char);
- CASE_TYPE(GestureScrollBegin);
- CASE_TYPE(GestureScrollEnd);
- CASE_TYPE(GestureScrollUpdate);
- CASE_TYPE(GestureFlingStart);
- CASE_TYPE(GestureFlingCancel);
- CASE_TYPE(GestureTap);
- CASE_TYPE(GestureTapUnconfirmed);
- CASE_TYPE(GestureTapDown);
- CASE_TYPE(GestureTapCancel);
- CASE_TYPE(GestureDoubleTap);
- CASE_TYPE(GestureTwoFingerTap);
- CASE_TYPE(GestureLongPress);
- CASE_TYPE(GestureLongTap);
- CASE_TYPE(GesturePinchBegin);
- CASE_TYPE(GesturePinchEnd);
- CASE_TYPE(GesturePinchUpdate);
- CASE_TYPE(TouchStart);
- CASE_TYPE(TouchMove);
- CASE_TYPE(TouchEnd);
- CASE_TYPE(TouchCancel);
- default:
- // Must include default to let WebKit::WebInputEvent add new event types
- // before they're added here.
- DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n";
- break;
- }
-#undef CASE_TYPE
- return "";
-}
typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
@@ -148,47 +110,229 @@ class TextInputModeMapSingleton {
static TextInputModeMapSingleton* GetInstance() {
return Singleton<TextInputModeMapSingleton>::get();
}
- TextInputModeMapSingleton()
- : map() {
- map["verbatim"] = ui::TEXT_INPUT_MODE_VERBATIM;
- map["latin"] = ui::TEXT_INPUT_MODE_LATIN;
- map["latin-name"] = ui::TEXT_INPUT_MODE_LATIN_NAME;
- map["latin-prose"] = ui::TEXT_INPUT_MODE_LATIN_PROSE;
- map["full-width-latin"] = ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN;
- map["kana"] = ui::TEXT_INPUT_MODE_KANA;
- map["katakana"] = ui::TEXT_INPUT_MODE_KATAKANA;
- map["numeric"] = ui::TEXT_INPUT_MODE_NUMERIC;
- map["tel"] = ui::TEXT_INPUT_MODE_TEL;
- map["email"] = ui::TEXT_INPUT_MODE_EMAIL;
- map["url"] = ui::TEXT_INPUT_MODE_URL;
- }
- TextInputModeMap& Map() {
- return map;
- }
+ TextInputModeMapSingleton() {
+ map_["verbatim"] = ui::TEXT_INPUT_MODE_VERBATIM;
+ map_["latin"] = ui::TEXT_INPUT_MODE_LATIN;
+ map_["latin-name"] = ui::TEXT_INPUT_MODE_LATIN_NAME;
+ map_["latin-prose"] = ui::TEXT_INPUT_MODE_LATIN_PROSE;
+ map_["full-width-latin"] = ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN;
+ map_["kana"] = ui::TEXT_INPUT_MODE_KANA;
+ map_["katakana"] = ui::TEXT_INPUT_MODE_KATAKANA;
+ map_["numeric"] = ui::TEXT_INPUT_MODE_NUMERIC;
+ map_["tel"] = ui::TEXT_INPUT_MODE_TEL;
+ map_["email"] = ui::TEXT_INPUT_MODE_EMAIL;
+ map_["url"] = ui::TEXT_INPUT_MODE_URL;
+ }
+ const TextInputModeMap& map() const { return map_; }
private:
- TextInputModeMap map;
+ TextInputModeMap map_;
friend struct DefaultSingletonTraits<TextInputModeMapSingleton>;
DISALLOW_COPY_AND_ASSIGN(TextInputModeMapSingleton);
};
-ui::TextInputMode ConvertInputMode(
- const WebKit::WebString& input_mode) {
+ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) {
static TextInputModeMapSingleton* singleton =
TextInputModeMapSingleton::GetInstance();
- TextInputModeMap::iterator it = singleton->Map().find(input_mode.utf8());
- if (it == singleton->Map().end())
+ TextInputModeMap::const_iterator it =
+ singleton->map().find(input_mode.utf8());
+ if (it == singleton->map().end())
return ui::TEXT_INPUT_MODE_DEFAULT;
return it->second;
}
+// TODO(brianderson): Replace the hard-coded threshold with a fraction of
+// the BeginMainFrame interval.
+// 4166us will allow 1/4 of a 60Hz interval or 1/2 of a 120Hz interval to
+// be spent in input hanlders before input starts getting throttled.
+const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166;
+
} // namespace
namespace content {
-RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
- const WebKit::WebScreenInfo& screen_info,
+// RenderWidget::ScreenMetricsEmulator ----------------------------------------
+
+class RenderWidget::ScreenMetricsEmulator {
+ public:
+ ScreenMetricsEmulator(
+ RenderWidget* widget,
+ const gfx::Rect& device_rect,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view);
+ virtual ~ScreenMetricsEmulator();
+
+ float scale() { return scale_; }
+ gfx::Point offset() { return offset_; }
+ gfx::Rect widget_rect() const { return widget_rect_; }
+ gfx::Rect original_screen_rect() const { return original_view_screen_rect_; }
+
+ void ChangeEmulationParams(
+ const gfx::Rect& device_rect,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view);
+
+ // The following methods alter handlers' behavior for messages related to
+ // widget size and position.
+ void OnResizeMessage(const ViewMsg_Resize_Params& params);
+ void OnUpdateScreenRectsMessage(const gfx::Rect& view_screen_rect,
+ const gfx::Rect& window_screen_rect);
+ void OnShowContextMenu(ContextMenuParams* params);
+
+ private:
+ void Apply(float overdraw_bottom_height,
+ gfx::Rect resizer_rect, bool is_fullscreen);
+
+ RenderWidget* widget_;
+
+ // Parameters as passed by RenderWidget::EnableScreenMetricsEmulation.
+ gfx::Rect device_rect_;
+ gfx::Rect widget_rect_;
+ float device_scale_factor_;
+ bool fit_to_view_;
+
+ // The computed scale and offset used to fit widget into browser window.
+ float scale_;
+ gfx::Point offset_;
+
+ // Original values to restore back after emulation ends.
+ gfx::Size original_size_;
+ gfx::Size original_physical_backing_size_;
+ blink::WebScreenInfo original_screen_info_;
+ gfx::Rect original_view_screen_rect_;
+ gfx::Rect original_window_screen_rect_;
+};
+
+RenderWidget::ScreenMetricsEmulator::ScreenMetricsEmulator(
+ RenderWidget* widget,
+ const gfx::Rect& device_rect,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view)
+ : widget_(widget),
+ device_rect_(device_rect),
+ widget_rect_(widget_rect),
+ device_scale_factor_(device_scale_factor),
+ fit_to_view_(fit_to_view),
+ scale_(1.f) {
+ original_size_ = widget_->size_;
+ original_physical_backing_size_ = widget_->physical_backing_size_;
+ original_screen_info_ = widget_->screen_info_;
+ original_view_screen_rect_ = widget_->view_screen_rect_;
+ original_window_screen_rect_ = widget_->window_screen_rect_;
+ Apply(widget_->overdraw_bottom_height_,
+ widget_->resizer_rect_, widget_->is_fullscreen_);
+}
+
+RenderWidget::ScreenMetricsEmulator::~ScreenMetricsEmulator() {
+ widget_->screen_info_ = original_screen_info_;
+
+ widget_->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor);
+ widget_->SetScreenMetricsEmulationParameters(0.f, gfx::Point(), 1.f);
+ widget_->view_screen_rect_ = original_view_screen_rect_;
+ widget_->window_screen_rect_ = original_window_screen_rect_;
+ widget_->Resize(original_size_, original_physical_backing_size_,
+ widget_->overdraw_bottom_height_, widget_->resizer_rect_,
+ widget_->is_fullscreen_, NO_RESIZE_ACK);
+}
+
+void RenderWidget::ScreenMetricsEmulator::ChangeEmulationParams(
+ const gfx::Rect& device_rect,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view) {
+ device_rect_ = device_rect;
+ widget_rect_ = widget_rect;
+ device_scale_factor_ = device_scale_factor;
+ fit_to_view_ = fit_to_view;
+ Apply(widget_->overdraw_bottom_height_,
+ widget_->resizer_rect_, widget_->is_fullscreen_);
+}
+
+void RenderWidget::ScreenMetricsEmulator::Apply(
+ float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) {
+ if (fit_to_view_) {
+ DCHECK(!original_size_.IsEmpty());
+
+ int width_with_gutter =
+ std::max(original_size_.width() - 2 * device_rect_.x(), 1);
+ int height_with_gutter =
+ std::max(original_size_.height() - 2 * device_rect_.y(), 1);
+ float width_ratio =
+ static_cast<float>(widget_rect_.width()) / width_with_gutter;
+ float height_ratio =
+ static_cast<float>(widget_rect_.height()) / height_with_gutter;
+ float ratio = std::max(1.0f, std::max(width_ratio, height_ratio));
+ scale_ = 1.f / ratio;
+ } else {
+ scale_ = 1.f;
+ }
+
+ // Center emulated view inside available view space.
+ offset_.set_x((original_size_.width() - scale_ * widget_rect_.width()) / 2);
+ offset_.set_y((original_size_.height() - scale_ * widget_rect_.height()) / 2);
+
+ widget_->screen_info_.rect = gfx::Rect(device_rect_.size());
+ widget_->screen_info_.availableRect = gfx::Rect(device_rect_.size());
+ widget_->screen_info_.deviceScaleFactor = device_scale_factor_;
+
+ // Pass three emulation parameters to the blink side:
+ // - we keep the real device scale factor in compositor to produce sharp image
+ // even when emulating different scale factor;
+ // - in order to fit into view, WebView applies offset and scale to the
+ // root layer.
+ widget_->SetScreenMetricsEmulationParameters(
+ original_screen_info_.deviceScaleFactor, offset_, scale_);
+
+ widget_->SetDeviceScaleFactor(device_scale_factor_);
+ widget_->view_screen_rect_ = widget_rect_;
+ widget_->window_screen_rect_ = widget_->screen_info_.availableRect;
+
+ gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize(
+ original_size_, original_screen_info_.deviceScaleFactor));
+ widget_->Resize(widget_rect_.size(), physical_backing_size,
+ overdraw_bottom_height, resizer_rect, is_fullscreen, NO_RESIZE_ACK);
+}
+
+void RenderWidget::ScreenMetricsEmulator::OnResizeMessage(
+ const ViewMsg_Resize_Params& params) {
+ bool need_ack = params.new_size != original_size_ &&
+ !params.new_size.IsEmpty() && !params.physical_backing_size.IsEmpty();
+ original_size_ = params.new_size;
+ original_physical_backing_size_ = params.physical_backing_size;
+ original_screen_info_ = params.screen_info;
+ Apply(params.overdraw_bottom_height, params.resizer_rect,
+ params.is_fullscreen);
+
+ if (need_ack) {
+ widget_->set_next_paint_is_resize_ack();
+ if (widget_->compositor_)
+ widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_));
+ }
+}
+
+void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage(
+ const gfx::Rect& view_screen_rect,
+ const gfx::Rect& window_screen_rect) {
+ original_view_screen_rect_ = view_screen_rect;
+ original_window_screen_rect_ = window_screen_rect;
+}
+
+void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu(
+ ContextMenuParams* params) {
+ params->x *= scale_;
+ params->x += offset_.x();
+ params->y *= scale_;
+ params->y += offset_.y();
+}
+
+// RenderWidget ---------------------------------------------------------------
+
+RenderWidget::RenderWidget(blink::WebPopupType popup_type,
+ const blink::WebScreenInfo& screen_info,
bool swapped_out,
bool hidden)
: routing_id_(MSG_ROUTING_NONE),
@@ -212,6 +356,7 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
has_focus_(false),
handling_input_event_(false),
handling_ime_event_(false),
+ handling_touchstart_event_(false),
closing_(false),
is_swapped_out_(swapped_out),
input_method_is_active_(false),
@@ -232,7 +377,8 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
#if defined(OS_ANDROID)
outstanding_ime_acks_(0),
#endif
- weak_ptr_factory_(this) {
+ popup_origin_scale_for_emulation_(0.f),
+ resizing_mode_selector_(new ResizingModeSelector()) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
DCHECK(RenderThread::Get());
@@ -266,8 +412,8 @@ RenderWidget::~RenderWidget() {
// static
RenderWidget* RenderWidget::Create(int32 opener_id,
- WebKit::WebPopupType popup_type,
- const WebKit::WebScreenInfo& screen_info) {
+ blink::WebPopupType popup_type,
+ const blink::WebScreenInfo& screen_info) {
DCHECK(opener_id != MSG_ROUTING_NONE);
scoped_refptr<RenderWidget> widget(
new RenderWidget(popup_type, screen_info, false, false));
@@ -280,15 +426,15 @@ RenderWidget* RenderWidget::Create(int32 opener_id,
// static
WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
switch (render_widget->popup_type_) {
- case WebKit::WebPopupTypeNone: // Nothing to create.
+ case blink::WebPopupTypeNone: // Nothing to create.
break;
- case WebKit::WebPopupTypeSelect:
- case WebKit::WebPopupTypeSuggestion:
+ case blink::WebPopupTypeSelect:
+ case blink::WebPopupTypeSuggestion:
return WebPopupMenu::create(render_widget);
- case WebKit::WebPopupTypePage:
+ case blink::WebPopupTypePage:
return WebPagePopup::create(render_widget);
- case WebKit::WebPopupTypeHelperPlugin:
- return WebKit::WebHelperPlugin::create(render_widget);
+ case blink::WebPopupTypeHelperPlugin:
+ return blink::WebHelperPlugin::create(render_widget);
default:
NOTREACHED();
}
@@ -370,6 +516,63 @@ bool RenderWidget::UsingSynchronousRendererCompositor() const {
#endif
}
+void RenderWidget::EnableScreenMetricsEmulation(
+ const gfx::Rect& device_rect,
+ const gfx::Rect& widget_rect,
+ float device_scale_factor,
+ bool fit_to_view) {
+ if (!screen_metrics_emulator_) {
+ screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this,
+ device_rect, widget_rect, device_scale_factor, fit_to_view));
+ } else {
+ screen_metrics_emulator_->ChangeEmulationParams(device_rect,
+ widget_rect, device_scale_factor, fit_to_view);
+ }
+}
+
+void RenderWidget::DisableScreenMetricsEmulation() {
+ screen_metrics_emulator_.reset();
+}
+
+void RenderWidget::SetPopupOriginAdjustmentsForEmulation(
+ ScreenMetricsEmulator* emulator) {
+ popup_origin_scale_for_emulation_ = emulator->scale();
+ popup_view_origin_for_emulation_ = emulator->widget_rect().origin();
+ popup_screen_origin_for_emulation_ = gfx::Point(
+ emulator->original_screen_rect().origin().x() + emulator->offset().x(),
+ emulator->original_screen_rect().origin().y() + emulator->offset().y());
+}
+
+void RenderWidget::SetScreenMetricsEmulationParameters(
+ float device_scale_factor,
+ const gfx::Point& root_layer_offset,
+ float root_layer_scale) {
+ // This is only supported in RenderView.
+ NOTREACHED();
+}
+
+void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation(
+ ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) {
+ popup->SetOriginScaleAndOffsetForEmulation(
+ emulator->scale(), emulator->offset());
+}
+
+void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
+ if (screen_metrics_emulator_)
+ screen_metrics_emulator_->OnShowContextMenu(params);
+}
+
+void RenderWidget::ScheduleCompositeWithForcedRedraw() {
+ if (compositor_) {
+ // Regardless of whether threaded compositing is enabled, always
+ // use this mechanism to force the compositor to redraw. However,
+ // the invalidation code path below is still needed for the
+ // non-threaded case.
+ compositor_->SetNeedsForcedRedraw();
+ }
+ scheduleComposite();
+}
+
bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
@@ -378,6 +581,8 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
OnCursorVisibilityChange)
IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
+ IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
+ OnSyntheticGestureCompleted)
IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
@@ -386,20 +591,20 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
- IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK,
- OnViewContextSwapBuffersComplete)
+ IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
+ IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowShown, OnCandidateWindowShown)
+ IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowUpdated,
+ OnCandidateWindowUpdated)
+ IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowHidden, OnCandidateWindowHidden)
IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
- IPC_MESSAGE_HANDLER(ViewMsg_SyntheticGestureCompleted,
- OnSyntheticGestureCompleted)
IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
#if defined(OS_ANDROID)
- IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged)
IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
#endif
@@ -434,8 +639,7 @@ void RenderWidget::Resize(const gfx::Size& new_size,
const gfx::Rect& resizer_rect,
bool is_fullscreen,
ResizeAck resize_ack) {
- if (!RenderThreadImpl::current() || // Will be NULL during unit tests.
- !RenderThreadImpl::current()->layout_test_mode()) {
+ if (resizing_mode_selector_->NeverUsesSynchronousResize()) {
// A resize ack shouldn't be requested if we have not ACK'd the previous
// one.
DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack());
@@ -474,14 +678,12 @@ void RenderWidget::Resize(const gfx::Size& new_size,
// send an ACK if we are resized to a non-empty rect.
webwidget_->resize(new_size);
- if (!RenderThreadImpl::current() || // Will be NULL during unit tests.
- !RenderThreadImpl::current()->layout_test_mode()) {
+ if (resizing_mode_selector_->NeverUsesSynchronousResize()) {
// Resize should have caused an invalidation of the entire view.
DCHECK(new_size.IsEmpty() || is_accelerated_compositing_active_ ||
paint_aggregator_.HasPendingUpdate());
}
- } else if (!RenderThreadImpl::current() || // Will be NULL during unit tests.
- !RenderThreadImpl::current()->layout_test_mode()) {
+ } else if (!resizing_mode_selector_->is_synchronous_mode()) {
resize_ack = NO_RESIZE_ACK;
}
@@ -503,6 +705,15 @@ void RenderWidget::Resize(const gfx::Size& new_size,
DCHECK(resize_ack != SEND_RESIZE_ACK || next_paint_is_resize_ack());
}
+void RenderWidget::ResizeSynchronously(const gfx::Rect& new_position) {
+ Resize(new_position.size(), new_position.size(), overdraw_bottom_height_,
+ gfx::Rect(), is_fullscreen_, NO_RESIZE_ACK);
+ view_screen_rect_ = new_position;
+ window_screen_rect_ = new_position;
+ if (!did_show_)
+ initial_pos_ = new_position;
+}
+
void RenderWidget::OnClose() {
if (closing_)
return;
@@ -533,6 +744,14 @@ void RenderWidget::OnCreatingNewAck() {
}
void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) {
+ if (resizing_mode_selector_->ShouldAbortOnResize(this, params))
+ return;
+
+ if (screen_metrics_emulator_) {
+ screen_metrics_emulator_->OnResizeMessage(params);
+ return;
+ }
+
screen_info_ = params.screen_info;
SetDeviceScaleFactor(screen_info_.deviceScaleFactor);
Resize(params.new_size, params.physical_backing_size,
@@ -586,6 +805,8 @@ void RenderWidget::OnWasShown(bool needs_repainting) {
if (!is_accelerated_compositing_active_) {
didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
} else {
+ if (compositor_)
+ compositor_->SetNeedsForcedRedraw();
scheduleComposite();
}
}
@@ -667,7 +888,7 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
// be optimized to resolve directly into the IOSurface shared between the
// GPU and browser processes. For these reasons and to avoid platform
// disparities we explicitly disable antialiasing.
- WebKit::WebGraphicsContext3D::Attributes attributes;
+ blink::WebGraphicsContext3D::Attributes attributes;
attributes.antialias = false;
attributes.shareResources = true;
attributes.noAutomaticFlushes = true;
@@ -675,9 +896,6 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
attributes.stencil = false;
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing))
- attributes.stencil = true;
-
scoped_refptr<ContextProviderCommandBuffer> context_provider;
if (!fallback) {
context_provider = ContextProviderCommandBuffer::Create(
@@ -736,7 +954,7 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
use_swap_compositor_frame_message));
}
-void RenderWidget::OnViewContextSwapBuffersAborted() {
+void RenderWidget::OnSwapBuffersAborted() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
while (!updates_pending_swap_.empty()) {
ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
@@ -752,7 +970,7 @@ void RenderWidget::OnViewContextSwapBuffersAborted() {
scheduleComposite();
}
-void RenderWidget::OnViewContextSwapBuffersPosted() {
+void RenderWidget::OnSwapBuffersPosted() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
if (using_asynchronous_swapbuffers_) {
@@ -769,7 +987,7 @@ void RenderWidget::OnViewContextSwapBuffersPosted() {
}
}
-void RenderWidget::OnViewContextSwapBuffersComplete() {
+void RenderWidget::OnSwapBuffersComplete() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
// Notify subclasses that composited rendering was flushed to the screen.
@@ -819,8 +1037,8 @@ void RenderWidget::OnViewContextSwapBuffersComplete() {
DoDeferredUpdateAndSendInputAck();
}
-void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
- const ui::LatencyInfo& latency_info,
+void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
+ ui::LatencyInfo latency_info,
bool is_keyboard_shortcut) {
handling_input_event_ = true;
if (!input_event) {
@@ -828,14 +1046,23 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
return;
}
- const char* const event_name = GetEventName(input_event->type);
+ base::TimeTicks start_time;
+ if (base::TimeTicks::IsHighResNowFastAndReliable())
+ start_time = base::TimeTicks::HighResNow();
+
+ const char* const event_name =
+ WebInputEventTraits::GetName(input_event->type);
TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent",
"event", event_name);
- if (compositor_)
- compositor_->SetLatencyInfo(latency_info);
- else
+ scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor;
+
+ if (compositor_) {
+ latency_info_swap_promise_monitor =
+ compositor_->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass();
+ } else {
latency_info_.MergeWith(latency_info);
+ }
base::TimeDelta now = base::TimeDelta::FromInternalValue(
base::TimeTicks::Now().ToInternalValue());
@@ -878,6 +1105,9 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
input_event->type == WebInputEvent::GestureLongPress)
resetInputMethod();
+ if (input_event->type == WebInputEvent::TouchStart)
+ handling_touchstart_event_ = true;
+
bool processed = prevent_default;
if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
suppress_next_char_events_ = false;
@@ -885,6 +1115,8 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
processed = webwidget_->handleInputEvent(*input_event);
}
+ handling_touchstart_event_ = false;
+
// If this RawKeyDown event corresponds to a browser keyboard shortcut and
// it's not processed by webkit, then we need to suppress the upcoming Char
// events.
@@ -896,41 +1128,66 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
if (!processed && input_event->type == WebInputEvent::TouchStart) {
const WebTouchEvent& touch_event =
*static_cast<const WebTouchEvent*>(input_event);
- ack_result = HasTouchEventHandlersAt(touch_event.touches[0].position) ?
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED :
- INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
+ // Hit-test for all the pressed touch points. If there is a touch-handler
+ // for any of the touch points, then the renderer should continue to receive
+ // touch events.
+ ack_result = INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
+ for (size_t i = 0; i < touch_event.touchesLength; ++i) {
+ if (touch_event.touches[i].state == WebTouchPoint::StatePressed &&
+ HasTouchEventHandlersAt(touch_event.touches[i].position)) {
+ ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
+ break;
+ }
+ }
}
- IPC::Message* response =
- new InputHostMsg_HandleInputEvent_ACK(routing_id_,
- input_event->type,
- ack_result,
- latency_info);
- bool event_type_gets_rate_limited =
+ bool event_type_can_be_rate_limited =
input_event->type == WebInputEvent::MouseMove ||
input_event->type == WebInputEvent::MouseWheel ||
- WebInputEvent::isTouchEventType(input_event->type);
+ input_event->type == WebInputEvent::TouchMove;
bool frame_pending = paint_aggregator_.HasPendingUpdate();
if (is_accelerated_compositing_active_) {
frame_pending = compositor_ &&
- compositor_->commitRequested();
- }
-
- if (event_type_gets_rate_limited && frame_pending && !is_hidden_) {
- // We want to rate limit the input events in this case, so we'll wait for
- // painting to finish before ACKing this message.
- if (pending_input_event_ack_) {
- // As two different kinds of events could cause us to postpone an ack
- // we send it now, if we have one pending. The Browser should never
- // send us the same kind of event we are delaying the ack for.
- Send(pending_input_event_ack_.release());
+ compositor_->BeginMainFrameRequested();
+ }
+
+ // If we don't have a fast and accurate HighResNow, we assume the input
+ // handlers are heavy and rate limit them.
+ bool rate_limiting_wanted = true;
+ if (base::TimeTicks::IsHighResNowFastAndReliable()) {
+ base::TimeTicks end_time = base::TimeTicks::HighResNow();
+ total_input_handling_time_this_frame_ += (end_time - start_time);
+ rate_limiting_wanted =
+ total_input_handling_time_this_frame_.InMicroseconds() >
+ kInputHandlingTimeThrottlingThresholdMicroseconds;
+ }
+
+ if (!WebInputEventTraits::IgnoresAckDisposition(input_event->type)) {
+ scoped_ptr<IPC::Message> response(
+ new InputHostMsg_HandleInputEvent_ACK(routing_id_,
+ input_event->type,
+ ack_result,
+ latency_info));
+ if (rate_limiting_wanted && event_type_can_be_rate_limited &&
+ frame_pending && !is_hidden_) {
+ // We want to rate limit the input events in this case, so we'll wait for
+ // painting to finish before ACKing this message.
+ TRACE_EVENT_INSTANT0("renderer",
+ "RenderWidget::OnHandleInputEvent ack throttled",
+ TRACE_EVENT_SCOPE_THREAD);
+ if (pending_input_event_ack_) {
+ // As two different kinds of events could cause us to postpone an ack
+ // we send it now, if we have one pending. The Browser should never
+ // send us the same kind of event we are delaying the ack for.
+ Send(pending_input_event_ack_.release());
+ }
+ pending_input_event_ack_ = response.Pass();
+ if (compositor_)
+ compositor_->NotifyInputThrottledUntilCommit();
+ } else {
+ Send(response.release());
}
- pending_input_event_ack_.reset(response);
- if (compositor_)
- compositor_->NotifyInputThrottledUntilCommit();
- } else {
- Send(response);
}
#if defined(OS_ANDROID)
@@ -1175,11 +1432,15 @@ void RenderWidget::InvalidationCallback() {
DoDeferredUpdateAndSendInputAck();
}
-void RenderWidget::DoDeferredUpdateAndSendInputAck() {
- DoDeferredUpdate();
-
+void RenderWidget::FlushPendingInputEventAck() {
if (pending_input_event_ack_)
Send(pending_input_event_ack_.release());
+ total_input_handling_time_this_frame_ = base::TimeDelta();
+}
+
+void RenderWidget::DoDeferredUpdateAndSendInputAck() {
+ DoDeferredUpdate();
+ FlushPendingInputEventAck();
}
void RenderWidget::DoDeferredUpdate() {
@@ -1212,8 +1473,8 @@ void RenderWidget::DoDeferredUpdate() {
}
// Tracking of frame rate jitter
- base::TimeTicks frame_begin_ticks = base::TimeTicks::Now();
- InstrumentWillBeginFrame();
+ base::TimeTicks frame_begin_ticks = gfx::FrameTime::Now();
+ InstrumentWillBeginFrame(0);
AnimateIfNeeded();
// Layout may generate more invalidation. It may also enable the
@@ -1271,9 +1532,9 @@ void RenderWidget::DoDeferredUpdate() {
last_do_deferred_update_time_ = frame_begin_ticks;
if (!is_accelerated_compositing_active_) {
- legacy_software_mode_stats_->IncrementAnimationFrameCount();
- legacy_software_mode_stats_->IncrementScreenFrameCount(1, true);
- legacy_software_mode_stats_->IssueTraceEventForMainThreadStats();
+ legacy_software_mode_stats_->IncrementFrameCount(1, true);
+ cc::BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent(
+ legacy_software_mode_stats_->main_thread_rendering_stats());
legacy_software_mode_stats_->AccumulateAndClearMainThreadStats();
}
@@ -1285,9 +1546,6 @@ void RenderWidget::DoDeferredUpdate() {
gfx::Rect scroll_damage = update.GetScrollDamage();
gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage);
- // Notify derived classes that we're about to initiate a paint.
- WillInitiatePaint();
-
// A plugin may be able to do an optimized paint. First check this, in which
// case we can skip all of the bitmap generation and regular paint code.
// This optimization allows PPAPI plugins that declare themselves on top of
@@ -1404,8 +1662,7 @@ void RenderWidget::DoDeferredUpdate() {
// UpdateReply message so we can receive another input event before the
// UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within
// the UpdateRect IPC message handler.
- if (pending_input_event_ack_)
- Send(pending_input_event_ack_.release());
+ FlushPendingInputEventAck();
// If Composite() called SwapBuffers, pending_update_params_ will be reset (in
// OnSwapBuffersPosted), meaning a message has been added to the
@@ -1518,7 +1775,7 @@ void RenderWidget::didAutoResize(const WebSize& new_size) {
// with invalid damage rects.
paint_aggregator_.ClearPendingUpdate();
- if (RenderThreadImpl::current()->layout_test_mode()) {
+ if (resizing_mode_selector_->is_synchronous_mode()) {
WebRect new_pos(rootWindowRect().x,
rootWindowRect().y,
new_size.width,
@@ -1529,7 +1786,7 @@ void RenderWidget::didAutoResize(const WebSize& new_size) {
AutoResizeCompositor();
- if (!RenderThreadImpl::current()->layout_test_mode())
+ if (!resizing_mode_selector_->is_synchronous_mode())
need_update_rect_for_auto_resize_ = true;
}
}
@@ -1598,7 +1855,7 @@ void RenderWidget::initializeLayerTreeView() {
compositor_->setSurfaceReady();
}
-WebKit::WebLayerTreeView* RenderWidget::layerTreeView() {
+blink::WebLayerTreeView* RenderWidget::layerTreeView() {
return compositor_.get();
}
@@ -1620,14 +1877,11 @@ void RenderWidget::willBeginCompositorFrame() {
UpdateTextInputState(false, true);
#endif
UpdateSelectionBounds();
-
- WillInitiatePaint();
}
void RenderWidget::didBecomeReadyForAdditionalInput() {
TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
- if (pending_input_event_ack_)
- Send(pending_input_event_ack_.release());
+ FlushPendingInputEventAck();
}
void RenderWidget::DidCommitCompositorFrame() {
@@ -1674,7 +1928,7 @@ void RenderWidget::didCompleteSwapBuffers() {
void RenderWidget::scheduleComposite() {
if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() &&
compositor_) {
- compositor_->setNeedsRedraw();
+ compositor_->setNeedsAnimate();
} else {
// TODO(nduca): replace with something a little less hacky. The reason this
// hack is still used is because the Invalidate-DoDeferredUpdate loop
@@ -1732,14 +1986,6 @@ void RenderWidget::show(WebNavigationPolicy) {
SetPendingWindowRect(initial_pos_);
}
-void RenderWidget::didProgrammaticallyScroll(
- const WebKit::WebPoint& scroll_point) {
- if (!compositor_)
- return;
- Send(new ViewHostMsg_DidProgrammaticallyScroll(
- routing_id_, gfx::Vector2d(scroll_point.x, scroll_point.y)));
-}
-
void RenderWidget::didFocus() {
}
@@ -1771,6 +2017,19 @@ void RenderWidget::closeWidgetSoon() {
FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
}
+void RenderWidget::QueueSyntheticGesture(
+ scoped_ptr<SyntheticGestureParams> gesture_params,
+ const SyntheticGestureCompletionCallback& callback) {
+ DCHECK(!callback.is_null());
+
+ pending_synthetic_gesture_callbacks_.push(callback);
+
+ SyntheticGesturePacket gesture_packet;
+ gesture_packet.set_gesture_params(gesture_params.Pass());
+
+ Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet));
+}
+
void RenderWidget::Close() {
if (webwidget_) {
webwidget_->willCloseLayerTreeView();
@@ -1787,25 +2046,30 @@ WebRect RenderWidget::windowRect() {
return view_screen_rect_;
}
-void RenderWidget::setToolTipText(const WebKit::WebString& text,
+void RenderWidget::setToolTipText(const blink::WebString& text,
WebTextDirection hint) {
Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
}
-void RenderWidget::setWindowRect(const WebRect& pos) {
- if (did_show_) {
- if (!RenderThreadImpl::current()->layout_test_mode()) {
+void RenderWidget::setWindowRect(const WebRect& rect) {
+ WebRect pos = rect;
+ if (popup_origin_scale_for_emulation_) {
+ float scale = popup_origin_scale_for_emulation_;
+ pos.x = popup_screen_origin_for_emulation_.x() +
+ (pos.x - popup_view_origin_for_emulation_.x()) * scale;
+ pos.y = popup_screen_origin_for_emulation_.y() +
+ (pos.y - popup_view_origin_for_emulation_.y()) * scale;
+ }
+
+ if (!resizing_mode_selector_->is_synchronous_mode()) {
+ if (did_show_) {
Send(new ViewHostMsg_RequestMove(routing_id_, pos));
SetPendingWindowRect(pos);
} else {
- WebSize new_size(pos.width, pos.height);
- Resize(new_size, new_size, overdraw_bottom_height_,
- WebRect(), is_fullscreen_, NO_RESIZE_ACK);
- view_screen_rect_ = pos;
- window_screen_rect_ = pos;
+ initial_pos_ = pos;
}
} else {
- initial_pos_ = pos;
+ ResizeSynchronously(pos);
}
}
@@ -1838,8 +2102,20 @@ void RenderWidget::OnSetInputMethodActive(bool is_active) {
input_method_is_active_ = is_active;
}
+void RenderWidget::OnCandidateWindowShown() {
+ webwidget_->didShowCandidateWindow();
+}
+
+void RenderWidget::OnCandidateWindowUpdated() {
+ webwidget_->didUpdateCandidateWindow();
+}
+
+void RenderWidget::OnCandidateWindowHidden() {
+ webwidget_->didHideCandidateWindow();
+}
+
void RenderWidget::OnImeSetComposition(
- const string16& text,
+ const base::string16& text,
const std::vector<WebCompositionUnderline>& underlines,
int selection_start, int selection_end) {
if (!ShouldHandleImeEvent())
@@ -1858,7 +2134,7 @@ void RenderWidget::OnImeSetComposition(
#endif
}
-void RenderWidget::OnImeConfirmComposition(const string16& text,
+void RenderWidget::OnImeConfirmComposition(const base::string16& text,
const gfx::Range& replacement_range,
bool keep_selection) {
if (!ShouldHandleImeEvent())
@@ -2022,7 +2298,10 @@ void RenderWidget::OnRepaint(gfx::Size size_to_paint) {
}
void RenderWidget::OnSyntheticGestureCompleted() {
- pending_synthetic_gesture_.Run();
+ DCHECK(!pending_synthetic_gesture_callbacks_.empty());
+
+ pending_synthetic_gesture_callbacks_.front().Run();
+ pending_synthetic_gesture_callbacks_.pop();
}
void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
@@ -2033,16 +2312,17 @@ void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
const gfx::Rect& window_screen_rect) {
- view_screen_rect_ = view_screen_rect;
- window_screen_rect_ = window_screen_rect;
+ if (screen_metrics_emulator_) {
+ screen_metrics_emulator_->OnUpdateScreenRectsMessage(
+ view_screen_rect, window_screen_rect);
+ } else {
+ view_screen_rect_ = view_screen_rect;
+ window_screen_rect_ = window_screen_rect;
+ }
Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
}
#if defined(OS_ANDROID)
-void RenderWidget::OnImeBatchStateChanged(bool is_begin) {
- Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin));
-}
-
void RenderWidget::OnShowImeIfNeeded() {
UpdateTextInputState(true, true);
}
@@ -2182,8 +2462,16 @@ void RenderWidget::FinishHandlingImeEvent() {
}
void RenderWidget::UpdateTextInputType() {
+ // On Windows, not only an IME but also an on-screen keyboard relies on the
+ // latest TextInputType to optimize its layout and functionality. Thus
+ // |input_method_is_active_| is no longer an appropriate condition to suppress
+ // TextInputTypeChanged IPC on Windows.
+ // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_|
+ // on other platforms as well as Windows if the overhead is acceptable.
+#if !defined(OS_WIN)
if (!input_method_is_active_)
return;
+#endif
ui::TextInputType new_type = GetTextInputType();
if (IsDateTimeInput(new_type))
@@ -2191,7 +2479,7 @@ void RenderWidget::UpdateTextInputType() {
bool new_can_compose_inline = CanComposeInline();
- WebKit::WebTextInputInfo new_info;
+ blink::WebTextInputInfo new_info;
if (webwidget_)
new_info = webwidget_->textInputInfo();
const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
@@ -2220,7 +2508,7 @@ void RenderWidget::UpdateTextInputState(bool show_ime_if_needed,
if (IsDateTimeInput(new_type))
return; // Not considered as a text input field in WebKit/Chromium.
- WebKit::WebTextInputInfo new_info;
+ blink::WebTextInputInfo new_info;
if (webwidget_)
new_info = webwidget_->textInputInfo();
@@ -2281,47 +2569,47 @@ void RenderWidget::UpdateSelectionBounds() {
#endif
}
-// Check WebKit::WebTextInputType and ui::TextInputType is kept in sync.
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \
+// Check blink::WebTextInputType and ui::TextInputType is kept in sync.
+COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \
int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \
int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \
int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeSearch) == \
int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeEmail) == \
int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeNumber) == \
int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeTelephone) == \
int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeURL) == \
int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeDate) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeDate) == \
int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTime) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeDateTime) == \
int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTimeLocal) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeLocal) == \
int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeMonth) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeMonth) == \
int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeTime) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeTime) == \
int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeWeek) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeWeek) == \
int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeTextArea) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeTextArea) == \
int(ui::TEXT_INPUT_TYPE_TEXT_AREA), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeContentEditable) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeContentEditable) == \
int(ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE), mismatching_enums);
-COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTimeField) == \
+COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeField) == \
int(ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD), mismatching_enums);
ui::TextInputType RenderWidget::WebKitToUiTextInputType(
- WebKit::WebTextInputType type) {
+ blink::WebTextInputType type) {
// Check the type is in the range representable by ui::TextInputType.
DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
- "WebKit::WebTextInputType and ui::TextInputType not synchronized";
+ "blink::WebTextInputType and ui::TextInputType not synchronized";
return static_cast<ui::TextInputType>(type);
}
@@ -2456,7 +2744,7 @@ void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
}
void RenderWidget::GetRenderingStats(
- WebKit::WebRenderingStatsImpl& stats) const {
+ blink::WebRenderingStatsImpl& stats) const {
if (compositor_)
compositor_->GetRenderingStats(&stats.rendering_stats);
@@ -2485,52 +2773,16 @@ void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) {
*stats = browser_rendering_stats_;
}
-void RenderWidget::BeginSmoothScroll(
- bool down,
- const SyntheticGestureCompletionCallback& callback,
- int pixels_to_scroll,
- int mouse_event_x,
- int mouse_event_y) {
- DCHECK(!callback.is_null());
-
- ViewHostMsg_BeginSmoothScroll_Params params;
- params.scroll_down = down;
- params.pixels_to_scroll = pixels_to_scroll;
- params.mouse_event_x = mouse_event_x;
- params.mouse_event_y = mouse_event_y;
-
- Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, params));
- pending_synthetic_gesture_ = callback;
-}
-
-void RenderWidget::BeginPinch(
- bool zoom_in,
- int pixels_to_move,
- int anchor_x,
- int anchor_y,
- const SyntheticGestureCompletionCallback& callback) {
- DCHECK(!callback.is_null());
-
- ViewHostMsg_BeginPinch_Params params;
- params.zoom_in = zoom_in;
- params.pixels_to_move = pixels_to_move;
- params.anchor_x = anchor_x;
- params.anchor_y = anchor_y;
-
- Send(new ViewHostMsg_BeginPinch(routing_id_, params));
- pending_synthetic_gesture_ = callback;
-}
-
-bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
+bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
return false;
}
-bool RenderWidget::WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event) {
+bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) {
return false;
}
bool RenderWidget::WillHandleGestureEvent(
- const WebKit::WebGestureEvent& event) {
+ const blink::WebGestureEvent& event) {
return false;
}
@@ -2538,25 +2790,50 @@ void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
}
+void RenderWidget::setTouchAction(
+ blink::WebTouchAction web_touch_action) {
+
+ // Ignore setTouchAction calls that result from synthetic touch events (eg.
+ // when blink is emulating touch with mouse).
+ if (!handling_touchstart_event_)
+ return;
+
+ content::TouchAction content_touch_action;
+ switch(web_touch_action) {
+ case blink::WebTouchActionNone:
+ content_touch_action = content::TOUCH_ACTION_NONE;
+ break;
+ case blink::WebTouchActionAuto:
+ content_touch_action = content::TOUCH_ACTION_AUTO;
+ break;
+ default:
+ NOTREACHED();
+ }
+ Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
+}
+
bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
return true;
}
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
RenderWidget::CreateGraphicsContext3D(
- const WebKit::WebGraphicsContext3D::Attributes& attributes) {
+ const blink::WebGraphicsContext3D::Attributes& attributes) {
if (!webwidget_)
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuCompositing))
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
- scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
- new WebGraphicsContext3DCommandBufferImpl(
- surface_id(),
- GetURLForGraphicsContext3D(),
- RenderThreadImpl::current(),
- weak_ptr_factory_.GetWeakPtr()));
+ if (!RenderThreadImpl::current())
+ return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
+ CauseForGpuLaunch cause =
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
+ scoped_refptr<GpuChannelHost> gpu_channel_host(
+ RenderThreadImpl::current()->EstablishGpuChannelSync(cause));
+ if (!gpu_channel_host)
+ return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
+ WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
#if defined(OS_ANDROID)
// If we raster too fast we become upload bound, and pending
// uploads consume memory. For maximum upload throughput, we would
@@ -2576,22 +2853,18 @@ RenderWidget::CreateGraphicsContext3D(
static const size_t kBytesPerMegabyte = 1024 * 1024;
// We keep the MappedMemoryReclaimLimit the same as the upload limit
// to avoid unnecessarily stalling the compositor thread.
- const size_t mapped_memory_reclaim_limit =
+ limits.mapped_memory_reclaim_limit =
max_transfer_buffer_usage_mb * kBytesPerMegabyte;
-#else
- const size_t mapped_memory_reclaim_limit =
- WebGraphicsContext3DCommandBufferImpl::kNoLimit;
#endif
- if (!context->Initialize(
+
+ scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
+ new WebGraphicsContext3DCommandBufferImpl(
+ surface_id(),
+ GetURLForGraphicsContext3D(),
+ gpu_channel_host.get(),
attributes,
false /* bind generates resources */,
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE,
- kDefaultCommandBufferSize,
- kDefaultStartTransferBufferSize,
- kDefaultMinTransferBufferSize,
- kDefaultMaxTransferBufferSize,
- mapped_memory_reclaim_limit))
- return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
+ limits));
return context.Pass();
}