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

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: Fixed calls to SetCapturingContents() on start/end of drag. 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 move_stacked_timer_.Stop(); 482 move_stacked_timer_.Stop();
483 483
484 if (waiting_for_run_loop_to_exit_) 484 if (waiting_for_run_loop_to_exit_)
485 return; 485 return;
486 486
487 if (!started_drag_) { 487 if (!started_drag_) {
488 if (!CanStartDrag(point_in_screen)) 488 if (!CanStartDrag(point_in_screen))
489 return; // User hasn't dragged far enough yet. 489 return; // User hasn't dragged far enough yet.
490 490
491 started_drag_ = true; 491 started_drag_ = true;
492 // Prevent the WebContents HWND from being hidden by any of the model
493 // operations performed during the drag.
494 source_dragged_contents()->SetCapturingContents(true);
sky 2013/02/04 15:02:25 At this point the tab is very likely still in the
miu 2013/02/04 21:36:52 Short story: It's the simplest solution that fixes
sky 2013/02/04 22:48:50 None-the-less it's the *wrong* state. The tab is n
miu 2013/02/05 01:06:25 Fixed. This was all a bit confusing to me. Would
492 SaveFocus(); 495 SaveFocus();
493 Attach(source_tabstrip_, gfx::Point()); 496 Attach(source_tabstrip_, gfx::Point());
494 if (detach_into_browser_ && static_cast<int>(drag_data_.size()) == 497 if (detach_into_browser_ && static_cast<int>(drag_data_.size()) ==
495 GetModel(source_tabstrip_)->count()) { 498 GetModel(source_tabstrip_)->count()) {
496 RunMoveLoop(GetWindowOffset(point_in_screen)); 499 RunMoveLoop(GetWindowOffset(point_in_screen));
497 return; 500 return;
498 } 501 }
499 } 502 }
500 503
501 ContinueDragging(point_in_screen); 504 ContinueDragging(point_in_screen);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1131
1129 selection_model_before_attach_.Copy(attached_tabstrip->GetSelectionModel()); 1132 selection_model_before_attach_.Copy(attached_tabstrip->GetSelectionModel());
1130 1133
1131 if (!detach_into_browser_) { 1134 if (!detach_into_browser_) {
1132 // Remove ourselves as the delegate now that the dragged WebContents is 1135 // Remove ourselves as the delegate now that the dragged WebContents is
1133 // being inserted back into a Browser. 1136 // being inserted back into a Browser.
1134 for (size_t i = 0; i < drag_data_.size(); ++i) { 1137 for (size_t i = 0; i < drag_data_.size(); ++i) {
1135 drag_data_[i].contents->SetDelegate(NULL); 1138 drag_data_[i].contents->SetDelegate(NULL);
1136 drag_data_[i].original_delegate = NULL; 1139 drag_data_[i].original_delegate = NULL;
1137 } 1140 }
1138
1139 // Return the WebContents to normalcy.
1140 source_dragged_contents()->SetCapturingContents(false);
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // Release ownership of the drag controller and mouse capture. When we 1216 // Release ownership of the drag controller and mouse capture. When we
1217 // reattach ownership is transfered. 1217 // reattach ownership is transfered.
1218 if (detach_into_browser_) { 1218 if (detach_into_browser_) {
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
1227 // operations performed during the drag.
1228 if (!detach_into_browser_)
1229 source_dragged_contents()->SetCapturingContents(true);
1230
1231 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(0); 1226 std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(0);
1232 TabStripModel* attached_model = GetModel(attached_tabstrip_); 1227 TabStripModel* attached_model = GetModel(attached_tabstrip_);
1233 std::vector<TabRendererData> tab_data; 1228 std::vector<TabRendererData> tab_data;
1234 for (size_t i = 0; i < drag_data_.size(); ++i) { 1229 for (size_t i = 0; i < drag_data_.size(); ++i) {
1235 tab_data.push_back(drag_data_[i].attached_tab->data()); 1230 tab_data.push_back(drag_data_[i].attached_tab->data());
1236 int index = attached_model->GetIndexOfWebContents(drag_data_[i].contents); 1231 int index = attached_model->GetIndexOfWebContents(drag_data_[i].contents);
1237 DCHECK_NE(-1, index); 1232 DCHECK_NE(-1, index);
1238 1233
1239 // Hide the tab so that the user doesn't see it animate closed. 1234 // Hide the tab so that the user doesn't see it animate closed.
1240 drag_data_[i].attached_tab->SetVisible(false); 1235 drag_data_[i].attached_tab->SetVisible(false);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1593 }
1599 dock_controllers_.clear(); 1594 dock_controllers_.clear();
1600 dock_windows_.clear(); 1595 dock_windows_.clear();
1601 1596
1602 if (type != TAB_DESTROYED) { 1597 if (type != TAB_DESTROYED) {
1603 // We only finish up the drag if we were actually dragging. If start_drag_ 1598 // We only finish up the drag if we were actually dragging. If start_drag_
1604 // is false, the user just clicked and released and didn't move the mouse 1599 // is false, the user just clicked and released and didn't move the mouse
1605 // enough to trigger a drag. 1600 // enough to trigger a drag.
1606 if (started_drag_) { 1601 if (started_drag_) {
1607 RestoreFocus(); 1602 RestoreFocus();
1603 source_dragged_contents()->SetCapturingContents(false);
1608 if (type == CANCELED) 1604 if (type == CANCELED)
1609 RevertDrag(); 1605 RevertDrag();
1610 else 1606 else
1611 CompleteDrag(); 1607 CompleteDrag();
1612 } 1608 }
1613 } else if (drag_data_.size() > 1) { 1609 } else if (drag_data_.size() > 1) {
1614 RevertDrag(); 1610 RevertDrag();
1615 } // else case the only tab we were dragging was deleted. Nothing to do. 1611 } // else case the only tab we were dragging was deleted. Nothing to do.
1616 1612
1617 if (!detach_into_browser_) 1613 if (!detach_into_browser_)
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 gfx::Vector2d TabDragController::GetWindowOffset( 2037 gfx::Vector2d TabDragController::GetWindowOffset(
2042 const gfx::Point& point_in_screen) { 2038 const gfx::Point& point_in_screen) {
2043 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2039 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2044 attached_tabstrip_ : source_tabstrip_; 2040 attached_tabstrip_ : source_tabstrip_;
2045 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2041 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2046 2042
2047 gfx::Point point = point_in_screen; 2043 gfx::Point point = point_in_screen;
2048 views::View::ConvertPointFromScreen(toplevel_view, &point); 2044 views::View::ConvertPointFromScreen(toplevel_view, &point);
2049 return point.OffsetFromOrigin(); 2045 return point.OffsetFromOrigin();
2050 } 2046 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698