diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-02 23:56:22 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-02 23:56:22 +0000 |
commit | ec94b4aeb47ae695d4fe20af71f2652df577a2cf (patch) | |
tree | 810771f044deb87e386d1c9e67b8dc58b4f14798 /chrome | |
parent | 4871b24189d52dc64c085be4122a3d6aede2102e (diff) | |
download | chromium_src-ec94b4aeb47ae695d4fe20af71f2652df577a2cf.zip chromium_src-ec94b4aeb47ae695d4fe20af71f2652df577a2cf.tar.gz chromium_src-ec94b4aeb47ae695d4fe20af71f2652df577a2cf.tar.bz2 |
Revert 19829.
BUG= http://crbug.com/1455
Review URL: http://codereview.chromium.org/149156
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/status_bubble_gtk.h | 4 | ||||
-rw-r--r-- | chrome/browser/status_bubble.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.cc | 182 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.h | 38 |
6 files changed, 9 insertions, 223 deletions
diff --git a/chrome/browser/cocoa/status_bubble_mac.h b/chrome/browser/cocoa/status_bubble_mac.h index 35b5dc5..b6843c0 100644 --- a/chrome/browser/cocoa/status_bubble_mac.h +++ b/chrome/browser/cocoa/status_bubble_mac.h @@ -25,7 +25,6 @@ class StatusBubbleMac : public StatusBubble { virtual void Hide(); virtual void MouseMoved(); virtual void UpdateDownloadShelfVisibility(bool visible); - virtual void SetBubbleWidth(int width); private: friend class StatusBubbleMacTest; diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm index e2d6c78..160b086 100644 --- a/chrome/browser/cocoa/status_bubble_mac.mm +++ b/chrome/browser/cocoa/status_bubble_mac.mm @@ -192,10 +192,6 @@ void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { NOTIMPLEMENTED(); } -void StatusBubbleMac::SetBubbleWidth(int width) { - NOTIMPLEMENTED(); -} - void StatusBubbleMac::Create() { if (window_) return; diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h index 1a5ca85..006efd0 100644 --- a/chrome/browser/gtk/status_bubble_gtk.h +++ b/chrome/browser/gtk/status_bubble_gtk.h @@ -36,10 +36,6 @@ class StatusBubbleGtk : public StatusBubble { // the download shelf, when it is visible. virtual void UpdateDownloadShelfVisibility(bool visible) { } - virtual void SetBubbleWidth(int width) { } - - void SetStatus(const std::string& status_utf8); - // Top of the widget hierarchy for a StatusBubble. This top level widget is // guarenteed to have its gtk_widget_name set to "status-bubble" for // identification. diff --git a/chrome/browser/status_bubble.h b/chrome/browser/status_bubble.h index 446e9c3..f5ecda4 100644 --- a/chrome/browser/status_bubble.h +++ b/chrome/browser/status_bubble.h @@ -44,9 +44,6 @@ class StatusBubble { // This is used by to ensure that the status bubble does not obscure // the download shelf, when it is visible. virtual void UpdateDownloadShelfVisibility(bool visible) = 0; - - // Allow StatusView animation to set width of StatusBubble. - virtual void SetBubbleWidth(int width) = 0; }; #endif // #ifndef CHROME_BROWSER_STATUS_BUBBLE_H_ diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 5afa4fb..ecaba94 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -28,7 +28,6 @@ #include "views/widget/root_view.h" #include "views/widget/widget.h" #if defined(OS_WIN) -#include "views/controls/scrollbar/native_scroll_bar.h" #include "views/widget/widget_win.h" #endif @@ -54,7 +53,7 @@ static const int kTextPositionX = 3; // The minimum horizontal space between the (right) end of the text and the edge // of the status bubble, not including the outer shadow ring, or a 1 px gap we -// leave so we can shift all the text by 1 px to produce a "highlight" effect. +// leave so we can shit all the text by 1 px to produce a "highlight" effect. static const int kTextHorizPadding = 1; // Delays before we start hiding or showing the bubble after we receive a @@ -67,9 +66,6 @@ static const int kShowFadeDurationMS = 120; static const int kHideFadeDurationMS = 200; static const int kFramerate = 25; -// How long each expansion step should take. -static const int kExpansionStepDurationMS = 150; - // View ----------------------------------------------------------------------- // StatusView manages the display of the bubble, applying text changes and // fading in or out the bubble as required. @@ -117,11 +113,6 @@ class StatusBubbleViews::StatusView : public views::Label, // Set the bubble text to a certain value, hides the bubble if text is // an empty string. - void SetTextAndAnimate(const std::wstring& text); - - // Set the bubble text to a certain value without triggering animation - // sequence. Called by the StatusViewExpander after bubble has been - // fully expanded. void SetText(const std::wstring& text); BubbleStage GetState() const { return stage_; } @@ -187,12 +178,6 @@ class StatusBubbleViews::StatusView : public views::Label, }; void StatusBubbleViews::StatusView::SetText(const std::wstring& text) { - text_ = text; - SchedulePaint(); -} - -void StatusBubbleViews::StatusView::SetTextAndAnimate( - const std::wstring& text) { if (text.empty()) { // The string was empty. StartHiding(); @@ -332,6 +317,7 @@ void StatusBubbleViews::StatusView::AnimateToState(double state) { void StatusBubbleViews::StatusView::AnimationEnded( const Animation* animation) { SetOpacity(opacity_end_); + if (stage_ == BUBBLE_HIDING_FADE) { stage_ = BUBBLE_HIDDEN; popup_->Hide(); @@ -467,83 +453,6 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) { body_bounds.height()); } - -// StatusViewExpander --------------------------------------------------------- -// StatusViewExpander manages the expansion and contraction of the status -// bubble as it accommodates URL's too long to fit in the standard bubble. -// Changes are passed through to the StatusView to paint. -class StatusBubbleViews::StatusViewExpander : public Animation, - public AnimationDelegate { - public: - StatusViewExpander(StatusBubble* status_bubble, StatusView* status_view) - : Animation(kFramerate, this), - status_bubble_(status_bubble), - status_view_(status_view), - expansion_start_(0), - expansion_end_(0) { - } - - // Manage the expansion of the bubble. - void StartExpansion(std::wstring expanded_text, int current_width, - int expansion_end); - - // Set width of fully expanded bubble. - void SetExpandedWidth(int expanded_width); - - private: - // Animation functions. - int GetCurrentBubbleWidth(); - void SetBubbleWidth(int width); - void AnimateToState(double state); - void AnimationEnded(const Animation* animation); - - // We are changing the bounds and text of this view. - StatusView* status_view_; - - // Manager that owns us. - StatusBubble* status_bubble_; - - // The currently displayed text. - std::wstring text_; - - // Text elided to fit maximum possible status bar width. - std::wstring expanded_text_; - - // Widths at expansion start and end. - int expansion_start_; - int expansion_end_; -}; - -void StatusBubbleViews::StatusViewExpander::AnimateToState(double state) { - SetBubbleWidth(GetCurrentBubbleWidth()); -} - -void StatusBubbleViews::StatusViewExpander::AnimationEnded( - const Animation* animation) { - SetBubbleWidth(expansion_end_); - status_view_->SetText(expanded_text_); -} - -void StatusBubbleViews::StatusViewExpander::StartExpansion( - std::wstring expanded_text, int expansion_start, - int expansion_end) { - expanded_text_ = expanded_text; - expansion_start_ = expansion_start; - expansion_end_ = expansion_end; - SetDuration(kExpansionStepDurationMS); - Start(); -} - -int StatusBubbleViews::StatusViewExpander::GetCurrentBubbleWidth() { - return static_cast<int>(expansion_start_ + - (expansion_end_ - expansion_start_) * Animation::GetCurrentValue()); -} - -void StatusBubbleViews::StatusViewExpander::SetBubbleWidth(int width) { - status_bubble_->SetBubbleWidth(width); - status_view_->SchedulePaint(); -} - // StatusBubble --------------------------------------------------------------- const int StatusBubbleViews::kShadowThickness = 1; @@ -554,13 +463,10 @@ StatusBubbleViews::StatusBubbleViews(views::Widget* frame) opacity_(0), frame_(frame), view_(NULL), - download_shelf_is_visible_(false), - is_expanded_(false), - expand_timer_factory_(this) { + download_shelf_is_visible_(false) { } StatusBubbleViews::~StatusBubbleViews() { - CancelExpandTimer(); if (popup_.get()) popup_->CloseNow(); } @@ -573,8 +479,6 @@ void StatusBubbleViews::Init() { if (!view_) view_ = new StatusView(this, popup, frame_->GetThemeProvider()); - if (!expand_view_) - expand_view_ = new StatusViewExpander(this, view_); popup->set_window_style(WS_POPUP); popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | @@ -631,34 +535,26 @@ void StatusBubbleViews::SetStatus(const std::wstring& status_text) { Init(); status_text_ = status_text; if (!status_text_.empty()) { - view_->SetTextAndAnimate(status_text); + view_->SetText(status_text); view_->Show(); } else if (!url_text_.empty()) { - view_->SetTextAndAnimate(url_text_); + view_->SetText(url_text_); } else { - view_->SetTextAndAnimate(std::wstring()); + view_->SetText(std::wstring()); } } void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { - languages_ = languages; - url_ = url; Init(); // If we want to clear a displayed URL but there is a status still to // display, display that status instead. if (url.is_empty() && !status_text_.empty()) { url_text_ = std::wstring(); - view_->SetTextAndAnimate(status_text_); + view_->SetText(status_text_); return; } - // Reset expansion state only when bubble is completely hidden. - if (view_->GetState() == StatusView::BUBBLE_HIDDEN) { - is_expanded_ = false; - SetBubbleWidth(GetStandardStatusBubbleWidth()); - } - // Set Elided Text corresponding to the GURL object. gfx::Rect popup_bounds; popup_->GetBounds(&popup_bounds, true); @@ -667,30 +563,13 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { url_text_ = gfx::ElideUrl(url, view_->Label::GetFont(), text_width, languages); - url_parse::Parsed parsed; - std::wstring original_url_text_ = - net::FormatUrl(url, languages, true, true, &parsed, NULL); - // An URL is always treated as a left-to-right string. On right-to-left UIs // we need to explicitly mark the URL as LTR to make sure it is displayed // correctly. if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && !url_text_.empty()) l10n_util::WrapStringWithLTRFormatting(&url_text_); - - view_->SetTextAndAnimate(url_text_); - - CancelExpandTimer(); - - // If bubble is already in expanded state, shift immediately to adjust to - // new text size (shrinking or expanding). Otherwise delay for - // kExpandHoverDelay ms. - if (is_expanded_ && !url.is_empty()) - ExpandBubble(); - else if (original_url_text_.length() > url_text_.length()) - MessageLoop::current()->PostDelayedTask(FROM_HERE, - expand_timer_factory_.NewRunnableMethod( - &StatusBubbleViews::ExpandBubble), kExpandHoverDelay); + view_->SetText(url_text_); } void StatusBubbleViews::Hide() { @@ -796,7 +675,7 @@ void StatusBubbleViews::AvoidMouse() { view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT); offset_ = 0; - // Subtract border width + bubble width. + // Substract border width + bubble width. int right_position_x = window_width - (position_.x() + size_.width()); popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x, top_left.y() + position_.y(), @@ -816,46 +695,3 @@ void StatusBubbleViews::AvoidMouse() { size_.width(), size_.height())); } } - -void StatusBubbleViews::ExpandBubble() { - // Elide url to maximum possible size, then check actual length (it may - // still be too long to fit) before expanding bubble. - gfx::Rect popup_bounds; - popup_->GetBounds(&popup_bounds, true); - int max_status_bubble_width = GetMaxStatusBubbleWidth(); - url_text_ = gfx::ElideUrl(url_, view_->Label::GetFont(), - max_status_bubble_width, languages_); - int expanded_bubble_width = - std::max(GetStandardStatusBubbleWidth(), - std::min(view_->Label::GetFont().GetStringWidth(url_text_) + - (kShadowThickness * 2) + kTextPositionX + kTextHorizPadding + 1, - max_status_bubble_width)); - is_expanded_ = true; - expand_view_->StartExpansion(url_text_, popup_bounds.width(), - expanded_bubble_width); -} - -int StatusBubbleViews::GetStandardStatusBubbleWidth() { - gfx::Rect frame_bounds; - frame_->GetBounds(&frame_bounds, false); - return frame_bounds.width() / 3; -} - -int StatusBubbleViews::GetMaxStatusBubbleWidth() { - gfx::Rect frame_bounds; - frame_->GetBounds(&frame_bounds, false); - return static_cast<int>(frame_bounds.width() - (kShadowThickness * 2) - - kTextPositionX - kTextHorizPadding - 1 - - views::NativeScrollBar::GetVerticalScrollBarWidth()); -} - -void StatusBubbleViews::SetBubbleWidth(int width) { - size_.set_width(width); - SetBounds(position_.x(), position_.y(), size_.width(), size_.height()); -} - -void StatusBubbleViews::CancelExpandTimer() { - if (!expand_timer_factory_.empty()) - expand_timer_factory_.RevokeAll(); -} - diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h index 6c37615..5adb3e0 100644 --- a/chrome/browser/views/status_bubble_views.h +++ b/chrome/browser/views/status_bubble_views.h @@ -8,9 +8,7 @@ #include "base/gfx/rect.h" #include "base/logging.h" #include "base/scoped_ptr.h" -#include "base/task.h" #include "chrome/browser/status_bubble.h" -#include "googleurl/src/gurl.h" class GURL; namespace views { @@ -28,9 +26,6 @@ class StatusBubbleViews : public StatusBubble { // The combined vertical padding above and below the text. static const int kTotalVerticalPadding = 7; - // On hover, expand status bubble to accommodate long URL after this delay. - static const int kExpandHoverDelay = 2000; - explicit StatusBubbleViews(views::Widget* frame); ~StatusBubbleViews(); @@ -45,9 +40,6 @@ class StatusBubbleViews : public StatusBubble { // Set the bounds of the bubble relative to the browser window. void SetBounds(int x, int y, int w, int h); - // Set bubble to new width; for animation of expansion. - void SetBubbleWidth(int width); - // Overridden from StatusBubble: virtual void SetStatus(const std::wstring& status); virtual void SetURL(const GURL& url, const std::wstring& languages); @@ -57,7 +49,6 @@ class StatusBubbleViews : public StatusBubble { private: class StatusView; - class StatusViewExpander; // Initializes the popup and view. void Init(); @@ -66,34 +57,12 @@ class StatusBubbleViews : public StatusBubble { // users to see links in the region normally occupied by the status bubble. void AvoidMouse(); - // Expand bubble size to accommodate an abridged URL. - void ExpandBubble(); - - // Cancel all the expansions waiting in the timer. - void CancelExpandTimer(); - - // Get the standard width for a status bubble in the current frame size. - int GetStandardStatusBubbleWidth(); - - // Get the maximum possible width for a status bubble in the current - // frame size. - int GetMaxStatusBubbleWidth(); - // The status text we want to display when there are no URLs to display. std::wstring status_text_; // The url we want to display when there is no status text to display. - // This string may be elided if the URL is too long to fit in status bubble. std::wstring url_text_; - // The original url. We need to keep this around to we can re-elide it to - // dynamically fit the bubble if we need to expand it to show a url that - // has been cut off. - GURL url_; - - // Keep this around so we can elide the original url when we expand it. - std::wstring languages_; - // Position relative to the parent window. gfx::Point position_; gfx::Size size_; @@ -108,17 +77,10 @@ class StatusBubbleViews : public StatusBubble { views::Widget* frame_; StatusView* view_; - StatusViewExpander* expand_view_; // If the download shelf is visible, do not obscure it. bool download_shelf_is_visible_; - // Is the bubble expanded? If so, change size immediately. - bool is_expanded_; - - // Times expansion of status bubble when URL is too long for standard width. - ScopedRunnableMethodFactory<StatusBubbleViews> expand_timer_factory_; - DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); }; |