| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #if defined(OS_LINUX) | 8 #if defined(OS_LINUX) |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #endif | 10 #endif |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 delegate_->GetRect().width(), | 175 delegate_->GetRect().width(), |
| 176 delegate_->GetRect().height()); | 176 delegate_->GetRect().height()); |
| 177 InvalidateRect(rect); | 177 InvalidateRect(rect); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { | 180 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { |
| 181 damaged_rect_ = damaged_rect_.Union(rect); | 181 damaged_rect_ = damaged_rect_.Union(rect); |
| 182 // Ignore NPN_InvalidateRect calls with empty rects. Also don't send an | 182 // Ignore NPN_InvalidateRect calls with empty rects. Also don't send an |
| 183 // invalidate if it's outside the clipping region, since if we did it won't | 183 // invalidate if it's outside the clipping region, since if we did it won't |
| 184 // lead to a paint and we'll be stuck waiting forever for a DidPaint response. | 184 // lead to a paint and we'll be stuck waiting forever for a DidPaint response. |
| 185 // |
| 186 // TODO(piman): There is a race condition here, because this test assumes |
| 187 // that when the paint actually occurs, the clip rect will not have changed. |
| 188 // This is not true because scrolling (or window resize) could occur and be |
| 189 // handled by the renderer before it receives the InvalidateRect message, |
| 190 // changing the clip rect and then not painting. |
| 185 if (rect.IsEmpty() || !delegate_->GetClipRect().Intersects(rect)) | 191 if (rect.IsEmpty() || !delegate_->GetClipRect().Intersects(rect)) |
| 186 return; | 192 return; |
| 187 | 193 |
| 188 // Only send a single InvalidateRect message at a time. From DidPaint we | 194 // Only send a single InvalidateRect message at a time. From DidPaint we |
| 189 // will dispatch an additional InvalidateRect message if necessary. | 195 // will dispatch an additional InvalidateRect message if necessary. |
| 190 if (!waiting_for_paint_) { | 196 if (!waiting_for_paint_) { |
| 191 waiting_for_paint_ = true; | 197 waiting_for_paint_ = true; |
| 192 // Invalidates caused by calls to NPN_InvalidateRect/NPN_InvalidateRgn | 198 // Invalidates caused by calls to NPN_InvalidateRect/NPN_InvalidateRgn |
| 193 // need to be painted asynchronously as per the NPAPI spec. | 199 // need to be painted asynchronously as per the NPAPI spec. |
| 194 MessageLoop::current()->PostTask(FROM_HERE, | 200 MessageLoop::current()->PostTask(FROM_HERE, |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 while (index != resource_clients_.end()) { | 682 while (index != resource_clients_.end()) { |
| 677 WebPluginResourceClient* client = (*index).second; | 683 WebPluginResourceClient* client = (*index).second; |
| 678 | 684 |
| 679 if (client == resource_client) { | 685 if (client == resource_client) { |
| 680 resource_clients_.erase(index++); | 686 resource_clients_.erase(index++); |
| 681 } else { | 687 } else { |
| 682 index++; | 688 index++; |
| 683 } | 689 } |
| 684 } | 690 } |
| 685 } | 691 } |
| OLD | NEW |