Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Unified Diff: ui/views/controls/button/label_button.h

Issue 371633002: LabelButton: cache the last computed preferred size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/label_button.h
diff --git a/ui/views/controls/button/label_button.h b/ui/views/controls/button/label_button.h
index bceaf715654a99e288ae0f677d463a2c16a5d6de..84b8fabcae6b7d7b96b7d2751d73d1f0317b95f4 100644
--- a/ui/views/controls/button/label_button.h
+++ b/ui/views/controls/button/label_button.h
@@ -65,9 +65,9 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
gfx::HorizontalAlignment GetHorizontalAlignment() const;
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
- // Call set_min_size(gfx::Size()) to clear the monotonically increasing size.
- void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; }
- void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; }
+ // Call SetMinSize(gfx::Size()) to clear the monotonically increasing size.
+ void SetMinSize(const gfx::Size& min_size);
+ void SetMaxSize(const gfx::Size& min_size);
msw 2014/07/23 19:20:16 nit: |max_size|
noms (inactive) 2014/07/24 14:20:25 Done.
// Get or set the option to handle the return key; false by default.
bool is_default() const { return is_default_; }
@@ -144,6 +144,9 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
virtual ui::NativeTheme::State GetForegroundThemeState(
ui::NativeTheme::ExtraParams* params) const OVERRIDE;
+ // Resets |button_size_| and marks |button_size_valid_| as false.
+ void ResetCachedSize();
sky 2014/07/23 22:42:36 Is it possible to override ChildPreferredSizeChang
noms (inactive) 2014/07/24 14:20:26 Hmm, but shouldn't actions on the LabelButton also
sky 2014/07/24 15:38:05 Yes, sorry, you may need a mix of the two. But it
+
// The image and label shown in the button.
ImageView* image_;
Label* label_;
@@ -164,6 +167,10 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
// |max_size_| may be set to clamp the preferred size.
gfx::Size max_size_;
+ // Cache the last computed preferred size.
+ mutable gfx::Size button_size_;
sky 2014/07/23 22:42:36 Can you name this better. It's the preferred size.
noms (inactive) 2014/07/24 14:20:26 Done.
+ mutable bool button_size_valid_;
+
// Flag indicating default handling of the return key via an accelerator.
// Whether or not the button appears or behaves as the default button in its
// current context;

Powered by Google App Engine
This is Rietveld 408576698