Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 // switches to them. Don't display animations for these unless they're | 484 // switches to them. Don't display animations for these unless they're |
| 485 // selected (i.e. in the foreground) -- we won't reload these | 485 // selected (i.e. in the foreground) -- we won't reload these |
| 486 // automatically since we don't want to get into a crash loop. | 486 // automatically since we don't want to get into a crash loop. |
| 487 if (IsSelected() || | 487 if (IsSelected() || |
| 488 data_.crashed_status != base::TERMINATION_STATUS_PROCESS_WAS_KILLED) | 488 data_.crashed_status != base::TERMINATION_STATUS_PROCESS_WAS_KILLED) |
| 489 StartCrashAnimation(); | 489 StartCrashAnimation(); |
| 490 #else | 490 #else |
| 491 StartCrashAnimation(); | 491 StartCrashAnimation(); |
| 492 #endif | 492 #endif |
| 493 } | 493 } |
| 494 | |
| 495 } else if ((data_.capture_state == TabRendererData::CAPTURE_STATE_NONE) && | |
| 496 (old.capture_state != TabRendererData::CAPTURE_STATE_NONE)) { | |
| 497 StopRecordingAnimation(); | |
| 498 | |
| 499 } else if ((data_.capture_state != TabRendererData::CAPTURE_STATE_NONE) && | |
| 500 (old.capture_state == TabRendererData::CAPTURE_STATE_NONE)) { | |
| 501 StartRecordingAnimation(); | |
| 494 } else { | 502 } else { |
| 495 if (IsPerformingCrashAnimation()) | 503 if (IsPerformingCrashAnimation()) |
| 496 StopCrashAnimation(); | 504 StopCrashAnimation(); |
| 497 ResetCrashedFavicon(); | 505 ResetCrashedFavicon(); |
| 498 } | 506 } |
| 499 | 507 |
| 500 // If the favicon changed, re-compute its dominant color. | 508 // If the favicon changed, re-compute its dominant color. |
| 501 if (controller() && | 509 if (controller() && |
| 502 controller()->IsImmersiveStyle() && | 510 controller()->IsImmersiveStyle() && |
| 503 !data_.favicon.isNull() && | 511 !data_.favicon.isNull() && |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 525 // need to advance the animation frame. | 533 // need to advance the animation frame. |
| 526 return; | 534 return; |
| 527 } | 535 } |
| 528 | 536 |
| 529 TabRendererData::NetworkState old_state = data_.network_state; | 537 TabRendererData::NetworkState old_state = data_.network_state; |
| 530 data_.network_state = state; | 538 data_.network_state = state; |
| 531 AdvanceLoadingAnimation(old_state, state); | 539 AdvanceLoadingAnimation(old_state, state); |
| 532 } | 540 } |
| 533 | 541 |
| 534 void Tab::StartPulse() { | 542 void Tab::StartPulse() { |
| 535 if (!pulse_animation_.get()) { | 543 if (!tab_animation_.get()) { |
| 536 pulse_animation_.reset(new ui::ThrobAnimation(this)); | 544 tab_animation_.reset(new ui::ThrobAnimation(this)); |
| 537 pulse_animation_->SetSlideDuration(kPulseDurationMs); | 545 tab_animation_->SetSlideDuration(kPulseDurationMs); |
| 538 if (animation_container_.get()) | 546 if (animation_container_.get()) |
| 539 pulse_animation_->SetContainer(animation_container_.get()); | 547 tab_animation_->SetContainer(animation_container_.get()); |
| 540 } | 548 } |
| 541 pulse_animation_->Reset(); | 549 tab_animation_->Reset(); |
| 542 pulse_animation_->StartThrobbing(std::numeric_limits<int>::max()); | 550 tab_animation_->StartThrobbing(std::numeric_limits<int>::max()); |
| 543 } | 551 } |
| 544 | 552 |
| 545 void Tab::StopPulse() { | 553 void Tab::StopPulse() { |
| 546 if (!pulse_animation_.get()) | 554 if (!tab_animation_.get()) |
| 547 return; | 555 return; |
| 548 | 556 |
| 549 pulse_animation_->Stop(); // Do stop so we get notified. | 557 tab_animation_->Stop(); // Do stop so we get notified. |
| 550 pulse_animation_.reset(NULL); | 558 tab_animation_.reset(NULL); |
| 551 } | 559 } |
| 552 | 560 |
| 553 void Tab::StartMiniTabTitleAnimation() { | 561 void Tab::StartMiniTabTitleAnimation() { |
| 554 if (!mini_title_animation_.get()) { | 562 if (!mini_title_animation_.get()) { |
| 555 ui::MultiAnimation::Parts parts; | 563 ui::MultiAnimation::Parts parts; |
| 556 parts.push_back( | 564 parts.push_back( |
| 557 ui::MultiAnimation::Part(kMiniTitleChangeAnimationDuration1MS, | 565 ui::MultiAnimation::Part(kMiniTitleChangeAnimationDuration1MS, |
| 558 ui::Tween::EASE_OUT)); | 566 ui::Tween::EASE_OUT)); |
| 559 parts.push_back( | 567 parts.push_back( |
| 560 ui::MultiAnimation::Part(kMiniTitleChangeAnimationDuration2MS, | 568 ui::MultiAnimation::Part(kMiniTitleChangeAnimationDuration2MS, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 int Tab::GetImmersiveHeight() { | 640 int Tab::GetImmersiveHeight() { |
| 633 return kImmersiveTabHeight; | 641 return kImmersiveTabHeight; |
| 634 } | 642 } |
| 635 | 643 |
| 636 //////////////////////////////////////////////////////////////////////////////// | 644 //////////////////////////////////////////////////////////////////////////////// |
| 637 // Tab, AnimationDelegate overrides: | 645 // Tab, AnimationDelegate overrides: |
| 638 | 646 |
| 639 void Tab::AnimationProgressed(const ui::Animation* animation) { | 647 void Tab::AnimationProgressed(const ui::Animation* animation) { |
| 640 // Ignore if the pulse animation is being performed on active tab because | 648 // Ignore if the pulse animation is being performed on active tab because |
| 641 // it repaints the same image. See |Tab::PaintTabBackground()|. | 649 // it repaints the same image. See |Tab::PaintTabBackground()|. |
| 642 if (animation == pulse_animation_.get() && IsActive()) | 650 if (animation == tab_animation_.get() && IsActive()) |
| 643 return; | 651 return; |
| 644 SchedulePaint(); | 652 SchedulePaint(); |
| 645 } | 653 } |
| 646 | 654 |
| 647 void Tab::AnimationCanceled(const ui::Animation* animation) { | 655 void Tab::AnimationCanceled(const ui::Animation* animation) { |
| 648 SchedulePaint(); | 656 SchedulePaint(); |
| 649 } | 657 } |
| 650 | 658 |
| 651 void Tab::AnimationEnded(const ui::Animation* animation) { | 659 void Tab::AnimationEnded(const ui::Animation* animation) { |
| 652 SchedulePaint(); | 660 SchedulePaint(); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); | 1296 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); |
| 1289 } | 1297 } |
| 1290 | 1298 |
| 1291 void Tab::PaintIcon(gfx::Canvas* canvas) { | 1299 void Tab::PaintIcon(gfx::Canvas* canvas) { |
| 1292 gfx::Rect bounds = GetIconBounds(); | 1300 gfx::Rect bounds = GetIconBounds(); |
| 1293 if (bounds.IsEmpty()) | 1301 if (bounds.IsEmpty()) |
| 1294 return; | 1302 return; |
| 1295 | 1303 |
| 1296 bounds.set_x(GetMirroredXForRect(bounds)); | 1304 bounds.set_x(GetMirroredXForRect(bounds)); |
| 1297 | 1305 |
| 1306 // Paint network activity (aka throbber) animation frame. | |
| 1298 if (data().network_state != TabRendererData::NETWORK_STATE_NONE) { | 1307 if (data().network_state != TabRendererData::NETWORK_STATE_NONE) { |
| 1299 ui::ThemeProvider* tp = GetThemeProvider(); | 1308 ui::ThemeProvider* tp = GetThemeProvider(); |
| 1300 gfx::ImageSkia frames(*tp->GetImageSkiaNamed( | 1309 gfx::ImageSkia frames(*tp->GetImageSkiaNamed( |
| 1301 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ? | 1310 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ? |
| 1302 IDR_THROBBER_WAITING : IDR_THROBBER)); | 1311 IDR_THROBBER_WAITING : IDR_THROBBER)); |
| 1303 | 1312 |
| 1304 int icon_size = frames.height(); | 1313 int icon_size = frames.height(); |
| 1305 int image_offset = loading_animation_frame_ * icon_size; | 1314 int image_offset = loading_animation_frame_ * icon_size; |
| 1306 DrawIconCenter(canvas, frames, image_offset, | 1315 DrawIconCenter(canvas, frames, image_offset, |
| 1307 icon_size, icon_size, bounds, false, SkPaint()); | 1316 icon_size, icon_size, bounds, false, SkPaint()); |
| 1317 return; | |
| 1318 } | |
| 1319 | |
| 1320 // Paint regular icon and potentially overlays. | |
| 1321 canvas->Save(); | |
| 1322 canvas->ClipRect(GetLocalBounds()); | |
| 1323 if (should_display_crashed_favicon_) { | |
| 1324 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 1325 gfx::ImageSkia crashed_favicon(*rb.GetImageSkiaNamed(IDR_SAD_FAVICON)); | |
| 1326 bounds.set_y(bounds.y() + favicon_hiding_offset_); | |
| 1327 DrawIconCenter(canvas, crashed_favicon, 0, | |
| 1328 crashed_favicon.width(), | |
| 1329 crashed_favicon.height(), bounds, true, SkPaint()); | |
| 1308 } else { | 1330 } else { |
| 1309 canvas->Save(); | 1331 if (!data().favicon.isNull()) { |
| 1310 canvas->ClipRect(GetLocalBounds()); | 1332 if (data().capture_state == TabRendererData::CAPTURE_STATE_PROJECTING) { |
| 1311 if (should_display_crashed_favicon_) { | 1333 // If projecting, shrink favicon and add projection screen instead. |
| 1312 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1334 gfx::ImageSkia resized_icon = |
| 1313 gfx::ImageSkia crashed_favicon(*rb.GetImageSkiaNamed(IDR_SAD_FAVICON)); | 1335 gfx::ImageSkiaOperations::CreateResizedImage( |
| 1314 bounds.set_y(bounds.y() + favicon_hiding_offset_); | 1336 data().favicon, |
| 1315 DrawIconCenter(canvas, crashed_favicon, 0, | 1337 skia::ImageOperations::RESIZE_BEST, |
| 1316 crashed_favicon.width(), | 1338 gfx::Size(data().favicon.width() * |
| 1317 crashed_favicon.height(), bounds, true, SkPaint()); | 1339 kProjectingFaviconResizeScale, |
| 1318 } else { | 1340 data().favicon.height() * |
| 1319 if (!data().favicon.isNull()) { | 1341 kProjectingFaviconResizeScale)); |
| 1320 if (data().capture_state == TabRendererData::CAPTURE_STATE_PROJECTING) { | |
| 1321 // If projecting, shrink favicon and add projection screen instead. | |
| 1322 gfx::ImageSkia resized_icon = | |
| 1323 gfx::ImageSkiaOperations::CreateResizedImage( | |
| 1324 data().favicon, | |
| 1325 skia::ImageOperations::RESIZE_BEST, | |
| 1326 gfx::Size(data().favicon.width() * | |
| 1327 kProjectingFaviconResizeScale, | |
| 1328 data().favicon.height() * | |
| 1329 kProjectingFaviconResizeScale)); | |
| 1330 | 1342 |
| 1331 gfx::Rect resized_bounds(bounds); | 1343 gfx::Rect resized_bounds(bounds); |
| 1332 // Need to shift it up a bit vertically because the projection screen | 1344 // Need to shift it up a bit vertically because the projection screen |
| 1333 // is thinner on the top and bottom. | 1345 // is thinner on the top and bottom. |
| 1334 resized_bounds.set_y(resized_bounds.y() - 1); | 1346 resized_bounds.set_y(resized_bounds.y() - 1); |
| 1335 | 1347 |
| 1336 DrawIconCenter(canvas, resized_icon, 0, | 1348 DrawIconCenter(canvas, resized_icon, 0, |
| 1337 resized_icon.width(), | 1349 resized_icon.width(), |
| 1338 resized_icon.height(), | 1350 resized_icon.height(), |
| 1339 resized_bounds, true, SkPaint()); | 1351 resized_bounds, true, SkPaint()); |
| 1340 | 1352 |
| 1341 ui::ThemeProvider* tp = GetThemeProvider(); | 1353 ui::ThemeProvider* tp = GetThemeProvider(); |
| 1342 gfx::ImageSkia projection_screen( | 1354 gfx::ImageSkia projection_screen( |
| 1343 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE)); | 1355 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE)); |
| 1344 | 1356 |
| 1345 DrawIconCenter(canvas, projection_screen, 0, | 1357 DrawIconCenter(canvas, projection_screen, 0, |
| 1346 data().favicon.width(), | 1358 data().favicon.width(), |
| 1347 data().favicon.height(), | 1359 data().favicon.height(), |
| 1348 bounds, true, SkPaint()); | 1360 bounds, true, SkPaint()); |
| 1349 } else { | 1361 } else { |
| 1350 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch | 1362 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch |
| 1351 // to using that class to render the favicon). | 1363 // to using that class to render the favicon). |
| 1352 DrawIconCenter(canvas, data().favicon, 0, | 1364 DrawIconCenter(canvas, data().favicon, 0, |
| 1353 data().favicon.width(), | 1365 data().favicon.width(), |
| 1354 data().favicon.height(), | 1366 data().favicon.height(), |
| 1355 bounds, true, SkPaint()); | 1367 bounds, true, SkPaint()); |
| 1356 } | |
| 1357 } | 1368 } |
| 1358 } | 1369 } |
| 1359 canvas->Restore(); | 1370 } |
| 1371 canvas->Restore(); | |
| 1360 | 1372 |
| 1361 if (data().capture_state != TabRendererData::CAPTURE_STATE_NONE) { | 1373 // Paint recording or projecting animation overlay. |
| 1362 if (!recording_animation_.get()) { | 1374 if (data().capture_state != TabRendererData::CAPTURE_STATE_NONE) { |
| 1363 recording_animation_.reset(new ui::ThrobAnimation(this)); | 1375 SkPaint paint; |
| 1364 recording_animation_->SetTweenType(ui::Tween::EASE_IN_OUT); | 1376 paint.setAntiAlias(true); |
| 1365 recording_animation_->SetThrobDuration(kRecordingDurationMs); | 1377 U8CPU alpha = icon_animation_->GetCurrentValue() * 0xff; |
| 1366 recording_animation_->StartThrobbing(-1); | 1378 paint.setAlpha(alpha); |
| 1367 } | 1379 ui::ThemeProvider* tp = GetThemeProvider(); |
| 1368 | 1380 |
| 1369 SkPaint paint; | 1381 if (data().capture_state == TabRendererData::CAPTURE_STATE_PROJECTING) { |
| 1370 paint.setAntiAlias(true); | 1382 // If projecting, add projection glow animation. |
| 1371 U8CPU alpha = recording_animation_->GetCurrentValue() * 0xff; | 1383 gfx::Rect glow_bounds(bounds); |
| 1372 paint.setAlpha(alpha); | 1384 glow_bounds.set_x(glow_bounds.x() - (32 - 24)); |
| 1373 ui::ThemeProvider* tp = GetThemeProvider(); | 1385 glow_bounds.set_y(0); |
| 1386 glow_bounds.set_width(glow_bounds.width() * | |
| 1387 kProjectingGlowResizeScale); | |
| 1388 glow_bounds.set_height(glow_bounds.height() * | |
| 1389 kProjectingGlowResizeScale); | |
| 1374 | 1390 |
| 1375 if (data().capture_state == TabRendererData::CAPTURE_STATE_PROJECTING) { | 1391 gfx::ImageSkia projection_glow( |
| 1376 // If projecting, add projection glow animation. | 1392 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE_GLOW)); |
| 1377 gfx::Rect glow_bounds(bounds); | 1393 DrawIconCenter(canvas, projection_glow, 0, |
| 1378 glow_bounds.set_x(glow_bounds.x() - (32 - 24)); | 1394 projection_glow.width(), projection_glow.height(), |
| 1379 glow_bounds.set_y(0); | 1395 glow_bounds, false, paint); |
| 1380 glow_bounds.set_width(glow_bounds.width() * | 1396 } else if (data().capture_state == |
| 1381 kProjectingGlowResizeScale); | 1397 TabRendererData::CAPTURE_STATE_RECORDING) { |
| 1382 glow_bounds.set_height(glow_bounds.height() * | 1398 // If recording, fade the recording icon on top of the favicon. |
| 1383 kProjectingGlowResizeScale); | 1399 gfx::ImageSkia recording_dot(*tp->GetImageSkiaNamed(IDR_TAB_RECORDING)); |
| 1384 | 1400 DrawIconCenter(canvas, recording_dot, 0, |
| 1385 gfx::ImageSkia projection_glow( | 1401 recording_dot.width(), recording_dot.height(), |
| 1386 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE_GLOW)); | 1402 bounds, false, paint); |
| 1387 DrawIconCenter(canvas, projection_glow, 0, | |
| 1388 projection_glow.width(), projection_glow.height(), | |
| 1389 glow_bounds, false, paint); | |
| 1390 } else if (data().capture_state == | |
| 1391 TabRendererData::CAPTURE_STATE_RECORDING) { | |
| 1392 // If recording, fade the recording icon on top of the favicon. | |
| 1393 gfx::ImageSkia recording_dot(*tp->GetImageSkiaNamed(IDR_TAB_RECORDING)); | |
| 1394 DrawIconCenter(canvas, recording_dot, 0, | |
| 1395 recording_dot.width(), recording_dot.height(), | |
| 1396 bounds, false, paint); | |
| 1397 } else { | |
| 1398 NOTREACHED(); | |
| 1399 } | |
| 1400 } else { | 1403 } else { |
| 1401 recording_animation_.reset(); | 1404 NOTREACHED(); |
| 1402 } | 1405 } |
| 1403 } | 1406 } |
| 1404 } | 1407 } |
| 1405 | 1408 |
| 1406 void Tab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { | 1409 void Tab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) { |
| 1407 // Paint the Title. | 1410 // Paint the Title. |
| 1408 const gfx::Rect& title_bounds = GetTitleBounds(); | 1411 const gfx::Rect& title_bounds = GetTitleBounds(); |
| 1409 string16 title = data().title; | 1412 string16 title = data().title; |
| 1410 | 1413 |
| 1411 if (title.empty()) { | 1414 if (title.empty()) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 bool Tab::ShouldShowCloseBox() const { | 1492 bool Tab::ShouldShowCloseBox() const { |
| 1490 // The active tab never clips close button. | 1493 // The active tab never clips close button. |
| 1491 return !data().mini && (IsActive() || IconCapacity() >= 3); | 1494 return !data().mini && (IsActive() || IconCapacity() >= 3); |
| 1492 } | 1495 } |
| 1493 | 1496 |
| 1494 double Tab::GetThrobValue() { | 1497 double Tab::GetThrobValue() { |
| 1495 bool is_selected = IsSelected(); | 1498 bool is_selected = IsSelected(); |
| 1496 double min = is_selected ? kSelectedTabOpacity : 0; | 1499 double min = is_selected ? kSelectedTabOpacity : 0; |
| 1497 double scale = is_selected ? kSelectedTabThrobScale : 1; | 1500 double scale = is_selected ? kSelectedTabThrobScale : 1; |
| 1498 | 1501 |
| 1499 if (pulse_animation_.get() && pulse_animation_->is_animating()) | 1502 if (tab_animation_.get() && tab_animation_->is_animating()) |
| 1500 return pulse_animation_->GetCurrentValue() * kHoverOpacity * scale + min; | 1503 return tab_animation_->GetCurrentValue() * kHoverOpacity * scale + min; |
| 1501 | 1504 |
| 1502 if (hover_controller_.ShouldDraw()) { | 1505 if (hover_controller_.ShouldDraw()) { |
| 1503 return kHoverOpacity * hover_controller_.GetAnimationValue() * scale + | 1506 return kHoverOpacity * hover_controller_.GetAnimationValue() * scale + |
| 1504 min; | 1507 min; |
| 1505 } | 1508 } |
| 1506 | 1509 |
| 1507 return is_selected ? kSelectedTabOpacity : 0; | 1510 return is_selected ? kSelectedTabOpacity : 0; |
| 1508 } | 1511 } |
| 1509 | 1512 |
| 1510 void Tab::SetFaviconHidingOffset(int offset) { | 1513 void Tab::SetFaviconHidingOffset(int offset) { |
| 1511 favicon_hiding_offset_ = offset; | 1514 favicon_hiding_offset_ = offset; |
| 1512 ScheduleIconPaint(); | 1515 ScheduleIconPaint(); |
| 1513 } | 1516 } |
| 1514 | 1517 |
| 1515 void Tab::DisplayCrashedFavicon() { | 1518 void Tab::DisplayCrashedFavicon() { |
| 1516 should_display_crashed_favicon_ = true; | 1519 should_display_crashed_favicon_ = true; |
| 1517 } | 1520 } |
| 1518 | 1521 |
| 1519 void Tab::ResetCrashedFavicon() { | 1522 void Tab::ResetCrashedFavicon() { |
| 1520 should_display_crashed_favicon_ = false; | 1523 should_display_crashed_favicon_ = false; |
| 1521 } | 1524 } |
| 1522 | 1525 |
| 1523 void Tab::StartCrashAnimation() { | 1526 void Tab::StartCrashAnimation() { |
| 1524 if (!crash_animation_.get()) | 1527 icon_animation_.reset(new FaviconCrashAnimation(this)); |
| 1525 crash_animation_.reset(new FaviconCrashAnimation(this)); | 1528 icon_animation_->Stop(); |
|
sky
2013/01/07 16:56:08
I don't think we need the Stop() here anymore (sin
cpu_(ooo_6.6-7.5)
2013/01/08 01:19:59
Done.
| |
| 1526 crash_animation_->Stop(); | 1529 icon_animation_->Start(); |
| 1527 crash_animation_->Start(); | |
| 1528 } | 1530 } |
| 1529 | 1531 |
| 1530 void Tab::StopCrashAnimation() { | 1532 void Tab::StopCrashAnimation() { |
| 1531 if (!crash_animation_.get()) | 1533 if (!icon_animation_.get()) |
| 1532 return; | 1534 return; |
| 1533 crash_animation_->Stop(); | 1535 icon_animation_->Stop(); |
|
sky
2013/01/07 16:56:08
Do you need the stop here anymore?
cpu_(ooo_6.6-7.5)
2013/01/08 01:19:59
Done.
| |
| 1536 icon_animation_.reset(); | |
| 1537 } | |
| 1538 | |
| 1539 void Tab::StartRecordingAnimation() { | |
| 1540 ui::ThrobAnimation* animation = new ui::ThrobAnimation(this); | |
| 1541 animation->SetTweenType(ui::Tween::EASE_IN_OUT); | |
| 1542 animation->SetThrobDuration(kRecordingDurationMs); | |
| 1543 animation->StartThrobbing(-1); | |
| 1544 icon_animation_.reset(animation); | |
| 1545 } | |
| 1546 | |
| 1547 void Tab::StopRecordingAnimation() { | |
| 1548 if (!icon_animation_.get()) | |
| 1549 return; | |
| 1550 icon_animation_->Stop(); | |
| 1551 icon_animation_.reset(); | |
| 1534 } | 1552 } |
| 1535 | 1553 |
| 1536 bool Tab::IsPerformingCrashAnimation() const { | 1554 bool Tab::IsPerformingCrashAnimation() const { |
| 1537 return crash_animation_.get() && crash_animation_->is_animating(); | 1555 return icon_animation_.get() && data_.IsCrashed(); |
| 1538 } | 1556 } |
| 1539 | 1557 |
| 1540 void Tab::ScheduleIconPaint() { | 1558 void Tab::ScheduleIconPaint() { |
| 1541 gfx::Rect bounds = GetIconBounds(); | 1559 gfx::Rect bounds = GetIconBounds(); |
| 1542 if (bounds.IsEmpty()) | 1560 if (bounds.IsEmpty()) |
| 1543 return; | 1561 return; |
| 1544 | 1562 |
| 1545 // Extends the area to the bottom when sad_favicon is | 1563 // Extends the area to the bottom when sad_favicon is |
| 1546 // animating. | 1564 // animating. |
| 1547 if (IsPerformingCrashAnimation()) | 1565 if (IsPerformingCrashAnimation()) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 const gfx::ImageSkia& image) { | 1630 const gfx::ImageSkia& image) { |
| 1613 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1631 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1614 ImageCacheEntry entry; | 1632 ImageCacheEntry entry; |
| 1615 entry.resource_id = resource_id; | 1633 entry.resource_id = resource_id; |
| 1616 entry.scale_factor = scale_factor; | 1634 entry.scale_factor = scale_factor; |
| 1617 entry.image = image; | 1635 entry.image = image; |
| 1618 image_cache_->push_front(entry); | 1636 image_cache_->push_front(entry); |
| 1619 if (image_cache_->size() > kMaxImageCacheSize) | 1637 if (image_cache_->size() > kMaxImageCacheSize) |
| 1620 image_cache_->pop_back(); | 1638 image_cache_->pop_back(); |
| 1621 } | 1639 } |
| OLD | NEW |