Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: chrome/plugin/webplugin_proxy.cc

Issue 173552: Fix invalidates from off-screen plugins on the Mac. (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 void WebPluginProxy::Invalidate() { 124 void WebPluginProxy::Invalidate() {
125 gfx::Rect rect(0, 0, 125 gfx::Rect rect(0, 0,
126 delegate_->GetRect().width(), 126 delegate_->GetRect().width(),
127 delegate_->GetRect().height()); 127 delegate_->GetRect().height());
128 InvalidateRect(rect); 128 InvalidateRect(rect);
129 } 129 }
130 130
131 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { 131 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) {
132 damaged_rect_ = damaged_rect_.Union(rect); 132 #if defined(OS_MACOSX)
133 // Some plugins will send invalidates larger than their own rect when
134 // offscreen, so constrain invalidates to the plugin rect.
135 gfx::Rect plugin_rect = delegate_->GetRect();
136 plugin_rect.set_origin(gfx::Point(0, 0));
137 const gfx::Rect invalidate_rect(rect.Intersect(plugin_rect));
138 #else
139 const gfx::Rect invalidate_rect(rect);
140 #endif
141 damaged_rect_ = damaged_rect_.Union(invalidate_rect);
133 // Ignore NPN_InvalidateRect calls with empty rects. Also don't send an 142 // Ignore NPN_InvalidateRect calls with empty rects. Also don't send an
134 // invalidate if it's outside the clipping region, since if we did it won't 143 // invalidate if it's outside the clipping region, since if we did it won't
135 // lead to a paint and we'll be stuck waiting forever for a DidPaint response. 144 // lead to a paint and we'll be stuck waiting forever for a DidPaint response.
136 // 145 //
137 // TODO(piman): There is a race condition here, because this test assumes 146 // TODO(piman): There is a race condition here, because this test assumes
138 // that when the paint actually occurs, the clip rect will not have changed. 147 // that when the paint actually occurs, the clip rect will not have changed.
139 // This is not true because scrolling (or window resize) could occur and be 148 // This is not true because scrolling (or window resize) could occur and be
140 // handled by the renderer before it receives the InvalidateRect message, 149 // handled by the renderer before it receives the InvalidateRect message,
141 // changing the clip rect and then not painting. 150 // changing the clip rect and then not painting.
142 if (rect.IsEmpty() || !delegate_->GetClipRect().Intersects(rect)) 151 if (invalidate_rect.IsEmpty() ||
152 !delegate_->GetClipRect().Intersects(invalidate_rect))
143 return; 153 return;
144 154
145 // Only send a single InvalidateRect message at a time. From DidPaint we 155 // Only send a single InvalidateRect message at a time. From DidPaint we
146 // will dispatch an additional InvalidateRect message if necessary. 156 // will dispatch an additional InvalidateRect message if necessary.
147 if (!waiting_for_paint_) { 157 if (!waiting_for_paint_) {
148 waiting_for_paint_ = true; 158 waiting_for_paint_ = true;
149 // Invalidates caused by calls to NPN_InvalidateRect/NPN_InvalidateRgn 159 // Invalidates caused by calls to NPN_InvalidateRect/NPN_InvalidateRgn
150 // need to be painted asynchronously as per the NPAPI spec. 160 // need to be painted asynchronously as per the NPAPI spec.
151 MessageLoop::current()->PostTask(FROM_HERE, 161 MessageLoop::current()->PostTask(FROM_HERE,
152 runnable_method_factory_.NewRunnableMethod( 162 runnable_method_factory_.NewRunnableMethod(
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 while (index != resource_clients_.end()) { 652 while (index != resource_clients_.end()) {
643 WebPluginResourceClient* client = (*index).second; 653 WebPluginResourceClient* client = (*index).second;
644 654
645 if (client == resource_client) { 655 if (client == resource_client) {
646 resource_clients_.erase(index++); 656 resource_clients_.erase(index++);
647 } else { 657 } else {
648 index++; 658 index++;
649 } 659 }
650 } 660 }
651 } 661 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698