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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 12179007: While screencasting a tab, do not disable rendering updates while hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finer-grained increment/decrement, per sky@'s comments. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 1130
1131 if (!detach_into_browser_) { 1131 if (!detach_into_browser_) {
1132 // Remove ourselves as the delegate now that the dragged WebContents is 1132 // Remove ourselves as the delegate now that the dragged WebContents is
1133 // being inserted back into a Browser. 1133 // being inserted back into a Browser.
1134 for (size_t i = 0; i < drag_data_.size(); ++i) { 1134 for (size_t i = 0; i < drag_data_.size(); ++i) {
1135 drag_data_[i].contents->SetDelegate(NULL); 1135 drag_data_[i].contents->SetDelegate(NULL);
1136 drag_data_[i].original_delegate = NULL; 1136 drag_data_[i].original_delegate = NULL;
1137 } 1137 }
1138 1138
1139 // Return the WebContents to normalcy. 1139 // Return the WebContents to normalcy.
1140 source_dragged_contents()->SetCapturingContents(false); 1140 source_dragged_contents()->DecrementCapturerCount();
1141 } 1141 }
1142 1142
1143 // Inserting counts as a move. We don't want the tabs to jitter when the 1143 // Inserting counts as a move. We don't want the tabs to jitter when the
1144 // user moves the tab immediately after attaching it. 1144 // user moves the tab immediately after attaching it.
1145 last_move_screen_loc_ = point_in_screen.x(); 1145 last_move_screen_loc_ = point_in_screen.x();
1146 1146
1147 // Figure out where to insert the tab based on the bounds of the dragged 1147 // Figure out where to insert the tab based on the bounds of the dragged
1148 // representation and the ideal bounds of the other Tabs already in the 1148 // representation and the ideal bounds of the other Tabs already in the
1149 // strip. ("ideal bounds" are stable even if the Tabs' actual bounds are 1149 // strip. ("ideal bounds" are stable even if the Tabs' actual bounds are
1150 // changing due to animation). 1150 // changing due to animation).
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 attached_tabstrip_->ReleaseDragController(); 1219 attached_tabstrip_->ReleaseDragController();
1220 if (release_capture == RELEASE_CAPTURE) 1220 if (release_capture == RELEASE_CAPTURE)
1221 attached_tabstrip_->GetWidget()->ReleaseCapture(); 1221 attached_tabstrip_->GetWidget()->ReleaseCapture();
1222 } 1222 }
1223 1223
1224 mouse_move_direction_ = kMovedMouseLeft | kMovedMouseRight; 1224 mouse_move_direction_ = kMovedMouseLeft | kMovedMouseRight;
1225 1225
1226 // Prevent the WebContents HWND from being hidden by any of the model 1226 // Prevent the WebContents HWND from being hidden by any of the model
1227 // operations performed during the drag. 1227 // operations performed during the drag.
1228 if (!detach_into_browser_) 1228 if (!detach_into_browser_)
1229 source_dragged_contents()->SetCapturingContents(true); 1229 source_dragged_contents()->IncrementCapturerCount();
1230 1230
1231 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(0); 1231 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(0);
1232 TabStripModel* attached_model = GetModel(attached_tabstrip_); 1232 TabStripModel* attached_model = GetModel(attached_tabstrip_);
1233 std::vector<TabRendererData> tab_data; 1233 std::vector<TabRendererData> tab_data;
1234 for (size_t i = 0; i < drag_data_.size(); ++i) { 1234 for (size_t i = 0; i < drag_data_.size(); ++i) {
1235 tab_data.push_back(drag_data_[i].attached_tab->data()); 1235 tab_data.push_back(drag_data_[i].attached_tab->data());
1236 int index = attached_model->GetIndexOfWebContents(drag_data_[i].contents); 1236 int index = attached_model->GetIndexOfWebContents(drag_data_[i].contents);
1237 DCHECK_NE(-1, index); 1237 DCHECK_NE(-1, index);
1238 1238
1239 // Hide the tab so that the user doesn't see it animate closed. 1239 // Hide the tab so that the user doesn't see it animate closed.
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 GetModel(source_tabstrip_)->SetSelectionFromModel(initial_selection_model_); 1653 GetModel(source_tabstrip_)->SetSelectionFromModel(initial_selection_model_);
1654 1654
1655 // If we're not attached to any TabStrip, or attached to some other TabStrip, 1655 // If we're not attached to any TabStrip, or attached to some other TabStrip,
1656 // we need to restore the bounds of the original TabStrip's frame, in case 1656 // we need to restore the bounds of the original TabStrip's frame, in case
1657 // it has been hidden. 1657 // it has been hidden.
1658 if (restore_frame && !restore_bounds_.IsEmpty()) 1658 if (restore_frame && !restore_bounds_.IsEmpty())
1659 source_tabstrip_->GetWidget()->SetBounds(restore_bounds_); 1659 source_tabstrip_->GetWidget()->SetBounds(restore_bounds_);
1660 1660
1661 if (detach_into_browser_ && source_tabstrip_) 1661 if (detach_into_browser_ && source_tabstrip_)
1662 source_tabstrip_->GetWidget()->Activate(); 1662 source_tabstrip_->GetWidget()->Activate();
1663
1664 // Return the WebContents to normalcy. If the tab was attached to a
1665 // TabStrip before the revert, the decrement has already occurred.
1666 // If the tab was destroyed, don't attempt to dereference the
1667 // WebContents pointer.
1668 if (!detach_into_browser_ && !attached_tabstrip_ && source_dragged_contents())
1669 source_dragged_contents()->DecrementCapturerCount();
1663 } 1670 }
1664 1671
1665 void TabDragController::ResetSelection(TabStripModel* model) { 1672 void TabDragController::ResetSelection(TabStripModel* model) {
1666 DCHECK(model); 1673 DCHECK(model);
1667 ui::ListSelectionModel selection_model; 1674 ui::ListSelectionModel selection_model;
1668 bool has_one_valid_tab = false; 1675 bool has_one_valid_tab = false;
1669 for (size_t i = 0; i < drag_data_.size(); ++i) { 1676 for (size_t i = 0; i < drag_data_.size(); ++i) {
1670 // |contents| is NULL if a tab was deleted out from under us. 1677 // |contents| is NULL if a tab was deleted out from under us.
1671 if (drag_data_[i].contents) { 1678 if (drag_data_[i].contents) {
1672 int index = model->GetIndexOfWebContents(drag_data_[i].contents); 1679 int index = model->GetIndexOfWebContents(drag_data_[i].contents);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 item.add_types = drag_data_[i].pinned ? TabStripModel::ADD_PINNED 1805 item.add_types = drag_data_[i].pinned ? TabStripModel::ADD_PINNED
1799 : TabStripModel::ADD_NONE; 1806 : TabStripModel::ADD_NONE;
1800 contentses.push_back(item); 1807 contentses.push_back(item);
1801 }; 1808 };
1802 1809
1803 Browser* new_browser = 1810 Browser* new_browser =
1804 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents( 1811 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents(
1805 contentses, window_bounds, dock_info_, widget->IsMaximized()); 1812 contentses, window_bounds, dock_info_, widget->IsMaximized());
1806 ResetSelection(new_browser->tab_strip_model()); 1813 ResetSelection(new_browser->tab_strip_model());
1807 new_browser->window()->Show(); 1814 new_browser->window()->Show();
1815
1816 // Return the WebContents to normalcy.
1817 if (!detach_into_browser_)
1818 source_dragged_contents()->DecrementCapturerCount();
1808 } 1819 }
1809 1820
1810 CleanUpHiddenFrame(); 1821 CleanUpHiddenFrame();
1811 } 1822 }
1812 1823
1813 void TabDragController::ResetDelegates() { 1824 void TabDragController::ResetDelegates() {
1814 DCHECK(!detach_into_browser_); 1825 DCHECK(!detach_into_browser_);
1815 for (size_t i = 0; i < drag_data_.size(); ++i) { 1826 for (size_t i = 0; i < drag_data_.size(); ++i) {
1816 if (drag_data_[i].contents && 1827 if (drag_data_[i].contents &&
1817 drag_data_[i].contents->GetDelegate() == this) { 1828 drag_data_[i].contents->GetDelegate() == this) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 gfx::Vector2d TabDragController::GetWindowOffset( 2052 gfx::Vector2d TabDragController::GetWindowOffset(
2042 const gfx::Point& point_in_screen) { 2053 const gfx::Point& point_in_screen) {
2043 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2054 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2044 attached_tabstrip_ : source_tabstrip_; 2055 attached_tabstrip_ : source_tabstrip_;
2045 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2056 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2046 2057
2047 gfx::Point point = point_in_screen; 2058 gfx::Point point = point_in_screen;
2048 views::View::ConvertPointFromScreen(toplevel_view, &point); 2059 views::View::ConvertPointFromScreen(toplevel_view, &point);
2049 return point.OffsetFromOrigin(); 2060 return point.OffsetFromOrigin();
2050 } 2061 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698