Commit 013b50f6 authored by pkasting@chromium.org's avatar pkasting@chromium.org

ContentSettingImageView cleanup, phase 2.

* Name/comment animation constants for clarity.  Make constants used in multiple
  places in the class be private static members to scope them to the class (not
  really a big deal as there are no other classes in the .cc file).
* Inline the calculations from GetTextAnimationSize() into GetPreferredSize()
  and nuke |visible_text_size_| as a result.
* To enable the above change, add a background_showing() method to tell us when
  the background painter is being painted.  This is basically equivalent to "are
  we animating", but also includes the "paused animation" state (during which
  the actual animation is technically reset).  Then use this everywhere
  appropriate.  This results in one functional change: if the content setting
  model changes our type while we're paused, we now just silently ignore it.
  This seems more correct, and I doubt this case can happen anyway.
* Eliminate pointless arg to OnClick().
* Make |background_painter_| a pointer, which will be necessary when it switches
  to being an image grid painter.
* Eliminate unnecessary #includes and a using directive.
* Other changes to braces, newlines, variable names, code order, comments, etc.
  with the aim of clarity, brevity, and stylistic consistency.

BUG=none
TEST=none
R=sky@chromium.org

Review URL: https://codereview.chromium.org/16209002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202978 0039d316-1c4b-4281-b951-d872f2087c98
parent 1f4e2757
......@@ -52,6 +52,14 @@ class ContentSettingImageView : public TouchableLocationBarView,
void Update(content::WebContents* web_contents);
private:
// Number of milliseconds spent animating open; also the time spent animating
// closed.
static const int kOpenTimeMS;
// The total animation time, including open and close as well as an
// intervening "stay open" period.
static const int kAnimationDurationMS;
// ui::AnimationDelegate:
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
......@@ -67,14 +75,16 @@ class ContentSettingImageView : public TouchableLocationBarView,
// views::WidgetObserver:
virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
// Invoked when the user clicks on the control.
void OnClick(LocationBarView* parent);
bool background_showing() const {
return slide_animator_.is_animating() || pause_animation_;
}
int GetTextAnimationSize(double state, int text_size);
// Invoked when the user clicks on the control.
void OnClick();
LocationBarView* parent_; // Weak, owns us.
scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
views::HorizontalPainter background_painter_;
scoped_ptr<views::Painter> background_painter_;
views::ImageView* icon_;
views::Label* text_label_;
ui::SlideAnimation slide_animator_;
......@@ -85,7 +95,6 @@ class ContentSettingImageView : public TouchableLocationBarView,
// TODO(pkasting): Eliminate these.
gfx::Font font_;
int text_size_;
int visible_text_size_;
DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment