summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 12:29:12 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 12:29:12 +0000
commitfe5ed19f21f9773d8c93d115035097a5f72161f5 (patch)
tree84c850b35b0ad606b387019fec48a398dfc8933a /webkit/glue
parente1dd56245e0d9e0c5ff69b7a14a61f3f010ac50e (diff)
downloadchromium_src-fe5ed19f21f9773d8c93d115035097a5f72161f5.zip
chromium_src-fe5ed19f21f9773d8c93d115035097a5f72161f5.tar.gz
chromium_src-fe5ed19f21f9773d8c93d115035097a5f72161f5.tar.bz2
Implement the Web Theme Engine for Android
BUG= TEST= Review URL: http://codereview.chromium.org/8889013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/webkit_glue.gypi5
-rw-r--r--webkit/glue/webthemeengine_impl_android.cc183
-rw-r--r--webkit/glue/webthemeengine_impl_android.h26
3 files changed, 214 insertions, 0 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 598dd88..ca2bae9 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -421,9 +421,14 @@
'websocketstreamhandle_delegate.h',
'websocketstreamhandle_impl.cc',
'websocketstreamhandle_impl.h',
+ 'webthemeengine_impl_android.cc',
+ 'webthemeengine_impl_android.h',
'webthemeengine_impl_linux.cc',
+ 'webthemeengine_impl_linux.h',
'webthemeengine_impl_mac.cc',
+ 'webthemeengine_impl_mac.h',
'webthemeengine_impl_win.cc',
+ 'webthemeengine_impl_win.h',
'webthread_impl.h',
'webthread_impl.cc',
'weburlloader_impl.cc',
diff --git a/webkit/glue/webthemeengine_impl_android.cc b/webkit/glue/webthemeengine_impl_android.cc
new file mode 100644
index 0000000..2101eeb
--- /dev/null
+++ b/webkit/glue/webthemeengine_impl_android.cc
@@ -0,0 +1,183 @@
+// Copyright (c) 2011 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_android.h"
+
+#include "base/logging.h"
+#include "skia/ext/platform_canvas.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
+#include "ui/gfx/native_theme_android.h"
+
+using WebKit::WebCanvas;
+using WebKit::WebColor;
+using WebKit::WebRect;
+using WebKit::WebThemeEngine;
+
+namespace webkit_glue {
+
+static gfx::NativeThemeAndroid::Part NativeThemePart(
+ WebThemeEngine::Part part) {
+ switch (part) {
+ case WebThemeEngine::PartScrollbarDownArrow:
+ return gfx::NativeThemeAndroid::SCROLLBAR_DOWN_ARROW;
+ case WebThemeEngine::PartScrollbarLeftArrow:
+ return gfx::NativeThemeAndroid::SCROLLBAR_LEFT_ARROW;
+ case WebThemeEngine::PartScrollbarRightArrow:
+ return gfx::NativeThemeAndroid::SCROLLBAR_RIGHT_ARROW;
+ case WebThemeEngine::PartScrollbarUpArrow:
+ return gfx::NativeThemeAndroid::SCROLLBAR_UP_ARROW;
+ case WebThemeEngine::PartScrollbarHorizontalThumb:
+ // Android doesn't draw scrollbars.
+ NOTREACHED();
+ return static_cast<gfx::NativeThemeAndroid::Part>(0);
+ case WebThemeEngine::PartScrollbarVerticalThumb:
+ // Android doesn't draw scrollbars.
+ NOTREACHED();
+ return static_cast<gfx::NativeThemeAndroid::Part>(0);
+ case WebThemeEngine::PartScrollbarHorizontalTrack:
+ // Android doesn't draw scrollbars.
+ NOTREACHED();
+ return static_cast<gfx::NativeThemeAndroid::Part>(0);
+ case WebThemeEngine::PartScrollbarVerticalTrack:
+ // Android doesn't draw scrollbars.
+ NOTREACHED();
+ return static_cast<gfx::NativeThemeAndroid::Part>(0);
+ case WebThemeEngine::PartCheckbox:
+ return gfx::NativeThemeAndroid::CHECKBOX;
+ case WebThemeEngine::PartRadio:
+ return gfx::NativeThemeAndroid::RADIO;
+ case WebThemeEngine::PartButton:
+ return gfx::NativeThemeAndroid::PUSH_BUTTON;
+ case WebThemeEngine::PartTextField:
+ return gfx::NativeThemeAndroid::TEXTFIELD;
+ case WebThemeEngine::PartMenuList:
+ return gfx::NativeThemeAndroid::MENU_LIST;
+ case WebThemeEngine::PartSliderTrack:
+ return gfx::NativeThemeAndroid::SLIDER_TRACK;
+ case WebThemeEngine::PartSliderThumb:
+ return gfx::NativeThemeAndroid::SLIDER_THUMB;
+ case WebThemeEngine::PartInnerSpinButton:
+ return gfx::NativeThemeAndroid::INNER_SPIN_BUTTON;
+ case WebThemeEngine::PartProgressBar:
+ return gfx::NativeThemeAndroid::PROGRESS_BAR;
+ default:
+ return gfx::NativeThemeAndroid::SCROLLBAR_DOWN_ARROW;
+ }
+}
+
+static gfx::NativeThemeAndroid::State NativeThemeState(
+ WebThemeEngine::State state) {
+ switch (state) {
+ case WebThemeEngine::StateDisabled:
+ return gfx::NativeThemeAndroid::DISABLED;
+ case WebThemeEngine::StateHover:
+ return gfx::NativeThemeAndroid::HOVERED;
+ case WebThemeEngine::StateNormal:
+ return gfx::NativeThemeAndroid::NORMAL;
+ case WebThemeEngine::StatePressed:
+ return gfx::NativeThemeAndroid::PRESSED;
+ default:
+ return gfx::NativeThemeAndroid::DISABLED;
+ }
+}
+
+static void GetNativeThemeExtraParams(
+ WebThemeEngine::Part part,
+ WebThemeEngine::State state,
+ const WebThemeEngine::ExtraParams* extra_params,
+ gfx::NativeThemeAndroid::ExtraParams* native_theme_extra_params) {
+ switch (part) {
+ case WebThemeEngine::PartScrollbarHorizontalTrack:
+ case WebThemeEngine::PartScrollbarVerticalTrack:
+ // Android doesn't draw scrollbars.
+ NOTREACHED();
+ break;
+ case WebThemeEngine::PartCheckbox:
+ native_theme_extra_params->button.checked = extra_params->button.checked;
+ native_theme_extra_params->button.indeterminate =
+ extra_params->button.indeterminate;
+ break;
+ case WebThemeEngine::PartRadio:
+ native_theme_extra_params->button.checked = extra_params->button.checked;
+ break;
+ case WebThemeEngine::PartButton:
+ native_theme_extra_params->button.is_default =
+ extra_params->button.isDefault;
+ native_theme_extra_params->button.has_border =
+ extra_params->button.hasBorder;
+ native_theme_extra_params->button.background_color =
+ extra_params->button.backgroundColor;
+ break;
+ case WebThemeEngine::PartTextField:
+ native_theme_extra_params->text_field.is_text_area =
+ extra_params->textField.isTextArea;
+ native_theme_extra_params->text_field.is_listbox =
+ extra_params->textField.isListbox;
+ native_theme_extra_params->text_field.background_color =
+ extra_params->textField.backgroundColor;
+ break;
+ case WebThemeEngine::PartMenuList:
+ native_theme_extra_params->menu_list.has_border =
+ extra_params->menuList.hasBorder;
+ native_theme_extra_params->menu_list.has_border_radius =
+ extra_params->menuList.hasBorderRadius;
+ native_theme_extra_params->menu_list.arrow_x =
+ extra_params->menuList.arrowX;
+ native_theme_extra_params->menu_list.arrow_y =
+ extra_params->menuList.arrowY;
+ native_theme_extra_params->menu_list.background_color =
+ extra_params->menuList.backgroundColor;
+ break;
+ case WebThemeEngine::PartSliderTrack:
+ case WebThemeEngine::PartSliderThumb:
+ native_theme_extra_params->slider.vertical =
+ extra_params->slider.vertical;
+ native_theme_extra_params->slider.in_drag = extra_params->slider.inDrag;
+ break;
+ case WebThemeEngine::PartInnerSpinButton:
+ native_theme_extra_params->inner_spin.spin_up =
+ extra_params->innerSpin.spinUp;
+ native_theme_extra_params->inner_spin.read_only =
+ extra_params->innerSpin.readOnly;
+ break;
+ case WebThemeEngine::PartProgressBar:
+ native_theme_extra_params->progress_bar.determinate =
+ extra_params->progressBar.determinate;
+ native_theme_extra_params->progress_bar.value_rect_x =
+ extra_params->progressBar.valueRectX;
+ native_theme_extra_params->progress_bar.value_rect_y =
+ extra_params->progressBar.valueRectY;
+ native_theme_extra_params->progress_bar.value_rect_width =
+ extra_params->progressBar.valueRectWidth;
+ native_theme_extra_params->progress_bar.value_rect_height =
+ extra_params->progressBar.valueRectHeight;
+ break;
+ default:
+ break; // Parts that have no extra params get here.
+ }
+}
+
+WebKit::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) {
+ return gfx::NativeThemeAndroid::instance()->GetPartSize(
+ NativeThemePart(part));
+}
+
+void WebThemeEngineImpl::paint(
+ WebKit::WebCanvas* canvas,
+ WebThemeEngine::Part part,
+ WebThemeEngine::State state,
+ const WebKit::WebRect& rect,
+ const WebThemeEngine::ExtraParams* extra_params) {
+ gfx::NativeThemeAndroid::ExtraParams native_theme_extra_params;
+ GetNativeThemeExtraParams(
+ part, state, extra_params, &native_theme_extra_params);
+ gfx::NativeThemeAndroid::instance()->Paint(
+ canvas,
+ NativeThemePart(part),
+ NativeThemeState(state),
+ gfx::Rect(rect),
+ native_theme_extra_params);
+}
+} // namespace webkit_glue
diff --git a/webkit/glue/webthemeengine_impl_android.h b/webkit/glue/webthemeengine_impl_android.h
new file mode 100644
index 0000000..8b9653a
--- /dev/null
+++ b/webkit/glue/webthemeengine_impl_android.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 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.
+
+#ifndef WEBKIT_GLUE_WEBTHEMEENGINE_IMPL_ANDROID_H_
+#define WEBKIT_GLUE_WEBTHEMEENGINE_IMPL_ANDROID_H_
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/android/WebThemeEngine.h"
+
+namespace webkit_glue {
+
+class WebThemeEngineImpl : public WebKit::WebThemeEngine {
+ public:
+ // WebThemeEngine methods:
+ virtual WebKit::WebSize getSize(WebKit::WebThemeEngine::Part);
+ virtual void paint(
+ WebKit::WebCanvas* canvas,
+ WebKit::WebThemeEngine::Part part,
+ WebKit::WebThemeEngine::State state,
+ const WebKit::WebRect& rect,
+ const WebKit::WebThemeEngine::ExtraParams* extra_params);
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBTHEMEENGINE_IMPL_ANDROID_H_