summaryrefslogtreecommitdiffstats
path: root/shared/render_widget_host_view_qt.h
blob: d21cbf051f2553e72915243f94981ee294e1f4d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_QT_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_QT_H_

#include "content/browser/renderer_host/render_widget_host_view_base.h"

#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__);

class QEvent;
class QFocusEvent;
class QKeyEvent;
class QMouseEvent;
class QWheelEvent;
class NativeViewQt;

namespace content {

class RenderWidgetHostViewQt
    : public content::RenderWidgetHostViewBase
{
public:
    RenderWidgetHostViewQt(content::RenderWidgetHost* widget);
    ~RenderWidgetHostViewQt();

    bool handleEvent(QEvent* event);

    virtual content::BackingStore *AllocBackingStore(const gfx::Size &size);
    static RenderWidgetHostView* CreateViewForWidget(content::RenderWidgetHost* widget);

    virtual void InitAsChild(gfx::NativeView parent_view);
    virtual void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&);
    virtual void InitAsFullscreen(content::RenderWidgetHostView*);
    virtual content::RenderWidgetHost* GetRenderWidgetHost() const;
    virtual void SetSize(const gfx::Size& size);
    virtual void SetBounds(const gfx::Rect& rect);
    virtual gfx::NativeView GetNativeView() const;
    virtual NativeViewQt* GetNativeViewQt() const OVERRIDE;
    virtual gfx::NativeViewId GetNativeViewId() const;
    virtual gfx::NativeViewAccessible GetNativeViewAccessible();
    virtual void Focus();
    virtual bool HasFocus() const;
    virtual bool IsSurfaceAvailableForCopy() const;
    virtual void Show();
    virtual void Hide();
    virtual bool IsShowing();
    virtual gfx::Rect GetViewBounds() const;
    virtual void SetBackground(const SkBitmap& background);
    virtual bool LockMouse();
    virtual void UnlockMouse();
    virtual bool IsMouseLocked();
#if defined(TOOLKIT_GTK)
    virtual GdkEventButton* GetLastMouseDown();
    virtual gfx::NativeView BuildInputMethodsGtkMenu();
#endif  // defined(TOOLKIT_GTK)
    virtual void WasShown();
    virtual void WasHidden();
    virtual void MovePluginWindows(const gfx::Vector2d&, const std::vector<webkit::npapi::WebPluginGeometry>&);
    virtual void Blur();
    virtual void UpdateCursor(const WebCursor&);
    virtual void SetIsLoading(bool);
    virtual void TextInputStateChanged(const ViewHostMsg_TextInputState_Params&);
    virtual void ImeCancelComposition();
    virtual void ImeCompositionRangeChanged(const ui::Range&, const std::vector<gfx::Rect>&);
    virtual void DidUpdateBackingStore(const gfx::Rect& scroll_rect, const gfx::Vector2d& scroll_delta, const std::vector<gfx::Rect>& copy_rects);
    virtual void RenderViewGone(base::TerminationStatus, int);
    virtual void Destroy();
    virtual void SetTooltipText(const string16&);
    virtual void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&);
    virtual void ScrollOffsetChanged();
    virtual void CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& /* dst_size */, const base::Callback<void(bool, const SkBitmap&)>& callback);
    virtual void CopyFromCompositingSurfaceToVideoFrame(const gfx::Rect& src_subrect, const scoped_refptr<media::VideoFrame>& target, const base::Callback<void(bool)>& callback);
    virtual bool CanCopyToVideoFrame() const;
    virtual void OnAcceleratedCompositingStateChange();
    virtual void AcceleratedSurfaceBuffersSwapped(const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id);
    virtual void AcceleratedSurfacePostSubBuffer(const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, int gpu_host_id);
    virtual void AcceleratedSurfaceSuspend();
    virtual void AcceleratedSurfaceRelease();
    virtual bool HasAcceleratedSurface(const gfx::Size&);
    virtual void GetScreenInfo(WebKit::WebScreenInfo* results);
    virtual gfx::Rect GetBoundsInRootWindow();
    virtual gfx::GLSurfaceHandle GetCompositingSurface();
    virtual void SetHasHorizontalScrollbar(bool);
    virtual void SetScrollOffsetPinning(bool, bool);
    virtual void OnAccessibilityNotifications(const std::vector<AccessibilityHostMsg_NotificationParams>&);

    void handleMouseEvent(QMouseEvent*);
    void handleKeyEvent(QKeyEvent*);
    void handleWheelEvent(QWheelEvent*);
    void handleFocusEvent(QFocusEvent*);
private:
    void Paint(const gfx::Rect& damage_rect);

    bool IsPopup() const;

    content::RenderWidgetHostImpl *m_host;
    NativeViewQt *m_view;
    gfx::Size m_requestedSize;

    // This is true when we are currently painting and thus should handle extra
    // paint requests by expanding the invalid rect rather than actually
    // painting.
    bool about_to_validate_and_paint_;

    // This is the rectangle which we'll paint.
    gfx::Rect invalid_rect_;
};

}

#endif