summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 16:14:39 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 16:14:39 +0000
commit529afc4a06f74fe8d93cb7d62ecfd23b338de78d (patch)
tree713f2796f45949844d135ec64282390213bbf77a /chrome/browser/cocoa
parenta7a478ce4507536d60554dd3885100a9964792fa (diff)
downloadchromium_src-529afc4a06f74fe8d93cb7d62ecfd23b338de78d.zip
chromium_src-529afc4a06f74fe8d93cb7d62ecfd23b338de78d.tar.gz
chromium_src-529afc4a06f74fe8d93cb7d62ecfd23b338de78d.tar.bz2
Fix extension installed bubble, so that it points to the correct page action icon when more than one page action is visible.
BUG= 38255 TEST= see bug report; this should no longer be reproducible. Review URL: http://codereview.chromium.org/1083002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm17
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h9
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm11
3 files changed, 19 insertions, 18 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index 2b5600a..4b719a1 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -304,13 +304,11 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
LocationBarViewMac::PageActionImageView* view =
page_action_views_->ViewAt(index);
- // If we are calculating space for a preview page action, the icon is still
- // loading. We use this function only to get the correct x value for the
- // extension installed bubble arrow.
- if (!view->preview_enabled() &&
- (!view->GetImage() || !view->IsVisible())) {
+ // When this method is called, all the icon images are still loading, so
+ // just check to see whether the view is visible when deciding whether
+ // its NSRect should be made available.
+ if (!view->preview_enabled() && !view->IsVisible())
return NSZeroRect;
- }
for (AutocompleteTextFieldIcon* icon in [self layedOutIcons:cellFrame]) {
if (view == [icon view])
@@ -418,8 +416,11 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
for (size_t i = 0; i < pageActionCount; ++i) {
LocationBarViewMac::PageActionImageView* view =
page_action_views_->ViewAt(i);
- if (view->preview_enabled() || (view->GetImage() && view->IsVisible())) {
- NSSize iconSize = view->GetImageSize();
+ if (view->preview_enabled() || view->IsVisible()) {
+ // If this function is called right after a page action icon has been
+ // created, the images for all views will still be loading; in this case,
+ // each visible view will give us its default size.
+ NSSize iconSize = view->GetPreferredImageSize();
NSRect pageActionFrame =
[self rightJustifyImage:iconSize
inRect:iconFrame
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index 9f376e6..393acf3 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -230,9 +230,12 @@ class LocationBarViewMac : public AutocompleteEditController,
bool preview_enabled() { return preview_enabled_; }
- // Return the size of the image, or a default size if no image available
- // and preview is enabled.
- virtual NSSize GetImageSize();
+ // Returns the size of the image, or a default size if no image available.
+ // When a new page action is created, all the icons are destroyed and
+ // recreated; at this point we need to calculate sizes to lay out the
+ // icons even though no images are available yet. For this case, we return
+ // the default image size for a page icon.
+ virtual NSSize GetPreferredImageSize();
// Either notify listeners or show a popup depending on the Page Action.
virtual void OnMousePressed(NSRect bounds);
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index bbd30c1..032443f 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -646,17 +646,14 @@ LocationBarViewMac::PageActionImageView::~PageActionImageView() {
tracker_->StopTrackingImageLoad();
}
-NSSize LocationBarViewMac::PageActionImageView::GetImageSize() {
+NSSize LocationBarViewMac::PageActionImageView::GetPreferredImageSize() {
NSImage* image = GetImage();
- if (preview_enabled_ && !image) {
+ if (image) {
+ return [image size];
+ } else {
return NSMakeSize(Extension::kPageActionIconMaxSize,
Extension::kPageActionIconMaxSize);
- } else if (image) {
- return [image size];
}
- // Default value for image size is undefined when preview is not enabled.
- NOTREACHED();
- return NSMakeSize(0, 0);
}
// Overridden from LocationBarImageView. Either notify listeners or show a