Avoid sending empty OnRepaint msgs and propagate window damage correctly

This fixes two issues related to OnRepaint (window damage) messages:

1.) In the case of a renderer-resized widget, the browser's information about
the size of the widget could be out of date. If the browser widget was asked to
paint in compositing mode before it received the proper size it could send a
ViewMsg_OnRepaint with 0x0 size and then set repaint_ack_pending_, expecting the
renderer to reply. The renderer wasn't actually replying with a frame since
damaging a 0x0 rect doesn't actually require painting anything. This suppresses
sending the OnRepaint message if the browser's size is 0x0. Either the size will
at some point become 0x0, triggering a repaint, or the user will never see it.

2.) In compositing mode on the renderer side we weren't plumbing the OnRepaint
window damage rect properly in to the compositor. Thus the compositor could end
up not producing a frame after receiving an OnRepaint message, confusing the
browser rate limiting logic greatly.

BUG=230766

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194510 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index f58b8a0..01f9089 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1871,16 +1871,20 @@
   return true;
 }
 
-void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) {
+void RenderWidget::OnRepaint(gfx::Size size_to_paint) {
   // During shutdown we can just ignore this message.
   if (!webwidget_)
     return;
 
+  // Even if the browser provides an empty damage rect, it's still expecting to
+  // receive a repaint ack so just damage the entire widget bounds.
+  if (size_to_paint.IsEmpty()) {
+    size_to_paint = size_;
+  }
+
   set_next_paint_is_repaint_ack();
-  if (is_accelerated_compositing_active_) {
-    if (compositor_)
-      compositor_->setNeedsRedraw();
-    scheduleComposite();
+  if (is_accelerated_compositing_active_ && compositor_) {
+    compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint));
   } else {
     gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
     didInvalidateRect(repaint_rect);