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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 2376213002: Remove ante-MD code in ui/views/tabs/tab_strip.cc (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('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) 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_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 26 matching lines...) Expand all
37 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
38 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "third_party/skia/include/core/SkColorFilter.h" 39 #include "third_party/skia/include/core/SkColorFilter.h"
40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" 41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h"
42 #include "third_party/skia/include/pathops/SkPathOps.h" 42 #include "third_party/skia/include/pathops/SkPathOps.h"
43 #include "ui/accessibility/ax_view_state.h" 43 #include "ui/accessibility/ax_view_state.h"
44 #include "ui/base/default_theme_provider.h" 44 #include "ui/base/default_theme_provider.h"
45 #include "ui/base/dragdrop/drag_drop_types.h" 45 #include "ui/base/dragdrop/drag_drop_types.h"
46 #include "ui/base/l10n/l10n_util.h" 46 #include "ui/base/l10n/l10n_util.h"
47 #include "ui/base/material_design/material_design_controller.h"
48 #include "ui/base/models/list_selection_model.h" 47 #include "ui/base/models/list_selection_model.h"
49 #include "ui/base/resource/resource_bundle.h" 48 #include "ui/base/resource/resource_bundle.h"
50 #include "ui/compositor/compositing_recorder.h" 49 #include "ui/compositor/compositing_recorder.h"
51 #include "ui/compositor/paint_recorder.h" 50 #include "ui/compositor/paint_recorder.h"
52 #include "ui/display/display.h" 51 #include "ui/display/display.h"
53 #include "ui/display/screen.h" 52 #include "ui/display/screen.h"
54 #include "ui/gfx/animation/animation_container.h" 53 #include "ui/gfx/animation/animation_container.h"
55 #include "ui/gfx/animation/throb_animation.h" 54 #include "ui/gfx/animation/throb_animation.h"
56 #include "ui/gfx/canvas.h" 55 #include "ui/gfx/canvas.h"
57 #include "ui/gfx/geometry/rect_conversions.h" 56 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 361 }
363 362
364 void NewTabButton::OnPaint(gfx::Canvas* canvas) { 363 void NewTabButton::OnPaint(gfx::Canvas* canvas) {
365 gfx::ScopedCanvas scoped_canvas(canvas); 364 gfx::ScopedCanvas scoped_canvas(canvas);
366 const int visible_height = GetLayoutSize(NEW_TAB_BUTTON).height(); 365 const int visible_height = GetLayoutSize(NEW_TAB_BUTTON).height();
367 canvas->Translate(gfx::Vector2d(0, height() - visible_height)); 366 canvas->Translate(gfx::Vector2d(0, height() - visible_height));
368 367
369 const bool pressed = state() == views::CustomButton::STATE_PRESSED; 368 const bool pressed = state() == views::CustomButton::STATE_PRESSED;
370 const float scale = canvas->image_scale(); 369 const float scale = canvas->image_scale();
371 370
371 // Fill.
372 SkPath fill; 372 SkPath fill;
373 const ui::ThemeProvider* tp = GetThemeProvider(); 373 const float fill_bottom = (visible_height - 2) * scale;
374 if (ui::MaterialDesignController::IsModeMaterial()) { 374 const float diag_height = fill_bottom - 3.5 * scale;
375 // Fill. 375 const float diag_width = diag_height * Tab::GetInverseDiagonalSlope();
376 const float fill_bottom = (visible_height - 2) * scale; 376 fill.moveTo(diag_width + 4 * scale, fill_bottom);
377 const float diag_height = fill_bottom - 3.5 * scale; 377 fill.rCubicTo(-0.75 * scale, 0, -1.625 * scale, -0.5 * scale, -2 * scale,
378 const float diag_width = diag_height * Tab::GetInverseDiagonalSlope(); 378 -1.5 * scale);
379 fill.moveTo(diag_width + 4 * scale, fill_bottom); 379 fill.rLineTo(-diag_width, -diag_height);
380 fill.rCubicTo(-0.75 * scale, 0, -1.625 * scale, -0.5 * scale, -2 * scale, 380 fill.rCubicTo(0, -0.5 * scale, 0.25 * scale, -scale, scale, -scale);
381 -1.5 * scale); 381 fill.lineTo((width() - 4) * scale - diag_width, scale);
382 fill.rLineTo(-diag_width, -diag_height); 382 fill.rCubicTo(0.75 * scale, 0, 1.625 * scale, 0.5 * scale, 2 * scale,
383 fill.rCubicTo(0, -0.5 * scale, 0.25 * scale, -scale, scale, -scale); 383 1.5 * scale);
384 fill.lineTo((width() - 4) * scale - diag_width, scale); 384 fill.rLineTo(diag_width, diag_height);
385 fill.rCubicTo(0.75 * scale, 0, 1.625 * scale, 0.5 * scale, 2 * scale, 385 fill.rCubicTo(0, 0.5 * scale, -0.25 * scale, scale, -scale, scale);
386 1.5 * scale); 386 fill.close();
387 fill.rLineTo(diag_width, diag_height); 387 PaintFill(pressed, scale, fill, canvas);
388 fill.rCubicTo(0, 0.5 * scale, -0.25 * scale, scale, -scale, scale);
389 fill.close();
390 PaintFill(pressed, scale, fill, canvas);
391 388
392 // Stroke. 389 // Stroke.
393 gfx::ScopedCanvas scoped_canvas(canvas); 390 canvas->UndoDeviceScaleFactor();
394 canvas->UndoDeviceScaleFactor(); 391 SkPath stroke;
395 SkPath stroke; 392 GetBorderPath(0, scale, false, &stroke);
396 GetBorderPath(0, scale, false, &stroke); 393 // We want to draw a drop shadow either inside or outside the stroke,
397 // We want to draw a drop shadow either inside or outside the stroke, 394 // depending on whether we're pressed; so, either clip out what's outside
398 // depending on whether we're pressed; so, either clip out what's outside 395 // the stroke, or clip out the fill inside it.
399 // the stroke, or clip out the fill inside it. 396 if (pressed)
400 if (pressed) 397 canvas->ClipPath(stroke, true);
401 canvas->ClipPath(stroke, true); 398 Op(stroke, fill, kDifference_SkPathOp, &stroke);
402 Op(stroke, fill, kDifference_SkPathOp, &stroke); 399 if (!pressed)
403 if (!pressed) 400 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true);
404 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true); 401 // Now draw the stroke and shadow; the stroke will always be visible, while
405 // Now draw the stroke and shadow; the stroke will always be visible, while 402 // the shadow will be affected by the clip we set above.
406 // the shadow will be affected by the clip we set above. 403 SkPaint paint;
407 SkPaint paint; 404 paint.setAntiAlias(true);
408 paint.setAntiAlias(true); 405 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor();
409 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor(); 406 const float alpha = SkColorGetA(stroke_color);
410 const float alpha = SkColorGetA(stroke_color); 407 const SkAlpha shadow_alpha =
411 const SkAlpha shadow_alpha = 408 base::saturated_cast<SkAlpha>(std::round(2.1875f * alpha));
412 base::saturated_cast<SkAlpha>(std::round(2.1875f * alpha)); 409 paint.setLooper(
413 paint.setLooper( 410 CreateShadowDrawLooper(SkColorSetA(stroke_color, shadow_alpha)));
414 CreateShadowDrawLooper(SkColorSetA(stroke_color, shadow_alpha))); 411 const SkAlpha path_alpha = static_cast<SkAlpha>(
415 const SkAlpha path_alpha = static_cast<SkAlpha>( 412 std::round((pressed ? 0.875f : 0.609375f) * alpha));
416 std::round((pressed ? 0.875f : 0.609375f) * alpha)); 413 paint.setColor(SkColorSetA(stroke_color, path_alpha));
417 paint.setColor(SkColorSetA(stroke_color, path_alpha)); 414 canvas->DrawPath(stroke, paint);
418 canvas->DrawPath(stroke, paint);
419 } else {
420 // Fill.
421 gfx::ImageSkia* mask = tp->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK);
422 // The canvas and mask have to use the same scale factor.
423 const float fill_canvas_scale = mask->HasRepresentation(scale) ?
424 scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P);
425 gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale,
426 false);
427 PaintFill(pressed, fill_canvas_scale, fill, &fill_canvas);
428 gfx::ImageSkia image(fill_canvas.ExtractImageRep());
429 canvas->DrawImageInt(
430 gfx::ImageSkiaOperations::CreateMaskedImage(image, *mask), 0, 0);
431
432 // Stroke. Draw the button border with a slight alpha.
433 static const SkAlpha kGlassFrameOverlayAlpha = 178;
434 static const SkAlpha kOpaqueFrameOverlayAlpha = 230;
435 const SkAlpha alpha = GetWidget()->ShouldWindowContentsBeTransparent() ?
436 kGlassFrameOverlayAlpha : kOpaqueFrameOverlayAlpha;
437 const int overlay_id = pressed ? IDR_NEWTAB_BUTTON_P : IDR_NEWTAB_BUTTON;
438 canvas->DrawImageInt(*tp->GetImageSkiaNamed(overlay_id), 0, 0, alpha);
439 }
440 } 415 }
441 416
442 bool NewTabButton::GetHitTestMask(gfx::Path* mask) const { 417 bool NewTabButton::GetHitTestMask(gfx::Path* mask) const {
443 DCHECK(mask); 418 DCHECK(mask);
444 419
445 if (ui::MaterialDesignController::IsModeMaterial()) { 420 SkPath border;
446 SkPath border; 421 const float scale = GetWidget()->GetCompositor()->device_scale_factor();
447 const float scale = GetWidget()->GetCompositor()->device_scale_factor(); 422 GetBorderPath(GetNewTabButtonTopOffset() * scale, scale,
448 GetBorderPath(GetNewTabButtonTopOffset() * scale, scale, 423 tab_strip_->SizeTabButtonToTopOfTabStrip(), &border);
449 tab_strip_->SizeTabButtonToTopOfTabStrip(), &border); 424 mask->addPath(border, SkMatrix::MakeScale(1 / scale));
450 mask->addPath(border, SkMatrix::MakeScale(1 / scale));
451 } else if (tab_strip_->SizeTabButtonToTopOfTabStrip()) {
452 // When the button is sized to the top of the tab strip, we want the hit
453 // test mask to be defined as the complete (rectangular) bounds of the
454 // button.
455 gfx::Rect button_bounds(GetContentsBounds());
456 button_bounds.set_x(GetMirroredXForRect(button_bounds));
457 mask->addRect(RectToSkRect(button_bounds));
458 } else {
459 SkScalar w = SkIntToScalar(width());
460 SkScalar v_offset = SkIntToScalar(GetNewTabButtonTopOffset());
461
462 // These values are defined by the shape of the new tab image. Should that
463 // image ever change, these values will need to be updated. They're so
464 // custom it's not really worth defining constants for.
465 // These values are correct for regular and USE_ASH versions of the image.
466 mask->moveTo(0, v_offset + 1);
467 mask->lineTo(w - 7, v_offset + 1);
468 mask->lineTo(w - 4, v_offset + 4);
469 mask->lineTo(w, v_offset + 16);
470 mask->lineTo(w - 1, v_offset + 17);
471 mask->lineTo(7, v_offset + 17);
472 mask->lineTo(4, v_offset + 13);
473 mask->lineTo(0, v_offset + 1);
474 mask->close();
475 }
476
477 return true; 425 return true;
478 } 426 }
479 427
480 void NewTabButton::GetBorderPath(float button_y, 428 void NewTabButton::GetBorderPath(float button_y,
481 float scale, 429 float scale,
482 bool extend_to_top, 430 bool extend_to_top,
483 SkPath* path) const { 431 SkPath* path) const {
484 const float inverse_slope = Tab::GetInverseDiagonalSlope(); 432 const float inverse_slope = Tab::GetInverseDiagonalSlope();
485 const float fill_bottom = 433 const float fill_bottom =
486 (GetLayoutSize(NEW_TAB_BUTTON).height() - 2) * scale; 434 (GetLayoutSize(NEW_TAB_BUTTON).height() - 2) * scale;
(...skipping 26 matching lines...) Expand all
513 path->rCubicTo(0.5 * scale, 1.125 * scale, -0.5 * scale, scale + 2, -scale, 461 path->rCubicTo(0.5 * scale, 1.125 * scale, -0.5 * scale, scale + 2, -scale,
514 scale + 2); 462 scale + 2);
515 } 463 }
516 path->close(); 464 path->close();
517 } 465 }
518 466
519 void NewTabButton::PaintFill(bool pressed, 467 void NewTabButton::PaintFill(bool pressed,
520 float scale, 468 float scale,
521 const SkPath& fill, 469 const SkPath& fill,
522 gfx::Canvas* canvas) const { 470 gfx::Canvas* canvas) const {
523 // First we compute the background image coordinates and scale, in case we 471 gfx::ScopedCanvas scoped_canvas(canvas);
524 // need to draw a custom background image. 472 canvas->UndoDeviceScaleFactor();
525 const ui::ThemeProvider* tp = GetThemeProvider();
526 bool custom_image;
527 const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image);
528 // For custom tab backgrounds the background starts at the top of the tab
529 // strip. Otherwise the background starts at the top of the frame.
530 const int offset_y = tp->HasCustomImage(bg_id) ? 0 : background_offset_.y();
531 // The new tab background is mirrored in RTL mode, but the theme background
532 // should never be mirrored. Mirror it here to compensate.
533 float x_scale = 1.0f;
534 int x = GetMirroredX() + background_offset_.x();
535 const gfx::Size size(GetLayoutSize(NEW_TAB_BUTTON));
536 if (base::i18n::IsRTL()) {
537 x_scale = -1.0f;
538 // Offset by |width| such that the same region is painted as if there was no
539 // flip.
540 x += size.width();
541 }
542 const int y = GetNewTabButtonTopOffset() + offset_y;
543 473
544 if (ui::MaterialDesignController::IsModeMaterial()) { 474 // For unpressed buttons, draw the fill and its shadow.
545 gfx::ScopedCanvas scoped_canvas(canvas); 475 if (!pressed) {
546 canvas->UndoDeviceScaleFactor();
547
548 // For unpressed buttons, draw the fill and its shadow.
549 if (!pressed) {
550 SkPaint paint;
551 paint.setAntiAlias(true);
552 if (custom_image) {
553 const bool succeeded = canvas->InitSkPaintForTiling(
554 *tp->GetImageSkiaNamed(bg_id), x, y, x_scale * scale, scale, 0, 0,
555 &paint);
556 DCHECK(succeeded);
557 } else {
558 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB));
559 }
560 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor();
561 const SkAlpha alpha = static_cast<SkAlpha>(
562 std::round(SkColorGetA(stroke_color) * 0.59375f));
563 paint.setLooper(
564 CreateShadowDrawLooper(SkColorSetA(stroke_color, alpha)));
565 canvas->DrawPath(fill, paint);
566 }
567
568 // Draw a white highlight on hover.
569 SkPaint paint; 476 SkPaint paint;
570 paint.setAntiAlias(true); 477 paint.setAntiAlias(true);
571 const SkAlpha hover_alpha = static_cast<SkAlpha>( 478 // First we compute the background image coordinates and scale, in case we
572 hover_animation().CurrentValueBetween(0x00, 0x4D)); 479 // need to draw a custom background image.
573 if (hover_alpha != SK_AlphaTRANSPARENT) { 480 const ui::ThemeProvider* tp = GetThemeProvider();
574 paint.setColor(SkColorSetA(SK_ColorWHITE, hover_alpha)); 481 bool custom_image;
575 canvas->DrawPath(fill, paint); 482 const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image);
483 if (custom_image) {
484 // For custom tab backgrounds the background starts at the top of the tab
485 // strip. Otherwise the background starts at the top of the frame.
486 const int offset_y =
487 tp->HasCustomImage(bg_id) ? 0 : background_offset_.y();
488 // The new tab background is mirrored in RTL mode, but the theme
489 // background should never be mirrored. Mirror it here to compensate.
490 float x_scale = 1.0f;
491 int x = GetMirroredX() + background_offset_.x();
492 const gfx::Size size(GetLayoutSize(NEW_TAB_BUTTON));
493 if (base::i18n::IsRTL()) {
494 x_scale = -1.0f;
495 // Offset by |width| such that the same region is painted as if there
496 // was no flip.
497 x += size.width();
498 }
499
500 const bool succeeded =
501 canvas->InitSkPaintForTiling(*tp->GetImageSkiaNamed(bg_id), x,
502 GetNewTabButtonTopOffset() + offset_y,
503 x_scale * scale, scale, 0, 0, &paint);
504 DCHECK(succeeded);
505 } else {
506 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB));
576 } 507 }
508 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor();
509 const SkAlpha alpha = static_cast<SkAlpha>(
510 std::round(SkColorGetA(stroke_color) * 0.59375f));
511 paint.setLooper(
512 CreateShadowDrawLooper(SkColorSetA(stroke_color, alpha)));
513 canvas->DrawPath(fill, paint);
Peter Kasting 2016/09/29 04:18:59 Nit: If you add a paint.setLooper(nullptr) call (I
Evan Stade 2016/09/29 16:44:00 Done.
514 }
577 515
578 // Most states' opacities are adjusted using an opacity recorder in 516 // Draw a white highlight on hover.
579 // TabStrip::PaintChildren(), but the pressed state is excluded there and 517 SkPaint paint;
580 // instead rendered using a dark overlay here. This produces a different 518 paint.setAntiAlias(true);
581 // effect than for non-MD, and avoiding the use of the opacity recorder 519 const SkAlpha hover_alpha = static_cast<SkAlpha>(
582 // keeps the stroke more visible in this state. 520 hover_animation().CurrentValueBetween(0x00, 0x4D));
583 if (pressed) { 521 if (hover_alpha != SK_AlphaTRANSPARENT) {
584 paint.setColor(SkColorSetA(SK_ColorBLACK, 0x14)); 522 paint.setColor(SkColorSetA(SK_ColorWHITE, hover_alpha));
585 canvas->DrawPath(fill, paint); 523 canvas->DrawPath(fill, paint);
586 } 524 }
587 } else {
588 // Draw the fill image.
589 canvas->TileImageInt(*tp->GetImageSkiaNamed(bg_id), x, y, x_scale, 1.0f,
590 0, 0, size.width(), size.height());
591 525
592 // Adjust the alpha of the fill to match that of inactive tabs (except for 526 // Most states' opacities are adjusted using an opacity recorder in
593 // pressed buttons, which get a different value). For MD, we do this with 527 // TabStrip::PaintChildren(), but the pressed state is excluded there and
594 // an opacity recorder in TabStrip::PaintChildren() so the fill and stroke 528 // instead rendered using a dark overlay here. Avoiding the use of the
595 // are both affected, to better match how tabs are handled, but in non-MD, 529 // opacity recorder keeps the stroke more visible in this state.
596 // the button stroke is already lighter than the tab stroke, and using the 530 if (pressed) {
597 // opacity recorder washes it out too much. 531 paint.setColor(SkColorSetA(SK_ColorBLACK, 0x14));
598 static const SkAlpha kPressedAlpha = 145; 532 canvas->DrawPath(fill, paint);
599 const SkAlpha fill_alpha =
600 pressed ? kPressedAlpha : tab_strip_->GetInactiveAlpha(true);
601 if (fill_alpha != 255) {
602 SkPaint paint;
603 paint.setAlpha(fill_alpha);
604 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
605 paint.setStyle(SkPaint::kFill_Style);
606 canvas->DrawRect(gfx::Rect(size), paint);
607 }
608
609 // Draw a white highlight on hover.
610 const SkAlpha hover_alpha = static_cast<SkAlpha>(
611 hover_animation().CurrentValueBetween(0x00, 0x40));
612 if (hover_alpha != SK_AlphaTRANSPARENT) {
613 canvas->FillRect(GetLocalBounds(),
614 SkColorSetA(SK_ColorWHITE, hover_alpha));
615 }
616 } 533 }
617 } 534 }
618 535
619 /////////////////////////////////////////////////////////////////////////////// 536 ///////////////////////////////////////////////////////////////////////////////
620 // TabStrip::RemoveTabDelegate 537 // TabStrip::RemoveTabDelegate
621 // 538 //
622 // AnimationDelegate used when removing a tab. Does the necessary cleanup when 539 // AnimationDelegate used when removing a tab. Does the necessary cleanup when
623 // done. 540 // done.
624 class TabStrip::RemoveTabDelegate : public TabAnimationDelegate { 541 class TabStrip::RemoveTabDelegate : public TabAnimationDelegate {
625 public: 542 public:
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 // Now selected but not active. We don't want these dimmed if using native 1436 // Now selected but not active. We don't want these dimmed if using native
1520 // frame, so they're painted after initial pass. 1437 // frame, so they're painted after initial pass.
1521 for (size_t i = 0; i < selected_tabs.size(); ++i) 1438 for (size_t i = 0; i < selected_tabs.size(); ++i)
1522 selected_tabs[i]->Paint(context); 1439 selected_tabs[i]->Paint(context);
1523 1440
1524 // Next comes the active tab. 1441 // Next comes the active tab.
1525 if (active_tab && !is_dragging) 1442 if (active_tab && !is_dragging)
1526 active_tab->Paint(context); 1443 active_tab->Paint(context);
1527 1444
1528 // Paint the New Tab button. 1445 // Paint the New Tab button.
1529 const bool md = ui::MaterialDesignController::IsModeMaterial(); 1446 if (newtab_button_->state() != views::CustomButton::STATE_PRESSED) {
1530 if (md && (newtab_button_->state() != views::CustomButton::STATE_PRESSED)) {
1531 // Match the inactive tab opacity for non-pressed states. See comments in 1447 // Match the inactive tab opacity for non-pressed states. See comments in
1532 // NewTabButton::PaintFill() for why we don't do this for the pressed state. 1448 // NewTabButton::PaintFill() for why we don't do this for the pressed state.
1533 // This call doesn't need to set |lcd_text_requires_opaque_layer| to false 1449 // This call doesn't need to set |lcd_text_requires_opaque_layer| to false
1534 // because no text will be drawn. 1450 // because no text will be drawn.
1535 ui::CompositingRecorder opacity_recorder(context, GetInactiveAlpha(true), 1451 ui::CompositingRecorder opacity_recorder(context, GetInactiveAlpha(true),
1536 true); 1452 true);
1537 newtab_button_->Paint(context); 1453 newtab_button_->Paint(context);
1538 } else {
1539 newtab_button_->Paint(context);
1540 } 1454 }
1541 1455
1542 // And the dragged tabs. 1456 // And the dragged tabs.
1543 for (size_t i = 0; i < tabs_dragging.size(); ++i) 1457 for (size_t i = 0; i < tabs_dragging.size(); ++i)
1544 tabs_dragging[i]->Paint(context); 1458 tabs_dragging[i]->Paint(context);
1545 1459
1546 // If the active tab is being dragged, it goes last. 1460 // If the active tab is being dragged, it goes last.
1547 if (active_tab && is_dragging) 1461 if (active_tab && is_dragging)
1548 active_tab->Paint(context); 1462 active_tab->Paint(context);
1549 1463
1550 if (md) { 1464 ui::PaintRecorder recorder(context, size());
1551 ui::PaintRecorder recorder(context, size()); 1465 gfx::Canvas* canvas = recorder.canvas();
1552 gfx::Canvas* canvas = recorder.canvas(); 1466 if (active_tab) {
1553 if (active_tab) { 1467 canvas->sk_canvas()->clipRect(
1554 canvas->sk_canvas()->clipRect( 1468 gfx::RectToSkRect(active_tab->GetMirroredBounds()),
1555 gfx::RectToSkRect(active_tab->GetMirroredBounds()), 1469 SkRegion::kDifference_Op);
1556 SkRegion::kDifference_Op);
1557 }
1558 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
1559 GetLocalBounds(), true);
1560 } 1470 }
1471 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
1472 GetLocalBounds(), true);
1561 } 1473 }
1562 1474
1563 const char* TabStrip::GetClassName() const { 1475 const char* TabStrip::GetClassName() const {
1564 static const char kViewClassName[] = "TabStrip"; 1476 static const char kViewClassName[] = "TabStrip";
1565 return kViewClassName; 1477 return kViewClassName;
1566 } 1478 }
1567 1479
1568 gfx::Size TabStrip::GetPreferredSize() const { 1480 gfx::Size TabStrip::GetPreferredSize() const {
1569 int needed_tab_width; 1481 int needed_tab_width;
1570 if (touch_layout_ || adjust_layout_) { 1482 if (touch_layout_ || adjust_layout_) {
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2800 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2889 if (view) 2801 if (view)
2890 return view; 2802 return view;
2891 } 2803 }
2892 Tab* tab = FindTabForEvent(point); 2804 Tab* tab = FindTabForEvent(point);
2893 if (tab) 2805 if (tab)
2894 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2806 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2895 } 2807 }
2896 return this; 2808 return this;
2897 } 2809 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698