summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 17:02:59 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 17:02:59 +0000
commitc9e1979455bd83b1d3c6d95be4c84cc7153ced7f (patch)
tree770e8e45f936db44009beee5318161321443d2c7
parent1c03f89408d129f8defb846779d3ecb57e43f9ad (diff)
downloadchromium_src-c9e1979455bd83b1d3c6d95be4c84cc7153ced7f.zip
chromium_src-c9e1979455bd83b1d3c6d95be4c84cc7153ced7f.tar.gz
chromium_src-c9e1979455bd83b1d3c6d95be4c84cc7153ced7f.tar.bz2
[Mac] Match popup contents to page zoom size.
Fix the size of the font used in popups presented by the browser UI thread. WebKit was modified to add a field containing the font size, the font size is then propagated in the message sent to the browser, and the web menu runner sets that font size on the popup button resonsible for running the popup menu. Requires WebKit release >= 55897. See WebKit bug https://bugs.webkit.org/show_bug.cgi?id=35990 BUG=14010 TEST=none Review URL: http://codereview.chromium.org/996001 Patch from scottbyer@chromium.org. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41845 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm4
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.h1
-rw-r--r--chrome/common/render_messages.h7
-rw-r--r--chrome/renderer/render_widget.cc1
-rw-r--r--webkit/glue/webmenurunner_mac.h6
-rw-r--r--webkit/glue/webmenurunner_mac.mm5
-rw-r--r--webkit/tools/test_shell/mac/test_webview_delegate.mm4
10 files changed, 27 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 1cdc0a8..152aae1 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -900,6 +900,7 @@ void RenderWidgetHost::OnMsgShowPopup(
const ViewHostMsg_ShowPopup_Params& params) {
view_->ShowPopupWithItems(params.bounds,
params.item_height,
+ params.item_font_size,
params.selected_item,
params.popup_items);
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index a022ec8..ad8a341 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -161,6 +161,7 @@ class RenderWidgetHostView {
// Display a native control popup menu for WebKit.
virtual void ShowPopupWithItems(gfx::Rect bounds,
int item_height,
+ double item_font_size,
int selected_item,
const std::vector<WebMenuItem>& items) = 0;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 10a21c8..bc9fbe9 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -113,6 +113,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
virtual VideoLayer* AllocVideoLayer(const gfx::Size& size);
virtual void ShowPopupWithItems(gfx::Rect bounds,
int item_height,
+ double item_font_size,
int selected_item,
const std::vector<WebMenuItem>& items);
virtual gfx::Rect GetWindowRect();
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index b46a3dd..1c04b36 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -439,6 +439,7 @@ VideoLayer* RenderWidgetHostViewMac::AllocVideoLayer(
void RenderWidgetHostViewMac::ShowPopupWithItems(
gfx::Rect bounds,
int item_height,
+ double item_font_size,
int selected_item,
const std::vector<WebMenuItem>& items) {
is_popup_menu_ = true;
@@ -458,7 +459,8 @@ void RenderWidgetHostViewMac::ShowPopupWithItems(
// Display the menu.
scoped_nsobject<WebMenuRunner> menu_runner;
- menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]);
+ menu_runner.reset([[WebMenuRunner alloc] initWithItems:items
+ fontSize:item_font_size]);
{
// Make sure events can be pumped while the menu is up.
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index 3939ad9..bbc6ea6 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -73,6 +73,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView {
#if defined(OS_MACOSX)
virtual void ShowPopupWithItems(gfx::Rect bounds,
int item_height,
+ double item_font_size,
int selected_item,
const std::vector<WebMenuItem>& items) {}
virtual gfx::Rect GetWindowRect();
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 533ac30..07639d4 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -478,6 +478,9 @@ struct ViewHostMsg_ShowPopup_Params {
// The height of each item in the menu.
int item_height;
+ // The size of the font to use for those items.
+ double item_font_size;
+
// The currently selected (displayed) item in the menu.
int selected_item;
@@ -2232,6 +2235,7 @@ struct ParamTraits<ViewHostMsg_ShowPopup_Params> {
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.bounds);
WriteParam(m, p.item_height);
+ WriteParam(m, p.item_font_size);
WriteParam(m, p.selected_item);
WriteParam(m, p.popup_items);
}
@@ -2239,6 +2243,7 @@ struct ParamTraits<ViewHostMsg_ShowPopup_Params> {
return
ReadParam(m, iter, &p->bounds) &&
ReadParam(m, iter, &p->item_height) &&
+ ReadParam(m, iter, &p->item_font_size) &&
ReadParam(m, iter, &p->selected_item) &&
ReadParam(m, iter, &p->popup_items);
}
@@ -2248,6 +2253,8 @@ struct ParamTraits<ViewHostMsg_ShowPopup_Params> {
l->append(L", ");
LogParam(p.item_height, l);
l->append(L", ");
+ LogParam(p.item_font_size, l);
+ l->append(L", ");
LogParam(p.selected_item, l);
l->append(L", ");
LogParam(p.popup_items, l);
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 686862f..c335d54 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -96,6 +96,7 @@ RenderWidget* RenderWidget::Create(int32 opener_id,
void RenderWidget::ConfigureAsExternalPopupMenu(const WebPopupMenuInfo& info) {
popup_params_.reset(new ViewHostMsg_ShowPopup_Params);
popup_params_->item_height = info.itemHeight;
+ popup_params_->item_font_size = info.itemFontSize;
popup_params_->selected_item = info.selectedIndex;
for (size_t i = 0; i < info.items.size(); ++i)
popup_params_->popup_items.push_back(WebMenuItem(info.items[i]));
diff --git a/webkit/glue/webmenurunner_mac.h b/webkit/glue/webmenurunner_mac.h
index b83abeb..6f01daf 100644
--- a/webkit/glue/webmenurunner_mac.h
+++ b/webkit/glue/webmenurunner_mac.h
@@ -30,10 +30,14 @@
// The index of the selected menu item.
int index_;
+
+ // The font size being used for the menu.
+ CGFloat fontSize_;
}
// Initializes the MenuDelegate with a list of items sent from WebKit.
-- (id)initWithItems:(const std::vector<WebMenuItem>&)items;
+- (id)initWithItems:(const std::vector<WebMenuItem>&)items
+ fontSize:(CGFloat)fontSize;
// Returns YES if an item was selected from the menu, NO if the menu was
// dismissed.
diff --git a/webkit/glue/webmenurunner_mac.mm b/webkit/glue/webmenurunner_mac.mm
index 99c52bd..65ff9e7 100644
--- a/webkit/glue/webmenurunner_mac.mm
+++ b/webkit/glue/webmenurunner_mac.mm
@@ -20,11 +20,13 @@
@implementation WebMenuRunner
-- (id)initWithItems:(const std::vector<WebMenuItem>&)items {
+- (id)initWithItems:(const std::vector<WebMenuItem>&)items
+ fontSize:(CGFloat)fontSize {
if ((self = [super init])) {
menu_.reset([[NSMenu alloc] initWithTitle:@""]);
[menu_ setAutoenablesItems:NO];
index_ = -1;
+ fontSize_ = fontSize;
for (size_t i = 0; i < items.size(); ++i)
[self addItem:items[i]];
}
@@ -68,6 +70,7 @@
[button autorelease];
[button setMenu:menu_];
[button selectItemAtIndex:index];
+ [button setFont:[NSFont menuFontOfSize:fontSize_]];
// Display the menu, and set a flag if a menu item was chosen.
[button performClickWithFrame:bounds inView:view];
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm
index ee5cef1..83d0237 100644
--- a/webkit/tools/test_shell/mac/test_webview_delegate.mm
+++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm
@@ -46,6 +46,7 @@ void TestWebViewDelegate::show(WebNavigationPolicy policy) {
items.push_back(popup_menu_info_->items[i]);
int item_height = popup_menu_info_->itemHeight;
+ double font_size = popup_menu_info_->itemFontSize;
int selected_index = popup_menu_info_->selectedIndex;
popup_menu_info_.reset(); // No longer needed.
@@ -60,7 +61,8 @@ void TestWebViewDelegate::show(WebNavigationPolicy policy) {
// Display the menu.
scoped_nsobject<WebMenuRunner> menu_runner;
- menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]);
+ menu_runner.reset([[WebMenuRunner alloc] initWithItems:items
+ fontSize:font_size]);
[menu_runner runMenuInView:shell_->webViewWnd()
withBounds:position