Commit 2dad4dfb authored by andresantoso's avatar andresantoso Committed by Commit bot

Mac: Fix for janky tab dragging/reordering.

-[TabView drawRect:] was called repeatedly to unnecessarily update the glow
that is not changing or should not have changed.

1. Selected tabs don't have glow, so don't redraw on mouseMoved.

2. When dragging an unselected tab, the mouse point relative to the tab view
does not change, so no need to redraw the glow.

3. When a dragged unselected tab slides behind another tab, let the dragged tab
keep the glow instead of the tab in front of it (this is a behavior change).
I think this is the more correct behavior, and we never have to redraw tabs
while dragging.

BUG=452925

Review URL: https://codereview.chromium.org/882193003

Cr-Commit-Position: refs/heads/master@{#313734}
parent 0cf9539d
...@@ -1867,6 +1867,12 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) { ...@@ -1867,6 +1867,12 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
} }
- (void)mouseMoved:(NSEvent*)event { - (void)mouseMoved:(NSEvent*)event {
// We don't want the draggged tab to repeatedly redraw its glow unnecessarily.
// We also want the dragged tab to keep the glow even when it slides behind
// another tab.
if ([dragController_ draggedTab])
return;
// Use hit test to figure out what view we are hovering over. // Use hit test to figure out what view we are hovering over.
NSView* targetView = [tabStripView_ hitTest:[event locationInWindow]]; NSView* targetView = [tabStripView_ hitTest:[event locationInWindow]];
......
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
TabWindowController* targetController_; // weak. Controller being targeted TabWindowController* targetController_; // weak. Controller being targeted
} }
// The tab being dragged, or nil if not dragging a tab.
@property(readonly) TabController* draggedTab;
// Designated initializer. // Designated initializer.
- (id)initWithTabStripController:(TabStripController*)controller; - (id)initWithTabStripController:(TabStripController*)controller;
......
...@@ -40,6 +40,8 @@ static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) { ...@@ -40,6 +40,8 @@ static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) {
@implementation TabStripDragController @implementation TabStripDragController
@synthesize draggedTab = draggedTab_;
- (id)initWithTabStripController:(TabStripController*)controller { - (id)initWithTabStripController:(TabStripController*)controller {
if ((self = [super init])) { if ((self = [super init])) {
tabStrip_ = controller; tabStrip_ = controller;
......
...@@ -136,9 +136,10 @@ const CGFloat kRapidCloseDist = 2.5; ...@@ -136,9 +136,10 @@ const CGFloat kRapidCloseDist = 2.5;
} }
- (void)mouseMoved:(NSEvent*)theEvent { - (void)mouseMoved:(NSEvent*)theEvent {
hoverPoint_ = [self convertPoint:[theEvent locationInWindow] if (state_ == NSOffState) {
fromView:nil]; hoverPoint_ = [self convertPoint:[theEvent locationInWindow] fromView:nil];
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
}
} }
- (void)mouseExited:(NSEvent*)theEvent { - (void)mouseExited:(NSEvent*)theEvent {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment