| Index: chrome/browser/views/tabs/tab_strip.cc
|
| ===================================================================
|
| --- chrome/browser/views/tabs/tab_strip.cc (revision 2596)
|
| +++ chrome/browser/views/tabs/tab_strip.cc (working copy)
|
| @@ -442,7 +442,7 @@
|
|
|
| // Overridden from AnimationDelegate:
|
| virtual void AnimationEnded(const Animation* animation) {
|
| - tabstrip_->resize_layout_scheduled_ = false;
|
| + tabstrip_->needs_resize_layout_ = false;
|
| TabStrip::TabAnimation::AnimationEnded(animation);
|
| }
|
|
|
| @@ -487,7 +487,7 @@
|
| : model_(model),
|
| resize_layout_factory_(this),
|
| added_as_message_loop_observer_(false),
|
| - resize_layout_scheduled_(false),
|
| + needs_resize_layout_(false),
|
| current_unselected_width_(Tab::GetStandardSize().width()),
|
| current_selected_width_(Tab::GetStandardSize().width()),
|
| available_width_for_tabs_(-1) {
|
| @@ -869,7 +869,7 @@
|
| // We have "tiny tabs" if the tabs are so tiny that the unselected ones are
|
| // a different size to the selected ones.
|
| bool tiny_tabs = current_unselected_width_ != current_selected_width_;
|
| - if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) {
|
| + if (!IsAnimating() && (!needs_resize_layout_ || tiny_tabs)) {
|
| Layout();
|
| } else {
|
| SchedulePaint();
|
| @@ -947,8 +947,7 @@
|
| // Tabs are not resized until a later time (when the mouse pointer leaves
|
| // the TabStrip).
|
| available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab);
|
| - resize_layout_scheduled_ = true;
|
| - AddMessageLoopObserver();
|
| + needs_resize_layout_ = true;
|
| model_->CloseTabContentsAt(tab_index);
|
| }
|
| }
|
| @@ -1053,34 +1052,36 @@
|
| }
|
|
|
| void TabStrip::DidProcessMessage(const MSG& msg) {
|
| - // We spy on three different Windows messages here to see if the mouse has
|
| - // moved out of the bounds of the tabstrip, which we use as our cue to kick
|
| - // of the resize animation. The messages are:
|
| - //
|
| - // WM_MOUSEMOVE:
|
| - // For when the mouse moves from the tabstrip over into the rest of the
|
| - // browser UI, i.e. within the bounds of the same windows HWND.
|
| - // WM_MOUSELEAVE:
|
| - // For when the mouse moves very rapidly from a tab closed in the middle of
|
| - // the tabstrip (_not_ the end) out of the bounds of the browser's HWND and
|
| - // over some other HWND.
|
| - // WM_NCMOUSELEAVE:
|
| - // For when the mouse moves very rapidly from the end of the tabstrip (when
|
| - // the last tab is closed and the mouse is left floating over the title
|
| - // bar). Because the empty area of the tabstrip at the end of the title bar
|
| - // is registered by the ChromeFrame as part of the "caption" area of the
|
| - // window (the frame's OnNCHitTest method returns HTCAPTION for this
|
| - // region), the frame's HWND receives a WM_MOUSEMOVE message immediately,
|
| - // because as far as it is concerned the mouse has _left_ the client area
|
| - // of the window (and is now over the non-client area). To be notified
|
| - // again when the mouse leaves the _non-client_ area, we use the
|
| - // WM_NCMOUSELEAVE message, which causes us to re-evaluate the cursor
|
| - // position and correctly resize the tabstrip.
|
| - //
|
| switch (msg.message) {
|
| + // We spy on three different Windows messages here to see if the mouse has
|
| + // moved out of the bounds of the tabstrip, which we use as our cue to kick
|
| + // of the resize animation. The messages are:
|
| + //
|
| + // WM_MOUSEMOVE:
|
| + // For when the mouse moves from the tabstrip over into the rest of the
|
| + // browser UI, i.e. within the bounds of the same windows HWND.
|
| + // WM_MOUSELEAVE:
|
| + // For when the mouse moves very rapidly from a tab closed in the middle
|
| + // of the tabstrip (_not_ the end) out of the bounds of the browser's
|
| + // HWND and over some other HWND.
|
| + // WM_NCMOUSELEAVE:
|
| + // For when the mouse moves very rapidly from the end of the tabstrip
|
| + // (when the last tab is closed and the mouse is left floating over the
|
| + // title bar). Because the empty area of the tabstrip at the end of the
|
| + // title bar is registered by the ChromeFrame as part of the "caption"
|
| + // area of the window (the frame's OnNCHitTest method returns HTCAPTION
|
| + // for this region), the frame's HWND receives a WM_MOUSEMOVE message
|
| + // immediately, because as far as it is concerned the mouse has _left_
|
| + // the client area of the window (and is now over the non-client area).
|
| + // To be notified again when the mouse leaves the _non-client_ area, we
|
| + // use the WM_NCMOUSELEAVE message, which causes us to re-evaluate the
|
| + // cursor position and correctly resize the tabstrip.
|
| + //
|
| case WM_MOUSEMOVE:
|
| case WM_MOUSELEAVE:
|
| case WM_NCMOUSELEAVE:
|
| + if (!needs_resize_layout_)
|
| + break;
|
| if (!IsCursorInTabStripZone()) {
|
| // Mouse moved outside the tab slop zone, start a timer to do a resize
|
| // layout after a short while...
|
| @@ -1097,6 +1098,20 @@
|
| resize_layout_factory_.RevokeAll();
|
| }
|
| break;
|
| + // We also watch out for mouse-wheel messages here to allow the user to
|
| + // leaf through the tabs by scrolling while the mouse cursor is in the tab
|
| + // strip zone.
|
| + case WM_MOUSEWHEEL:
|
| + if (!IsCursorInTabStripZone())
|
| + break;
|
| + CHECK(model_);
|
| + // A positive value indicates that the wheel was rotated away from the
|
| + // user; a negative value indicates rotation toward the user.
|
| + if (GET_WHEEL_DELTA_WPARAM(msg.wParam) > 0)
|
| + model_->SelectPreviousTab();
|
| + else
|
| + model_->SelectNextTab();
|
| + break;
|
| }
|
| }
|
|
|
| @@ -1129,6 +1144,8 @@
|
| drop_indicator_width = drop_image->width();
|
| drop_indicator_height = drop_image->height();
|
| }
|
| +
|
| + AddMessageLoopObserver();
|
| }
|
|
|
| Tab* TabStrip::GetTabAt(int index) const {
|
| @@ -1224,10 +1241,6 @@
|
| void TabStrip::ResizeLayoutTabs() {
|
| resize_layout_factory_.RevokeAll();
|
|
|
| - // It is critically important that this is unhooked here, otherwise we will
|
| - // keep spying on messages forever.
|
| - RemoveMessageLoopObserver();
|
| -
|
| available_width_for_tabs_ = -1;
|
| double unselected, selected;
|
| GetDesiredTabWidths(GetTabCount(), &unselected, &selected);
|
| @@ -1461,7 +1474,7 @@
|
| void TabStrip::LayoutNewTabButton(double last_tab_right,
|
| double unselected_width) {
|
| int delta = abs(Round(unselected_width) - Tab::GetStandardSize().width());
|
| - if (delta > 1 && !resize_layout_scheduled_) {
|
| + if (delta > 1 && !needs_resize_layout_) {
|
| // We're shrinking tabs, so we need to anchor the New Tab button to the
|
| // right edge of the TabStrip's bounds, rather than the right edge of the
|
| // right-most Tab, otherwise it'll bounce when animating.
|
|
|