diff options
author | dominicc@chromium.org <dominicc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 07:35:44 +0000 |
---|---|---|
committer | dominicc@chromium.org <dominicc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 07:35:44 +0000 |
commit | fc987c45fd4086eeaebb8d6bf0574bb1c7e41989 (patch) | |
tree | dbcce7a5858b0c33a3a191bf5cc0dba5c991d7b8 /content | |
parent | aa9a424890c6a463af8b7c31e3cd8f0903e68d19 (diff) | |
download | chromium_src-fc987c45fd4086eeaebb8d6bf0574bb1c7e41989.zip chromium_src-fc987c45fd4086eeaebb8d6bf0574bb1c7e41989.tar.gz chromium_src-fc987c45fd4086eeaebb8d6bf0574bb1c7e41989.tar.bz2 |
Apply a CursorRect to the extent of the render widget view for web page cursors.
BUG=114517
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10450012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_mac.h | 11 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_mac.mm | 44 |
2 files changed, 22 insertions, 33 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 7685f29..b808699 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -66,6 +66,9 @@ class RenderWidgetHostImpl; NSWindow* lastWindow_; // weak + // The cursor for the page. This is passed up from the renderer. + scoped_nsobject<NSCursor> currentCursor_; + // Variables used by our implementaion of the NSTextInput protocol. // An input method of Mac calls the methods of this protocol not only to // notify an application of its status, but also to retrieve the status of @@ -154,7 +157,7 @@ class RenderWidgetHostImpl; // Evaluates the event in the context of plugin IME, if plugin IME is enabled. // Returns YES if the event was handled. - (BOOL)postProcessEventForPluginIme:(NSEvent*)event; - +- (void)updateCursor:(NSCursor*)cursor; @end /////////////////////////////////////////////////////////////////////////////// @@ -388,9 +391,6 @@ class RenderWidgetHostViewMac : public content::RenderWidgetHostViewBase { // Returns whether this render view is a popup (autocomplete window). bool IsPopup() const; - // Updates the display cursor if the current event is over the view's window. - void UpdateCursorIfNecessary(); - // Shuts down the render_widget_host_. This is a separate function so we can // invoke it from the message loop. void ShutdownHost(); @@ -404,9 +404,6 @@ class RenderWidgetHostViewMac : public content::RenderWidgetHostViewBase { // to own this RenderWidgetHostViewMac object. RenderWidgetHostViewCocoa* cocoa_view_; - // The cursor for the page. This is passed up from the renderer. - WebCursor current_cursor_; - // Indicates if the page is loading. bool is_loading_; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 1916544..ea03b57 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -560,32 +560,14 @@ gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const { } void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { - current_cursor_ = cursor; - UpdateCursorIfNecessary(); -} - -void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { - // Do something special (as Win Chromium does) for arrow cursor while loading - // a page? TODO(avi): decide - - // Don't update the cursor if a context menu is being shown. - if (IsShowingContextMenu()) - return; - - // Can we synchronize to the event stream? Switch to -[NSWindow - // mouseLocationOutsideOfEventStream] if we cannot. TODO(avi): test and see - NSEvent* event = [[cocoa_view_ window] currentEvent]; - if ([event window] != [cocoa_view_ window]) - return; - - NSCursor* ns_cursor = current_cursor_.GetNativeCursor(); - [ns_cursor set]; + WebCursor web_cursor = cursor; + [cocoa_view_ updateCursor:web_cursor.GetNativeCursor()]; } void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { is_loading_ = is_loading; // If we ever decide to show the waiting cursor while the page is loading - // like Chrome does on Windows, call |UpdateCursorIfNecessary()| here. + // like Chrome does on Windows, call |UpdateCursor()| here. } void RenderWidgetHostViewMac::TextInputStateChanged( @@ -767,11 +749,6 @@ void RenderWidgetHostViewMac::SelectionChanged(const string16& text, void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { content::RenderWidgetHostViewBase::SetShowingContextMenu(showing); - // If the menu was closed, restore the cursor to the saved version initially, - // as the renderer will not re-send it if there was no change. - if (!showing) - UpdateCursorIfNecessary(); - // Create a fake mouse event to inform the render widget that the mouse // left or entered. NSWindow* window = [cocoa_view_ window]; @@ -1319,6 +1296,13 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { [super dealloc]; } +- (void)resetCursorRects { + if (currentCursor_) { + [self addCursorRect:[self visibleRect] cursor:currentCursor_]; + [currentCursor_ setOnMouseEntered:YES]; + } +} + - (void)setRWHVDelegate:(NSObject<RenderWidgetHostViewMacDelegate>*)delegate { delegate_ = delegate; } @@ -2924,6 +2908,14 @@ extern NSString *NSTextInputReplacementRangeAttributeName; widget->Send(new ViewMsg_SetInLiveResize(widget->GetRoutingID(), false)); } +- (void)updateCursor:(NSCursor*)cursor { + if (currentCursor_ == cursor) + return; + + currentCursor_.reset(cursor, base::scoped_policy::RETAIN); + [[self window] invalidateCursorRectsForView:self]; +} + @end // |