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

Side by Side Diff: chrome/browser/cocoa/location_bar/location_bar_view_mac.mm

Issue 4544004: Fix bubble offset issue (bubble x-coordinate pointing to wrong place) on OS X... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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/cocoa/base_bubble_controller.mm ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/nsimage_cache_mac.h" 9 #include "base/nsimage_cache_mac.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "chrome/common/notification_service.h" 51 #include "chrome/common/notification_service.h"
52 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
53 #include "net/base/net_util.h" 53 #include "net/base/net_util.h"
54 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
55 #include "grit/theme_resources.h" 55 #include "grit/theme_resources.h"
56 #include "skia/ext/skia_utils_mac.h" 56 #include "skia/ext/skia_utils_mac.h"
57 #include "third_party/skia/include/core/SkBitmap.h" 57 #include "third_party/skia/include/core/SkBitmap.h"
58 58
59 namespace { 59 namespace {
60 60
61 // Horizontal space between the right edge of the |location_icon_decoration_|
62 // and the first run bubble arrow point.
63 const static int kFirstRunBubbleXOffset = 4;
64
65 // Vertical space between the bottom edge of the location_bar and the first run 61 // Vertical space between the bottom edge of the location_bar and the first run
66 // bubble arrow point. 62 // bubble arrow point.
67 const static int kFirstRunBubbleYOffset = 1; 63 const static int kFirstRunBubbleYOffset = 1;
68 64
69 } 65 }
70 66
71 // TODO(shess): This code is mostly copied from the gtk 67 // TODO(shess): This code is mostly copied from the gtk
72 // implementation. Make sure it's all appropriate and flesh it out. 68 // implementation. Make sure it's all appropriate and flesh it out.
73 69
74 LocationBarViewMac::LocationBarViewMac( 70 LocationBarViewMac::LocationBarViewMac(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 Task* task = first_run_bubble_.NewRunnableMethod( 117 Task* task = first_run_bubble_.NewRunnableMethod(
122 &LocationBarViewMac::ShowFirstRunBubbleInternal, bubble_type); 118 &LocationBarViewMac::ShowFirstRunBubbleInternal, bubble_type);
123 MessageLoop::current()->PostTask(FROM_HERE, task); 119 MessageLoop::current()->PostTask(FROM_HERE, task);
124 } 120 }
125 121
126 void LocationBarViewMac::ShowFirstRunBubbleInternal( 122 void LocationBarViewMac::ShowFirstRunBubbleInternal(
127 FirstRun::BubbleType bubble_type) { 123 FirstRun::BubbleType bubble_type) {
128 if (!field_ || ![field_ window]) 124 if (!field_ || ![field_ window])
129 return; 125 return;
130 126
131 // The bubble needs to be just below the Omnibox and slightly to the right 127 // The first run bubble's left edge should line up with the left edge of the
132 // of the left omnibox icon, so shift x and y co-ordinates. 128 // omnibox. This is different from other bubbles, which line up at a point
133 const NSPoint kOffset = GetFirstRunBubblePoint(); 129 // set by their top arrow. Because the BaseBubbleController adjusts the
130 // window origin left to account for the arrow spacing, the first run bubble
131 // moves the window origin right by this spacing, so that the
132 // BaseBubbleController will move it back to the correct position.
133 const NSPoint kOffset = NSMakePoint(
134 info_bubble::kBubbleArrowXOffset + info_bubble::kBubbleArrowWidth/2.0,
135 kFirstRunBubbleYOffset);
134 [FirstRunBubbleController showForView:field_ offset:kOffset profile:profile_]; 136 [FirstRunBubbleController showForView:field_ offset:kOffset profile:profile_];
135 } 137 }
136 138
137 std::wstring LocationBarViewMac::GetInputString() const { 139 std::wstring LocationBarViewMac::GetInputString() const {
138 return location_input_; 140 return location_input_;
139 } 141 }
140 142
141 void LocationBarViewMac::SetSuggestedText(const string16& text) { 143 void LocationBarViewMac::SetSuggestedText(const string16& text) {
142 // TODO(rohitrao): implement me. http://crbug.com/56385 144 // TODO(rohitrao): implement me. http://crbug.com/56385
143 } 145 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } else { 500 } else {
499 const NSRect frame = 501 const NSRect frame =
500 [cell frameForDecoration:location_icon_decoration_.get() 502 [cell frameForDecoration:location_icon_decoration_.get()
501 inFrame:[field_ bounds]]; 503 inFrame:[field_ bounds]];
502 const NSPoint point = 504 const NSPoint point =
503 location_icon_decoration_->GetBubblePointInFrame(frame); 505 location_icon_decoration_->GetBubblePointInFrame(frame);
504 return [field_ convertPoint:point toView:nil]; 506 return [field_ convertPoint:point toView:nil];
505 } 507 }
506 } 508 }
507 509
508 NSPoint LocationBarViewMac::GetFirstRunBubblePoint() const {
509 AutocompleteTextFieldCell* cell = [field_ cell];
510 const NSRect frame =
511 [cell frameForDecoration:location_icon_decoration_.get()
512 inFrame:[field_ bounds]];
513 return NSMakePoint(
514 NSMaxX(frame) + kFirstRunBubbleXOffset,
515 kFirstRunBubbleYOffset);
516 }
517
518 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) { 510 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) {
519 const TemplateURL* template_url = 511 const TemplateURL* template_url =
520 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); 512 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
521 if (template_url && template_url->IsExtensionKeyword()) { 513 if (template_url && template_url->IsExtensionKeyword()) {
522 const SkBitmap& bitmap = profile_->GetExtensionsService()-> 514 const SkBitmap& bitmap = profile_->GetExtensionsService()->
523 GetOmniboxIcon(template_url->GetExtensionId()); 515 GetOmniboxIcon(template_url->GetExtensionId());
524 return gfx::SkBitmapToNSImage(bitmap); 516 return gfx::SkBitmapToNSImage(bitmap);
525 } 517 }
526 518
527 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); 519 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 667
676 // These need to change anytime the layout changes. 668 // These need to change anytime the layout changes.
677 // TODO(shess): Anytime the field editor might have changed, the 669 // TODO(shess): Anytime the field editor might have changed, the
678 // cursor rects almost certainly should have changed. The tooltips 670 // cursor rects almost certainly should have changed. The tooltips
679 // might change even when the rects don't change. 671 // might change even when the rects don't change.
680 [field_ resetFieldEditorFrameIfNeeded]; 672 [field_ resetFieldEditorFrameIfNeeded];
681 [field_ updateCursorAndToolTipRects]; 673 [field_ updateCursorAndToolTipRects];
682 674
683 [field_ setNeedsDisplay:YES]; 675 [field_ setNeedsDisplay:YES];
684 } 676 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/base_bubble_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698