summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/renderer/render_view.cc4
-rw-r--r--ui/gfx/native_theme.h1
-rw-r--r--ui/gfx/native_theme_chromeos.cc35
-rw-r--r--ui/gfx/native_theme_chromeos.h32
-rw-r--r--ui/gfx/native_theme_linux.cc61
-rw-r--r--ui/gfx/native_theme_linux.h132
-rw-r--r--webkit/glue/webthemeengine_impl_linux.cc62
7 files changed, 119 insertions, 208 deletions
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 3392c97..e8a391d 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -176,7 +176,7 @@
#include "ui/gfx/native_theme_win.h"
#elif defined(USE_X11)
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.h"
-#include "ui/gfx/native_theme_linux.h"
+#include "ui/gfx/native_theme.h"
#elif defined(OS_MACOSX)
#include "skia/ext/skia_utils_mac.h"
#endif
@@ -4262,7 +4262,7 @@ void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) {
WebColorName name = WebKit::WebColorWebkitFocusRingColor;
WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1);
WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval);
- gfx::NativeThemeLinux::instance()->SetScrollbarColors(
+ gfx::NativeTheme::instance()->SetScrollbarColors(
renderer_prefs.thumb_inactive_color,
renderer_prefs.thumb_active_color,
renderer_prefs.track_color);
diff --git a/ui/gfx/native_theme.h b/ui/gfx/native_theme.h
index 807427d..e3e66a6 100644
--- a/ui/gfx/native_theme.h
+++ b/ui/gfx/native_theme.h
@@ -151,7 +151,6 @@ class NativeTheme {
NativeTheme() {}
virtual ~NativeTheme() {}
- private:
static unsigned int thumb_inactive_color_;
static unsigned int thumb_active_color_;
static unsigned int track_color_;
diff --git a/ui/gfx/native_theme_chromeos.cc b/ui/gfx/native_theme_chromeos.cc
index fe3ed72..3a4b397 100644
--- a/ui/gfx/native_theme_chromeos.cc
+++ b/ui/gfx/native_theme_chromeos.cc
@@ -231,7 +231,7 @@ void GetRadioIndicatorGradientPaint(const gfx::Rect bounds,
} // namespace
/* static */
-gfx::NativeThemeLinux* gfx::NativeThemeLinux::instance() {
+const gfx::NativeThemeLinux* gfx::NativeThemeLinux::instance() {
// The global NativeThemeChromeos instance.
static NativeThemeChromeos s_native_theme;
return &s_native_theme;
@@ -295,9 +295,12 @@ gfx::Size NativeThemeChromeos::GetPartSize(Part part) const {
return gfx::Size(width, height);
}
-void NativeThemeChromeos::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
- Part part, State state,
- const ScrollbarTrackExtraParams& extra_params, const gfx::Rect& rect) {
+void NativeThemeChromeos::PaintScrollbarTrack(
+ skia::PlatformCanvas* canvas,
+ Part part,
+ State state,
+ const ScrollbarTrackExtraParams& extra_params,
+ const gfx::Rect& rect) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
if (part == kScrollbarVerticalTrack) {
SkBitmap* background = rb.GetBitmapNamed(IDR_SCROLL_BACKGROUND);
@@ -340,7 +343,7 @@ void NativeThemeChromeos::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
}
void NativeThemeChromeos::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
- Part part, State state, const gfx::Rect& rect) {
+ Part part, State state, const gfx::Rect& rect) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int resource_id = IDR_SCROLL_THUMB;
if (state == kHovered)
@@ -385,7 +388,7 @@ void NativeThemeChromeos::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
}
void NativeThemeChromeos::PaintArrowButton(skia::PlatformCanvas* canvas,
- const gfx::Rect& rect, Part part, State state) {
+ const gfx::Rect& rect, Part part, State state) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int resource_id =
(part == kScrollbarUpArrow || part == kScrollbarLeftArrow) ?
@@ -406,7 +409,7 @@ void NativeThemeChromeos::PaintArrowButton(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintCheckbox(skia::PlatformCanvas* canvas,
State state, const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
PaintButtonLike(canvas, state, rect, true);
if (button.checked) {
@@ -428,7 +431,7 @@ void NativeThemeChromeos::PaintCheckbox(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintRadio(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
gfx::Point center = rect.CenterPoint();
SkPath border;
border.addCircle(SkIntToScalar(center.x()), SkIntToScalar(center.y()),
@@ -461,14 +464,14 @@ void NativeThemeChromeos::PaintRadio(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
PaintButtonLike(canvas, state, rect, button.has_border);
}
void NativeThemeChromeos::PaintTextField(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const TextFieldExtraParams& text) {
+ const TextFieldExtraParams& text) const {
if (rect.height() == 0)
return;
@@ -515,7 +518,7 @@ void NativeThemeChromeos::PaintTextField(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintSliderTrack(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) {
+ const SliderExtraParams& slider) const {
const int kMidX = rect.x() + rect.width() / 2;
const int kMidY = rect.y() + rect.height() / 2;
@@ -548,7 +551,7 @@ void NativeThemeChromeos::PaintSliderTrack(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintSliderThumb(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) {
+ const SliderExtraParams& slider) const {
if (state != kDisabled && slider.in_drag)
state = kPressed;
@@ -558,7 +561,7 @@ void NativeThemeChromeos::PaintSliderThumb(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintInnerSpinButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const InnerSpinButtonExtraParams& spin_button) {
+ const InnerSpinButtonExtraParams& spin_button) const {
// Adjust bounds to compensate the overridden "2px inset" parent border.
gfx::Rect bounds = rect;
bounds.Inset(0, -1, -1, -1);
@@ -569,7 +572,7 @@ void NativeThemeChromeos::PaintInnerSpinButton(skia::PlatformCanvas* canvas,
void NativeThemeChromeos::PaintProgressBar(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ProgressBarExtraParams& progress_bar) {
+ const ProgressBarExtraParams& progress_bar) const {
static const int kBorderWidth = 1;
static const SkColor kBackgroundColors[] = {
kProgressBarBackgroundGradient0,
@@ -674,7 +677,7 @@ void NativeThemeChromeos::PaintProgressBar(skia::PlatformCanvas* canvas,
}
}
-SkBitmap* NativeThemeChromeos::GetHorizontalBitmapNamed(int resource_id) {
+SkBitmap* NativeThemeChromeos::GetHorizontalBitmapNamed(int resource_id) const {
SkImageMap::const_iterator found = horizontal_bitmaps_.find(resource_id);
if (found != horizontal_bitmaps_.end())
return found->second;
@@ -694,7 +697,7 @@ SkBitmap* NativeThemeChromeos::GetHorizontalBitmapNamed(int resource_id) {
}
void NativeThemeChromeos::PaintButtonLike(skia::PlatformCanvas* canvas,
- State state, const gfx::Rect& rect, bool stroke_border) {
+ State state, const gfx::Rect& rect, bool stroke_border) const {
SkPath border;
GetRoundRectPath(rect, kBorderCornerRadius, &border);
diff --git a/ui/gfx/native_theme_chromeos.h b/ui/gfx/native_theme_chromeos.h
index 4b9f19b..97d1606 100644
--- a/ui/gfx/native_theme_chromeos.h
+++ b/ui/gfx/native_theme_chromeos.h
@@ -17,74 +17,76 @@ class NativeThemeChromeos : public gfx::NativeThemeLinux {
NativeThemeChromeos();
virtual ~NativeThemeChromeos();
- // Scrollbar painting overrides
+ // NativeTheme overrides
virtual gfx::Size GetPartSize(Part part) const OVERRIDE;
+
+ // NativeThemeLinux overrides
virtual void PaintScrollbarTrack(skia::PlatformCanvas* canvas,
Part part, State state,
const ScrollbarTrackExtraParams& extra_params,
- const gfx::Rect& rect) OVERRIDE;
+ const gfx::Rect& rect) const OVERRIDE;
virtual void PaintArrowButton(skia::PlatformCanvas* canvas,
- const gfx::Rect& rect, Part direction, State state) OVERRIDE;
+ const gfx::Rect& rect, Part direction, State state) const OVERRIDE;
virtual void PaintScrollbarThumb(skia::PlatformCanvas* canvas,
- Part part, State state, const gfx::Rect& rect) OVERRIDE;
+ Part part, State state, const gfx::Rect& rect) const OVERRIDE;
// Draw the checkbox.
virtual void PaintCheckbox(skia::PlatformCanvas* canvas,
State state, const gfx::Rect& rect,
- const ButtonExtraParams& button) OVERRIDE;
+ const ButtonExtraParams& button) const OVERRIDE;
// Draw the radio.
virtual void PaintRadio(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) OVERRIDE;
+ const ButtonExtraParams& button) const OVERRIDE;
// Draw the push button.
virtual void PaintButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) OVERRIDE;
+ const ButtonExtraParams& button) const OVERRIDE;
// Draw the text field.
virtual void PaintTextField(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const TextFieldExtraParams& text) OVERRIDE;
+ const TextFieldExtraParams& text) const OVERRIDE;
// Draw the slider track.
virtual void PaintSliderTrack(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) OVERRIDE;
+ const SliderExtraParams& slider) const OVERRIDE;
// Draw the slider thumb.
virtual void PaintSliderThumb(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) OVERRIDE;
+ const SliderExtraParams& slider) const OVERRIDE;
// Draw the inner spin button.
virtual void PaintInnerSpinButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const InnerSpinButtonExtraParams& spin_button) OVERRIDE;
+ const InnerSpinButtonExtraParams& spin_button) const OVERRIDE;
// Draw the progress bar.
virtual void PaintProgressBar(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ProgressBarExtraParams& progress_bar) OVERRIDE;
+ const ProgressBarExtraParams& progress_bar) const OVERRIDE;
- SkBitmap* GetHorizontalBitmapNamed(int resource_id);
+ SkBitmap* GetHorizontalBitmapNamed(int resource_id) const;
// Paint a button like rounded rect with gradient background and stroke.
void PaintButtonLike(skia::PlatformCanvas* canvas,
- State state, const gfx::Rect& rect, bool stroke_border);
+ State state, const gfx::Rect& rect, bool stroke_border) const;
// Cached images. Resource loader caches all retrieved bitmaps and keeps
// ownership of the pointers.
typedef std::map<int, SkBitmap*> SkImageMap;
- SkImageMap horizontal_bitmaps_;
+ mutable SkImageMap horizontal_bitmaps_;
DISALLOW_COPY_AND_ASSIGN(NativeThemeChromeos);
};
diff --git a/ui/gfx/native_theme_linux.cc b/ui/gfx/native_theme_linux.cc
index e6d0d14..5a81c4c 100644
--- a/ui/gfx/native_theme_linux.cc
+++ b/ui/gfx/native_theme_linux.cc
@@ -18,9 +18,6 @@ namespace gfx {
unsigned int NativeThemeLinux::button_length_ = 14;
unsigned int NativeThemeLinux::scrollbar_width_ = 15;
-unsigned int NativeThemeLinux::thumb_inactive_color_ = 0xeaeaea;
-unsigned int NativeThemeLinux::thumb_active_color_ = 0xf4f4f4;
-unsigned int NativeThemeLinux::track_color_ = 0xd3d3d3;
// These are the default dimensions of radio buttons and checkboxes.
static const int kCheckboxAndRadioWidth = 13;
@@ -37,10 +34,15 @@ static const SkColor kSliderThumbDarkGrey = SkColorSetRGB(0xea, 0xe5, 0xe0);
static const SkColor kSliderThumbBorderDarkGrey =
SkColorSetRGB(0x9d, 0x96, 0x8e);
+// static
+const NativeTheme* NativeTheme::instance() {
+ return NativeThemeLinux::instance();
+}
+
#if !defined(OS_CHROMEOS)
// Chromeos has a different look.
// static
-NativeThemeLinux* NativeThemeLinux::instance() {
+const NativeThemeLinux* NativeThemeLinux::instance() {
// The global NativeThemeLinux instance.
static NativeThemeLinux s_native_theme;
return &s_native_theme;
@@ -99,13 +101,16 @@ gfx::Size NativeThemeLinux::GetPartSize(Part part) const {
case kSliderTrack:
case kProgressBar:
return gfx::Size(); // No default size.
+ default:
+ NOTREACHED() << "Unknown theme part: " << part;
+ break;
}
return gfx::Size();
}
void NativeThemeLinux::PaintArrowButton(
skia::PlatformCanvas* canvas,
- const gfx::Rect& rect, Part direction, State state) {
+ const gfx::Rect& rect, Part direction, State state) const {
int widthMiddle, lengthMiddle;
SkPaint paint;
if (direction == kScrollbarUpArrow || direction == kScrollbarDownArrow) {
@@ -233,7 +238,7 @@ void NativeThemeLinux::Paint(skia::PlatformCanvas* canvas,
Part part,
State state,
const gfx::Rect& rect,
- const ExtraParams& extra) {
+ const ExtraParams& extra) const {
switch (part) {
case kScrollbarDownArrow:
case kScrollbarUpArrow:
@@ -276,6 +281,9 @@ void NativeThemeLinux::Paint(skia::PlatformCanvas* canvas,
case kProgressBar:
PaintProgressBar(canvas, state, rect, extra.progress_bar);
break;
+ default:
+ NOTREACHED() << "Unknown theme part: " << part;
+ break;
}
}
@@ -283,7 +291,7 @@ void NativeThemeLinux::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
Part part,
State state,
const ScrollbarTrackExtraParams& extra_params,
- const gfx::Rect& rect) {
+ const gfx::Rect& rect) const {
SkPaint paint;
SkIRect skrect;
@@ -303,7 +311,7 @@ void NativeThemeLinux::PaintScrollbarTrack(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
Part part,
State state,
- const gfx::Rect& rect) {
+ const gfx::Rect& rect) const {
const bool hovered = state == kHovered;
const int midx = rect.x() + rect.width() / 2;
const int midy = rect.y() + rect.height() / 2;
@@ -382,7 +390,7 @@ void NativeThemeLinux::PaintScrollbarThumb(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintCheckbox(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = NULL;
if (button.indeterminate) {
@@ -407,7 +415,7 @@ void NativeThemeLinux::PaintCheckbox(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintRadio(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = NULL;
if (state == kDisabled) {
@@ -428,7 +436,7 @@ void NativeThemeLinux::PaintRadio(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button) {
+ const ButtonExtraParams& button) const {
SkPaint paint;
SkRect skrect;
const int kRight = rect.right();
@@ -497,7 +505,7 @@ void NativeThemeLinux::PaintButton(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintTextField(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const TextFieldExtraParams& text) {
+ const TextFieldExtraParams& text) const {
// The following drawing code simulates the user-agent css border for
// text area and text input so that we do not break layout tests. Once we
// have decided the desired looks, we should update the code here and
@@ -584,10 +592,11 @@ void NativeThemeLinux::PaintTextField(skia::PlatformCanvas* canvas,
}
}
-void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas,
- State state,
- const gfx::Rect& rect,
- const MenuListExtraParams& menu_list) {
+void NativeThemeLinux::PaintMenuList(
+ skia::PlatformCanvas* canvas,
+ State state,
+ const gfx::Rect& rect,
+ const MenuListExtraParams& menu_list) const {
// If a border radius is specified, we let the WebCore paint the background
// and the border of the control.
if (!menu_list.has_border_radius) {
@@ -613,7 +622,7 @@ void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintSliderTrack(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) {
+ const SliderExtraParams& slider) const {
const int kMidX = rect.x() + rect.width() / 2;
const int kMidY = rect.y() + rect.height() / 2;
@@ -638,7 +647,7 @@ void NativeThemeLinux::PaintSliderTrack(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintSliderThumb(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider) {
+ const SliderExtraParams& slider) const {
const bool hovered = (state == kHovered) || slider.in_drag;
const int kMidX = rect.x() + rect.width() / 2;
const int kMidY = rect.y() + rect.height() / 2;
@@ -676,7 +685,7 @@ void NativeThemeLinux::PaintSliderThumb(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintInnerSpinButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const InnerSpinButtonExtraParams& spin_button) {
+ const InnerSpinButtonExtraParams& spin_button) const {
if (spin_button.read_only)
state = kDisabled;
@@ -698,7 +707,7 @@ void NativeThemeLinux::PaintInnerSpinButton(skia::PlatformCanvas* canvas,
void NativeThemeLinux::PaintProgressBar(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ProgressBarExtraParams& progress_bar) {
+ const ProgressBarExtraParams& progress_bar) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* bar_image = rb.GetBitmapNamed(IDR_PROGRESS_BAR);
SkBitmap* left_border_image = rb.GetBitmapNamed(IDR_PROGRESS_BORDER_LEFT);
@@ -748,7 +757,7 @@ void NativeThemeLinux::PaintProgressBar(skia::PlatformCanvas* canvas,
}
bool NativeThemeLinux::IntersectsClipRectInt(
- skia::PlatformCanvas* canvas, int x, int y, int w, int h) {
+ skia::PlatformCanvas* canvas, int x, int y, int w, int h) const {
SkRect clip;
return canvas->getClipBounds(&clip) &&
clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w),
@@ -789,7 +798,7 @@ void NativeThemeLinux::DrawBox(SkCanvas* canvas,
void NativeThemeLinux::DrawBitmapInt(
skia::PlatformCanvas* canvas, const SkBitmap& bitmap,
int src_x, int src_y, int src_w, int src_h,
- int dest_x, int dest_y, int dest_w, int dest_h) {
+ int dest_x, int dest_y, int dest_w, int dest_h) const {
DLOG_ASSERT(src_x + src_w < std::numeric_limits<int16_t>::max() &&
src_y + src_h < std::numeric_limits<int16_t>::max());
if (src_w <= 0 || src_h <= 0 || dest_w <= 0 || dest_h <= 0) {
@@ -917,12 +926,4 @@ SkColor NativeThemeLinux::OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const {
return SaturateAndBrighten(hsv2, -0.2, diff);
}
-void NativeThemeLinux::SetScrollbarColors(unsigned inactive_color,
- unsigned active_color,
- unsigned track_color) const {
- thumb_inactive_color_ = inactive_color;
- thumb_active_color_ = active_color;
- track_color_ = track_color;
-}
-
} // namespace gfx
diff --git a/ui/gfx/native_theme_linux.h b/ui/gfx/native_theme_linux.h
index 5bd9a28..2b117c1 100644
--- a/ui/gfx/native_theme_linux.h
+++ b/ui/gfx/native_theme_linux.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "skia/ext/platform_canvas.h"
+#include "ui/gfx/native_theme.h"
namespace skia {
class PlatformCanvas;
@@ -17,110 +18,18 @@ class Rect;
class Size;
// Linux theming API.
-class NativeThemeLinux {
+class NativeThemeLinux : public NativeTheme {
public:
- // The part to be painted / sized.
- enum Part {
- kScrollbarDownArrow,
- kScrollbarLeftArrow,
- kScrollbarRightArrow,
- kScrollbarUpArrow,
- kScrollbarHorizontalThumb,
- kScrollbarVerticalThumb,
- kScrollbarHorizontalTrack,
- kScrollbarVerticalTrack,
- kCheckbox,
- kRadio,
- kPushButton,
- kTextField,
- kMenuList,
- kSliderTrack,
- kSliderThumb,
- kInnerSpinButton,
- kProgressBar,
- };
-
- // The state of the part.
- enum State {
- kDisabled,
- kHovered,
- kNormal,
- kPressed,
- };
-
- // Extra data needed to draw scrollbar track correctly.
- struct ScrollbarTrackExtraParams {
- int track_x;
- int track_y;
- int track_width;
- int track_height;
- };
-
- struct ButtonExtraParams {
- bool checked;
- bool indeterminate; // Whether the button state is indeterminate.
- bool is_default; // Whether the button is default button.
- bool has_border;
- SkColor background_color;
- };
-
- struct TextFieldExtraParams {
- bool is_text_area;
- bool is_listbox;
- SkColor background_color;
- };
-
- struct MenuListExtraParams {
- bool has_border;
- bool has_border_radius;
- int arrow_x;
- int arrow_y;
- SkColor background_color;
- };
-
- struct SliderExtraParams {
- bool vertical;
- bool in_drag;
- };
-
- struct InnerSpinButtonExtraParams {
- bool spin_up;
- bool read_only;
- };
-
- struct ProgressBarExtraParams {
- bool determinate;
- int value_rect_x;
- int value_rect_y;
- int value_rect_width;
- int value_rect_height;
- };
-
- union ExtraParams {
- ScrollbarTrackExtraParams scrollbar_track;
- ButtonExtraParams button;
- MenuListExtraParams menu_list;
- SliderExtraParams slider;
- TextFieldExtraParams text_field;
- InnerSpinButtonExtraParams inner_spin;
- ProgressBarExtraParams progress_bar;
- };
-
// Gets our singleton instance.
- static NativeThemeLinux* instance();
+ static const NativeThemeLinux* instance();
- // Return the size of the part.
+ // NativeTheme implementation:
virtual gfx::Size GetPartSize(Part part) const;
- // Paint the part to the canvas.
virtual void Paint(skia::PlatformCanvas* canvas,
Part part,
State state,
const gfx::Rect& rect,
- const ExtraParams& extra);
- // Supports theme specific colors.
- void SetScrollbarColors(unsigned inactive_color,
- unsigned active_color,
- unsigned track_color) const;
+ const ExtraParams& extra) const;
protected:
NativeThemeLinux();
@@ -131,72 +40,72 @@ class NativeThemeLinux {
skia::PlatformCanvas* gc,
const gfx::Rect& rect,
Part direction,
- State state);
+ State state) const;
// Paint the scrollbar track. Done before the thumb so that it can contain
// alpha.
virtual void PaintScrollbarTrack(skia::PlatformCanvas* canvas,
Part part,
State state,
const ScrollbarTrackExtraParams& extra_params,
- const gfx::Rect& rect);
+ const gfx::Rect& rect) const;
// Draw the scrollbar thumb over the track.
virtual void PaintScrollbarThumb(skia::PlatformCanvas* canvas,
Part part,
State state,
- const gfx::Rect& rect);
+ const gfx::Rect& rect) const;
// Draw the checkbox.
virtual void PaintCheckbox(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button);
+ const ButtonExtraParams& button) const;
// Draw the radio.
virtual void PaintRadio(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button);
+ const ButtonExtraParams& button) const;
// Draw the push button.
virtual void PaintButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ButtonExtraParams& button);
+ const ButtonExtraParams& button) const;
// Draw the text field.
virtual void PaintTextField(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const TextFieldExtraParams& text);
+ const TextFieldExtraParams& text) const;
// Draw the menu list.
virtual void PaintMenuList(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const MenuListExtraParams& menu_list);
+ const MenuListExtraParams& menu_list) const;
// Draw the slider track.
virtual void PaintSliderTrack(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider);
+ const SliderExtraParams& slider) const;
// Draw the slider thumb.
virtual void PaintSliderThumb(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const SliderExtraParams& slider);
+ const SliderExtraParams& slider) const;
// Draw the inner spin button.
virtual void PaintInnerSpinButton(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const InnerSpinButtonExtraParams& spin_button);
+ const InnerSpinButtonExtraParams& spin_button) const;
// Draw the progress bar.
virtual void PaintProgressBar(skia::PlatformCanvas* canvas,
State state,
const gfx::Rect& rect,
- const ProgressBarExtraParams& progress_bar);
+ const ProgressBarExtraParams& progress_bar) const;
protected:
bool IntersectsClipRectInt(skia::PlatformCanvas* canvas,
- int x, int y, int w, int h);
+ int x, int y, int w, int h) const;
void DrawBitmapInt(skia::PlatformCanvas* canvas, const SkBitmap& bitmap,
int src_x, int src_y, int src_w, int src_h,
- int dest_x, int dest_y, int dest_w, int dest_h);
+ int dest_x, int dest_y, int dest_w, int dest_h) const;
void DrawTiledImage(SkCanvas* canvas,
const SkBitmap& bitmap,
@@ -229,9 +138,6 @@ class NativeThemeLinux {
static unsigned int scrollbar_width_;
static unsigned int button_length_;
- static unsigned int thumb_inactive_color_;
- static unsigned int thumb_active_color_;
- static unsigned int track_color_;
DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux);
};
diff --git a/webkit/glue/webthemeengine_impl_linux.cc b/webkit/glue/webthemeengine_impl_linux.cc
index 6cdda79..dde3f50 100644
--- a/webkit/glue/webthemeengine_impl_linux.cc
+++ b/webkit/glue/webthemeengine_impl_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -7,7 +7,7 @@
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
-#include "ui/gfx/native_theme_linux.h"
+#include "ui/gfx/native_theme.h"
using WebKit::WebCanvas;
using WebKit::WebColor;
@@ -19,61 +19,61 @@ static gfx::Rect WebRectToRect(const WebRect& rect) {
return gfx::Rect(rect.x, rect.y, rect.width, rect.height);
}
-static gfx::NativeThemeLinux::Part NativeThemePart(
+static gfx::NativeTheme::Part NativeThemePart(
WebKit::WebThemeEngine::Part part) {
switch (part) {
case WebKit::WebThemeEngine::PartScrollbarDownArrow:
- return gfx::NativeThemeLinux::kScrollbarDownArrow;
+ return gfx::NativeTheme::kScrollbarDownArrow;
case WebKit::WebThemeEngine::PartScrollbarLeftArrow:
- return gfx::NativeThemeLinux::kScrollbarLeftArrow;
+ return gfx::NativeTheme::kScrollbarLeftArrow;
case WebKit::WebThemeEngine::PartScrollbarRightArrow:
- return gfx::NativeThemeLinux::kScrollbarRightArrow;
+ return gfx::NativeTheme::kScrollbarRightArrow;
case WebKit::WebThemeEngine::PartScrollbarUpArrow:
- return gfx::NativeThemeLinux::kScrollbarUpArrow;
+ return gfx::NativeTheme::kScrollbarUpArrow;
case WebKit::WebThemeEngine::PartScrollbarHorizontalThumb:
- return gfx::NativeThemeLinux::kScrollbarHorizontalThumb;
+ return gfx::NativeTheme::kScrollbarHorizontalThumb;
case WebKit::WebThemeEngine::PartScrollbarVerticalThumb:
- return gfx::NativeThemeLinux::kScrollbarVerticalThumb;
+ return gfx::NativeTheme::kScrollbarVerticalThumb;
case WebKit::WebThemeEngine::PartScrollbarHorizontalTrack:
- return gfx::NativeThemeLinux::kScrollbarHorizontalTrack;
+ return gfx::NativeTheme::kScrollbarHorizontalTrack;
case WebKit::WebThemeEngine::PartScrollbarVerticalTrack:
- return gfx::NativeThemeLinux::kScrollbarVerticalTrack;
+ return gfx::NativeTheme::kScrollbarVerticalTrack;
case WebKit::WebThemeEngine::PartCheckbox:
- return gfx::NativeThemeLinux::kCheckbox;
+ return gfx::NativeTheme::kCheckbox;
case WebKit::WebThemeEngine::PartRadio:
- return gfx::NativeThemeLinux::kRadio;
+ return gfx::NativeTheme::kRadio;
case WebKit::WebThemeEngine::PartButton:
- return gfx::NativeThemeLinux::kPushButton;
+ return gfx::NativeTheme::kPushButton;
case WebKit::WebThemeEngine::PartTextField:
- return gfx::NativeThemeLinux::kTextField;
+ return gfx::NativeTheme::kTextField;
case WebKit::WebThemeEngine::PartMenuList:
- return gfx::NativeThemeLinux::kMenuList;
+ return gfx::NativeTheme::kMenuList;
case WebKit::WebThemeEngine::PartSliderTrack:
- return gfx::NativeThemeLinux::kSliderTrack;
+ return gfx::NativeTheme::kSliderTrack;
case WebKit::WebThemeEngine::PartSliderThumb:
- return gfx::NativeThemeLinux::kSliderThumb;
+ return gfx::NativeTheme::kSliderThumb;
case WebKit::WebThemeEngine::PartInnerSpinButton:
- return gfx::NativeThemeLinux::kInnerSpinButton;
+ return gfx::NativeTheme::kInnerSpinButton;
case WebKit::WebThemeEngine::PartProgressBar:
- return gfx::NativeThemeLinux::kProgressBar;
+ return gfx::NativeTheme::kProgressBar;
default:
- return gfx::NativeThemeLinux::kScrollbarDownArrow;
+ return gfx::NativeTheme::kScrollbarDownArrow;
}
}
-static gfx::NativeThemeLinux::State NativeThemeState(
+static gfx::NativeTheme::State NativeThemeState(
WebKit::WebThemeEngine::State state) {
switch (state) {
case WebKit::WebThemeEngine::StateDisabled:
- return gfx::NativeThemeLinux::kDisabled;
+ return gfx::NativeTheme::kDisabled;
case WebKit::WebThemeEngine::StateHover:
- return gfx::NativeThemeLinux::kHovered;
+ return gfx::NativeTheme::kHovered;
case WebKit::WebThemeEngine::StateNormal:
- return gfx::NativeThemeLinux::kNormal;
+ return gfx::NativeTheme::kNormal;
case WebKit::WebThemeEngine::StatePressed:
- return gfx::NativeThemeLinux::kPressed;
+ return gfx::NativeTheme::kPressed;
default:
- return gfx::NativeThemeLinux::kDisabled;
+ return gfx::NativeTheme::kDisabled;
}
}
@@ -81,7 +81,7 @@ static void GetNativeThemeExtraParams(
WebKit::WebThemeEngine::Part part,
WebKit::WebThemeEngine::State state,
const WebKit::WebThemeEngine::ExtraParams* extra_params,
- gfx::NativeThemeLinux::ExtraParams* native_theme_extra_params) {
+ gfx::NativeTheme::ExtraParams* native_theme_extra_params) {
switch (part) {
case WebKit::WebThemeEngine::PartScrollbarHorizontalTrack:
case WebKit::WebThemeEngine::PartScrollbarVerticalTrack:
@@ -160,7 +160,7 @@ static void GetNativeThemeExtraParams(
}
WebKit::WebSize WebThemeEngineImpl::getSize(WebKit::WebThemeEngine::Part part) {
- return gfx::NativeThemeLinux::instance()->GetPartSize(NativeThemePart(part));
+ return gfx::NativeTheme::instance()->GetPartSize(NativeThemePart(part));
}
void WebThemeEngineImpl::paint(
@@ -169,10 +169,10 @@ void WebThemeEngineImpl::paint(
WebKit::WebThemeEngine::State state,
const WebKit::WebRect& rect,
const WebKit::WebThemeEngine::ExtraParams* extra_params) {
- gfx::NativeThemeLinux::ExtraParams native_theme_extra_params;
+ gfx::NativeTheme::ExtraParams native_theme_extra_params;
GetNativeThemeExtraParams(
part, state, extra_params, &native_theme_extra_params);
- gfx::NativeThemeLinux::instance()->Paint(
+ gfx::NativeTheme::instance()->Paint(
canvas,
NativeThemePart(part),
NativeThemeState(state),