Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / views / controls / button / label_button.cc
index 0cfd1a4..691f815 100644 (file)
@@ -50,7 +50,8 @@ LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
       button_state_colors_(),
       explicitly_set_colors_(),
       is_default_(false),
-      style_(STYLE_TEXTBUTTON) {
+      style_(STYLE_TEXTBUTTON),
+      border_is_themed_border_(true) {
   SetAnimationDuration(kHoverAnimationDurationMs);
   SetText(text);
   SetFontList(gfx::FontList());
@@ -165,12 +166,7 @@ void LabelButton::SetStyle(ButtonStyle style) {
   if (style == STYLE_BUTTON)
     set_min_size(gfx::Size(70, 33));
 
-  ResetColorsFromNativeTheme();
-
-  UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_)));
-
-  // Invalidate the layout to pickup the new insets from the border.
-  InvalidateLayout();
+  OnNativeThemeChanged(GetNativeTheme());
 }
 
 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) {
@@ -270,6 +266,11 @@ const char* LabelButton::GetClassName() const {
   return kViewClassName;
 }
 
+void LabelButton::SetBorder(scoped_ptr<Border> border) {
+  border_is_themed_border_ = false;
+  View::SetBorder(border.Pass());
+}
+
 void LabelButton::OnPaint(gfx::Canvas* canvas) {
   View::OnPaint(canvas);
   Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
@@ -351,6 +352,10 @@ void LabelButton::UpdateImage() {
 }
 
 void LabelButton::UpdateThemedBorder(scoped_ptr<Border> label_button_border) {
+  // Don't override borders set by others.
+  if (!border_is_themed_border_)
+    return;
+
 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
   views::LinuxUI* linux_ui = views::LinuxUI::instance();
   if (linux_ui) {
@@ -360,6 +365,8 @@ void LabelButton::UpdateThemedBorder(scoped_ptr<Border> label_button_border) {
   {
     SetBorder(label_button_border.Pass());
   }
+
+  border_is_themed_border_ = true;
 }
 
 void LabelButton::StateChanged() {
@@ -379,6 +386,9 @@ void LabelButton::ChildPreferredSizeChanged(View* child) {
 
 void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
   ResetColorsFromNativeTheme();
+  UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_)));
+  // Invalidate the layout to pickup the new insets from the border.
+  InvalidateLayout();
 }
 
 ui::NativeTheme::Part LabelButton::GetThemePart() const {