diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-02 23:52:36 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-02 23:52:36 +0000 |
commit | 6b61206b0fd96ff657db3e0bb59bec6b9d02486c (patch) | |
tree | fd195e60bf115cb5d59165fd21efe6075c6a59f5 /ui | |
parent | 207f025a30871a6b132c55ff275ba35d50fd317f (diff) | |
download | chromium_src-6b61206b0fd96ff657db3e0bb59bec6b9d02486c.zip chromium_src-6b61206b0fd96ff657db3e0bb59bec6b9d02486c.tar.gz chromium_src-6b61206b0fd96ff657db3e0bb59bec6b9d02486c.tar.bz2 |
views: Improve a constant name to make it more clearer and improve LayoutTitleBar().
This patch also check if window_icon_ is NULL in UpdateWindowIcon(), because there is a
possibility of window_icon_ being NULL. This protect us from crashing.
TEST=views_unittests
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9959047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/window/custom_frame_view.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/ui/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc index 901bd42..b42fa05 100644 --- a/ui/views/window/custom_frame_view.cc +++ b/ui/views/window/custom_frame_view.cc @@ -59,9 +59,9 @@ const int kTitlebarTopAndBottomEdgeThickness = 2; const int kIconLeftSpacing = 2; // The icon never shrinks below 16 px on a side. const int kIconMinimumSize = 16; -// There is a 4 px gap between the icon and the title text. -const int kIconTitleSpacing = 4; -// There is a 5 px gap between the title text and the caption buttons. +// The space between the window icon and the title text. +const int kTitleIconOffsetX = 4; +// The space between the title text and the caption buttons. const int kTitleCaptionSpacing = 5; #if defined(USE_AURA) @@ -209,7 +209,8 @@ void CustomFrameView::ResetWindowControls() { } void CustomFrameView::UpdateWindowIcon() { - window_icon_->SchedulePaint(); + if (window_icon_) + window_icon_->SchedulePaint(); } /////////////////////////////////////////////////////////////////////////////// @@ -501,15 +502,16 @@ void CustomFrameView::LayoutWindowControls() { } void CustomFrameView::LayoutTitleBar() { - // The window title is based on the calculated icon position, even when there - // is no icon. + // The window title position is calculated based on the icon position, even + // when there is no icon. gfx::Rect icon_bounds(IconBounds()); - if (frame_->widget_delegate()->ShouldShowWindowIcon()) + bool show_window_icon = window_icon_ != NULL; + if (show_window_icon) window_icon_->SetBoundsRect(icon_bounds); - // Size the title. - int title_x = frame_->widget_delegate()->ShouldShowWindowIcon() ? - icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); + // The offset between the window left edge and the title text. + int title_x = show_window_icon ? icon_bounds.right() + kTitleIconOffsetX + : icon_bounds.x(); int title_height = GetTitleFont().GetHeight(); // We bias the title position so that when the difference between the icon and // title heights is odd, the extra pixel of the title is above the vertical |