Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 6 |
| 7 #include "Document.h" | 7 #include "Document.h" |
| 8 #include "DocumentLoader.h" | 8 #include "DocumentLoader.h" |
| 9 #include "Event.h" | 9 #include "Event.h" |
| 10 #include "EventNames.h" | 10 #include "EventNames.h" |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 // containing window. We ask our delegate to reposition us accordingly. | 720 // containing window. We ask our delegate to reposition us accordingly. |
| 721 WebCore::Frame* frame = element_->document()->frame(); | 721 WebCore::Frame* frame = element_->document()->frame(); |
| 722 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); | 722 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); |
| 723 WebViewImpl* webview = webframe->GetWebViewImpl(); | 723 WebViewImpl* webview = webframe->GetWebViewImpl(); |
| 724 // It is valid for this function to be invoked in code paths where the | 724 // It is valid for this function to be invoked in code paths where the |
| 725 // the webview is closed. | 725 // the webview is closed. |
| 726 if (!webview->delegate()) { | 726 if (!webview->delegate()) { |
| 727 return; | 727 return; |
| 728 } | 728 } |
| 729 | 729 |
| 730 WebCore::IntRect window_rect; | 730 gfx::Rect window_rect; |
| 731 WebCore::IntRect clip_rect; | 731 gfx::Rect clip_rect; |
| 732 std::vector<gfx::Rect> cutout_rects; | 732 std::vector<gfx::Rect> cutout_rects; |
| 733 CalculateBounds(rect, &window_rect, &clip_rect, &cutout_rects); | 733 CalculateBounds(rect, &window_rect, &clip_rect, &cutout_rects); |
| 734 | 734 |
| 735 if (window_) { | 735 if (window_) { |
| 736 // Notify the window hosting the plugin (the WebViewDelegate) that | 736 // Notify the window hosting the plugin (the WebViewDelegate) that |
| 737 // it needs to adjust the plugin, so that all the HWNDs can be moved | 737 // it needs to adjust the plugin, so that all the HWNDs can be moved |
| 738 // at the same time. | 738 // at the same time. |
| 739 WebPluginGeometry move; | 739 WebPluginGeometry move; |
| 740 move.window = window_; | 740 move.window = window_; |
| 741 move.window_rect = webkit_glue::FromIntRect(window_rect); | 741 move.window_rect = window_rect; |
| 742 move.clip_rect = webkit_glue::FromIntRect(clip_rect); | 742 move.clip_rect = clip_rect; |
| 743 move.cutout_rects = cutout_rects; | 743 move.cutout_rects = cutout_rects; |
| 744 move.rects_valid = true; | 744 move.rects_valid = true; |
| 745 move.visible = widget_->isVisible(); | 745 move.visible = widget_->isVisible(); |
| 746 | 746 |
| 747 webview->delegate()->DidMovePlugin(move); | 747 webview->delegate()->DidMovePlugin(move); |
| 748 } | 748 } |
| 749 | 749 |
| 750 // Notify the plugin that its parameters have changed. | 750 if (first_geometry_update_ || window_rect != window_rect_ || |
|
jam
2009/08/06 18:20:39
This code is pretty fragile, we went through a lot
| |
| 751 delegate_->UpdateGeometry(webkit_glue::FromIntRect(window_rect), | 751 clip_rect != clip_rect_) { |
| 752 webkit_glue::FromIntRect(clip_rect)); | 752 window_rect_ = window_rect; |
| 753 clip_rect_ = clip_rect; | |
| 754 // Notify the plugin that its parameters have changed. | |
| 755 delegate_->UpdateGeometry(window_rect_, clip_rect_); | |
| 753 | 756 |
| 754 // Initiate a download on the plugin url. This should be done for the | 757 // Initiate a download on the plugin url. This should be done for the |
| 755 // first update geometry sequence. We need to ensure that the plugin | 758 // first update geometry sequence. We need to ensure that the plugin |
| 756 // receives the geometry update before it starts receiving data. | 759 // receives the geometry update before it starts receiving data. |
| 757 if (first_geometry_update_) { | 760 if (first_geometry_update_) { |
| 758 first_geometry_update_ = false; | 761 first_geometry_update_ = false; |
| 759 // An empty url corresponds to an EMBED tag with no src attribute. | 762 // An empty url corresponds to an EMBED tag with no src attribute. |
| 760 if (!load_manually_ && plugin_url_.is_valid()) { | 763 if (!load_manually_ && plugin_url_.is_valid()) { |
| 761 // The Flash plugin hangs for a while if it receives data before | 764 // The Flash plugin hangs for a while if it receives data before |
| 762 // receiving valid plugin geometry. By valid geometry we mean the | 765 // receiving valid plugin geometry. By valid geometry we mean the |
| 763 // geometry received by a call to setFrameRect in the Webkit | 766 // geometry received by a call to setFrameRect in the Webkit |
| 764 // layout code path. To workaround this issue we download the | 767 // layout code path. To workaround this issue we download the |
| 765 // plugin source url on a timer. | 768 // plugin source url on a timer. |
| 766 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 769 MessageLoop::current()->PostDelayedTask( |
| 767 method_factory_.NewRunnableMethod( | 770 FROM_HERE, method_factory_.NewRunnableMethod( |
| 768 &WebPluginImpl::OnDownloadPluginSrcUrl), | 771 &WebPluginImpl::OnDownloadPluginSrcUrl), 0); |
| 769 0); | 772 } |
| 770 } | 773 } |
| 771 } | 774 } |
| 772 } | 775 } |
| 773 | 776 |
| 774 void WebPluginImpl::OnDownloadPluginSrcUrl() { | 777 void WebPluginImpl::OnDownloadPluginSrcUrl() { |
| 775 HandleURLRequestInternal("GET", false, NULL, 0, NULL, false, false, | 778 HandleURLRequestInternal("GET", false, NULL, 0, NULL, false, false, |
| 776 plugin_url_.spec().c_str(), NULL, false, | 779 plugin_url_.spec().c_str(), NULL, false, |
| 777 false); | 780 false); |
| 778 } | 781 } |
| 779 | 782 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1112 } | 1115 } |
| 1113 | 1116 |
| 1114 WebCore::ScrollView* WebPluginImpl::parent() const { | 1117 WebCore::ScrollView* WebPluginImpl::parent() const { |
| 1115 if (widget_) | 1118 if (widget_) |
| 1116 return widget_->parent(); | 1119 return widget_->parent(); |
| 1117 | 1120 |
| 1118 return NULL; | 1121 return NULL; |
| 1119 } | 1122 } |
| 1120 | 1123 |
| 1121 void WebPluginImpl::CalculateBounds(const WebCore::IntRect& frame_rect, | 1124 void WebPluginImpl::CalculateBounds(const WebCore::IntRect& frame_rect, |
| 1122 WebCore::IntRect* window_rect, | 1125 gfx::Rect* window_rect, |
| 1123 WebCore::IntRect* clip_rect, | 1126 gfx::Rect* clip_rect, |
| 1124 std::vector<gfx::Rect>* cutout_rects) { | 1127 std::vector<gfx::Rect>* cutout_rects) { |
| 1125 DCHECK(parent()->isFrameView()); | 1128 DCHECK(parent()->isFrameView()); |
| 1126 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); | 1129 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); |
| 1127 | 1130 |
| 1128 *window_rect = | 1131 WebCore::IntRect web_window_rect = |
| 1129 WebCore::IntRect(view->contentsToWindow(frame_rect.location()), | 1132 WebCore::IntRect(view->contentsToWindow(frame_rect.location()), |
| 1130 frame_rect.size()); | 1133 frame_rect.size()); |
| 1134 *window_rect = webkit_glue::FromIntRect(web_window_rect); | |
| 1131 // Calculate a clip-rect so that we don't overlap the scrollbars, etc. | 1135 // Calculate a clip-rect so that we don't overlap the scrollbars, etc. |
| 1132 *clip_rect = windowClipRect(); | 1136 *clip_rect = webkit_glue::FromIntRect(windowClipRect()); |
| 1133 clip_rect->move(-window_rect->x(), -window_rect->y()); | 1137 clip_rect->Offset(-window_rect->x(), -window_rect->y()); |
| 1134 | 1138 |
| 1135 cutout_rects->clear(); | 1139 cutout_rects->clear(); |
| 1136 WTF::Vector<WebCore::IntRect> rects; | 1140 WTF::Vector<WebCore::IntRect> rects; |
| 1137 widget_->windowCutoutRects(frame_rect, &rects); | 1141 widget_->windowCutoutRects(frame_rect, &rects); |
| 1138 // Convert to gfx::Rect and subtract out the plugin position. | 1142 // Convert to gfx::Rect and subtract out the plugin position. |
| 1139 for (size_t i = 0; i < rects.size(); i++) { | 1143 for (size_t i = 0; i < rects.size(); i++) { |
| 1140 gfx::Rect r = webkit_glue::FromIntRect(rects[i]); | 1144 gfx::Rect r = webkit_glue::FromIntRect(rects[i]); |
| 1141 r.Offset(-frame_rect.x(), -frame_rect.y()); | 1145 r.Offset(-frame_rect.x(), -frame_rect.y()); |
| 1142 cutout_rects->push_back(r); | 1146 cutout_rects->push_back(r); |
| 1143 } | 1147 } |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1461 | 1465 |
| 1462 WebPluginGeometry move; | 1466 WebPluginGeometry move; |
| 1463 move.window = window_; | 1467 move.window = window_; |
| 1464 move.window_rect = gfx::Rect(); | 1468 move.window_rect = gfx::Rect(); |
| 1465 move.clip_rect = gfx::Rect(); | 1469 move.clip_rect = gfx::Rect(); |
| 1466 move.rects_valid = false; | 1470 move.rects_valid = false; |
| 1467 move.visible = widget_->isVisible(); | 1471 move.visible = widget_->isVisible(); |
| 1468 | 1472 |
| 1469 webview->delegate()->DidMovePlugin(move); | 1473 webview->delegate()->DidMovePlugin(move); |
| 1470 } | 1474 } |
| OLD | NEW |