| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/webview_host.h" | 7 #include "webkit/tools/test_shell/webview_host.h" |
| 8 #include "webkit/tools/test_shell/mac/test_shell_webview.h" | 8 #include "webkit/tools/test_shell/mac/test_shell_webview.h" |
| 9 | 9 |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| 11 #include "base/gfx/size.h" | 11 #include "base/gfx/size.h" |
| 12 #include "skia/ext/platform_canvas.h" | 12 #include "skia/ext/platform_canvas.h" |
| 13 #include "webkit/api/public/WebSize.h" | 13 #include "webkit/api/public/WebSize.h" |
| 14 #include "webkit/api/public/WebView.h" |
| 14 #include "webkit/glue/webpreferences.h" | 15 #include "webkit/glue/webpreferences.h" |
| 15 #include "webkit/glue/webview.h" | |
| 16 #include "webkit/tools/test_shell/test_webview_delegate.h" | 16 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 17 | 17 |
| 18 using WebKit::WebSize; | 18 using WebKit::WebSize; |
| 19 using WebKit::WebView; |
| 19 | 20 |
| 20 // static | 21 // static |
| 21 WebViewHost* WebViewHost::Create(NSView* parent_view, | 22 WebViewHost* WebViewHost::Create(NSView* parent_view, |
| 22 TestWebViewDelegate* delegate, | 23 TestWebViewDelegate* delegate, |
| 23 const WebPreferences& prefs) { | 24 const WebPreferences& prefs) { |
| 24 WebViewHost* host = new WebViewHost(); | 25 WebViewHost* host = new WebViewHost(); |
| 25 | 26 |
| 26 NSRect content_rect = [parent_view frame]; | 27 NSRect content_rect = [parent_view frame]; |
| 27 // bump down the top of the view so that it doesn't overlap the buttons | 28 // bump down the top of the view so that it doesn't overlap the buttons |
| 28 // and URL field. 32 is an ad hoc constant. | 29 // and URL field. 32 is an ad hoc constant. |
| 29 // TODO(awalker): replace explicit view layout with a little nib file | 30 // TODO(awalker): replace explicit view layout with a little nib file |
| 30 // and use that for view geometry. | 31 // and use that for view geometry. |
| 31 content_rect.size.height -= 32; | 32 content_rect.size.height -= 32; |
| 32 host->view_ = [[TestShellWebView alloc] initWithFrame:content_rect]; | 33 host->view_ = [[TestShellWebView alloc] initWithFrame:content_rect]; |
| 33 // make the height and width track the window size. | 34 // make the height and width track the window size. |
| 34 [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; | 35 [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; |
| 35 [parent_view addSubview:host->view_]; | 36 [parent_view addSubview:host->view_]; |
| 36 [host->view_ release]; | 37 [host->view_ release]; |
| 37 | 38 |
| 38 host->webwidget_ = WebView::Create(delegate); | 39 host->webwidget_ = WebView::create(delegate); |
| 39 prefs.Apply(host->webview()); | 40 prefs.Apply(host->webview()); |
| 40 host->webview()->initializeMainFrame(delegate); | 41 host->webview()->initializeMainFrame(delegate); |
| 41 host->webwidget_->resize(WebSize(content_rect.size.width, | 42 host->webwidget_->resize(WebSize(content_rect.size.width, |
| 42 content_rect.size.height)); | 43 content_rect.size.height)); |
| 43 | 44 |
| 44 return host; | 45 return host; |
| 45 } | 46 } |
| 46 | 47 |
| 47 WebView* WebViewHost::webview() const { | 48 WebView* WebViewHost::webview() const { |
| 48 return static_cast<WebView*>(webwidget_); | 49 return static_cast<WebView*>(webwidget_); |
| 49 } | 50 } |
| OLD | NEW |