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

Side by Side Diff: chrome/browser/views/toolbar_view.cc

Issue 18799: Make popups closer to pixel-perfect. The main problem is that the toolbar is... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | « chrome/browser/views/toolbar_view.h ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 "chrome/browser/views/toolbar_view.h" 5 #include "chrome/browser/views/toolbar_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/app/chrome_dll_resource.h" 11 #include "chrome/app/chrome_dll_resource.h"
12 #include "chrome/app/theme/theme_resources.h" 12 #include "chrome/app/theme/theme_resources.h"
13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h"
14 #include "chrome/browser/bookmarks/bookmark_model.h" 14 #include "chrome/browser/bookmarks/bookmark_model.h"
15 #include "chrome/browser/browser.h" 15 #include "chrome/browser/browser.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/character_encoding.h" 17 #include "chrome/browser/character_encoding.h"
18 #include "chrome/browser/drag_utils.h" 18 #include "chrome/browser/drag_utils.h"
19 #include "chrome/browser/metrics/user_metrics.h" 19 #include "chrome/browser/metrics/user_metrics.h"
20 #include "chrome/browser/profile.h" 20 #include "chrome/browser/profile.h"
21 #include "chrome/browser/tab_contents/navigation_controller.h" 21 #include "chrome/browser/tab_contents/navigation_controller.h"
22 #include "chrome/browser/tab_contents/navigation_entry.h" 22 #include "chrome/browser/tab_contents/navigation_entry.h"
23 #include "chrome/browser/user_data_manager.h" 23 #include "chrome/browser/user_data_manager.h"
24 #include "chrome/browser/views/dom_view.h" 24 #include "chrome/browser/views/dom_view.h"
25 #include "chrome/browser/views/frame/browser_view.h"
25 #include "chrome/browser/views/go_button.h" 26 #include "chrome/browser/views/go_button.h"
26 #include "chrome/browser/views/location_bar_view.h" 27 #include "chrome/browser/views/location_bar_view.h"
27 #include "chrome/browser/views/theme_helpers.h" 28 #include "chrome/browser/views/theme_helpers.h"
28 #include "chrome/browser/views/toolbar_star_toggle.h" 29 #include "chrome/browser/views/toolbar_star_toggle.h"
29 #include "chrome/browser/view_ids.h" 30 #include "chrome/browser/view_ids.h"
30 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
31 #include "chrome/common/drag_drop_types.h" 32 #include "chrome/common/drag_drop_types.h"
32 #include "chrome/common/l10n_util.h" 33 #include "chrome/common/l10n_util.h"
33 #include "chrome/common/notification_service.h" 34 #include "chrome/common/notification_service.h"
34 #include "chrome/common/os_exchange_data.h" 35 #include "chrome/common/os_exchange_data.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
36 #include "chrome/common/pref_service.h" 37 #include "chrome/common/pref_service.h"
37 #include "chrome/common/resource_bundle.h" 38 #include "chrome/common/resource_bundle.h"
38 #include "chrome/views/background.h" 39 #include "chrome/views/background.h"
39 #include "chrome/views/button_dropdown.h" 40 #include "chrome/views/button_dropdown.h"
40 #include "chrome/views/hwnd_view.h" 41 #include "chrome/views/hwnd_view.h"
41 #include "chrome/views/label.h" 42 #include "chrome/views/label.h"
42 #include "chrome/views/tooltip_manager.h" 43 #include "chrome/views/tooltip_manager.h"
43 #include "chrome/views/widget.h" 44 #include "chrome/views/widget.h"
44 #include "net/base/net_util.h" 45 #include "net/base/net_util.h"
45 46
46 #include "chromium_strings.h" 47 #include "chromium_strings.h"
47 #include "generated_resources.h" 48 #include "generated_resources.h"
48 49
49 static const int kControlHorizOffset = 4; 50 static const int kControlHorizOffset = 4;
50 static const int kControlVertOffset = 6; 51 static const int kControlVertOffset = 6;
51 static const int kControlVertOffsetLocationOnly = 4;
52 // The left and right margin of the toolbar in location-bar only mode.
53 static const int kToolbarHorizontalMargin = 1;
54 static const int kControlIndent = 3; 52 static const int kControlIndent = 3;
55 static const int kStatusBubbleWidth = 480; 53 static const int kStatusBubbleWidth = 480;
56 54
57 // Separation between the location bar and the menus. 55 // Separation between the location bar and the menus.
58 static const int kMenuButtonOffset = 3; 56 static const int kMenuButtonOffset = 3;
59 57
60 // Padding to the right of the location bar 58 // Padding to the right of the location bar
61 static const int kPaddingRight = 2; 59 static const int kPaddingRight = 2;
62 60
63 BrowserToolbarView::BrowserToolbarView(Browser* browser) 61 BrowserToolbarView::BrowserToolbarView(Browser* browser)
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 310
313 sz = app_menu_->GetPreferredSize(); 311 sz = app_menu_->GetPreferredSize();
314 right_side_width += sz.width() + kPaddingRight; 312 right_side_width += sz.width() + kPaddingRight;
315 313
316 sz = go_->GetPreferredSize(); 314 sz = go_->GetPreferredSize();
317 location_bar_height = sz.height(); 315 location_bar_height = sz.height();
318 right_side_width += sz.width(); 316 right_side_width += sz.width();
319 317
320 left_side_width = star_->x() + star_->width(); 318 left_side_width = star_->x() + star_->width();
321 } else { 319 } else {
322 gfx::Size temp = location_bar_->GetPreferredSize(); 320 location_bar_height = location_bar_->GetPreferredSize().height();
323 location_bar_height = temp.height(); 321 location_bar_y = 0;
324 left_side_width = kToolbarHorizontalMargin;
325 right_side_width = kToolbarHorizontalMargin;
326 location_bar_y = kControlVertOffsetLocationOnly;
327 } 322 }
328 323
329 location_bar_->SetBounds(left_side_width, location_bar_y, 324 location_bar_->SetBounds(left_side_width, location_bar_y,
330 width() - left_side_width - right_side_width, 325 width() - left_side_width - right_side_width,
331 location_bar_height); 326 location_bar_height);
332 327
333 if (IsDisplayModeNormal()) { 328 if (IsDisplayModeNormal()) {
334 go_->SetBounds(location_bar_->x() + location_bar_->width(), 329 go_->SetBounds(location_bar_->x() + location_bar_->width(),
335 kControlVertOffset, sz.width(), sz.height()); 330 kControlVertOffset, sz.width(), sz.height());
336 331
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 gfx::Size BrowserToolbarView::GetPreferredSize() { 472 gfx::Size BrowserToolbarView::GetPreferredSize() {
478 if (IsDisplayModeNormal()) { 473 if (IsDisplayModeNormal()) {
479 static SkBitmap normal_background; 474 static SkBitmap normal_background;
480 if (normal_background.isNull()) { 475 if (normal_background.isNull()) {
481 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 476 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
482 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); 477 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
483 } 478 }
484 return gfx::Size(0, normal_background.height()); 479 return gfx::Size(0, normal_background.height());
485 } 480 }
486 481
487 int locbar_height = location_bar_->GetPreferredSize().height(); 482 int client_edge_height =
488 return gfx::Size(0, locbar_height + 2 * kControlVertOffsetLocationOnly); 483 (browser_->window() && !browser_->window()->IsMaximized()) ?
484 BrowserView::kClientEdgeThickness : 0;
485 return gfx::Size(0,
486 location_bar_->GetPreferredSize().height() + client_edge_height);
489 } 487 }
490 488
491 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { 489 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) {
492 Menu::AnchorPoint anchor = Menu::TOPRIGHT; 490 Menu::AnchorPoint anchor = Menu::TOPRIGHT;
493 if (UILayoutIsRightToLeft()) 491 if (UILayoutIsRightToLeft())
494 anchor = Menu::TOPLEFT; 492 anchor = Menu::TOPLEFT;
495 493
496 Menu menu(this, anchor, hwnd); 494 Menu menu(this, anchor, hwnd);
497 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS, 495 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS,
498 l10n_util::GetString(IDS_CREATE_SHORTCUTS)); 496 l10n_util::GetString(IDS_CREATE_SHORTCUTS));
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 *accel = views::Accelerator(L'C', false, true, false); 803 *accel = views::Accelerator(L'C', false, true, false);
806 return true; 804 return true;
807 case IDC_PASTE: 805 case IDC_PASTE:
808 *accel = views::Accelerator(L'V', false, true, false); 806 *accel = views::Accelerator(L'V', false, true, false);
809 return true; 807 return true;
810 } 808 }
811 // Else, we retrieve the accelerator information from the frame. 809 // Else, we retrieve the accelerator information from the frame.
812 return GetWidget()->GetAccelerator(id, accel); 810 return GetWidget()->GetAccelerator(id, accel);
813 } 811 }
814 812
OLDNEW
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698