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

Side by Side Diff: webkit/tools/test_shell/webwidget_host.h

Issue 15028002: Delete test_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add dummy test_shell build target. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_
6 #define WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "skia/ext/platform_canvas.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gfx/rect.h"
14
15 namespace gfx {
16 class Size;
17 }
18
19 namespace WebKit {
20 class WebWidget;
21 class WebWidgetClient;
22 struct WebScreenInfo;
23 }
24
25 #if defined(OS_MACOSX)
26 #ifdef __OBJC__
27 @class NSEvent;
28 #else
29 class NSEvent;
30 #endif
31 #endif
32
33 // This class is a simple NativeView-based host for a WebWidget
34 class WebWidgetHost {
35 public:
36 // The new instance is deleted once the associated NativeView is destroyed.
37 // The newly created window should be resized after it is created, using the
38 // MoveWindow (or equivalent) function.
39 static WebWidgetHost* Create(gfx::NativeView parent_view,
40 WebKit::WebWidgetClient* client);
41
42 #if defined(OS_MACOSX)
43 static void HandleEvent(gfx::NativeView view, NSEvent* event);
44 #endif
45
46 gfx::NativeView view_handle() const { return view_; }
47 WebKit::WebWidget* webwidget() const { return webwidget_; }
48
49 void DidInvalidateRect(const gfx::Rect& rect);
50 void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
51 void ScheduleComposite();
52 void ScheduleAnimation();
53 #if defined(OS_WIN)
54 void SetCursor(HCURSOR cursor);
55 #endif
56
57 void DiscardBackingStore();
58 // Allow clients to update the paint rect. For example, if we get a gdk
59 // expose or WM_PAINT event, we need to update the paint rect.
60 void UpdatePaintRect(const gfx::Rect& rect);
61 void Paint();
62
63 skia::PlatformCanvas* canvas() const { return canvas_.get(); }
64
65 WebKit::WebScreenInfo GetScreenInfo();
66
67 // Paints the entire canvas a semi-transparent black (grayish). This is used
68 // by the layout tests in fast/repaint. The alpha value matches upstream.
69 void DisplayRepaintMask() {
70 canvas()->drawARGB(167, 0, 0, 0);
71 }
72
73 void PaintRect(const gfx::Rect& rect);
74
75 protected:
76 WebWidgetHost();
77 ~WebWidgetHost();
78
79 #if defined(OS_WIN)
80 // Per-class wndproc. Returns true if the event should be swallowed.
81 virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
82
83 void Resize(LPARAM lparam);
84 void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
85 void WheelEvent(WPARAM wparam, LPARAM lparam);
86 void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
87 void CaptureLostEvent();
88 void SetFocus(bool enable);
89
90 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
91 #elif defined(OS_MACOSX)
92 // These need to be called from a non-subclass, so they need to be public.
93 public:
94 void Resize(const gfx::Rect& rect);
95 void MouseEvent(NSEvent *);
96 void WheelEvent(NSEvent *);
97 void KeyEvent(NSEvent *);
98 void SetFocus(bool enable);
99 protected:
100 #elif defined(TOOLKIT_GTK)
101 public:
102 // ---------------------------------------------------------------------------
103 // This is needed on Linux because the GtkWidget creation is the same between
104 // both web view hosts and web widget hosts. The Windows code manages this by
105 // reusing the WndProc function (static, above). However, GTK doesn't use a
106 // single big callback function like that so we have a static function that
107 // sets up a GtkWidget correctly.
108 // parent: a GtkBox to pack the new widget at the end of
109 // host: a pointer to a WebWidgetHost (or subclass thereof)
110 // ---------------------------------------------------------------------------
111 static gfx::NativeView CreateWidget(gfx::NativeView parent_view,
112 WebWidgetHost* host);
113 void WindowDestroyed();
114 void Resize(const gfx::Size& size);
115 #endif
116
117 #if defined(OS_WIN)
118 void TrackMouseLeave(bool enable);
119 #endif
120
121 void ResetScrollRect();
122
123 void set_painting(bool value) {
124 #ifndef NDEBUG
125 painting_ = value;
126 #endif
127 }
128
129 gfx::NativeView view_;
130 WebKit::WebWidget* webwidget_;
131 scoped_ptr<skia::PlatformCanvas> canvas_;
132
133 // specifies the portion of the webwidget that needs painting
134 gfx::Rect paint_rect_;
135
136 // specifies the portion of the webwidget that needs scrolling
137 gfx::Rect scroll_rect_;
138 int scroll_dx_;
139 int scroll_dy_;
140
141 #if defined(OS_WIN)
142 bool track_mouse_leave_;
143 #endif
144
145 #if defined(TOOLKIT_GTK)
146 // Since GtkWindow resize is asynchronous, we have to stash the dimensions,
147 // so that the backing store doesn't have to wait for sizing to take place.
148 gfx::Size logical_size_;
149 #endif
150
151 #ifndef NDEBUG
152 bool painting_;
153 #endif
154
155 private:
156 base::WeakPtrFactory<WebWidgetHost> weak_factory_;
157 };
158
159 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698