render_widget.h revision 7d4cd473f85ac64c3747c96c277f9e506a0d2246
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_RENDERER_RENDER_WIDGET_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <deque> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/weak_ptr.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/time.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/timer.h" 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/debug/rendering_stats.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/common/browser_rendering_stats.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/renderer/paint_aggregator.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_listener.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_sender.h" 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebRect.h" 267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebCompositionUnderline.h" 277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebPopupType.h" 287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebTextDirection.h" 297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebTextInputInfo.h" 307d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebWidgetClient.h" 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkBitmap.h" 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/ime/text_input_type.h" 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/range/range.h" 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h" 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/vector2d.h" 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/gfx/vector2d_f.h" 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/surface/transport_dib.h" 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "webkit/common/cursors/webcursor.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ViewHostMsg_UpdateRect_Params; 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)struct ViewMsg_Resize_Params; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ViewHostMsg_UpdateRect; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace IPC { 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SyncMessage; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace WebKit { 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebGestureEvent; 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebInputEvent; 527d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class WebKeyboardEvent; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebMouseEvent; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebTouchEvent; 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct WebPoint; 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct WebRenderingStatsImpl; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc { class OutputSurface; } 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui { 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Range; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace webkit { 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace npapi { 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct WebPluginGeometry; 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace npapi 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ppapi { 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PluginInstance; 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ppapi 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace webkit 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct GpuRenderingStats; 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class RenderWidgetCompositor; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderWidgetTest; 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// RenderWidget provides a communication bridge between a WebWidget and 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a RenderWidgetHost, the latter of which lives in a different process. 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT RenderWidget 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : public IPC::Listener, 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public IPC::Sender, 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NON_EXPORTED_BASE(virtual public WebKit::WebWidgetClient), 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NON_EXPORTED_BASE(public WebGraphicsContext3DSwapBuffersClient), 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public base::RefCounted<RenderWidget> { 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates a new RenderWidget. The opener_id is the routing ID of the 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderView that this widget lives inside. 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static RenderWidget* Create(int32 opener_id, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebPopupType popup_type, 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const WebKit::WebScreenInfo& screen_info); 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates a WebWidget based on the popup type. 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static WebKit::WebWidget* CreateWebWidget(RenderWidget* render_widget); 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The compositing surface assigned by the RenderWidgetHost 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (or RenderViewHost). Will be gfx::kNullPluginWindow if not assigned yet, 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in which case we should not create any GPU command buffers with it. 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not yet assigned a view ID, in which case, the process MUST NOT send 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // messages with this ID to the parent. 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 routing_id() const { 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return routing_id_; 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 surface_id() const { 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return surface_id_; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // May return NULL when the window is closing. 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebWidget* webwidget() const { return webwidget_; } 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size size() const { return size_; } 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_focus() const { return has_focus_; } 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_fullscreen() const { return is_fullscreen_; } 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_hidden() const { return is_hidden_; } 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // IPC::Listener 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // IPC::Sender 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool Send(IPC::Message* msg) OVERRIDE; 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // WebKit::WebWidgetClient 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void suppressCompositorScheduling(bool enable); 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void willBeginCompositorFrame(); 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didInvalidateRect(const WebKit::WebRect&); 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void didScrollRect(int dx, int dy, 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const WebKit::WebRect& clipRect); 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didAutoResize(const WebKit::WebSize& new_size); 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didActivateCompositor(int input_handler_identifier); 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didDeactivateCompositor(); 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void initializeLayerTreeView(); 1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual WebKit::WebLayerTreeView* layerTreeView(); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didBecomeReadyForAdditionalInput(); 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didCommitAndDrawCompositorFrame(); 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didCompleteSwapBuffers(); 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void scheduleComposite(); 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void scheduleAnimation(); 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didFocus(); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didBlur(); 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void didChangeCursor(const WebKit::WebCursorInfo&); 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void closeWidgetSoon(); 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void show(WebKit::WebNavigationPolicy); 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void runModal() {} 14890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual void didProgrammaticallyScroll(const WebKit::WebPoint& scroll_point); 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual WebKit::WebRect windowRect(); 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void setToolTipText(const WebKit::WebString& text, 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebTextDirection hint); 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void setWindowRect(const WebKit::WebRect&); 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual WebKit::WebRect windowResizerRect(); 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual WebKit::WebRect rootWindowRect(); 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual WebKit::WebScreenInfo screenInfo(); 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual float deviceScaleFactor(); 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void resetInputMethod(); 1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void didHandleGestureEvent(const WebKit::WebGestureEvent& event, 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool event_cancelled); 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when a plugin is moved. These events are queued up and sent with 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the next paint or scroll message to the host. 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SchedulePluginMove(const webkit::npapi::WebPluginGeometry& move); 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when a plugin window has been destroyed, to make sure the currently 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // pending moves don't try to reference it. 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window); 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Fills in a WebRenderingStatsImpl struct containing information about 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // rendering, e.g. count of frames rendered, time spent painting. 1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void GetRenderingStats(WebKit::WebRenderingStatsImpl&) const; 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills in a GpuRenderingStats struct containing information about 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // GPU rendering, e.g. count of texture uploads performed, time spent 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // uploading. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This call is relatively expensive as it blocks on the GPU process 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetGpuRenderingStats(GpuRenderingStats*) const; 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void GetBrowserRenderingStats(BrowserRenderingStats* stats); 180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderWidgetCompositor* compositor() const; 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(); 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Callback for use with BeginSmoothScroll. 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef base::Callback<void()> SmoothScrollCompletionCallback; 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Directs the host to begin a smooth scroll. This scroll should have the same 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // performance characteristics as a user-initiated scroll. Returns an ID of 1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the scroll gesture. |mouse_event_x| and |mouse_event_y| are expected to be 1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // in local DIP coordinates. 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void BeginSmoothScroll(bool scroll_down, 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const SmoothScrollCompletionCallback& callback, 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int pixels_to_scroll, 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int mouse_event_x, 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int mouse_event_y); 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Close the underlying WebWidget. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Close(); 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Notifies about a compositor frame commit operation having finished. 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void DidCommitCompositorFrame(); 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float filtered_time_per_frame() const { 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return filtered_time_per_frame_; 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum ShowIme { 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DO_NOT_SHOW_IME, 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SHOW_IME_IF_NEEDED 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 21390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Handle common setup/teardown for handling IME events. 21490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void StartHandlingImeEvent(); 21590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) void FinishHandlingImeEvent(); 21690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InstrumentWillBeginFrame() {} 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InstrumentDidBeginFrame() {} 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InstrumentDidCancelFrame() {} 2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void InstrumentWillComposite() {} 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool AllowPartialSwap() const; 22390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool UsingSynchronousRendererCompositor() const; 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Friend RefCounted so that the dtor can be non-public. Using this class 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // without ref-counting is an error. 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class base::RefCounted<RenderWidget>; 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For unit tests. 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class RenderWidgetTest; 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum ResizeAck { 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SEND_RESIZE_ACK, 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NO_RESIZE_ACK, 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderWidget(WebKit::WebPopupType popup_type, 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const WebKit::WebScreenInfo& screen_info, 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool swapped_out); 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~RenderWidget(); 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initializes this view with the given opener. CompleteInit must be called 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // later. 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool Init(int32 opener_id); 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by Init and subclasses to perform initialization. 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool DoInit(int32 opener_id, 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebWidget* web_widget, 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC::SyncMessage* create_widget_message); 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finishes creation of a pending view started with Init. 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CompleteInit(); 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets whether this RenderWidget has been swapped out to be displayed by 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a RenderWidget in a different process. If so, no new IPC messages will be 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sent (only ACKs) and the process is free to exit when there are no other 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // active RenderWidgets. 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetSwappedOut(bool is_swapped_out); 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Paints the given rectangular region of the WebWidget into canvas (a 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // shared memory segment returned by AllocPaintBuf on Windows). The caller 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // must ensure that the given rect fits within the bounds of the WebWidget. 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin, 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SkCanvas* canvas); 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Paints a border at the given rect for debugging purposes. 2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void PaintDebugBorder(const gfx::Rect& rect, SkCanvas* canvas); 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsRenderingVSynced(); 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AnimationCallback(); 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AnimateIfNeeded(); 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InvalidationCallback(); 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DoDeferredUpdateAndSendInputAck(); 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DoDeferredUpdate(); 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DoDeferredClose(); 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DoDeferredSetWindowRect(const WebKit::WebRect& pos); 2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void Composite(base::TimeTicks frame_begin_time); 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set the background of the render widget to a bitmap. The bitmap will be 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tiled in both directions if it isn't big enough to fill the area. This is 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // mainly intended to be used in conjuction with WebView::SetIsTransparent(). 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetBackground(const SkBitmap& bitmap); 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Resizes the render widget. 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Resize(const gfx::Size& new_size, 2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Size& physical_backing_size, 2882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) float overdraw_bottom_height, 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& resizer_rect, 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_fullscreen, 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ResizeAck resize_ack); 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderWidget IPC message handlers 294c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnHandleInputEvent(const WebKit::WebInputEvent* event, 29590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const ui::LatencyInfo& latency_info, 296c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bool keyboard_shortcut); 297c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnCursorVisibilityChange(bool is_visible); 298c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnMouseCaptureLost(); 299c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void OnSetFocus(bool enable); 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnClose(); 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnCreatingNewAck(); 30290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual void OnResize(const ViewMsg_Resize_Params& params); 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnChangeResizeRect(const gfx::Rect& resizer_rect); 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWasHidden(); 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWasShown(bool needs_repainting); 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWasSwappedOut(); 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnUpdateRectAck(); 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnCreateVideoAck(int32 video_id); 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnUpdateVideoAck(int32 video_id); 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnRequestMoveAck(); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnSetInputMethodActive(bool is_active); 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnImeSetComposition( 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const string16& text, 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::vector<WebKit::WebCompositionUnderline>& underlines, 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int selection_start, 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int selection_end); 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnImeConfirmComposition( 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const string16& text, const ui::Range& replacement_range); 3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnPaintAtSize(const TransportDIB::Handle& dib_id, 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int tag, 3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Size& page_size, 3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Size& desired_size); 323c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnRepaint(gfx::Size size_to_paint); 324c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnSmoothScrollCompleted(); 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnSetTextDirection(WebKit::WebTextDirection direction); 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnGetFPS(); 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnUpdateScreenRects(const gfx::Rect& view_screen_rect, 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& window_screen_rect); 3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_ANDROID) 3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnImeBatchStateChanged(bool is_begin); 3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnShowImeIfNeeded(); 3322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 3332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void OnSnapshot(const gfx::Rect& src_subrect); 334868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void OnSetBrowserRenderingStats(const BrowserRenderingStats& stats); 3352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Notify the compositor about a change in viewport size. This should be 3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // used only with auto resize mode WebWidgets, as normal WebWidgets should 3382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // go through OnResize. 3392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void AutoResizeCompositor(); 3402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetDeviceScaleFactor(float device_scale_factor); 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Override points to notify derived classes that a paint has happened. 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // WillInitiatePaint happens when we're about to generate a new bitmap and 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // send it to the browser. DidInitiatePaint happens when that has completed, 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and subsequent rendering won't affect the painted content. DidFlushPaint 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // happens once we've received the ACK that the screen has been updated. 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For a given paint operation, these overrides will always be called in the 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // order WillInitiatePaint, DidInitiatePaint, DidFlushPaint. 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WillInitiatePaint() {} 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidInitiatePaint() {} 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidFlushPaint() {} 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Override and return true when the widget is rendered with a graphics 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // context that supports asynchronous swapbuffers. When returning true, the 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // subclass must call OnSwapBuffersPosted() when swap is posted, 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the context is lost. 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool SupportsAsynchronousSwapBuffers(); 3602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual GURL GetURLForGraphicsContext3D(); 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool ForceCompositingModeEnabled(); 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // WebGraphicsContext3DSwapBuffersClient implementation. 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Called by a GraphicsContext associated with this view when swapbuffers 3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // is posted, completes or is aborted. 3682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnViewContextSwapBuffersPosted() OVERRIDE; 3692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnViewContextSwapBuffersComplete() OVERRIDE; 3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnViewContextSwapBuffersAborted() OVERRIDE; 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Detects if a suitable opaque plugin covers the given paint bounds with no 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // compositing necessary. 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the plugin instance that's the source of the paint if the paint 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // can be handled by just blitting the plugin bitmap. In this case, the 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // location, clipping, and ID of the backing store will be filled into the 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // given output parameters. 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A return value of null means optimized painting can not be used and we 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // should continue with the normal painting code path. 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& paint_bounds, 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TransportDIB** dib, 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect* location, 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect* clip, 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float* scale_factor); 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the scroll offset of this widget, if this widget has a notion of 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // scroll offset. 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Vector2d GetScrollOffset(); 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the "hidden" state of this widget. All accesses to is_hidden_ should 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // use this method so that we can properly inform the RenderThread of our 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // state. 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetHidden(bool hidden); 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void WillToggleFullscreen(); 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DidToggleFullscreen(); 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool next_paint_is_resize_ack() const; 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool next_paint_is_restore_ack() const; 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_next_paint_is_resize_ack(); 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_next_paint_is_restore_ack(); 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_next_paint_is_repaint_ack(); 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks if the text input state and compose inline mode have been changed. 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If they are changed, the new value will be sent to the browser process. 4097d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) void UpdateTextInputType(); 4107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 4117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#if defined(OS_ANDROID) 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |show_ime_if_needed| should be SHOW_IME_IF_NEEDED iff the update may cause 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the ime to be displayed, e.g. after a tap on an input field on mobile. 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateTextInputState(ShowIme show_ime); 4157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks if the selection bounds have been changed. If they are changed, 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the new value will be sent to the browser process. 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateSelectionBounds(); 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks if the composition range or composition character bounds have been 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // changed. If they are changed, the new value will be sent to the browser 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // process. 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateCompositionInfo( 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ui::Range& range, 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::vector<gfx::Rect>& character_bounds); 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Override point to obtain that the current input method state and caret 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // position. 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ui::TextInputType GetTextInputType(); 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ui::TextInputType WebKitToUiTextInputType( 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebTextInputType type); 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Override point to obtain that the current composition character bounds. 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // In the case of surrogate pairs, the character is treated as two characters: 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the bounds for first character is actual one, and the bounds for second 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // character is zero width rectangle. 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetCompositionCharacterBounds( 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<gfx::Rect>* character_bounds); 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the composition range or composition character bounds 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // should be sent to the browser process. 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldUpdateCompositionInfo( 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ui::Range& range, 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::vector<gfx::Rect>& bounds); 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Override point to obtain that the current input method state about 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // composition text. 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool CanComposeInline(); 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tells the renderer it does not have focus. Used to prevent us from getting 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the focus on our own when the browser did not focus us. 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ClearFocus(); 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set the pending window rect. 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Because the real render_widget is hosted in another process, there is 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a time period where we may have set a new window rect which has not yet 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // been processed by the browser. So we maintain a pending window rect 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // size. If JS code sets the WindowRect, and then immediately calls 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // GetWindowRect() we'll use this pending window rect as the size. 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetPendingWindowRect(const WebKit::WebRect& r); 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a key event was 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // just handled. 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidHandleKeyEvent() {} 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a mouse event is 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // about to be handled. 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if no further handling is needed. In that case, the event 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // won't be sent to WebKit or trigger DidHandleMouseEvent(). 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event); 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4747d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a key event is 4757d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // about to be handled. 4767d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Returns true if no further handling is needed. In that case, the event 4777d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // won't be sent to WebKit or trigger DidHandleKeyEvent(). 4787d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual bool WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event); 4797d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a gesture event is 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // about to be handled. 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if no further handling is needed. In that case, the event 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // won't be sent to WebKit. 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool WillHandleGestureEvent(const WebKit::WebGestureEvent& event); 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a mouse event was 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // just handled. 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by OnHandleInputEvent() to notify subclasses that a touch event was 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // just handled. 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) {} 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Check whether the WebWidget has any touch event handlers registered 4952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // at the given point. 4962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const; 4972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 498c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Check whether the WebWidget has any touch event handlers registered. 499c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void hasTouchEventHandlers(bool has_handlers); 500c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Creates a 3D context associated with this view. 502c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WebGraphicsContext3DCommandBufferImpl* CreateGraphicsContext3D( 5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const WebKit::WebGraphicsContext3D::Attributes& attributes); 5042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool OnSnapshotHelper(const gfx::Rect& src_subrect, SkBitmap* bitmap); 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Routing ID that allows us to communicate to the parent browser process 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 routing_id_; 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 surface_id_; 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We are responsible for destroying this object via its Close method. 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebWidget* webwidget_; 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // This is lazily constructed and must not outlive webwidget_. 5172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<RenderWidgetCompositor> compositor_; 5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to the ID of the view that initiated creating this view, if any. When 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the view was initiated by the browser (the common case), this will be 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // MSG_ROUTING_NONE. This is used in determining ownership when opening 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // child tabs. See RenderWidget::createWebViewWithRequest. 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This ID may refer to an invalid view if that view is closed before this 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // view is. 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 opener_id_; 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The position where this view should be initially shown. 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect initial_pos_; 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool init_complete_; 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We store the current cursor object so we can avoid spamming SetCursor 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // messages. 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebCursor current_cursor_; 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The size of the RenderWidget. 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size size_; 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The TransportDIB that is being used to transfer an image to the browser. 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TransportDIB* current_paint_buf_; 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PaintAggregator paint_aggregator_; 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The size of the view's backing surface in non-DPI-adjusted pixels. 5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Size physical_backing_size_; 5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The height of the physical backing surface that is overdrawn opaquely in 5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels). 5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) float overdraw_bottom_height_; 5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The area that must be reserved for drawing the resize corner. 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect resizer_rect_; 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Flags for the next ViewHostMsg_UpdateRect message. 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int next_paint_flags_; 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Filtered time per frame based on UpdateRect messages. 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float filtered_time_per_frame_; 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if we are expecting an UpdateRect_ACK message (i.e., that a 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UpdateRect message has been sent). 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool update_reply_pending_; 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Whether the WebWidget is in auto resize mode, which is used for example 5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // by extension popups. 5672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool auto_resize_mode_; 5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if we need to send an UpdateRect message to notify the browser about 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // an already-completed auto-resize. 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool need_update_rect_for_auto_resize_; 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the underlying graphics context supports asynchronous swap. 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Cached on the RenderWidget because determining support is costly. 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool using_asynchronous_swapbuffers_; 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Number of OnSwapBuffersComplete we are expecting. Incremented each time 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // WebWidget::composite has been been performed when the RenderWidget subclass 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // rendering. 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int num_swapbuffers_complete_pending_; 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // When accelerated rendering is on, is the maximum number of swapbuffers that 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // can be outstanding before we start throttling based on 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnSwapBuffersComplete callback. 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kMaxSwapBuffersPending = 2; 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to true if we should ignore RenderWidget::Show calls. 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool did_show_; 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates that we shouldn't bother generated paint events. 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_hidden_; 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates that we are in fullscreen mode. 5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_fullscreen_; 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates that we should be repainted when restored. This flag is set to 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // true if we receive an invalidation / scroll event from webkit while our 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is_hidden_ flag is set to true. This is used to force a repaint once we 6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // restore to account for the fact that our host would not know about the 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // invalidation / scroll event(s) from webkit while we are hidden. 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool needs_repainting_on_restore_; 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates whether we have been focused/unfocused by the browser. 6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_focus_; 6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Are we currently handling an input event? 6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool handling_input_event_; 6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Are we currently handling an ime event? 6112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool handling_ime_event_; 6122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if we have requested this widget be closed. No more messages will 6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be sent, except for a Close. 6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool closing_; 6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether this RenderWidget is currently swapped out, such that the view is 6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // being rendered by another process. If all RenderWidgets in a process are 6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // swapped out, the process can exit. 6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_swapped_out_; 6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates if an input method is active in the browser process. 6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool input_method_is_active_; 6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores information about the current text input. 6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebTextInputInfo text_input_info_; 6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the current text input type of |webwidget_|. 6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::TextInputType text_input_type_; 6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the current type of composition text rendering of |webwidget_|. 6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool can_compose_inline_; 6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the current selection bounds. 6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect selection_focus_rect_; 6362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Rect selection_anchor_rect_; 6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the current composition character bounds. 6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<gfx::Rect> composition_character_bounds_; 6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stores the current composition range. 6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::Range composition_range_; 6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The kind of popup this widget represents, NONE if not a popup. 6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebPopupType popup_type_; 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Holds all the needed plugin window moves for a scroll. 6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef std::vector<webkit::npapi::WebPluginGeometry> WebPluginGeometryVector; 6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebPluginGeometryVector plugin_window_moves_; 6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A custom background for the widget. 6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SkBitmap background_; 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // While we are waiting for the browser to update window sizes, we track the 6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // pending size temporarily. 6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int pending_window_rect_count_; 6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebRect pending_window_rect_; 6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The screen rects of the view and the window that contains it. 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect view_screen_rect_; 6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect window_screen_rect_; 6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<IPC::Message> pending_input_event_ack_; 6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates if the next sequence of Char events should be suppressed or not. 6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool suppress_next_char_events_; 6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to true if painting to the window is handled by the accelerated 6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // compositor. 6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_accelerated_compositing_active_; 6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::OneShotTimer<RenderWidget> animation_timer_; 6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time animation_floor_time_; 6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool animation_update_pending_; 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool invalidation_task_posted_; 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_disable_gpu_vsync_switch_; 6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TimeTicks last_do_deferred_update_time_; 6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) cc::RenderingStats software_stats_; 6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // UpdateRect parameters for the current compositing pass. This is used to 6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // pass state between DoDeferredUpdate and OnSwapBuffersPosted. 6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<ViewHostMsg_UpdateRect_Params> pending_update_params_; 6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Queue of UpdateRect messages corresponding to a SwapBuffers. We want to 6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // delay sending of UpdateRect until the corresponding SwapBuffers has been 6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // executed. Since we can have several in flight, we need to keep them in a 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // queue. Note: some SwapBuffers may not correspond to an update, in which 6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // case NULL is added to the queue. 6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::deque<ViewHostMsg_UpdateRect*> updates_pending_swap_; 6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Properties of the screen hosting this RenderWidget instance. 6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebScreenInfo screen_info_; 6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The device scale factor. This value is computed from the DPI entries in 6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |screen_info_| on some platforms, and defaults to 1 on other platforms. 6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float device_scale_factor_; 6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // State associated with the BeginSmoothScroll synthetic scrolling function. 701c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) SmoothScrollCompletionCallback pending_smooth_scroll_gesture_; 7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Specified whether the compositor will run in its own thread. 7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_threaded_compositing_enabled_; 7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 706868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The last set of rendering stats received from the browser. This is only 707868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // received when using the --enable-gpu-benchmarking flag. 708868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) BrowserRenderingStats browser_rendering_stats_; 709868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 710868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The latency information for any current non-accelerated-compositing 711868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // frame. 712868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ui::LatencyInfo latency_info_; 713868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::WeakPtrFactory<RenderWidget> weak_ptr_factory_; 7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RenderWidget); 7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 7185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 7205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_RENDERER_RENDER_WIDGET_H_ 722