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

Side by Side Diff: content/renderer/external_popup_menu.cc

Issue 23364004: Implementation of device metrics emulation in render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebase Created 7 years, 2 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 | « content/renderer/external_popup_menu.h ('k') | content/renderer/render_view_impl.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/external_popup_menu.h" 5 #include "content/renderer/external_popup_menu.h"
6 6
7 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
8 #include "content/renderer/menu_item_builder.h" 8 #include "content/renderer/menu_item_builder.h"
9 #include "content/renderer/render_view_impl.h" 9 #include "content/renderer/render_view_impl.h"
10 #include "third_party/WebKit/public/platform/WebRect.h" 10 #include "third_party/WebKit/public/platform/WebRect.h"
11 #include "third_party/WebKit/public/web/WebExternalPopupMenuClient.h" 11 #include "third_party/WebKit/public/web/WebExternalPopupMenuClient.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 ExternalPopupMenu::ExternalPopupMenu( 15 ExternalPopupMenu::ExternalPopupMenu(
16 RenderViewImpl* render_view, 16 RenderViewImpl* render_view,
17 const WebKit::WebPopupMenuInfo& popup_menu_info, 17 const WebKit::WebPopupMenuInfo& popup_menu_info,
18 WebKit::WebExternalPopupMenuClient* popup_menu_client) 18 WebKit::WebExternalPopupMenuClient* popup_menu_client)
19 : render_view_(render_view), 19 : render_view_(render_view),
20 popup_menu_info_(popup_menu_info), 20 popup_menu_info_(popup_menu_info),
21 popup_menu_client_(popup_menu_client) { 21 popup_menu_client_(popup_menu_client),
22 origin_scale_for_emulation_(0) {
23 }
24
25 void ExternalPopupMenu::SetOriginScaleForEmulation(float scale) {
26 origin_scale_for_emulation_ = scale;
22 } 27 }
23 28
24 void ExternalPopupMenu::show(const WebKit::WebRect& bounds) { 29 void ExternalPopupMenu::show(const WebKit::WebRect& bounds) {
30 WebKit::WebRect rect = bounds;
31 if (origin_scale_for_emulation_) {
32 rect.x *= origin_scale_for_emulation_;
33 rect.y *= origin_scale_for_emulation_;
34 }
35
25 ViewHostMsg_ShowPopup_Params popup_params; 36 ViewHostMsg_ShowPopup_Params popup_params;
26 popup_params.bounds = bounds; 37 popup_params.bounds = rect;
27 popup_params.item_height = popup_menu_info_.itemHeight; 38 popup_params.item_height = popup_menu_info_.itemHeight;
28 popup_params.item_font_size = popup_menu_info_.itemFontSize; 39 popup_params.item_font_size = popup_menu_info_.itemFontSize;
29 popup_params.selected_item = popup_menu_info_.selectedIndex; 40 popup_params.selected_item = popup_menu_info_.selectedIndex;
30 for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) { 41 for (size_t i = 0; i < popup_menu_info_.items.size(); ++i) {
31 popup_params.popup_items.push_back( 42 popup_params.popup_items.push_back(
32 MenuItemBuilder::Build(popup_menu_info_.items[i])); 43 MenuItemBuilder::Build(popup_menu_info_.items[i]));
33 } 44 }
34 popup_params.right_aligned = popup_menu_info_.rightAligned; 45 popup_params.right_aligned = popup_menu_info_.rightAligned;
35 popup_params.allow_multiple_selection = 46 popup_params.allow_multiple_selection =
36 popup_menu_info_.allowMultipleSelection; 47 popup_menu_info_.allowMultipleSelection;
(...skipping 23 matching lines...) Expand all
60 if (!popup_menu_client_) 71 if (!popup_menu_client_)
61 return; 72 return;
62 if (canceled) 73 if (canceled)
63 popup_menu_client_->didCancel(); 74 popup_menu_client_->didCancel();
64 else 75 else
65 popup_menu_client_->didAcceptIndices(indices); 76 popup_menu_client_->didAcceptIndices(indices);
66 } 77 }
67 #endif 78 #endif
68 79
69 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/external_popup_menu.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698