#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/context_menu_params.h"
#include "content/renderer/cursor_utils.h"
#include "content/renderer/external_popup_menu.h"
#include "content/renderer/gpu/compositor_output_surface.h"
#include "ui/gfx/skia_util.h"
#include "ui/gl/gl_switches.h"
#include "ui/surface/transport_dib.h"
-#include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h"
#if defined(OS_ANDROID)
#include "base/android/sys_utils.h"
outstanding_ime_acks_(0),
#endif
popup_origin_scale_for_emulation_(0.f),
- resizing_mode_selector_(new ResizingModeSelector()) {
+ resizing_mode_selector_(new ResizingModeSelector()),
+ context_menu_source_type_(ui::MENU_SOURCE_MOUSE) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
DCHECK(RenderThread::Get());
legacy_software_mode_stats_ = cc::RenderingStatsInstrumentation::Create();
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableGpuBenchmarking))
+ cc::switches::kEnableGpuBenchmarking))
legacy_software_mode_stats_->set_record_rendering_stats(true);
}
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_SetTextDirection, OnSetTextDirection)
IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
#endif
IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
- IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats,
- OnSetBrowserRenderingStats)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
(now.InSecondsF() - input_event->timeStampSeconds) *
base::Time::kMicrosecondsPerSecond);
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.AggregatedLatency.Renderer2",
- delta, 0, 10000000, 100);
+ delta, 1, 10000000, 100);
base::HistogramBase* counter_for_type =
base::Histogram::FactoryGet(
base::StringPrintf("Event.Latency.Renderer2.%s", event_name),
- 0,
+ 1,
10000000,
100,
base::HistogramBase::kUmaTargetedHistogramFlag);
*static_cast<const WebMouseEvent*>(input_event);
TRACE_EVENT2("renderer", "HandleMouseMove",
"x", mouse_event.x, "y", mouse_event.y);
+ context_menu_source_type_ = ui::MENU_SOURCE_MOUSE;
prevent_default = WillHandleMouseEvent(mouse_event);
}
- if (WebInputEvent::isKeyboardEventType(input_event->type)) {
- const WebKeyboardEvent& key_event =
- *static_cast<const WebKeyboardEvent*>(input_event);
- prevent_default = WillHandleKeyEvent(key_event);
- }
+ if (WebInputEvent::isKeyboardEventType(input_event->type))
+ context_menu_source_type_ = ui::MENU_SOURCE_KEYBOARD;
if (WebInputEvent::isGestureEventType(input_event->type)) {
const WebGestureEvent& gesture_event =
*static_cast<const WebGestureEvent*>(input_event);
+ context_menu_source_type_ = ui::MENU_SOURCE_TOUCH;
prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
}
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)) {
+ HasTouchEventHandlersAt(
+ blink::WebPoint(touch_event.touches[i].position.x,
+ touch_event.touches[i].position.y))) {
ack_result = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
break;
}
&RenderWidget::AnimationCallback);
animation_update_pending_ = false;
if (is_accelerated_compositing_active_ && compositor_) {
- compositor_->Animate(base::TimeTicks::Now());
+ compositor_->UpdateAnimations(base::TimeTicks::Now());
} else {
double frame_begin_time =
(base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
#endif
}
-// This message causes the renderer to render an image of the
-// desired_size, regardless of whether the tab is hidden or not.
-void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle,
- int tag,
- const gfx::Size& page_size,
- const gfx::Size& desired_size) {
- if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
- if (TransportDIB::is_valid_handle(dib_handle)) {
- // Close our unused handle.
-#if defined(OS_WIN)
- ::CloseHandle(dib_handle);
-#elif defined(OS_MACOSX)
- base::SharedMemory::CloseHandle(dib_handle);
-#endif
- }
- return;
- }
-
- if (page_size.IsEmpty() || desired_size.IsEmpty()) {
- // If one of these is empty, then we just return the dib we were
- // given, to avoid leaking it.
- Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size));
- return;
- }
-
- // Map the given DIB ID into this process, and unmap it at the end
- // of this function.
- scoped_ptr<TransportDIB> paint_at_size_buffer(
- TransportDIB::CreateWithHandle(dib_handle));
-
- gfx::Size page_size_in_pixel = gfx::ToFlooredSize(
- gfx::ScaleSize(page_size, device_scale_factor_));
- gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
- gfx::ScaleSize(desired_size, device_scale_factor_));
- gfx::Size canvas_size = page_size_in_pixel;
- float x_scale = static_cast<float>(desired_size_in_pixel.width()) /
- static_cast<float>(canvas_size.width());
- float y_scale = static_cast<float>(desired_size_in_pixel.height()) /
- static_cast<float>(canvas_size.height());
-
- gfx::Rect orig_bounds(canvas_size);
- canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));
- canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));
- gfx::Rect bounds(canvas_size);
-
- scoped_ptr<skia::PlatformCanvas> canvas(
- paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(),
- canvas_size.height()));
- if (!canvas) {
- NOTREACHED();
- return;
- }
-
- // Reset bounds to what we actually received, but they should be the
- // same.
- DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
- DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
- bounds.set_width(canvas->getDevice()->width());
- bounds.set_height(canvas->getDevice()->height());
-
- canvas->save();
- // Add the scale factor to the canvas, so that we'll get the desired size.
- canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
-
- // Have to make sure we're laid out at the right size before
- // rendering.
- gfx::Size old_size = webwidget_->size();
- webwidget_->resize(page_size);
- webwidget_->layout();
-
- // Paint the entire thing (using original bounds, not scaled bounds).
- PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
- canvas->restore();
-
- // Return the widget to its previous size.
- webwidget_->resize(old_size);
-
- Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
-}
-
void RenderWidget::OnSnapshot(const gfx::Rect& src_subrect) {
SkBitmap snapshot;
}
}
-void RenderWidget::GetRenderingStats(
- blink::WebRenderingStatsImpl& stats) const {
- if (compositor_)
- compositor_->GetRenderingStats(&stats.rendering_stats);
-
- stats.rendering_stats.Add(
- legacy_software_mode_stats_->GetRenderingStats());
-}
-
-bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
- GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
- if (!gpu_channel)
- return false;
-
- return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
-}
RenderWidgetCompositor* RenderWidget::compositor() const {
return compositor_.get();
}
-void RenderWidget::OnSetBrowserRenderingStats(
- const BrowserRenderingStats& stats) {
- browser_rendering_stats_ = stats;
-}
-
-void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) {
- *stats = browser_rendering_stats_;
-}
-
bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
return false;
}
-bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) {
- return false;
-}
-
bool RenderWidget::WillHandleGestureEvent(
const blink::WebGestureEvent& event) {
return false;