diff options
author | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 19:54:42 +0000 |
---|---|---|
committer | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 19:54:42 +0000 |
commit | faf19bbf27a42842d4d2bc9a1e689dfcac3bd675 (patch) | |
tree | ffd7eb58cac407e6f66595f5201fb4b394260d17 /webkit/tools/test_shell/mac/webview_host.mm | |
parent | 8dd3dddd1cd80d28cc8237a5dbcf9f60e3c24566 (diff) | |
download | chromium_src-faf19bbf27a42842d4d2bc9a1e689dfcac3bd675.zip chromium_src-faf19bbf27a42842d4d2bc9a1e689dfcac3bd675.tar.gz chromium_src-faf19bbf27a42842d4d2bc9a1e689dfcac3bd675.tar.bz2 |
Add test shell WebView and WebWidget host classes. This are stopgaps and
are subject to change as the rest of the rendering and event handling paths
come together.
Review URL: http://codereview.chromium.org/3062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/mac/webview_host.mm')
-rw-r--r-- | webkit/tools/test_shell/mac/webview_host.mm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm new file mode 100644 index 0000000..803555a --- /dev/null +++ b/webkit/tools/test_shell/mac/webview_host.mm @@ -0,0 +1,42 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#include "webkit/tools/test_shell/webview_host.h" +#include "webkit/tools/test_shell/mac/test_shell_webview.h" + +#include "base/gfx/platform_canvas.h" +#include "base/gfx/rect.h" +#include "base/gfx/size.h" +#include "webkit/glue/webinputevent.h" +#include "webkit/glue/webview.h" + +/*static*/ +WebViewHost* WebViewHost::Create(NSWindow *parent_window, + WebViewDelegate* delegate, + const WebPreferences& prefs) { + WebViewHost* host = new WebViewHost(); + + NSRect content_rect = [[parent_window contentView] frame]; + // bump down the top of the view so that it doesn't overlap the buttons + // and URL field. 32 is an ad hoc constant. + // TODO(awalker): replace explicit view layout with a little nib file + // and use that for view geometry. + content_rect.size.height -= 32; + host->view_ = [[TestShellWebView alloc] initWithFrame:content_rect]; + // make the height and width track the window size. + [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [[parent_window contentView] addSubview:host->view_]; + + host->webwidget_ = WebView::Create(delegate, prefs); + host->webwidget_->Resize(gfx::Size(content_rect.size.width, + content_rect.size.height)); + + return host; +} + +WebView* WebViewHost::webview() const { + return static_cast<WebView*>(webwidget_); +} |