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

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

Issue 42413: The street view in Google maps, which is implemented with a windowed flash pl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 #if USE(JSC) 126 #if USE(JSC)
127 bool WebPluginContainer::isPluginView() const { 127 bool WebPluginContainer::isPluginView() const {
128 return true; 128 return true;
129 } 129 }
130 #endif 130 #endif
131 131
132 132
133 void WebPluginContainer::setFrameRect(const WebCore::IntRect& rect) { 133 void WebPluginContainer::setFrameRect(const WebCore::IntRect& rect) {
134 // WebKit calls move every time it paints (see RenderWidget::paint). No need 134 bool widget_dimensions_changed = (rect != frameRect());
135 // to do expensive operations if we didn't actually move.
136 if (rect == frameRect())
137 return;
138 135
139 WebCore::Widget::setFrameRect(rect); 136 if (widget_dimensions_changed)
140 impl_->setFrameRect(rect); 137 WebCore::Widget::setFrameRect(rect);
138
139 impl_->setFrameRect(rect, widget_dimensions_changed);
141 } 140 }
142 141
143 void WebPluginContainer::paint(WebCore::GraphicsContext* gc, 142 void WebPluginContainer::paint(WebCore::GraphicsContext* gc,
144 const WebCore::IntRect& damage_rect) { 143 const WebCore::IntRect& damage_rect) {
145 // In theory, we should call impl_->print(gc); when 144 // In theory, we should call impl_->print(gc); when
146 // impl_->webframe_->printing() is true but it still has placement issues so 145 // impl_->webframe_->printing() is true but it still has placement issues so
147 // keep that code off for now. 146 // keep that code off for now.
148 impl_->paint(gc, damage_rect); 147 impl_->paint(gc, damage_rect);
149 } 148 }
150 149
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 189 }
191 190
192 void WebPluginContainer::handleEvent(WebCore::Event* event) { 191 void WebPluginContainer::handleEvent(WebCore::Event* event) {
193 impl_->handleEvent(event); 192 impl_->handleEvent(event);
194 } 193 }
195 194
196 void WebPluginContainer::frameRectsChanged() { 195 void WebPluginContainer::frameRectsChanged() {
197 WebCore::Widget::frameRectsChanged(); 196 WebCore::Widget::frameRectsChanged();
198 // This is a hack to tickle re-positioning of the plugin in the case where 197 // This is a hack to tickle re-positioning of the plugin in the case where
199 // our parent view was scrolled. 198 // our parent view was scrolled.
200 impl_->setFrameRect(frameRect()); 199 impl_->setFrameRect(frameRect(), true);
201 } 200 }
202 201
203 // We override this function, to make sure that geometry updates are sent 202 // We override this function, to make sure that geometry updates are sent
204 // over to the plugin. For e.g. when a plugin is instantiated it does 203 // over to the plugin. For e.g. when a plugin is instantiated it does
205 // not have a valid parent. As a result the first geometry update from 204 // not have a valid parent. As a result the first geometry update from
206 // webkit is ignored. This function is called when the plugin eventually 205 // webkit is ignored. This function is called when the plugin eventually
207 // gets a parent. 206 // gets a parent.
208 void WebPluginContainer::setParentVisible(bool visible) { 207 void WebPluginContainer::setParentVisible(bool visible) {
209 WebCore::Widget::setParentVisible(visible); 208 WebCore::Widget::setParentVisible(visible);
210 if (visible) 209 if (visible)
211 show(); 210 show();
212 else 211 else
213 hide(); 212 hide();
214 } 213 }
215 214
216 // We override this function so that if the plugin is windowed, we can call 215 // We override this function so that if the plugin is windowed, we can call
217 // NPP_SetWindow at the first possible moment. This ensures that NPP_SetWindow 216 // NPP_SetWindow at the first possible moment. This ensures that NPP_SetWindow
218 // is called before the manual load data is sent to a plugin. If this order is 217 // is called before the manual load data is sent to a plugin. If this order is
219 // reversed, Flash won't load videos. 218 // reversed, Flash won't load videos.
220 void WebPluginContainer::setParent(WebCore::ScrollView* view) { 219 void WebPluginContainer::setParent(WebCore::ScrollView* view) {
221 WebCore::Widget::setParent(view); 220 WebCore::Widget::setParent(view);
222 if (view) { 221 if (view) {
223 impl_->setFrameRect(frameRect()); 222 impl_->setFrameRect(frameRect(), true);
224 impl_->delegate_->FlushGeometryUpdates(); 223 impl_->delegate_->FlushGeometryUpdates();
225 } 224 }
226 } 225 }
227 226
228 void WebPluginContainer::windowCutoutRects(const WebCore::IntRect& bounds, 227 void WebPluginContainer::windowCutoutRects(const WebCore::IntRect& bounds,
229 WTF::Vector<WebCore::IntRect>* 228 WTF::Vector<WebCore::IntRect>*
230 cutouts) const { 229 cutouts) const {
231 impl_->windowCutoutRects(bounds, cutouts); 230 impl_->windowCutoutRects(bounds, cutouts);
232 } 231 }
233 232
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 WebCore::IntPoint point = roundedIntPoint(ro->localToAbsolute()); 630 WebCore::IntPoint point = roundedIntPoint(ro->localToAbsolute());
632 WebCore::RenderBox* rbox = WebCore::toRenderBox(ro); 631 WebCore::RenderBox* rbox = WebCore::toRenderBox(ro);
633 WebCore::IntSize size(rbox->width(), rbox->height()); 632 WebCore::IntSize size(rbox->width(), rbox->height());
634 cutouts->append(WebCore::IntRect(point, size)); 633 cutouts->append(WebCore::IntRect(point, size));
635 } 634 }
636 } 635 }
637 } 636 }
638 } 637 }
639 } 638 }
640 639
641 void WebPluginImpl::setFrameRect(const WebCore::IntRect& rect) { 640 void WebPluginImpl::setFrameRect(const WebCore::IntRect& rect,
641 bool widget_dimensions_changed) {
642 if (!parent()) 642 if (!parent())
643 return; 643 return;
644 644
645 // Compute a new position and clip rect for ourselves relative to the 645 // Compute a new position and clip rect for ourselves relative to the
646 // containing window. We ask our delegate to reposition us accordingly. 646 // containing window. We ask our delegate to reposition us accordingly.
647 WebCore::Frame* frame = element_->document()->frame(); 647 WebCore::Frame* frame = element_->document()->frame();
648 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); 648 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
649 WebViewImpl* webview = webframe->webview_impl(); 649 WebViewImpl* webview = webframe->webview_impl();
650 // It is valid for this function to be invoked in code paths where the 650 // It is valid for this function to be invoked in code paths where the
651 // the webview is closed. 651 // the webview is closed.
652 if (!webview->delegate()) { 652 if (!webview->delegate()) {
653 return; 653 return;
654 } 654 }
655 655
656 WebCore::IntRect window_rect; 656 WebCore::IntRect window_rect;
657 WebCore::IntRect clip_rect; 657 WebCore::IntRect clip_rect;
658 std::vector<gfx::Rect> cutout_rects; 658 std::vector<gfx::Rect> cutout_rects;
659 CalculateBounds(rect, &window_rect, &clip_rect, &cutout_rects); 659 CalculateBounds(rect, &window_rect, &clip_rect, &cutout_rects);
660 660
661 delegate_->UpdateGeometry( 661 if (widget_dimensions_changed) {
662 webkit_glue::FromIntRect(window_rect), 662 delegate_->UpdateGeometry(
663 webkit_glue::FromIntRect(clip_rect)); 663 webkit_glue::FromIntRect(window_rect),
664 webkit_glue::FromIntRect(clip_rect));
665 }
664 666
665 if (window_) { 667 if (window_) {
666 // Let the WebViewDelegate know that the plugin window needs to be moved, 668 // Let the WebViewDelegate know that the plugin window needs to be moved,
667 // so that all the HWNDs are moved together. 669 // so that all the HWNDs are moved together.
668 WebPluginGeometry move; 670 WebPluginGeometry move;
669 move.window = window_; 671 move.window = window_;
670 move.window_rect = webkit_glue::FromIntRect(window_rect); 672 move.window_rect = webkit_glue::FromIntRect(window_rect);
671 move.clip_rect = webkit_glue::FromIntRect(clip_rect); 673 move.clip_rect = webkit_glue::FromIntRect(clip_rect);
672 move.cutout_rects = cutout_rects; 674 move.cutout_rects = cutout_rects;
673 move.visible = visible_; 675 move.visible = visible_;
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 client_index = clients_.erase(client_index); 1425 client_index = clients_.erase(client_index);
1424 if (resource_client) 1426 if (resource_client)
1425 resource_client->DidFail(); 1427 resource_client->DidFail();
1426 } 1428 }
1427 1429
1428 // This needs to be called now and not in the destructor since the 1430 // This needs to be called now and not in the destructor since the
1429 // webframe_ might not be valid anymore. 1431 // webframe_ might not be valid anymore.
1430 webframe_->set_plugin_delegate(NULL); 1432 webframe_->set_plugin_delegate(NULL);
1431 webframe_ = NULL; 1433 webframe_ = NULL;
1432 } 1434 }
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