| Index: chrome/browser/ui/views/tabs/tab.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
|
| index 10c7ed5952d93de7a81406d175a1cc9a1ae5446d..6df01e27b9814d564359ce6c8ec0fe113a9aa4ed 100644
|
| --- a/chrome/browser/ui/views/tabs/tab.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab.cc
|
| @@ -342,75 +342,6 @@
|
| };
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// ThrobberView
|
| -//
|
| -// A Layer-backed view for updating a waiting or loading tab throbber.
|
| -class Tab::ThrobberView : public views::View {
|
| - public:
|
| - explicit ThrobberView(Tab* owner);
|
| -
|
| - // Resets the times tracking when the throbber changes state.
|
| - void ResetStartTimes();
|
| -
|
| - private:
|
| - // views::View:
|
| - bool CanProcessEventsWithinSubtree() const override;
|
| - void OnPaint(gfx::Canvas* canvas) override;
|
| -
|
| - Tab* owner_; // Weak. Owns |this|.
|
| -
|
| - // The point in time when the tab icon was first painted in the waiting state.
|
| - base::TimeTicks waiting_start_time_;
|
| -
|
| - // The point in time when the tab icon was first painted in the loading state.
|
| - base::TimeTicks loading_start_time_;
|
| -
|
| - // Paint state for the throbber after the most recent waiting paint.
|
| - gfx::ThrobberWaitingState waiting_state_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ThrobberView);
|
| -};
|
| -
|
| -Tab::ThrobberView::ThrobberView(Tab* owner) : owner_(owner) {}
|
| -
|
| -void Tab::ThrobberView::ResetStartTimes() {
|
| - waiting_start_time_ = base::TimeTicks();
|
| - loading_start_time_ = base::TimeTicks();
|
| - waiting_state_ = gfx::ThrobberWaitingState();
|
| -}
|
| -
|
| -bool Tab::ThrobberView::CanProcessEventsWithinSubtree() const {
|
| - return false;
|
| -}
|
| -
|
| -void Tab::ThrobberView::OnPaint(gfx::Canvas* canvas) {
|
| - const TabRendererData::NetworkState state = owner_->data().network_state;
|
| - if (state == TabRendererData::NETWORK_STATE_NONE)
|
| - return;
|
| -
|
| - ui::ThemeProvider* tp = GetThemeProvider();
|
| - const gfx::Rect bounds = GetLocalBounds();
|
| - if (state == TabRendererData::NETWORK_STATE_WAITING) {
|
| - if (waiting_start_time_ == base::TimeTicks())
|
| - waiting_start_time_ = base::TimeTicks::Now();
|
| -
|
| - waiting_state_.elapsed_time = base::TimeTicks::Now() - waiting_start_time_;
|
| - gfx::PaintThrobberWaiting(
|
| - canvas, bounds, tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING),
|
| - waiting_state_.elapsed_time);
|
| - } else {
|
| - if (loading_start_time_ == base::TimeTicks())
|
| - loading_start_time_ = base::TimeTicks::Now();
|
| -
|
| - waiting_state_.color =
|
| - tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING);
|
| - gfx::PaintThrobberSpinningAfterWaiting(
|
| - canvas, bounds, tp->GetColor(ThemeProperties::COLOR_THROBBER_SPINNING),
|
| - base::TimeTicks::Now() - loading_start_time_, &waiting_state_);
|
| - }
|
| -}
|
| -
|
| -////////////////////////////////////////////////////////////////////////////////
|
| // ImageCacheEntry
|
|
|
| Tab::ImageCacheEntry::ImageCacheEntry()
|
| @@ -441,7 +372,6 @@
|
| favicon_hiding_offset_(0),
|
| immersive_loading_step_(0),
|
| should_display_crashed_favicon_(false),
|
| - throbber_(nullptr),
|
| media_indicator_button_(nullptr),
|
| close_button_(nullptr),
|
| title_(new views::Label()),
|
| @@ -469,10 +399,6 @@
|
|
|
| SetEventTargeter(
|
| scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
|
| -
|
| - throbber_ = new ThrobberView(this);
|
| - throbber_->SetVisible(false);
|
| - AddChildView(throbber_);
|
|
|
| media_indicator_button_ = new MediaIndicatorButton(this);
|
| AddChildView(media_indicator_button_);
|
| @@ -528,7 +454,6 @@
|
| return;
|
|
|
| TabRendererData old(data_);
|
| - UpdateLoadingAnimation(data.network_state);
|
| data_ = data;
|
|
|
| base::string16 title = data_.title;
|
| @@ -588,8 +513,9 @@
|
| return;
|
| }
|
|
|
| + TabRendererData::NetworkState old_state = data_.network_state;
|
| data_.network_state = state;
|
| - AdvanceLoadingAnimation();
|
| + AdvanceLoadingAnimation(old_state, state);
|
| }
|
|
|
| void Tab::StartPulse() {
|
| @@ -869,7 +795,6 @@
|
| favicon_bounds_.set_y(lb.y() + (lb.height() - gfx::kFaviconSize + 1) / 2);
|
| MaybeAdjustLeftForPinnedTab(&favicon_bounds_);
|
| }
|
| - throbber_->SetBoundsRect(favicon_bounds_);
|
|
|
| showing_close_button_ = ShouldShowCloseBox();
|
| if (showing_close_button_) {
|
| @@ -1426,7 +1351,28 @@
|
| return;
|
|
|
| if (data().network_state != TabRendererData::NETWORK_STATE_NONE) {
|
| - // Throbber will do its own painting.
|
| + // Paint network activity (aka throbber) animation frame.
|
| + ui::ThemeProvider* tp = GetThemeProvider();
|
| + if (data().network_state == TabRendererData::NETWORK_STATE_WAITING) {
|
| + if (waiting_start_time_ == base::TimeTicks())
|
| + waiting_start_time_ = base::TimeTicks::Now();
|
| +
|
| + waiting_state_.elapsed_time =
|
| + base::TimeTicks::Now() - waiting_start_time_;
|
| + gfx::PaintThrobberWaiting(
|
| + canvas, bounds, tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING),
|
| + waiting_state_.elapsed_time);
|
| + } else {
|
| + if (loading_start_time_ == base::TimeTicks())
|
| + loading_start_time_ = base::TimeTicks::Now();
|
| +
|
| + waiting_state_.color =
|
| + tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING);
|
| + gfx::PaintThrobberSpinningAfterWaiting(
|
| + canvas, bounds,
|
| + tp->GetColor(ThemeProperties::COLOR_THROBBER_SPINNING),
|
| + base::TimeTicks::Now() - loading_start_time_, &waiting_state_);
|
| + }
|
| } else {
|
| const gfx::ImageSkia& favicon = should_display_crashed_favicon_ ?
|
| *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
|
| @@ -1440,46 +1386,27 @@
|
| }
|
| }
|
|
|
| -void Tab::AdvanceLoadingAnimation() {
|
| - const TabRendererData::NetworkState state = data().network_state;
|
| +void Tab::AdvanceLoadingAnimation(TabRendererData::NetworkState old_state,
|
| + TabRendererData::NetworkState state) {
|
| + if (state == TabRendererData::NETWORK_STATE_WAITING) {
|
| + // Waiting steps backwards.
|
| + immersive_loading_step_ =
|
| + (immersive_loading_step_ - 1 + kImmersiveLoadingStepCount) %
|
| + kImmersiveLoadingStepCount;
|
| + } else if (state == TabRendererData::NETWORK_STATE_LOADING) {
|
| + immersive_loading_step_ = (immersive_loading_step_ + 1) %
|
| + kImmersiveLoadingStepCount;
|
| + } else {
|
| + waiting_start_time_ = base::TimeTicks();
|
| + loading_start_time_ = base::TimeTicks();
|
| + waiting_state_ = gfx::ThrobberWaitingState();
|
| + immersive_loading_step_ = 0;
|
| + }
|
| if (controller_->IsImmersiveStyle()) {
|
| - if (state == TabRendererData::NETWORK_STATE_WAITING) {
|
| - // Waiting steps backwards.
|
| - immersive_loading_step_ =
|
| - (immersive_loading_step_ - 1 + kImmersiveLoadingStepCount) %
|
| - kImmersiveLoadingStepCount;
|
| - } else if (state == TabRendererData::NETWORK_STATE_LOADING) {
|
| - immersive_loading_step_ =
|
| - (immersive_loading_step_ + 1) % kImmersiveLoadingStepCount;
|
| - } else {
|
| - immersive_loading_step_ = 0;
|
| - }
|
| -
|
| SchedulePaintInRect(GetImmersiveBarRect());
|
| - return;
|
| - }
|
| -
|
| - if (state == TabRendererData::NETWORK_STATE_NONE) {
|
| - throbber_->ResetStartTimes();
|
| - throbber_->SetVisible(false);
|
| + } else {
|
| ScheduleIconPaint();
|
| - return;
|
| - }
|
| -
|
| - // Since the throbber can animate for a long time, paint to a separate layer
|
| - // when possible to reduce repaint overhead.
|
| - const bool paint_to_layer = controller_->CanPaintThrobberToLayer();
|
| - if (paint_to_layer != !!throbber_->layer()) {
|
| - throbber_->SetPaintToLayer(paint_to_layer);
|
| - throbber_->SetFillsBoundsOpaquely(false);
|
| - if (paint_to_layer)
|
| - ScheduleIconPaint(); // Ensure the non-layered throbber goes away.
|
| - }
|
| - if (!throbber_->visible()) {
|
| - ScheduleIconPaint(); // Repaint the icon area to hide the favicon.
|
| - throbber_->SetVisible(true);
|
| - }
|
| - throbber_->SchedulePaint();
|
| + }
|
| }
|
|
|
| int Tab::IconCapacity() const {
|
|
|