Commit fcee59f1 authored by jongkwon.lee's avatar jongkwon.lee Committed by Commit Bot

Fix the eye dropper cursor of DevTools

|updateCursor:| might be called outside the view bounds. Check the mouse
location before setting the cursor. Also, do not set cursor if it's not a
key window.

Bug: 837182
Change-Id: Idd2f12648e858284c6fc4cb1ba3b03eb7ad4f274
Reviewed-on: https://chromium-review.googlesource.com/1039283Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555979}
parent 92755f44
...@@ -484,6 +484,11 @@ void ExtractUnderlines(NSAttributedString* string, ...@@ -484,6 +484,11 @@ void ExtractUnderlines(NSAttributedString* string,
} }
} }
// Because |updateCursor:| changes the current cursor, we have to reset it to
// the default cursor on mouse exit.
if (type == NSMouseExited)
[[NSCursor arrowCursor] set];
if ([self shouldIgnoreMouseEvent:theEvent]) { if ([self shouldIgnoreMouseEvent:theEvent]) {
// If this is the first such event, send a mouse exit to the host view. // If this is the first such event, send a mouse exit to the host view.
if (!mouseEventWasIgnored_) { if (!mouseEventWasIgnored_) {
...@@ -1848,6 +1853,23 @@ extern NSString* NSTextInputReplacementRangeAttributeName; ...@@ -1848,6 +1853,23 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
return requestor; return requestor;
} }
- (BOOL)shouldChangeCurrentCursor {
// |updateCursor:| might be called outside the view bounds. Check the mouse
// location before setting the cursor. Also, do not set cursor if it's not a
// key window.
NSPoint location = ui::ConvertPointFromScreenToWindow(
[self window], [NSEvent mouseLocation]);
location = [self convertPoint:location fromView:nil];
if (![self mouse:location inRect:[self bounds]] ||
![[self window] isKeyWindow])
return NO;
if (cursorHidden_ || showingContextMenu_)
return NO;
return YES;
}
- (void)updateCursor:(NSCursor*)cursor { - (void)updateCursor:(NSCursor*)cursor {
if (currentCursor_ == cursor) if (currentCursor_ == cursor)
return; return;
...@@ -1857,8 +1879,8 @@ extern NSString* NSTextInputReplacementRangeAttributeName; ...@@ -1857,8 +1879,8 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
// NSWindow's invalidateCursorRectsForView: resets cursor rects but does not // NSWindow's invalidateCursorRectsForView: resets cursor rects but does not
// update the cursor instantly. The cursor is updated when the mouse moves. // update the cursor instantly. The cursor is updated when the mouse moves.
// Update the cursor by setting the current cursor if not hidden. // Update the cursor instantly by setting the current cursor.
if (!cursorHidden_ && !showingContextMenu_) if ([self shouldChangeCurrentCursor])
[currentCursor_ set]; [currentCursor_ set];
} }
......
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