diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 20:34:00 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 20:34:00 +0000 |
commit | 04bf33c244a1d3f9d5e904d06ce158e068102db0 (patch) | |
tree | 8761ae0639bdbba9da226d63ae362b7463cec906 /chrome/views | |
parent | ceb4a1d8df81d1b4c2997e641ef5c3fb55cdd571 (diff) | |
download | chromium_src-04bf33c244a1d3f9d5e904d06ce158e068102db0.zip chromium_src-04bf33c244a1d3f9d5e904d06ce158e068102db0.tar.gz chromium_src-04bf33c244a1d3f9d5e904d06ce158e068102db0.tar.bz2 |
Checkbox/RadioButton labels have to reserve space for the focus rects, even if they're not actively being painted as focused, otherwise layout breaks badly.
http://crbug.com/10958
Review URL: http://codereview.chromium.org/93142
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14464 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/controls/button/checkbox.cc | 1 | ||||
-rw-r--r-- | chrome/views/controls/label.cc | 3 | ||||
-rw-r--r-- | chrome/views/controls/label.h | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/chrome/views/controls/button/checkbox.cc b/chrome/views/controls/button/checkbox.cc index ae023ce..d0ec64a 100644 --- a/chrome/views/controls/button/checkbox.cc +++ b/chrome/views/controls/button/checkbox.cc @@ -164,6 +164,7 @@ bool Checkbox::HitTestLabel(const MouseEvent& e) { void Checkbox::Init(const std::wstring& label_text) { set_minimum_size(gfx::Size(0, 0)); label_ = new Label(label_text); + label_->set_has_focus_border(true); label_->SetHorizontalAlignment(Label::ALIGN_LEFT); AddChildView(label_); } diff --git a/chrome/views/controls/label.cc b/chrome/views/controls/label.cc index 1f499b2..22c11d7 100644 --- a/chrome/views/controls/label.cc +++ b/chrome/views/controls/label.cc @@ -48,6 +48,7 @@ void Label::Init(const std::wstring& text, const ChromeFont& font) { collapse_when_hidden_ = false; rtl_alignment_mode_ = USE_UI_ALIGNMENT; paint_as_focused_ = false; + has_focus_border_ = false; } Label::~Label() { @@ -335,7 +336,7 @@ void Label::SetEnabled(bool enabled) { gfx::Insets Label::GetInsets() const { gfx::Insets insets = View::GetInsets(); - if (IsFocusable() || paint_as_focused_) { + if (IsFocusable() || has_focus_border_) { insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, kFocusBorderPadding, kFocusBorderPadding); } diff --git a/chrome/views/controls/label.h b/chrome/views/controls/label.h index 11608fa..15e90ae 100644 --- a/chrome/views/controls/label.h +++ b/chrome/views/controls/label.h @@ -190,6 +190,9 @@ class Label : public View { void set_paint_as_focused(bool paint_as_focused) { paint_as_focused_ = paint_as_focused; } + void set_has_focus_border(bool has_focus_border) { + has_focus_border_ = has_focus_border; + } private: // These tests call CalculateDrawStringParams in order to verify the @@ -241,6 +244,10 @@ class Label : public View { // When embedded in a larger control that is focusable, setting this flag // allows this view to be painted as focused even when it is itself not. bool paint_as_focused_; + // When embedded in a larger control that is focusable, setting this flag + // allows this view to reserve space for a focus border that it otherwise + // might not have because it is not itself focusable. + bool has_focus_border_; DISALLOW_COPY_AND_ASSIGN(Label); }; |