Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / child / webthemeengine_impl_mac.cc
blob62a5da11ef3a90fb85e5e6c25a44c0266f6ecc32
1 // Copyright 2014 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 "content/child/webthemeengine_impl_mac.h"
7 #include <Carbon/Carbon.h>
9 #include "skia/ext/skia_utils_mac.h"
10 #include "third_party/WebKit/public/platform/WebCanvas.h"
11 #include "third_party/WebKit/public/platform/WebRect.h"
13 using blink::WebCanvas;
14 using blink::WebRect;
15 using blink::WebThemeEngine;
17 namespace content {
19 static ThemeTrackEnableState stateToHIEnableState(WebThemeEngine::State state) {
20 switch (state) {
21 case WebThemeEngine::StateDisabled:
22 return kThemeTrackDisabled;
23 case WebThemeEngine::StateInactive:
24 return kThemeTrackInactive;
25 default:
26 return kThemeTrackActive;
30 void WebThemeEngineImpl::paintScrollbarThumb(
31 WebCanvas* canvas,
32 WebThemeEngine::State state,
33 WebThemeEngine::Size size,
34 const WebRect& rect,
35 const WebThemeEngine::ScrollbarInfo& scrollbarInfo) {
36 HIThemeTrackDrawInfo trackInfo;
37 trackInfo.version = 0;
38 trackInfo.kind = size == WebThemeEngine::SizeRegular ?
39 kThemeMediumScrollBar : kThemeSmallScrollBar;
40 trackInfo.bounds = CGRectMake(rect.x, rect.y, rect.width, rect.height);
41 trackInfo.min = 0;
42 trackInfo.max = scrollbarInfo.maxValue;
43 trackInfo.value = scrollbarInfo.currentValue;
44 trackInfo.trackInfo.scrollbar.viewsize = scrollbarInfo.visibleSize;
45 trackInfo.attributes = 0;
46 if (scrollbarInfo.orientation ==
47 WebThemeEngine::ScrollbarOrientationHorizontal) {
48 trackInfo.attributes |= kThemeTrackHorizontal;
51 trackInfo.enableState = stateToHIEnableState(state);
53 trackInfo.trackInfo.scrollbar.pressState =
54 state == WebThemeEngine::StatePressed ? kThemeThumbPressed : 0;
55 trackInfo.attributes |= (kThemeTrackShowThumb | kThemeTrackHideTrack);
56 gfx::SkiaBitLocker bitLocker(canvas);
57 CGContextRef cgContext = bitLocker.cgContext();
58 HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
61 } // namespace content