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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/tabs/tab_resources.h"
7 #include "base/logging.h"
8 #include "ui/gfx/path.h"
12 // Hit mask constants.
13 const SkScalar kTabCapWidth
= 15;
14 const SkScalar kTabTopCurveWidth
= 4;
15 const SkScalar kTabBottomCurveWidth
= 3;
16 #if defined(TOOLKIT_VIEWS)
17 // Windows and Ash have shadows in the left, right and top parts of the tab.
18 const SkScalar kTabInset
= 6;
19 const SkScalar kTabTop
= 2;
21 // Linux GTK and Mac don't have the shadows.
22 const SkScalar kTabInset
= 0;
23 const SkScalar kTabTop
= 0;
29 void TabResources::GetHitTestMask(int width
,
31 bool include_top_shadow
,
35 SkScalar left
= kTabInset
;
36 SkScalar top
= kTabTop
;
37 SkScalar right
= SkIntToScalar(width
) - kTabInset
;
38 SkScalar bottom
= SkIntToScalar(height
);
40 // Start in the lower-left corner.
41 path
->moveTo(left
, bottom
);
44 path
->lineTo(left
+ kTabBottomCurveWidth
, bottom
- kTabBottomCurveWidth
);
45 path
->lineTo(left
+ kTabCapWidth
- kTabTopCurveWidth
,
46 top
+ kTabTopCurveWidth
);
47 path
->lineTo(left
+ kTabCapWidth
, top
);
49 // Extend over the top shadow area if we have one and the caller wants it.
50 if (kTabTop
> 0 && include_top_shadow
) {
51 path
->lineTo(left
+ kTabCapWidth
, 0);
52 path
->lineTo(right
- kTabCapWidth
, 0);
55 // Connect to the right cap.
56 path
->lineTo(right
- kTabCapWidth
, top
);
59 path
->lineTo(right
- kTabCapWidth
+ kTabTopCurveWidth
,
60 top
+ kTabTopCurveWidth
);
61 path
->lineTo(right
- kTabBottomCurveWidth
, bottom
- kTabBottomCurveWidth
);
62 path
->lineTo(right
, bottom
);
64 // Close out the path.
65 path
->lineTo(left
, bottom
);