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

Side by Side Diff: webkit/glue/webplugin_impl.cc

Issue 118359: Don't call NPP_SetWindow before we have the plugin geometry. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 #include "webkit/glue/webplugin_impl.h" 6 #include "webkit/glue/webplugin_impl.h"
7 7
8 #include "Cursor.h" 8 #include "Cursor.h"
9 #include "Document.h" 9 #include "Document.h"
10 #include "DocumentLoader.h" 10 #include "DocumentLoader.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 parent()->hostWindow()->repaint(damageRect, true); 165 parent()->hostWindow()->repaint(damageRect, true);
166 } 166 }
167 } 167 }
168 168
169 void WebPluginContainer::setFocus() { 169 void WebPluginContainer::setFocus() {
170 WebCore::Widget::setFocus(); 170 WebCore::Widget::setFocus();
171 impl_->setFocus(); 171 impl_->setFocus();
172 } 172 }
173 173
174 void WebPluginContainer::show() { 174 void WebPluginContainer::show() {
175 bool old_visible = isVisible();
176 setSelfVisible(true); 175 setSelfVisible(true);
177 // We don't want to force a geometry update when the plugin widget is 176 impl_->UpdateVisibility();
178 // already visible as this involves a geometry update which may lead
179 // to unnecessary window moves in the plugin process.
180 if (old_visible != isVisible()) {
181 // This is to force an updategeometry call to the plugin process
182 // where the plugin window can be hidden or shown.
183 frameRectsChanged();
184 }
185 177
186 WebCore::Widget::show(); 178 WebCore::Widget::show();
187 } 179 }
188 180
189 void WebPluginContainer::hide() { 181 void WebPluginContainer::hide() {
190 bool old_visible = isVisible();
191 setSelfVisible(false); 182 setSelfVisible(false);
192 if (old_visible != isVisible()) { 183 impl_->UpdateVisibility();
193 // This is to force an updategeometry call to the plugin process
194 // where the plugin window can be hidden or shown.
195 frameRectsChanged();
196 }
197 184
198 WebCore::Widget::hide(); 185 WebCore::Widget::hide();
199 } 186 }
200 187
201 void WebPluginContainer::handleEvent(WebCore::Event* event) { 188 void WebPluginContainer::handleEvent(WebCore::Event* event) {
202 impl_->handleEvent(event); 189 impl_->handleEvent(event);
203 } 190 }
204 191
205 void WebPluginContainer::frameRectsChanged() { 192 void WebPluginContainer::frameRectsChanged() {
206 WebCore::Widget::frameRectsChanged(); 193 WebCore::Widget::frameRectsChanged();
207 // This is a hack to tickle re-positioning of the plugin in the case where 194 // This is a hack to tickle re-positioning of the plugin in the case where
208 // our parent view was scrolled. 195 // our parent view was scrolled.
209 impl_->setFrameRect(frameRect()); 196 impl_->setFrameRect(frameRect());
210 } 197 }
211 198
212 // We override this function, to make sure that geometry updates are sent 199 // We override this function, to make sure that geometry updates are sent
213 // over to the plugin. For e.g. when a plugin is instantiated it does 200 // over to the plugin. For e.g. when a plugin is instantiated it does
214 // not have a valid parent. As a result the first geometry update from 201 // not have a valid parent. As a result the first geometry update from
215 // webkit is ignored. This function is called when the plugin eventually 202 // webkit is ignored. This function is called when the plugin eventually
216 // gets a parent. 203 // gets a parent.
217 void WebPluginContainer::setParentVisible(bool visible) { 204 void WebPluginContainer::setParentVisible(bool visible) {
218 if (isParentVisible() == visible) 205 if (isParentVisible() == visible)
219 return; // No change. 206 return; // No change.
220 207
221 WebCore::Widget::setParentVisible(visible); 208 WebCore::Widget::setParentVisible(visible);
222 if (!isSelfVisible()) 209 if (!isSelfVisible())
223 return; // This widget has explicitely been marked as not visible. 210 return; // This widget has explicitely been marked as not visible.
224 211
225 // This is to force an updategeometry call to the plugin process 212 impl_->UpdateVisibility();
226 // where the plugin window can be hidden or shown.
227 frameRectsChanged();
228 }
229
230 // We override this function so that if the plugin is windowed, we can call
231 // NPP_SetWindow at the first possible moment. This ensures that NPP_SetWindow
232 // is called before the manual load data is sent to a plugin. If this order is
233 // reversed, Flash won't load videos.
234 void WebPluginContainer::setParent(WebCore::ScrollView* view) {
235 WebCore::Widget::setParent(view);
236 if (view) {
237 impl_->setFrameRect(frameRect());
238 }
239 } 213 }
240 214
241 void WebPluginContainer::windowCutoutRects(const WebCore::IntRect& bounds, 215 void WebPluginContainer::windowCutoutRects(const WebCore::IntRect& bounds,
242 WTF::Vector<WebCore::IntRect>* 216 WTF::Vector<WebCore::IntRect>*
243 cutouts) const { 217 cutouts) const {
244 impl_->windowCutoutRects(bounds, cutouts); 218 impl_->windowCutoutRects(bounds, cutouts);
245 } 219 }
246 220
247 void WebPluginContainer::didReceiveResponse( 221 void WebPluginContainer::didReceiveResponse(
248 const WebCore::ResourceResponse& response) { 222 const WebCore::ResourceResponse& response) {
249 set_ignore_response_error(false); 223 set_ignore_response_error(false);
250 224
225 // Manual loading, so make sure that the plugin receives window geometry
226 // before data, or else plugins misbehave.
227 frameRectsChanged();
228
251 HttpResponseInfo http_response_info; 229 HttpResponseInfo http_response_info;
252 ReadHttpResponseInfo(response, &http_response_info); 230 ReadHttpResponseInfo(response, &http_response_info);
253 231
254 impl_->delegate_->DidReceiveManualResponse( 232 impl_->delegate_->DidReceiveManualResponse(
255 http_response_info.url, 233 http_response_info.url,
256 base::SysWideToNativeMB(http_response_info.mime_type), 234 base::SysWideToNativeMB(http_response_info.mime_type),
257 base::SysWideToNativeMB(impl_->GetAllHeaders(response)), 235 base::SysWideToNativeMB(impl_->GetAllHeaders(response)),
258 http_response_info.expected_length, 236 http_response_info.expected_length,
259 http_response_info.last_modified); 237 http_response_info.last_modified);
260 } 238 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 642
665 if (window_) { 643 if (window_) {
666 // Notify the window hosting the plugin (the WebViewDelegate) that 644 // Notify the window hosting the plugin (the WebViewDelegate) that
667 // it needs to adjust the plugin, so that all the HWNDs can be moved 645 // it needs to adjust the plugin, so that all the HWNDs can be moved
668 // at the same time. 646 // at the same time.
669 WebPluginGeometry move; 647 WebPluginGeometry move;
670 move.window = window_; 648 move.window = window_;
671 move.window_rect = webkit_glue::FromIntRect(window_rect); 649 move.window_rect = webkit_glue::FromIntRect(window_rect);
672 move.clip_rect = webkit_glue::FromIntRect(clip_rect); 650 move.clip_rect = webkit_glue::FromIntRect(clip_rect);
673 move.cutout_rects = cutout_rects; 651 move.cutout_rects = cutout_rects;
652 move.rects_valid = true;
674 move.visible = widget_->isVisible(); 653 move.visible = widget_->isVisible();
675 654
676 webview->delegate()->DidMove(webview, move); 655 webview->delegate()->DidMove(webview, move);
677 } 656 }
678 657
679 // Notify the plugin that its parameters have changed. 658 // Notify the plugin that its parameters have changed.
680 delegate_->UpdateGeometry(webkit_glue::FromIntRect(window_rect), 659 delegate_->UpdateGeometry(webkit_glue::FromIntRect(window_rect),
681 webkit_glue::FromIntRect(clip_rect)); 660 webkit_glue::FromIntRect(clip_rect));
682 661
683 // Initiate a download on the plugin url. This should be done for the 662 // Initiate a download on the plugin url. This should be done for the
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 client_index = clients_.erase(client_index); 1323 client_index = clients_.erase(client_index);
1345 if (resource_client) 1324 if (resource_client)
1346 resource_client->DidFail(); 1325 resource_client->DidFail();
1347 } 1326 }
1348 1327
1349 // This needs to be called now and not in the destructor since the 1328 // This needs to be called now and not in the destructor since the
1350 // webframe_ might not be valid anymore. 1329 // webframe_ might not be valid anymore.
1351 webframe_->set_plugin_delegate(NULL); 1330 webframe_->set_plugin_delegate(NULL);
1352 webframe_ = NULL; 1331 webframe_ = NULL;
1353 } 1332 }
1333
1334 void WebPluginImpl::UpdateVisibility() {
1335 if (!window_)
1336 return;
1337
1338 WebCore::Frame* frame = element_->document()->frame();
1339 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
1340 WebViewImpl* webview = webframe->GetWebViewImpl();
1341 if (!webview->delegate())
1342 return;
1343
1344 WebPluginGeometry move;
1345 move.window = window_;
1346 move.window_rect = gfx::Rect();
1347 move.clip_rect = gfx::Rect();
1348 move.rects_valid = false;
1349 move.visible = widget_->isVisible();
1350
1351 webview->delegate()->DidMove(webview, move);
1352 }
OLDNEW
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698