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

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

Issue 10274006: Fix a small layout glitch in Metro after the recent Ash/Desktop merge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/defaults.h" 10 #include "chrome/browser/defaults.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 value = 7; 98 value = 7;
99 break; 99 break;
100 default: 100 default:
101 NOTREACHED(); 101 NOTREACHED();
102 } 102 }
103 } 103 }
104 return value; 104 return value;
105 } 105 }
106 106
107 // Height of the shadow at the top of the tab image assets. 107 // Height of the shadow at the top of the tab image assets.
108 static const int kDropShadowHeight = 4; 108 const int GetDropShadowHeight() {
109 static int value = -1;
110 if (value == -1) {
111 switch (ui::GetDisplayLayout()) {
112 case ui::LAYOUT_ASH:
113 case ui::LAYOUT_DESKTOP:
114 value = 4;
115 break;
116 case ui::LAYOUT_TOUCH:
117 value = 2;
118 break;
119 default:
120 NOTREACHED();
121 }
122 }
123 return value;
124 }
125
109 static const int kToolbarOverlap = 1; 126 static const int kToolbarOverlap = 1;
110 static const int kFaviconTitleSpacing = 4; 127 static const int kFaviconTitleSpacing = 4;
111 #if defined(USE_ASH) 128 #if defined(USE_ASH)
112 // Additional vertical offset for title text relative to top of tab. 129 // Additional vertical offset for title text relative to top of tab.
113 // Ash text rendering may be different than Windows. 130 // Ash text rendering may be different than Windows.
114 // TODO(jamescook): Make this Chrome OS or Linux only? 131 // TODO(jamescook): Make this Chrome OS or Linux only?
115 static const int kTitleTextOffsetY = 1; 132 static const int kTitleTextOffsetY = 1;
116 #else 133 #else
117 static const int kTitleTextOffsetY = 0; 134 static const int kTitleTextOffsetY = 0;
118 #endif 135 #endif
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 offset + width() - tab_image->r_width, bg_offset_y, 564 offset + width() - tab_image->r_width, bg_offset_y,
548 tab_image->r_width, height()); 565 tab_image->r_width, height());
549 SkBitmap theme_r = 566 SkBitmap theme_r =
550 SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r); 567 SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r);
551 background_canvas.DrawBitmapInt(theme_r, 568 background_canvas.DrawBitmapInt(theme_r,
552 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, 569 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
553 width() - theme_r.width(), 0, theme_r.width(), 570 width() - theme_r.width(), 0, theme_r.width(),
554 theme_r.height() - kToolbarOverlap, false); 571 theme_r.height() - kToolbarOverlap, false);
555 572
556 // Draw center. Instead of masking out the top portion we simply skip over 573 // Draw center. Instead of masking out the top portion we simply skip over
557 // it by incrementing by kDropShadowHeight, since it's a simple rectangle. 574 // it by incrementing by GetDropShadowHeight(), since it's a simple
558 // And again, don't draw over the toolbar. 575 // rectangle. And again, don't draw over the toolbar.
559 background_canvas.TileImageInt(*tab_bg, 576 background_canvas.TileImageInt(*tab_bg,
560 offset + tab_image->l_width, 577 offset + tab_image->l_width,
561 bg_offset_y + kDropShadowHeight + tab_image->y_offset, 578 bg_offset_y + GetDropShadowHeight() + tab_image->y_offset,
562 tab_image->l_width, 579 tab_image->l_width,
563 kDropShadowHeight + tab_image->y_offset, 580 GetDropShadowHeight() + tab_image->y_offset,
564 width() - tab_image->l_width - tab_image->r_width, 581 width() - tab_image->l_width - tab_image->r_width,
565 height() - kDropShadowHeight - kToolbarOverlap - tab_image->y_offset); 582 height() - GetDropShadowHeight() - kToolbarOverlap - tab_image->y_offset);
566 583
567 canvas->DrawBitmapInt(background_canvas.ExtractBitmap(), 0, 0); 584 canvas->DrawBitmapInt(background_canvas.ExtractBitmap(), 0, 0);
568 585
569 if (!GetThemeProvider()->HasCustomImage(tab_id) && 586 if (!GetThemeProvider()->HasCustomImage(tab_id) &&
570 hover_controller().ShouldDraw()) { 587 hover_controller().ShouldDraw()) {
571 hover_controller().Draw(canvas, background_canvas.ExtractBitmap()); 588 hover_controller().Draw(canvas, background_canvas.ExtractBitmap());
572 } 589 }
573 590
574 // Now draw the highlights/shadows around the tab edge. 591 // Now draw the highlights/shadows around the tab edge.
575 canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0); 592 canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0);
(...skipping 24 matching lines...) Expand all
600 canvas->DrawBitmapInt(theme_l, 0, 0); 617 canvas->DrawBitmapInt(theme_l, 0, 0);
601 618
602 // Draw right edge. 619 // Draw right edge.
603 SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg, 620 SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
604 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); 621 offset + width() - tab_image->r_width, 0, tab_image->r_width, height());
605 SkBitmap theme_r = 622 SkBitmap theme_r =
606 SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r); 623 SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r);
607 canvas->DrawBitmapInt(theme_r, width() - tab_image->r_width, 0); 624 canvas->DrawBitmapInt(theme_r, width() - tab_image->r_width, 0);
608 625
609 // Draw center. Instead of masking out the top portion we simply skip over it 626 // Draw center. Instead of masking out the top portion we simply skip over it
610 // by incrementing by kDropShadowHeight, since it's a simple rectangle. 627 // by incrementing by GetDropShadowHeight(), since it's a simple rectangle.
611 canvas->TileImageInt(*tab_bg, 628 canvas->TileImageInt(*tab_bg,
612 offset + tab_image->l_width, 629 offset + tab_image->l_width,
613 kDropShadowHeight + tab_image->y_offset, 630 GetDropShadowHeight() + tab_image->y_offset,
614 tab_image->l_width, 631 tab_image->l_width,
615 kDropShadowHeight + tab_image->y_offset, 632 GetDropShadowHeight() + tab_image->y_offset,
616 width() - tab_image->l_width - tab_image->r_width, 633 width() - tab_image->l_width - tab_image->r_width,
617 height() - kDropShadowHeight - tab_image->y_offset); 634 height() - GetDropShadowHeight() - tab_image->y_offset);
618 635
619 // Now draw the highlights/shadows around the tab edge. 636 // Now draw the highlights/shadows around the tab edge.
620 canvas->DrawBitmapInt(*tab_image->image_l, 0, 0); 637 canvas->DrawBitmapInt(*tab_image->image_l, 0, 0);
621 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, 638 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0,
622 width() - tab_image->l_width - tab_image->r_width, height()); 639 width() - tab_image->l_width - tab_image->r_width, height());
623 canvas->DrawBitmapInt(*tab_image->image_r, width() - tab_image->r_width, 0); 640 canvas->DrawBitmapInt(*tab_image->image_r, width() - tab_image->r_width, 0);
624 } 641 }
625 642
626 int Tab::IconCapacity() const { 643 int Tab::IconCapacity() const {
627 if (height() < GetMinimumUnselectedSize().height()) 644 if (height() < GetMinimumUnselectedSize().height())
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); 708 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
692 tab_active_.l_width = tab_active_.image_l->width(); 709 tab_active_.l_width = tab_active_.image_l->width();
693 tab_active_.r_width = tab_active_.image_r->width(); 710 tab_active_.r_width = tab_active_.image_r->width();
694 711
695 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); 712 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
696 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); 713 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
697 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); 714 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
698 tab_inactive_.l_width = tab_inactive_.image_l->width(); 715 tab_inactive_.l_width = tab_inactive_.image_l->width();
699 tab_inactive_.r_width = tab_inactive_.image_r->width(); 716 tab_inactive_.r_width = tab_inactive_.image_r->width();
700 } 717 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698