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 #pragma warning(push, 0) | 7 #pragma warning(push, 0) |
8 #include "Document.h" | 8 #include "Document.h" |
9 #include "Element.h" | 9 #include "Element.h" |
10 #include "Event.h" | 10 #include "Event.h" |
11 #include "EventNames.h" | 11 #include "EventNames.h" |
12 #include "FormData.h" | 12 #include "FormData.h" |
13 #include "FocusController.h" | 13 #include "FocusController.h" |
14 #include "Frame.h" | 14 #include "Frame.h" |
15 #include "FrameLoader.h" | 15 #include "FrameLoader.h" |
16 #include "FrameLoadRequest.h" | 16 #include "FrameLoadRequest.h" |
17 #include "FrameTree.h" | 17 #include "FrameTree.h" |
18 #include "FrameView.h" | 18 #include "FrameView.h" |
19 #include "GraphicsContext.h" | 19 #include "GraphicsContext.h" |
| 20 #include "HTMLNames.h" |
20 #include "HTMLPluginElement.h" | 21 #include "HTMLPluginElement.h" |
21 #include "IntRect.h" | 22 #include "IntRect.h" |
22 #include "KURL.h" | 23 #include "KURL.h" |
23 #include "KeyboardEvent.h" | 24 #include "KeyboardEvent.h" |
24 #include "MouseEvent.h" | 25 #include "MouseEvent.h" |
25 #include "Page.h" | 26 #include "Page.h" |
26 #include "PlatformMouseEvent.h" | 27 #include "PlatformMouseEvent.h" |
27 #include "PlatformString.h" | 28 #include "PlatformString.h" |
28 #include "ResourceHandle.h" | 29 #include "ResourceHandle.h" |
29 #include "ResourceHandleClient.h" | 30 #include "ResourceHandleClient.h" |
30 #include "ResourceResponse.h" | 31 #include "ResourceResponse.h" |
31 #include "ScriptController.h" | 32 #include "ScriptController.h" |
32 #include "ScrollView.h" | 33 #include "ScrollView.h" |
33 #include "Widget.h" | 34 #include "Widget.h" |
34 #pragma warning(pop) | 35 #pragma warning(pop) |
35 #undef LOG | 36 #undef LOG |
36 | 37 |
37 #include "base/gfx/rect.h" | 38 #include "base/gfx/rect.h" |
38 #include "base/logging.h" | 39 #include "base/logging.h" |
39 #include "base/message_loop.h" | 40 #include "base/message_loop.h" |
40 #include "base/string_util.h" | 41 #include "base/string_util.h" |
41 #include "base/sys_string_conversions.h" | 42 #include "base/sys_string_conversions.h" |
42 #include "net/base/escape.h" | 43 #include "net/base/escape.h" |
43 #include "webkit/glue/glue_util.h" | 44 #include "webkit/glue/glue_util.h" |
44 #include "webkit/glue/multipart_response_delegate.h" | 45 #include "webkit/glue/multipart_response_delegate.h" |
45 #include "webkit/glue/webkit_glue.h" | 46 #include "webkit/glue/webkit_glue.h" |
46 #include "webkit/glue/webplugin_impl.h" | 47 #include "webkit/glue/webplugin_impl.h" |
47 #include "webkit/glue/plugins/plugin_host.h" | 48 #include "webkit/glue/plugins/plugin_host.h" |
48 #include "webkit/glue/plugins/plugin_instance.h" | 49 #include "webkit/glue/plugins/plugin_instance.h" |
| 50 #include "webkit/glue/stacking_order_iterator.h" |
49 #include "webkit/glue/webview_impl.h" | 51 #include "webkit/glue/webview_impl.h" |
50 #include "googleurl/src/gurl.h" | 52 #include "googleurl/src/gurl.h" |
51 #include "webkit/port/platform/cursor.h" | 53 #include "webkit/port/platform/cursor.h" |
52 | 54 |
53 // This class handles invididual multipart responses. It is instantiated when | 55 // This class handles invididual multipart responses. It is instantiated when |
54 // we receive HTTP status code 206 in the HTTP response. This indicates | 56 // we receive HTTP status code 206 in the HTTP response. This indicates |
55 // that the response could have multiple parts each separated by a boundary | 57 // that the response could have multiple parts each separated by a boundary |
56 // specified in the response header. | 58 // specified in the response header. |
57 class MultiPartResponseClient : public WebCore::ResourceHandleClient { | 59 class MultiPartResponseClient : public WebCore::ResourceHandleClient { |
58 public: | 60 public: |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 void WebPluginContainer::attachToWindow() { | 174 void WebPluginContainer::attachToWindow() { |
173 Widget::attachToWindow(); | 175 Widget::attachToWindow(); |
174 show(); | 176 show(); |
175 } | 177 } |
176 | 178 |
177 void WebPluginContainer::detachFromWindow() { | 179 void WebPluginContainer::detachFromWindow() { |
178 Widget::detachFromWindow(); | 180 Widget::detachFromWindow(); |
179 hide(); | 181 hide(); |
180 } | 182 } |
181 | 183 |
| 184 void WebPluginContainer::windowCutoutRects(WTF::Vector<WebCore::IntRect>* |
| 185 cutouts) const { |
| 186 impl_->windowCutoutRects(cutouts); |
| 187 } |
| 188 |
182 void WebPluginContainer::didReceiveResponse( | 189 void WebPluginContainer::didReceiveResponse( |
183 const WebCore::ResourceResponse& response) { | 190 const WebCore::ResourceResponse& response) { |
184 | 191 |
185 HttpResponseInfo http_response_info; | 192 HttpResponseInfo http_response_info; |
186 ReadHttpResponseInfo(response, &http_response_info); | 193 ReadHttpResponseInfo(response, &http_response_info); |
187 | 194 |
188 impl_->delegate_->DidReceiveManualResponse( | 195 impl_->delegate_->DidReceiveManualResponse( |
189 http_response_info.url, | 196 http_response_info.url, |
190 base::SysWideToNativeMB(http_response_info.mime_type), | 197 base::SysWideToNativeMB(http_response_info.mime_type), |
191 base::SysWideToNativeMB(impl_->GetAllHeaders(response)), | 198 base::SysWideToNativeMB(impl_->GetAllHeaders(response)), |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 // document()->renderer() can be NULL when we receive messages from the | 530 // document()->renderer() can be NULL when we receive messages from the |
524 // plugins while we are destroying a frame. | 531 // plugins while we are destroying a frame. |
525 if (element_->renderer()->document()->renderer()) { | 532 if (element_->renderer()->document()->renderer()) { |
526 WebCore::FrameView* parent_view = element_->document()->view(); | 533 WebCore::FrameView* parent_view = element_->document()->view(); |
527 clip_rect.intersect(parent_view->windowClipRectForLayer(layer, true)); | 534 clip_rect.intersect(parent_view->windowClipRectForLayer(layer, true)); |
528 } | 535 } |
529 | 536 |
530 return clip_rect; | 537 return clip_rect; |
531 } | 538 } |
532 | 539 |
| 540 void WebPluginImpl::windowCutoutRects( |
| 541 WTF::Vector<WebCore::IntRect>* cutouts) const { |
| 542 WebCore::RenderObject* plugin_node = element_->renderer(); |
| 543 ASSERT(plugin_node); |
| 544 |
| 545 // Find all iframes that stack higher than this plugin. |
| 546 bool higher = false; |
| 547 StackingOrderIterator iterator; |
| 548 WebCore::RenderLayer* root = element_->document()->renderer()-> |
| 549 enclosingLayer(); |
| 550 iterator.Reset(root); |
| 551 |
| 552 while (WebCore::RenderObject* ro = iterator.Next()) { |
| 553 if (ro == plugin_node) { |
| 554 // All nodes after this one are higher than plugin. |
| 555 higher = true; |
| 556 } else if (higher) { |
| 557 // Is this a visible iframe? |
| 558 WebCore::Node* n = ro->node(); |
| 559 if (n && n->hasTagName(WebCore::HTMLNames::iframeTag)) { |
| 560 if (!ro->style() || ro->style()->visibility() == WebCore::VISIBLE) { |
| 561 int x, y; |
| 562 ro->absolutePosition(x, y); |
| 563 cutouts->append(WebCore::IntRect(x, y, ro->width(), ro->height())); |
| 564 } |
| 565 } |
| 566 } |
| 567 } |
| 568 } |
| 569 |
533 void WebPluginImpl::geometryChanged() const { | 570 void WebPluginImpl::geometryChanged() const { |
534 if (!widget_) | 571 if (!widget_) |
535 return; | 572 return; |
536 | 573 |
537 // This is a hack to tickle re-positioning of the plugin in the case where | 574 // This is a hack to tickle re-positioning of the plugin in the case where |
538 // our parent view was scrolled. | 575 // our parent view was scrolled. |
539 const_cast<WebPluginImpl*>(this)->widget_->setFrameGeometry( | 576 const_cast<WebPluginImpl*>(this)->widget_->setFrameGeometry( |
540 widget_->frameGeometry()); | 577 widget_->frameGeometry()); |
541 } | 578 } |
542 | 579 |
543 void WebPluginImpl::setFrameGeometry(const WebCore::IntRect& rect) { | 580 void WebPluginImpl::setFrameGeometry(const WebCore::IntRect& rect) { |
544 // Compute a new position and clip rect for ourselves relative to the | 581 // Compute a new position and clip rect for ourselves relative to the |
545 // containing window. We ask our delegate to reposition us accordingly. | 582 // containing window. We ask our delegate to reposition us accordingly. |
546 | 583 |
547 // When the plugin is loaded we don't have a parent frame yet. We need | 584 // When the plugin is loaded we don't have a parent frame yet. We need |
548 // to force the plugin window to get created in the plugin process, | 585 // to force the plugin window to get created in the plugin process, |
549 // when the plugin widget position is updated. This occurs just after | 586 // when the plugin widget position is updated. This occurs just after |
550 // the plugin is loaded (See http://b/issue?id=892174). | 587 // the plugin is loaded (See http://b/issue?id=892174). |
551 if (!parent()) { | 588 if (!parent()) { |
552 force_geometry_update_ = true; | 589 force_geometry_update_ = true; |
553 return; | 590 return; |
554 } | 591 } |
555 | 592 |
556 WebCore::Frame* frame = element_->document()->frame(); | 593 WebCore::Frame* frame = element_->document()->frame(); |
557 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); | 594 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); |
558 WebViewImpl* webview = webframe->webview_impl(); | 595 WebViewImpl* webview = webframe->webview_impl(); |
559 // It is valid for this function to be invoked in code paths where the | 596 // It is valid for this function to be invoked in code paths where the |
560 // the webview is closed. | 597 // the webview is closed. |
561 if (!webview->delegate()) { | 598 if (!webview->delegate()) { |
562 return; | 599 return; |
563 } | 600 } |
564 | 601 |
565 WebCore::IntRect window_rect; | 602 WebCore::IntRect window_rect; |
566 WebCore::IntRect clip_rect; | 603 WebCore::IntRect clip_rect; |
567 CalculateBounds(rect, &window_rect, &clip_rect); | 604 std::vector<gfx::Rect> cutout_rects; |
| 605 CalculateBounds(rect, &window_rect, &clip_rect, &cutout_rects); |
568 | 606 |
569 if (window_ && received_first_paint_notification_) { | 607 if (window_ && received_first_paint_notification_) { |
570 // Let the WebViewDelegate know that the plugin window needs to be moved, | 608 // Let the WebViewDelegate know that the plugin window needs to be moved, |
571 // so that all the HWNDs are moved together. | 609 // so that all the HWNDs are moved together. |
572 WebPluginGeometry move; | 610 WebPluginGeometry move; |
573 move.window = window_; | 611 move.window = window_; |
574 move.window_rect = gfx::Rect(window_rect); | 612 move.window_rect = gfx::Rect(window_rect); |
575 move.clip_rect = gfx::Rect(clip_rect); | 613 move.clip_rect = gfx::Rect(clip_rect); |
| 614 move.cutout_rects = cutout_rects; |
576 move.visible = visible_; | 615 move.visible = visible_; |
| 616 |
577 webview->delegate()->DidMove(webview, move); | 617 webview->delegate()->DidMove(webview, move); |
578 } | 618 } |
579 | 619 |
580 delegate_->UpdateGeometry( | 620 delegate_->UpdateGeometry( |
581 gfx::Rect(window_rect), gfx::Rect(clip_rect), | 621 gfx::Rect(window_rect), gfx::Rect(clip_rect), cutout_rects, |
582 received_first_paint_notification_? visible_ : false); | 622 received_first_paint_notification_? visible_ : false); |
583 | 623 |
584 // delegate_ can go away as a result of above call, so check it first. | 624 // delegate_ can go away as a result of above call, so check it first. |
585 if (force_geometry_update_ && delegate_) { | 625 if (force_geometry_update_ && delegate_) { |
586 force_geometry_update_ = false; | 626 force_geometry_update_ = false; |
587 delegate_->FlushGeometryUpdates(); | 627 delegate_->FlushGeometryUpdates(); |
588 } | 628 } |
589 } | 629 } |
590 | 630 |
591 void WebPluginImpl::paint(WebCore::GraphicsContext* gc, | 631 void WebPluginImpl::paint(WebCore::GraphicsContext* gc, |
(...skipping 14 matching lines...) Expand all Loading... |
606 // it becomes visible. | 646 // it becomes visible. |
607 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=18901 for more | 647 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=18901 for more |
608 // details on this issue. | 648 // details on this issue. |
609 // TODO(iyengar): Remove this hack when this issue is fixed in webkit. | 649 // TODO(iyengar): Remove this hack when this issue is fixed in webkit. |
610 if (!received_first_paint_notification_) { | 650 if (!received_first_paint_notification_) { |
611 received_first_paint_notification_ = true; | 651 received_first_paint_notification_ = true; |
612 | 652 |
613 if (!windowless_) { | 653 if (!windowless_) { |
614 WebCore::IntRect window_rect; | 654 WebCore::IntRect window_rect; |
615 WebCore::IntRect clip_rect; | 655 WebCore::IntRect clip_rect; |
| 656 std::vector<gfx::Rect> cutout_rects; |
616 | 657 |
617 CalculateBounds(widget_->frameGeometry(), &window_rect, &clip_rect); | 658 CalculateBounds(widget_->frameGeometry(), &window_rect, &clip_rect, |
| 659 &cutout_rects); |
618 | 660 |
619 delegate_->UpdateGeometry(gfx::Rect(window_rect), gfx::Rect(clip_rect), | 661 delegate_->UpdateGeometry(gfx::Rect(window_rect), gfx::Rect(clip_rect), |
620 visible_); | 662 cutout_rects, visible_); |
621 delegate_->FlushGeometryUpdates(); | 663 delegate_->FlushGeometryUpdates(); |
622 } | 664 } |
623 } | 665 } |
624 | 666 |
625 gc->save(); | 667 gc->save(); |
626 | 668 |
627 DCHECK(parent()->isFrameView()); | 669 DCHECK(parent()->isFrameView()); |
628 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); | 670 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); |
629 | 671 |
630 // The plugin is positioned in window coordinates, so it needs to be painted | 672 // The plugin is positioned in window coordinates, so it needs to be painted |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 | 1032 |
991 WebCore::ScrollView* WebPluginImpl::parent() const { | 1033 WebCore::ScrollView* WebPluginImpl::parent() const { |
992 if (widget_) | 1034 if (widget_) |
993 return widget_->parent(); | 1035 return widget_->parent(); |
994 | 1036 |
995 return NULL; | 1037 return NULL; |
996 } | 1038 } |
997 | 1039 |
998 void WebPluginImpl::CalculateBounds(const WebCore::IntRect& frame_rect, | 1040 void WebPluginImpl::CalculateBounds(const WebCore::IntRect& frame_rect, |
999 WebCore::IntRect* window_rect, | 1041 WebCore::IntRect* window_rect, |
1000 WebCore::IntRect* clip_rect) { | 1042 WebCore::IntRect* clip_rect, |
| 1043 std::vector<gfx::Rect>* cutout_rects) { |
1001 DCHECK(parent()->isFrameView()); | 1044 DCHECK(parent()->isFrameView()); |
1002 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); | 1045 WebCore::FrameView* view = static_cast<WebCore::FrameView*>(parent()); |
1003 | 1046 |
1004 *window_rect = | 1047 *window_rect = |
1005 WebCore::IntRect(view->contentsToWindow(frame_rect.location()), | 1048 WebCore::IntRect(view->contentsToWindow(frame_rect.location()), |
1006 frame_rect.size()); | 1049 frame_rect.size()); |
1007 // Calculate a clip-rect so that we don't overlap the scrollbars, etc. | 1050 // Calculate a clip-rect so that we don't overlap the scrollbars, etc. |
1008 *clip_rect = widget_->windowClipRect(); | 1051 *clip_rect = widget_->windowClipRect(); |
1009 clip_rect->move(-window_rect->x(), -window_rect->y()); | 1052 clip_rect->move(-window_rect->x(), -window_rect->y()); |
| 1053 |
| 1054 cutout_rects->clear(); |
| 1055 WTF::Vector<WebCore::IntRect> rects; |
| 1056 widget_->windowCutoutRects(&rects); |
| 1057 // Convert to gfx::Rect and subtract out the plugin position. |
| 1058 for (size_t i = 0; i < rects.size(); i++) { |
| 1059 gfx::Rect r(rects[i]); |
| 1060 r.Offset(-frame_rect.x(), -frame_rect.y()); |
| 1061 cutout_rects->push_back(r); |
| 1062 } |
1010 } | 1063 } |
1011 | 1064 |
1012 void WebPluginImpl::HandleURLRequest(const char *method, | 1065 void WebPluginImpl::HandleURLRequest(const char *method, |
1013 bool is_javascript_url, | 1066 bool is_javascript_url, |
1014 const char* target, unsigned int len, | 1067 const char* target, unsigned int len, |
1015 const char* buf, bool is_file_data, | 1068 const char* buf, bool is_file_data, |
1016 bool notify, const char* url, | 1069 bool notify, const char* url, |
1017 void* notify_data, bool popups_allowed) { | 1070 void* notify_data, bool popups_allowed) { |
1018 // For this request, we either route the output to a frame | 1071 // For this request, we either route the output to a frame |
1019 // because a target has been specified, or we handle the request | 1072 // because a target has been specified, or we handle the request |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 | 1212 |
1160 MultiPartResponseClient* multi_part_response_client = | 1213 MultiPartResponseClient* multi_part_response_client = |
1161 new MultiPartResponseClient(client); | 1214 new MultiPartResponseClient(client); |
1162 | 1215 |
1163 MultipartResponseDelegate* multi_part_response_handler = | 1216 MultipartResponseDelegate* multi_part_response_handler = |
1164 new MultipartResponseDelegate(multi_part_response_client, NULL, | 1217 new MultipartResponseDelegate(multi_part_response_client, NULL, |
1165 response, | 1218 response, |
1166 multipart_boundary); | 1219 multipart_boundary); |
1167 multi_part_response_map_[client] = multi_part_response_handler; | 1220 multi_part_response_map_[client] = multi_part_response_handler; |
1168 } | 1221 } |
OLD | NEW |