| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "content/child/webthemeengine_impl_mac.h" | |
| 6 | |
| 7 #include <Carbon/Carbon.h> | |
| 8 | |
| 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" | |
| 12 | |
| 13 using blink::WebCanvas; | |
| 14 using blink::WebRect; | |
| 15 using blink::WebThemeEngine; | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 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; | |
| 27 } | |
| 28 } | |
| 29 | |
| 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; | |
| 49 } | |
| 50 | |
| 51 trackInfo.enableState = stateToHIEnableState(state); | |
| 52 | |
| 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); | |
| 59 } | |
| 60 | |
| 61 } // namespace content | |
| OLD | NEW |