OLD | NEW |
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "webkit/tools/test_shell/webwidget_host.h" | 7 #include "webkit/tools/test_shell/webwidget_host.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact
ory.h" | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact
ory.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact
ory.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact
ory.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
19 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
20 #include "webkit/tools/test_shell/test_shell.h" | 20 #include "webkit/tools/test_shell/test_shell.h" |
21 | 21 |
22 using WebKit::WebInputEvent; | 22 using WebKit::WebInputEvent; |
23 using WebKit::WebInputEventFactory; | 23 using WebKit::WebInputEventFactory; |
24 using WebKit::WebKeyboardEvent; | 24 using WebKit::WebKeyboardEvent; |
25 using WebKit::WebMouseEvent; | 25 using WebKit::WebMouseEvent; |
26 using WebKit::WebMouseWheelEvent; | 26 using WebKit::WebMouseWheelEvent; |
27 using WebKit::WebPopupMenu; | 27 using WebKit::WebPopupMenu; |
28 using WebKit::WebScreenInfo; | 28 using WebKit::WebScreenInfo; |
29 using WebKit::WebScreenInfoFactory; | 29 using WebKit::WebScreenInfoFactory; |
30 using WebKit::WebSize; | 30 using WebKit::WebSize; |
31 using WebKit::WebWidgetClient; | 31 using WebKit::WebWidgetClient; |
32 | 32 |
33 /*static*/ | 33 // static |
34 WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, | 34 WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, |
35 WebWidgetClient* client) { | 35 WebWidgetClient* client) { |
36 WebWidgetHost* host = new WebWidgetHost(); | 36 WebWidgetHost* host = new WebWidgetHost(); |
37 | 37 |
38 NSRect content_rect = [parent_view frame]; | 38 NSRect content_rect = [parent_view frame]; |
39 content_rect.origin.y += 64; | 39 content_rect.origin.y += 64; |
40 content_rect.size.height -= 64; | 40 content_rect.size.height -= 64; |
41 host->view_ = [[NSView alloc] initWithFrame:content_rect]; | 41 host->view_ = [[NSView alloc] initWithFrame:content_rect]; |
42 [parent_view addSubview:host->view_]; | 42 [parent_view addSubview:host->view_]; |
43 | 43 |
44 // app::win::SetWindowUserData(host->hwnd_, host); | 44 // base::win::SetWindowUserData(host->hwnd_, host); |
45 | 45 |
46 host->webwidget_ = WebPopupMenu::create(client); | 46 host->webwidget_ = WebPopupMenu::create(client); |
47 host->webwidget_->resize(WebSize(content_rect.size.width, | 47 host->webwidget_->resize(WebSize(content_rect.size.width, |
48 content_rect.size.height)); | 48 content_rect.size.height)); |
49 return host; | 49 return host; |
50 } | 50 } |
51 | 51 |
52 /*static*/ | 52 /*static*/ |
53 void WebWidgetHost::HandleEvent(NSView* view, NSEvent* event) { | 53 void WebWidgetHost::HandleEvent(NSView* view, NSEvent* event) { |
54 /* TODO(port): rig up a way to get to the host */ | 54 /* TODO(port): rig up a way to get to the host */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 WebWidgetHost::WebWidgetHost() | 148 WebWidgetHost::WebWidgetHost() |
149 : view_(NULL), | 149 : view_(NULL), |
150 webwidget_(NULL), | 150 webwidget_(NULL), |
151 scroll_dx_(0), | 151 scroll_dx_(0), |
152 scroll_dy_(0), | 152 scroll_dy_(0), |
153 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) { | 153 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) { |
154 set_painting(false); | 154 set_painting(false); |
155 } | 155 } |
156 | 156 |
157 WebWidgetHost::~WebWidgetHost() { | 157 WebWidgetHost::~WebWidgetHost() { |
158 // app::win::SetWindowUserData(hwnd_, 0); | 158 // base::win::SetWindowUserData(hwnd_, 0); |
159 | 159 |
160 webwidget_->close(); | 160 webwidget_->close(); |
161 } | 161 } |
162 | 162 |
163 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { | 163 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { |
164 paint_rect_ = paint_rect_.Union(rect); | 164 paint_rect_ = paint_rect_.Union(rect); |
165 } | 165 } |
166 | 166 |
167 void WebWidgetHost::Paint() { | 167 void WebWidgetHost::Paint() { |
168 gfx::Rect client_rect(NSRectToCGRect([view_ frame])); | 168 gfx::Rect client_rect(NSRectToCGRect([view_ frame])); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
278 #ifndef NDEBUG | 278 #ifndef NDEBUG |
279 DCHECK(!painting_); | 279 DCHECK(!painting_); |
280 #endif | 280 #endif |
281 DCHECK(canvas_.get()); | 281 DCHECK(canvas_.get()); |
282 | 282 |
283 set_painting(true); | 283 set_painting(true); |
284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); | 284 webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); |
285 set_painting(false); | 285 set_painting(false); |
286 } | 286 } |
OLD | NEW |