[Mac] PepperFlash default on DEV channel.
[chromium-blink-merge.git] / webkit / glue / webthemeengine_impl_mac.cc
blobe9b9cf333f901a1b6186e200099a483baa320f5d
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/glue/webthemeengine_impl_mac.h"
7 #include <Carbon/Carbon.h>
9 #include "skia/ext/skia_utils_mac.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
13 using WebKit::WebCanvas;
14 using WebKit::WebRect;
15 using WebKit::WebThemeEngine;
17 namespace webkit_glue {
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 webkit_glue