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 "webkit/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
;
15 using blink::WebThemeEngine
;
17 namespace webkit_glue
{
19 static ThemeTrackEnableState
stateToHIEnableState(WebThemeEngine::State state
) {
21 case WebThemeEngine::StateDisabled
:
22 return kThemeTrackDisabled
;
23 case WebThemeEngine::StateInactive
:
24 return kThemeTrackInactive
;
26 return kThemeTrackActive
;
30 void WebThemeEngineImpl::paintScrollbarThumb(
32 WebThemeEngine::State state
,
33 WebThemeEngine::Size size
,
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
);
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 webkit_glue