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

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

Issue 143153004: [Reland] Fix crash when accidentally touching the screen during a multi window resize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // Need to delete the view here manually _before_ we reset the dragged 430 // Need to delete the view here manually _before_ we reset the dragged
431 // contents to NULL, otherwise if the view is animating to its destination 431 // contents to NULL, otherwise if the view is animating to its destination
432 // bounds, it won't be able to clean up properly since its cleanup routine 432 // bounds, it won't be able to clean up properly since its cleanup routine
433 // uses GetIndexForDraggedContents, which will be invalid. 433 // uses GetIndexForDraggedContents, which will be invalid.
434 view_.reset(NULL); 434 view_.reset(NULL);
435 435
436 // Reset the delegate of the dragged WebContents. This ends up doing nothing 436 // Reset the delegate of the dragged WebContents. This ends up doing nothing
437 // if the drag was completed. 437 // if the drag was completed.
438 if (!detach_into_browser_) 438 if (!detach_into_browser_)
439 ResetDelegates(); 439 ResetDelegates();
440
441 if (event_source_ == EVENT_SOURCE_TOUCH) {
442 TabStrip* capture_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
443 attached_tabstrip_ : source_tabstrip_;
444 capture_tabstrip->GetWidget()->ReleaseCapture();
445 }
440 } 446 }
441 447
442 void TabDragController::Init( 448 void TabDragController::Init(
443 TabStrip* source_tabstrip, 449 TabStrip* source_tabstrip,
444 Tab* source_tab, 450 Tab* source_tab,
445 const std::vector<Tab*>& tabs, 451 const std::vector<Tab*>& tabs,
446 const gfx::Point& mouse_offset, 452 const gfx::Point& mouse_offset,
447 int source_tab_offset, 453 int source_tab_offset,
448 const ui::ListSelectionModel& initial_selection_model, 454 const ui::ListSelectionModel& initial_selection_model,
449 DetachBehavior detach_behavior, 455 DetachBehavior detach_behavior,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Listen for Esc key presses. 488 // Listen for Esc key presses.
483 base::MessageLoopForUI::current()->AddObserver(this); 489 base::MessageLoopForUI::current()->AddObserver(this);
484 490
485 if (source_tab->width() > 0) { 491 if (source_tab->width() > 0) {
486 offset_to_width_ratio_ = static_cast<float>( 492 offset_to_width_ratio_ = static_cast<float>(
487 source_tab->GetMirroredXInView(source_tab_offset)) / 493 source_tab->GetMirroredXInView(source_tab_offset)) /
488 static_cast<float>(source_tab->width()); 494 static_cast<float>(source_tab->width());
489 } 495 }
490 InitWindowCreatePoint(); 496 InitWindowCreatePoint();
491 initial_selection_model_.Copy(initial_selection_model); 497 initial_selection_model_.Copy(initial_selection_model);
498
499 // Gestures don't automatically do a capture. We don't allow multiple drags at
500 // the same time, so we explicitly capture.
501 if (event_source == EVENT_SOURCE_TOUCH)
502 source_tabstrip_->GetWidget()->SetCapture(source_tabstrip_);
492 } 503 }
493 504
494 // static 505 // static
495 bool TabDragController::IsAttachedTo(const TabStrip* tab_strip) { 506 bool TabDragController::IsAttachedTo(const TabStrip* tab_strip) {
496 return (instance_ && instance_->active() && 507 return (instance_ && instance_->active() &&
497 instance_->attached_tabstrip() == tab_strip); 508 instance_->attached_tabstrip() == tab_strip);
498 } 509 }
499 510
500 // static 511 // static
501 bool TabDragController::IsActive() { 512 bool TabDragController::IsActive() {
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 gfx::Vector2d TabDragController::GetWindowOffset( 2331 gfx::Vector2d TabDragController::GetWindowOffset(
2321 const gfx::Point& point_in_screen) { 2332 const gfx::Point& point_in_screen) {
2322 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2333 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2323 attached_tabstrip_ : source_tabstrip_; 2334 attached_tabstrip_ : source_tabstrip_;
2324 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2335 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2325 2336
2326 gfx::Point point = point_in_screen; 2337 gfx::Point point = point_in_screen;
2327 views::View::ConvertPointFromScreen(toplevel_view, &point); 2338 views::View::ConvertPointFromScreen(toplevel_view, &point);
2328 return point.OffsetFromOrigin(); 2339 return point.OffsetFromOrigin();
2329 } 2340 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698