diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 03:25:30 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 03:25:30 +0000 |
commit | 7281e4cf77a6ebcd7c79db4f87629c7565ff4289 (patch) | |
tree | a0c5b4c4b7b64453ffe6f5cc606e0e9384808e74 /webkit/glue/webthemeengine_impl_linux.cc | |
parent | b83af49ec37d7354cd6134d0cac0ea85101f9c4f (diff) | |
download | chromium_src-7281e4cf77a6ebcd7c79db4f87629c7565ff4289.zip chromium_src-7281e4cf77a6ebcd7c79db4f87629c7565ff4289.tar.gz chromium_src-7281e4cf77a6ebcd7c79db4f87629c7565ff4289.tar.bz2 |
Move implementation of linux scrollbars from webkit using new
WebThemeEngine api. Also implement chromeos specific version.
BUG=chromium-os:6857
TEST=Verify that both linux and chromeos scrollbars look right.
Review URL: http://codereview.chromium.org/3618014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webthemeengine_impl_linux.cc')
-rw-r--r-- | webkit/glue/webthemeengine_impl_linux.cc | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/webkit/glue/webthemeengine_impl_linux.cc b/webkit/glue/webthemeengine_impl_linux.cc new file mode 100644 index 0000000..d5cc9b4 --- /dev/null +++ b/webkit/glue/webthemeengine_impl_linux.cc @@ -0,0 +1,100 @@ +// 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_linux.h" + +#include "gfx/native_theme_linux.h" +#include "skia/ext/platform_canvas.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" + +using WebKit::WebCanvas; +using WebKit::WebColor; +using WebKit::WebRect; + +namespace webkit_glue { + +static gfx::Rect WebRectToRect(const WebRect& rect) { + return gfx::Rect(rect.x, rect.y, rect.width, rect.height); +} + +static gfx::NativeThemeLinux::Part NativeThemePart( + WebKit::WebThemeEngine::Part part) { + switch (part) { + case WebKit::WebThemeEngine::PartScrollbarDownArrow: + return gfx::NativeThemeLinux::kScrollbarDownArrow; + case WebKit::WebThemeEngine::PartScrollbarLeftArrow: + return gfx::NativeThemeLinux::kScrollbarLeftArrow; + case WebKit::WebThemeEngine::PartScrollbarRightArrow: + return gfx::NativeThemeLinux::kScrollbarRightArrow; + case WebKit::WebThemeEngine::PartScrollbarUpArrow: + return gfx::NativeThemeLinux::kScrollbarUpArrow; + case WebKit::WebThemeEngine::PartScrollbarHorizontalThumb: + return gfx::NativeThemeLinux::kScrollbarHorizontalThumb; + case WebKit::WebThemeEngine::PartScrollbarVerticalThumb: + return gfx::NativeThemeLinux::kScrollbarVerticalThumb; + case WebKit::WebThemeEngine::PartScrollbarHoriztonalTrack: + return gfx::NativeThemeLinux::kScrollbarHorizontalTrack; + case WebKit::WebThemeEngine::PartScrollbarVerticalTrack: + return gfx::NativeThemeLinux::kScrollbarVerticalTrack; + default: + return gfx::NativeThemeLinux::kScrollbarDownArrow; + } +} + +static gfx::NativeThemeLinux::State NativeThemeState( + WebKit::WebThemeEngine::State state) { + switch (state) { + case WebKit::WebThemeEngine::StateDisabled: + return gfx::NativeThemeLinux::kDisabled; + case WebKit::WebThemeEngine::StateHover: + return gfx::NativeThemeLinux::kHover; + case WebKit::WebThemeEngine::StateNormal: + return gfx::NativeThemeLinux::kNormal; + case WebKit::WebThemeEngine::StatePressed: + return gfx::NativeThemeLinux::kPressed; + default: + return gfx::NativeThemeLinux::kDisabled; + } +} + +static void GetNativeThemeExtraParams( + WebKit::WebThemeEngine::Part part, + WebKit::WebThemeEngine::State state, + const WebKit::WebThemeEngine::ExtraParams* extra_params, + gfx::NativeThemeLinux::ExtraParams* native_theme_extra_params) { + if (part == WebKit::WebThemeEngine::PartScrollbarHoriztonalTrack || + part == WebKit::WebThemeEngine::PartScrollbarVerticalTrack) { + native_theme_extra_params->scrollbar_track.track_x = + extra_params->scrollbarTrack.trackX; + native_theme_extra_params->scrollbar_track.track_y = + extra_params->scrollbarTrack.trackY; + native_theme_extra_params->scrollbar_track.track_width = + extra_params->scrollbarTrack.trackWidth; + native_theme_extra_params->scrollbar_track.track_height = + extra_params->scrollbarTrack.trackHeight; + } +} + +WebKit::WebSize WebThemeEngineImpl::getSize(WebKit::WebThemeEngine::Part part) { + return gfx::NativeThemeLinux::instance()->GetSize(NativeThemePart(part)); +} + +void WebThemeEngineImpl::paint( + WebKit::WebCanvas* canvas, + WebKit::WebThemeEngine::Part part, + WebKit::WebThemeEngine::State state, + const WebKit::WebRect& rect, + const WebKit::WebThemeEngine::ExtraParams* extra_params) { + gfx::NativeThemeLinux::ExtraParams native_theme_extra_params; + GetNativeThemeExtraParams( + part, state, extra_params, &native_theme_extra_params); + gfx::NativeThemeLinux::instance()->Paint( + canvas, + NativeThemePart(part), + NativeThemeState(state), + WebRectToRect(rect), + native_theme_extra_params); +} +} // namespace webkit_glue |