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

Side by Side Diff: webkit/tools/test_shell/mac/test_webview_delegate.mm

Issue 155378: Replace ShowAsPopupWithItems to CreatePopupWidgetWithInfo. Also,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« no previous file with comments | « webkit/glue/webworker_impl.cc ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "webkit/tools/test_shell/test_webview_delegate.h" 5 #include "webkit/tools/test_shell/test_webview_delegate.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "webkit/api/public/WebCursorInfo.h" 10 #include "webkit/api/public/WebCursorInfo.h"
11 #include "webkit/api/public/WebRect.h"
12 #include "webkit/glue/webcursor.h" 11 #include "webkit/glue/webcursor.h"
13 #include "webkit/glue/webview.h" 12 #include "webkit/glue/webview.h"
14 #include "webkit/glue/plugins/plugin_list.h" 13 #include "webkit/glue/plugins/plugin_list.h"
15 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 14 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
16 #include "webkit/glue/webmenurunner_mac.h" 15 #include "webkit/glue/webmenurunner_mac.h"
17 #include "webkit/tools/test_shell/test_shell.h" 16 #include "webkit/tools/test_shell/test_shell.h"
18 17
19 using WebKit::WebCursorInfo; 18 using WebKit::WebCursorInfo;
19 using WebKit::WebPopupMenuInfo;
20 using WebKit::WebRect; 20 using WebKit::WebRect;
21 21
22 // WebViewDelegate ----------------------------------------------------------- 22 // WebViewDelegate -----------------------------------------------------------
23 23
24 TestWebViewDelegate::~TestWebViewDelegate() { 24 TestWebViewDelegate::~TestWebViewDelegate() {
25 } 25 }
26 26
27 WebWidget* TestWebViewDelegate::CreatePopupWidgetWithInfo(
28 WebView* webview,
29 const WebPopupMenuInfo& info) {
30 WebWidget* webwidget = shell_->CreatePopupWidget(webview);
31 popup_menu_info_.reset(new WebPopupMenuInfo(info));
32 return webwidget;
33 }
34
27 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( 35 WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
28 WebView* webview, 36 WebView* webview,
29 const GURL& url, 37 const GURL& url,
30 const std::string& mime_type, 38 const std::string& mime_type,
31 const std::string& clsid, 39 const std::string& clsid,
32 std::string* actual_mime_type) { 40 std::string* actual_mime_type) {
33 WebWidgetHost *host = GetHostForWidget(webview); 41 WebWidgetHost *host = GetHostForWidget(webview);
34 if (!host) 42 if (!host)
35 return NULL; 43 return NULL;
36 gfx::NativeView view = host->view_handle(); 44 gfx::NativeView view = host->view_handle();
(...skipping 18 matching lines...) Expand all
55 defaultButton:@"OK" 63 defaultButton:@"OK"
56 alternateButton:nil 64 alternateButton:nil
57 otherButton:nil 65 otherButton:nil
58 informativeTextWithFormat:text]; 66 informativeTextWithFormat:text];
59 [alert runModal]; 67 [alert runModal];
60 } 68 }
61 69
62 70
63 // WebWidgetDelegate --------------------------------------------------------- 71 // WebWidgetDelegate ---------------------------------------------------------
64 72
65 void TestWebViewDelegate::Show(WebWidget* webview, 73 void TestWebViewDelegate::Show(WebWidget* webwidget,
66 WindowOpenDisposition disposition) { 74 WindowOpenDisposition disposition) {
67 } 75 if (!popup_menu_info_.get())
76 return;
77 if (webwidget != shell_->popup())
78 return;
79 // Display a HTML select menu.
68 80
69 // Display a HTML select menu. 81 std::vector<WebMenuItem> items;
70 void TestWebViewDelegate::ShowAsPopupWithItems( 82 for (size_t i = 0; i < popup_menu_info_->items.size(); ++i)
71 WebWidget* webview, 83 items.push_back(popup_menu_info_->items[i]);
72 const WebRect& bounds, 84
73 int item_height, 85 int item_height = popup_menu_info_->itemHeight;
74 int selected_index, 86 int selected_index = popup_menu_info_->selectedIndex;
75 const std::vector<WebMenuItem>& items) { 87 popup_menu_info_.reset(); // No longer needed.
88
89 const WebRect& bounds = popup_bounds_;
90
76 // Set up the menu position. 91 // Set up the menu position.
77 NSView* web_view = shell_->webViewWnd(); 92 NSView* web_view = shell_->webViewWnd();
78 NSRect view_rect = [web_view bounds]; 93 NSRect view_rect = [web_view bounds];
79 int y_offset = bounds.y + bounds.height; 94 int y_offset = bounds.y + bounds.height;
80 NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset, 95 NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset,
81 bounds.width, bounds.height); 96 bounds.width, bounds.height);
82 97
83 // Display the menu. 98 // Display the menu.
84 scoped_nsobject<WebMenuRunner> menu_runner; 99 scoped_nsobject<WebMenuRunner> menu_runner;
85 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]); 100 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 *out_rect = gfx::Rect(NSRectToCGRect(rect)); 154 *out_rect = gfx::Rect(NSRectToCGRect(rect));
140 } 155 }
141 } 156 }
142 157
143 void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, 158 void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
144 const WebRect& rect) { 159 const WebRect& rect) {
145 // TODO: Mac window movement 160 // TODO: Mac window movement
146 if (webwidget == shell_->webView()) { 161 if (webwidget == shell_->webView()) {
147 // ignored 162 // ignored
148 } else if (webwidget == shell_->popup()) { 163 } else if (webwidget == shell_->popup()) {
149 // MoveWindow(shell_->popupWnd(), 164 popup_bounds_ = rect; // The initial position of the popup.
150 // rect.x(), rect.y(), rect.width(), rect.height(), FALSE);
151 } 165 }
152 } 166 }
153 167
154 void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, 168 void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget,
155 WebRect* out_rect) { 169 WebRect* out_rect) {
156 if (WebWidgetHost* host = GetHostForWidget(webwidget)) { 170 if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
157 NSView *view = host->view_handle(); 171 NSView *view = host->view_handle();
158 NSRect rect = [[[view window] contentView] frame]; 172 NSRect rect = [[[view window] contentView] frame];
159 *out_rect = gfx::Rect(NSRectToCGRect(rect)); 173 *out_rect = gfx::Rect(NSRectToCGRect(rect));
160 } 174 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { 220 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) {
207 [[shell_->webViewHost()->view_handle() window] 221 [[shell_->webViewHost()->view_handle() window]
208 setTitle:[NSString stringWithUTF8String:WideToUTF8(title).c_str()]]; 222 setTitle:[NSString stringWithUTF8String:WideToUTF8(title).c_str()]];
209 } 223 }
210 224
211 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { 225 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) {
212 const char* frameURL = url.spec().c_str(); 226 const char* frameURL = url.spec().c_str();
213 NSString *address = [NSString stringWithUTF8String:frameURL]; 227 NSString *address = [NSString stringWithUTF8String:frameURL];
214 [shell_->editWnd() setStringValue:address]; 228 [shell_->editWnd() setStringValue:address];
215 } 229 }
OLDNEW
« no previous file with comments | « webkit/glue/webworker_impl.cc ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698