GTK Render Widget Host View resets cached center location on mouse lock.


BUG=129584
TEST=


Review URL: https://chromiumcodereview.appspot.com/10454013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138944 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc
index 678e186..dad450e 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -207,8 +207,7 @@
   static gboolean OnConfigureEvent(GtkWidget* widget,
                                    GdkEventConfigure* event,
                                    RenderWidgetHostViewGtk* host_view) {
-    host_view->widget_center_valid_ = false;
-    host_view->mouse_has_been_warped_to_new_center_ = false;
+    host_view->MarkCachedWidgetCenterStale();
     return FALSE;
   }
 
@@ -1288,6 +1287,11 @@
   // Clear the tooltip window.
   SetTooltipText(string16());
 
+  // Ensure that the widget center location will be relevant for this mouse
+  // lock session. It is updated whenever the window geometry moves
+  // but may be out of date due to switching tabs.
+  MarkCachedWidgetCenterStale();
+
   return true;
 }
 
@@ -1365,6 +1369,11 @@
   last_mouse_down_ = temp;
 }
 
+void RenderWidgetHostViewGtk::MarkCachedWidgetCenterStale() {
+  widget_center_valid_ = false;
+  mouse_has_been_warped_to_new_center_ = false;
+}
+
 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() {
   if (widget_center_valid_)
     return widget_center_;
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h
index c3d2cc2..d500a4a 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.h
@@ -200,6 +200,9 @@
 
   void set_last_mouse_down(GdkEventButton* event);
 
+  // Cause the next query for the widget center to recompute the cached value.
+  void MarkCachedWidgetCenterStale();
+
   gfx::Point GetWidgetCenter();
 
   // The model object.