From 1c4ff85935600c96ac8cadeaa21c2122ba07e9a3 Mon Sep 17 00:00:00 2001 From: "mihaip@chromium.org" Date: Wed, 29 Dec 2010 21:27:01 +0000 Subject: Add implementation of WebThemeEngine for the Mac (declared by http://webkit.org/b/51507). This allows scrollbar thumb rendering to be overridden, so that we can match the Mac port's when running under the DRT. BUG=23498 TEST=Layout tests Review URL: http://codereview.chromium.org/6041005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70278 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/webthemeengine_impl_mac.cc | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 webkit/glue/webthemeengine_impl_mac.cc (limited to 'webkit/glue/webthemeengine_impl_mac.cc') diff --git a/webkit/glue/webthemeengine_impl_mac.cc b/webkit/glue/webthemeengine_impl_mac.cc new file mode 100644 index 0000000..ac28334 --- /dev/null +++ b/webkit/glue/webthemeengine_impl_mac.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/webthemeengine_impl_mac.h" + +#include + +#include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" + +using WebKit::WebCanvas; +using WebKit::WebRect; +using WebKit::WebThemeEngine; + +namespace webkit_glue { + +static ThemeTrackEnableState stateToHIEnableState(WebThemeEngine::State state) { + switch (state) { + case WebThemeEngine::StateDisabled: + return kThemeTrackDisabled; + case WebThemeEngine::StateInactive: + return kThemeTrackInactive; + default: + return kThemeTrackActive; + } +} + +void WebThemeEngineImpl::paintScrollbarThumb( + WebCanvas* canvas, + WebThemeEngine::State state, + WebThemeEngine::Size size, + const WebRect& rect, + const WebThemeEngine::ScrollbarInfo& scrollbarInfo) { + HIThemeTrackDrawInfo trackInfo; + trackInfo.version = 0; + trackInfo.kind = size == WebThemeEngine::SizeRegular ? + kThemeMediumScrollBar : kThemeSmallScrollBar; + trackInfo.bounds = CGRectMake(rect.x, rect.y, rect.width, rect.height); + trackInfo.min = 0; + trackInfo.max = scrollbarInfo.maxValue; + trackInfo.value = scrollbarInfo.currentValue; + trackInfo.trackInfo.scrollbar.viewsize = scrollbarInfo.visibleSize; + trackInfo.attributes = 0; + if (scrollbarInfo.orientation == + WebThemeEngine::ScrollbarOrientationHorizontal) { + trackInfo.attributes |= kThemeTrackHorizontal; + } + + trackInfo.enableState = stateToHIEnableState(state); + + trackInfo.trackInfo.scrollbar.pressState = + state == WebThemeEngine::StatePressed ? kThemeThumbPressed : 0; + trackInfo.attributes |= (kThemeTrackShowThumb | kThemeTrackHideTrack); + HIThemeDrawTrack(&trackInfo, 0, canvas, kHIThemeOrientationNormal); +} + +} // namespace webkit_glue -- cgit v1.1