Code:  gfx::Size LauncherView::GetPreferredSize() {
   IdealBounds ideal_bounds;
   CalculateIdealBounds(&ideal_bounds);
   if (is_horizontal_alignment()) {
    if (view_model_->view_size() >= 2) {
      return gfx::Size(view_model_->ideal_bounds(1).right() + kLeadingInset,
                       kLauncherPreferredSize);
    }
    return gfx::Size(kLauncherPreferredSize * 2 + kLeadingInset * 2,
                      kLauncherPreferredSize);
   }
  if (view_model_->view_size() >= 2) {
    return gfx::Size(kLauncherPreferredSize,
                     view_model_->ideal_bounds(1).bottom() + kLeadingInset);
  }
   return gfx::Size(kLauncherPreferredSize,
                   kLauncherPreferredSize * 2 + kLeadingInset * 2);
 }

Commit Message: ash: Add launcher overflow bubble.

- Host a LauncherView in bubble to display overflown items;
- Mouse wheel and two-finger scroll to scroll the LauncherView in bubble in case overflow bubble is overflown;
- Fit bubble when items are added/removed;
- Keep launcher bar on screen when the bubble is shown;

BUG=128054
TEST=Verify launcher overflown items are in a bubble instead of menu.


Review URL: https://chromiumcodereview.appspot.com/10659003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146460 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119
 gfx::Size LauncherView::GetPreferredSize() {
   IdealBounds ideal_bounds;
   CalculateIdealBounds(&ideal_bounds);

  const int app_list_index = view_model_->view_size() - 1;
  const int last_button_index = is_overflow_mode() ?
      last_visible_index_ : app_list_index;
  const gfx::Rect last_button_bounds =
      last_button_index  >= first_visible_index_ ?
          view_model_->view_at(last_button_index)->bounds() :
          gfx::Rect(gfx::Size(kLauncherPreferredSize,
                              kLauncherPreferredSize));

   if (is_horizontal_alignment()) {
    return gfx::Size(last_button_bounds.right() + leading_inset(),
                      kLauncherPreferredSize);
   }

   return gfx::Size(kLauncherPreferredSize,
                   last_button_bounds.bottom() + leading_inset());
 }
