Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / tabs / tab_resources.cc
blob5b9dee508559d26c3c810de77bdbd1bb803a8340
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"
10 namespace {
12 // Hit mask constants.
13 const SkScalar kTabCapWidth = 15;
14 const SkScalar kTabTopCurveWidth = 4;
15 const SkScalar kTabBottomCurveWidth = 3;
16 #if defined(OS_MACOSX)
17 // Mac's Cocoa UI doesn't have shadows.
18 const SkScalar kTabInset = 0;
19 const SkScalar kTabTop = 0;
20 #elif defined(TOOLKIT_VIEWS)
21 // The views browser UI has shadows in the left, right and top parts of the tab.
22 const SkScalar kTabInset = 6;
23 const SkScalar kTabTop = 2;
24 #endif
26 } // namespace
28 // static
29 void TabResources::GetHitTestMask(int width,
30 int height,
31 bool include_top_shadow,
32 gfx::Path* path) {
33 DCHECK(path);
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);
43 // Left end cap.
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);
58 // Right end cap.
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);
66 path->close();