| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 #include "public/web/WebPlugin.h" | 105 #include "public/web/WebPlugin.h" |
| 106 #include "public/web/WebPrintParams.h" | 106 #include "public/web/WebPrintParams.h" |
| 107 #include "public/web/WebPrintPresetOptions.h" | 107 #include "public/web/WebPrintPresetOptions.h" |
| 108 #include "public/web/WebViewClient.h" | 108 #include "public/web/WebViewClient.h" |
| 109 | 109 |
| 110 namespace blink { | 110 namespace blink { |
| 111 | 111 |
| 112 // Public methods -------------------------------------------------------------- | 112 // Public methods -------------------------------------------------------------- |
| 113 | 113 |
| 114 void WebPluginContainerImpl::SetParent(FrameView* parent) { | 114 void WebPluginContainerImpl::SetParent(FrameView* parent) { |
| 115 if (parent) { |
| 116 SetFrameOrPluginState(kAttached); |
| 117 DCHECK(parent == ParentFrameView()); |
| 118 } |
| 119 if (!parent) { |
| 120 DCHECK(plugin_state_ == kAttached || |
| 121 (plugin_state_ == kDisposed && parent_)); |
| 122 SetFrameOrPluginState(kNotAttached); |
| 123 } |
| 124 |
| 115 DCHECK(!parent || !parent_); | 125 DCHECK(!parent || !parent_); |
| 116 if (!parent || !parent->IsVisible()) | 126 if (!parent || !parent->IsVisible()) |
| 117 SetParentVisible(false); | 127 SetParentVisible(false); |
| 118 parent_ = parent; | 128 parent_ = parent; |
| 119 if (parent && parent->IsVisible()) | 129 if (parent && parent->IsVisible()) |
| 120 SetParentVisible(true); | 130 SetParentVisible(true); |
| 121 } | 131 } |
| 122 | 132 |
| 133 FrameView* WebPluginContainerImpl::Parent() const { |
| 134 if ((plugin_state_ == kAttached || plugin_state_ == kNotAttached) && |
| 135 element_->GetDocument().GetFrame()) |
| 136 DCHECK(ParentFrameView() == parent_); |
| 137 |
| 138 return parent_; |
| 139 } |
| 140 |
| 141 FrameView* WebPluginContainerImpl::ParentFrameView() const { |
| 142 if (plugin_state_ != kAttached) |
| 143 return nullptr; |
| 144 |
| 145 LocalFrame* frame = element_->GetDocument().GetFrame(); |
| 146 if (!frame) |
| 147 return nullptr; |
| 148 |
| 149 return frame->View(); |
| 150 } |
| 151 |
| 152 void WebPluginContainerImpl::SetFrameOrPluginState(FrameOrPluginState state) { |
| 153 VLOG(1) << "SetFrameOrPluginState " << this << " " << plugin_state_ << "->" |
| 154 << state; |
| 155 if (VLOG_IS_ON(2)) |
| 156 base::debug::StackTrace(10).Print(); |
| 157 switch (state) { |
| 158 case kNotAttached: |
| 159 DCHECK(plugin_state_ == kAttached); |
| 160 break; |
| 161 case kAttached: |
| 162 DCHECK(plugin_state_ == kNotAttached); |
| 163 break; |
| 164 case kDeferred: |
| 165 DCHECK(plugin_state_ == kNotAttached || plugin_state_ == kAttached || |
| 166 plugin_state_ == kDeferred); |
| 167 break; |
| 168 case kDisposed: |
| 169 DCHECK(plugin_state_ == kNotAttached || plugin_state_ == kAttached || |
| 170 plugin_state_ == kDeferred || plugin_state_ == kDisposed); |
| 171 break; |
| 172 default: |
| 173 NOTREACHED(); |
| 174 } |
| 175 plugin_state_ = state; |
| 176 } |
| 177 |
| 123 void WebPluginContainerImpl::UpdateAllLifecyclePhases() { | 178 void WebPluginContainerImpl::UpdateAllLifecyclePhases() { |
| 124 if (!web_plugin_) | 179 if (!web_plugin_) |
| 125 return; | 180 return; |
| 126 | 181 |
| 127 web_plugin_->UpdateAllLifecyclePhases(); | 182 web_plugin_->UpdateAllLifecyclePhases(); |
| 128 } | 183 } |
| 129 | 184 |
| 130 void WebPluginContainerImpl::Paint(GraphicsContext& context, | 185 void WebPluginContainerImpl::Paint(GraphicsContext& context, |
| 131 const CullRect& cull_rect) const { | 186 const CullRect& cull_rect) const { |
| 132 if (!parent_) | 187 DCHECK(plugin_state_ == kAttached); |
| 188 FrameView* parent = ParentFrameView(); |
| 189 if (!parent) |
| 133 return; | 190 return; |
| 134 | 191 |
| 135 // Don't paint anything if the plugin doesn't intersect. | 192 // Don't paint anything if the plugin doesn't intersect. |
| 136 if (!cull_rect.IntersectsCullRect(frame_rect_)) | 193 if (!cull_rect.IntersectsCullRect(frame_rect_)) |
| 137 return; | 194 return; |
| 138 | 195 |
| 139 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && web_layer_) { | 196 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && web_layer_) { |
| 140 // With Slimming Paint v2, composited plugins should have their layers | 197 // With Slimming Paint v2, composited plugins should have their layers |
| 141 // inserted rather than invoking WebPlugin::paint. | 198 // inserted rather than invoking WebPlugin::paint. |
| 142 RecordForeignLayer(context, *element_->GetLayoutObject(), | 199 RecordForeignLayer(context, *element_->GetLayoutObject(), |
| 143 DisplayItem::kForeignLayerPlugin, web_layer_, | 200 DisplayItem::kForeignLayerPlugin, web_layer_, |
| 144 frame_rect_.Location(), frame_rect_.Size()); | 201 frame_rect_.Location(), frame_rect_.Size()); |
| 145 return; | 202 return; |
| 146 } | 203 } |
| 147 | 204 |
| 148 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( | 205 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( |
| 149 context, *element_->GetLayoutObject(), DisplayItem::Type::kWebPlugin)) | 206 context, *element_->GetLayoutObject(), DisplayItem::Type::kWebPlugin)) |
| 150 return; | 207 return; |
| 151 | 208 |
| 152 LayoutObjectDrawingRecorder drawing_recorder( | 209 LayoutObjectDrawingRecorder drawing_recorder( |
| 153 context, *element_->GetLayoutObject(), DisplayItem::Type::kWebPlugin, | 210 context, *element_->GetLayoutObject(), DisplayItem::Type::kWebPlugin, |
| 154 cull_rect.rect_); | 211 cull_rect.rect_); |
| 155 context.Save(); | 212 context.Save(); |
| 156 | 213 |
| 157 // The plugin is positioned in the root frame's coordinates, so it needs to | 214 // The plugin is positioned in the root frame's coordinates, so it needs to |
| 158 // be painted in them too. | 215 // be painted in them too. |
| 159 IntPoint origin = parent_->ContentsToRootFrame(IntPoint(0, 0)); | 216 IntPoint origin = parent->ContentsToRootFrame(IntPoint(0, 0)); |
| 160 context.Translate(static_cast<float>(-origin.X()), | 217 context.Translate(static_cast<float>(-origin.X()), |
| 161 static_cast<float>(-origin.Y())); | 218 static_cast<float>(-origin.Y())); |
| 162 | 219 |
| 163 WebCanvas* canvas = context.Canvas(); | 220 WebCanvas* canvas = context.Canvas(); |
| 164 | 221 |
| 165 IntRect window_rect = parent_->ContentsToRootFrame(cull_rect.rect_); | 222 IntRect window_rect = parent->ContentsToRootFrame(cull_rect.rect_); |
| 166 web_plugin_->Paint(canvas, window_rect); | 223 web_plugin_->Paint(canvas, window_rect); |
| 167 | 224 |
| 168 context.Restore(); | 225 context.Restore(); |
| 169 } | 226 } |
| 170 | 227 |
| 171 void WebPluginContainerImpl::InvalidateRect(const IntRect& rect) { | 228 void WebPluginContainerImpl::InvalidateRect(const IntRect& rect) { |
| 172 if (!parent_) | 229 // TODO(joelhockey): Usually parent should only be called when attached, |
| 230 // but this is also called in state kDisposed in Dispose. |
| 231 // Also called in state kDeferred in plugins/tabindex.html |
| 232 DCHECK(plugin_state_ == kAttached || plugin_state_ == kDeferred || |
| 233 plugin_state_ == kDisposed); |
| 234 FrameView* parent = ParentFrameView(); |
| 235 if (!parent) |
| 173 return; | 236 return; |
| 174 | 237 |
| 175 LayoutBox* layout_object = ToLayoutBox(element_->GetLayoutObject()); | 238 LayoutBox* layout_object = ToLayoutBox(element_->GetLayoutObject()); |
| 176 if (!layout_object) | 239 if (!layout_object) |
| 177 return; | 240 return; |
| 178 | 241 |
| 179 IntRect dirty_rect = rect; | 242 IntRect dirty_rect = rect; |
| 180 dirty_rect.Move( | 243 dirty_rect.Move( |
| 181 (layout_object->BorderLeft() + layout_object->PaddingLeft()).ToInt(), | 244 (layout_object->BorderLeft() + layout_object->PaddingLeft()).ToInt(), |
| 182 (layout_object->BorderTop() + layout_object->PaddingTop()).ToInt()); | 245 (layout_object->BorderTop() + layout_object->PaddingTop()).ToInt()); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 void WebPluginContainerImpl::ScrollRect(const WebRect& rect) { | 487 void WebPluginContainerImpl::ScrollRect(const WebRect& rect) { |
| 425 InvalidateRect(rect); | 488 InvalidateRect(rect); |
| 426 } | 489 } |
| 427 | 490 |
| 428 void WebPluginContainerImpl::ScheduleAnimation() { | 491 void WebPluginContainerImpl::ScheduleAnimation() { |
| 429 if (auto* frame_view = element_->GetDocument().View()) | 492 if (auto* frame_view = element_->GetDocument().View()) |
| 430 frame_view->ScheduleAnimation(); | 493 frame_view->ScheduleAnimation(); |
| 431 } | 494 } |
| 432 | 495 |
| 433 void WebPluginContainerImpl::ReportGeometry() { | 496 void WebPluginContainerImpl::ReportGeometry() { |
| 497 DCHECK(plugin_state_ == kAttached); |
| 498 FrameView* parent = ParentFrameView(); |
| 434 // We cannot compute geometry without a parent or layoutObject. | 499 // We cannot compute geometry without a parent or layoutObject. |
| 435 if (!parent_ || !element_ || !element_->GetLayoutObject() || !web_plugin_) | 500 if (!parent || !element_ || !element_->GetLayoutObject() || !web_plugin_) |
| 436 return; | 501 return; |
| 437 | 502 |
| 438 IntRect window_rect, clip_rect, unobscured_rect; | 503 IntRect window_rect, clip_rect, unobscured_rect; |
| 439 CalculateGeometry(window_rect, clip_rect, unobscured_rect); | 504 CalculateGeometry(window_rect, clip_rect, unobscured_rect); |
| 440 web_plugin_->UpdateGeometry(window_rect, clip_rect, unobscured_rect, | 505 web_plugin_->UpdateGeometry(window_rect, clip_rect, unobscured_rect, |
| 441 self_visible_); | 506 self_visible_); |
| 442 } | 507 } |
| 443 | 508 |
| 444 v8::Local<v8::Object> WebPluginContainerImpl::V8ObjectForElement() { | 509 v8::Local<v8::Object> WebPluginContainerImpl::V8ObjectForElement() { |
| 445 LocalFrame* frame = element_->GetDocument().GetFrame(); | 510 LocalFrame* frame = element_->GetDocument().GetFrame(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 EventHandlerRegistry::kWheelEventBlocking); | 633 EventHandlerRegistry::kWheelEventBlocking); |
| 569 else | 634 else |
| 570 registry.DidRemoveEventHandler(*element_, | 635 registry.DidRemoveEventHandler(*element_, |
| 571 EventHandlerRegistry::kWheelEventBlocking); | 636 EventHandlerRegistry::kWheelEventBlocking); |
| 572 } | 637 } |
| 573 | 638 |
| 574 wants_wheel_events_ = wants_wheel_events; | 639 wants_wheel_events_ = wants_wheel_events; |
| 575 if (Page* page = element_->GetDocument().GetPage()) { | 640 if (Page* page = element_->GetDocument().GetPage()) { |
| 576 if (ScrollingCoordinator* scrolling_coordinator = | 641 if (ScrollingCoordinator* scrolling_coordinator = |
| 577 page->GetScrollingCoordinator()) { | 642 page->GetScrollingCoordinator()) { |
| 578 if (parent_) | 643 // TODO(joelhockey): Usually parent should only be called when in state |
| 644 // kAttached, but this is called by TestPlugin::Initialize in state |
| 645 // kNotAttached. |
| 646 // Called in state kDisposed in plugins/re-request-touch-events-crash.html |
| 647 DCHECK(plugin_state_ == kNotAttached || plugin_state_ == kAttached || |
| 648 plugin_state_ == kDisposed); |
| 649 FrameView* parent = ParentFrameView(); |
| 650 if (parent) |
| 579 scrolling_coordinator->NotifyGeometryChanged(); | 651 scrolling_coordinator->NotifyGeometryChanged(); |
| 580 } | 652 } |
| 581 } | 653 } |
| 582 } | 654 } |
| 583 | 655 |
| 584 WebPoint WebPluginContainerImpl::RootFrameToLocalPoint( | 656 WebPoint WebPluginContainerImpl::RootFrameToLocalPoint( |
| 585 const WebPoint& point_in_root_frame) { | 657 const WebPoint& point_in_root_frame) { |
| 586 if (!parent_) | 658 DCHECK(plugin_state_ == kAttached); |
| 659 FrameView* parent = ParentFrameView(); |
| 660 if (!parent) |
| 587 return point_in_root_frame; | 661 return point_in_root_frame; |
| 588 WebPoint point_in_content = parent_->RootFrameToContents(point_in_root_frame); | 662 WebPoint point_in_content = parent->RootFrameToContents(point_in_root_frame); |
| 589 return RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 663 return RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 590 FloatPoint(point_in_content), kUseTransforms)); | 664 FloatPoint(point_in_content), kUseTransforms)); |
| 591 } | 665 } |
| 592 | 666 |
| 593 WebPoint WebPluginContainerImpl::LocalToRootFramePoint( | 667 WebPoint WebPluginContainerImpl::LocalToRootFramePoint( |
| 594 const WebPoint& point_in_local) { | 668 const WebPoint& point_in_local) { |
| 595 if (!parent_) | 669 DCHECK(plugin_state_ == kAttached); |
| 670 FrameView* parent = ParentFrameView(); |
| 671 if (!parent) |
| 596 return point_in_local; | 672 return point_in_local; |
| 597 IntPoint absolute_point = | 673 IntPoint absolute_point = |
| 598 RoundedIntPoint(element_->GetLayoutObject()->LocalToAbsolute( | 674 RoundedIntPoint(element_->GetLayoutObject()->LocalToAbsolute( |
| 599 FloatPoint(point_in_local), kUseTransforms)); | 675 FloatPoint(point_in_local), kUseTransforms)); |
| 600 return parent_->ContentsToRootFrame(absolute_point); | 676 return parent->ContentsToRootFrame(absolute_point); |
| 601 } | 677 } |
| 602 | 678 |
| 603 void WebPluginContainerImpl::DidReceiveResponse( | 679 void WebPluginContainerImpl::DidReceiveResponse( |
| 604 const ResourceResponse& response) { | 680 const ResourceResponse& response) { |
| 605 // Make sure that the plugin receives window geometry before data, or else | 681 // Make sure that the plugin receives window geometry before data, or else |
| 606 // plugins misbehave. | 682 // plugins misbehave. |
| 607 FrameRectsChanged(); | 683 FrameRectsChanged(); |
| 608 | 684 |
| 609 WrappedResourceResponse url_response(response); | 685 WrappedResourceResponse url_response(response); |
| 610 web_plugin_->DidReceiveResponse(url_response); | 686 web_plugin_->DidReceiveResponse(url_response); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 735 |
| 660 bool WebPluginContainerImpl::WantsWheelEvents() { | 736 bool WebPluginContainerImpl::WantsWheelEvents() { |
| 661 return wants_wheel_events_; | 737 return wants_wheel_events_; |
| 662 } | 738 } |
| 663 | 739 |
| 664 // Private methods ------------------------------------------------------------- | 740 // Private methods ------------------------------------------------------------- |
| 665 | 741 |
| 666 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, | 742 WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, |
| 667 WebPlugin* web_plugin) | 743 WebPlugin* web_plugin) |
| 668 : ContextClient(element->GetDocument().GetFrame()), | 744 : ContextClient(element->GetDocument().GetFrame()), |
| 745 parent_(nullptr), |
| 746 plugin_state_(kNotAttached), |
| 669 element_(element), | 747 element_(element), |
| 670 web_plugin_(web_plugin), | 748 web_plugin_(web_plugin), |
| 671 web_layer_(nullptr), | 749 web_layer_(nullptr), |
| 672 touch_event_request_type_(kTouchEventRequestTypeNone), | 750 touch_event_request_type_(kTouchEventRequestTypeNone), |
| 673 wants_wheel_events_(false), | 751 wants_wheel_events_(false), |
| 674 self_visible_(false), | 752 self_visible_(false), |
| 675 parent_visible_(false), | 753 parent_visible_(false), |
| 676 is_disposed_(false) {} | 754 is_disposed_(false) {} |
| 677 | 755 |
| 678 WebPluginContainerImpl::~WebPluginContainerImpl() { | 756 WebPluginContainerImpl::~WebPluginContainerImpl() { |
| 679 // The plugin container must have been disposed of by now. | 757 // The plugin container must have been disposed of by now. |
| 680 DCHECK(!web_plugin_); | 758 DCHECK(!web_plugin_); |
| 681 } | 759 } |
| 682 | 760 |
| 683 void WebPluginContainerImpl::Dispose() { | 761 void WebPluginContainerImpl::Dispose() { |
| 684 is_disposed_ = true; | 762 is_disposed_ = true; |
| 763 SetFrameOrPluginState(kDisposed); |
| 685 | 764 |
| 686 RequestTouchEventType(kTouchEventRequestTypeNone); | 765 RequestTouchEventType(kTouchEventRequestTypeNone); |
| 687 SetWantsWheelEvents(false); | 766 SetWantsWheelEvents(false); |
| 688 | 767 |
| 689 if (web_plugin_) { | 768 if (web_plugin_) { |
| 690 CHECK(web_plugin_->Container() == this); | 769 CHECK(web_plugin_->Container() == this); |
| 691 web_plugin_->Destroy(); | 770 web_plugin_->Destroy(); |
| 692 web_plugin_ = nullptr; | 771 web_plugin_ = nullptr; |
| 693 } | 772 } |
| 694 | 773 |
| 695 if (web_layer_) { | 774 if (web_layer_) { |
| 696 GraphicsLayer::UnregisterContentsLayer(web_layer_); | 775 GraphicsLayer::UnregisterContentsLayer(web_layer_); |
| 697 web_layer_ = nullptr; | 776 web_layer_ = nullptr; |
| 698 } | 777 } |
| 699 } | 778 } |
| 700 | 779 |
| 701 DEFINE_TRACE(WebPluginContainerImpl) { | 780 DEFINE_TRACE(WebPluginContainerImpl) { |
| 702 visitor->Trace(parent_); | 781 visitor->Trace(parent_); |
| 703 visitor->Trace(element_); | 782 visitor->Trace(element_); |
| 704 ContextClient::Trace(visitor); | 783 ContextClient::Trace(visitor); |
| 705 PluginView::Trace(visitor); | 784 PluginView::Trace(visitor); |
| 706 } | 785 } |
| 707 | 786 |
| 708 void WebPluginContainerImpl::HandleMouseEvent(MouseEvent* event) { | 787 void WebPluginContainerImpl::HandleMouseEvent(MouseEvent* event) { |
| 709 // We cache the parent FrameView here as the plugin widget could be deleted | 788 // We cache the parent FrameView here as the plugin widget could be deleted |
| 710 // in the call to HandleEvent. See http://b/issue?id=1362948 | 789 // in the call to HandleEvent. See http://b/issue?id=1362948 |
| 711 FrameView* parent_view = parent_; | 790 DCHECK(plugin_state_ == kAttached); |
| 791 FrameView* parent = ParentFrameView(); |
| 712 | 792 |
| 713 // TODO(dtapuska): Move WebMouseEventBuilder into the anonymous namespace | 793 // TODO(dtapuska): Move WebMouseEventBuilder into the anonymous namespace |
| 714 // in this class. | 794 // in this class. |
| 715 WebMouseEventBuilder transformed_event( | 795 WebMouseEventBuilder transformed_event( |
| 716 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 796 parent, LayoutItem(element_->GetLayoutObject()), *event); |
| 717 if (transformed_event.GetType() == WebInputEvent::kUndefined) | 797 if (transformed_event.GetType() == WebInputEvent::kUndefined) |
| 718 return; | 798 return; |
| 719 | 799 |
| 720 if (event->type() == EventTypeNames::mousedown) | 800 if (event->type() == EventTypeNames::mousedown) |
| 721 FocusPlugin(); | 801 FocusPlugin(); |
| 722 | 802 |
| 723 WebCursorInfo cursor_info; | 803 WebCursorInfo cursor_info; |
| 724 if (web_plugin_ && web_plugin_->HandleInputEvent( | 804 if (web_plugin_ && web_plugin_->HandleInputEvent( |
| 725 WebCoalescedInputEvent(transformed_event), | 805 WebCoalescedInputEvent(transformed_event), |
| 726 cursor_info) != WebInputEventResult::kNotHandled) | 806 cursor_info) != WebInputEventResult::kNotHandled) |
| 727 event->SetDefaultHandled(); | 807 event->SetDefaultHandled(); |
| 728 | 808 |
| 729 // A windowless plugin can change the cursor in response to a mouse move | 809 // A windowless plugin can change the cursor in response to a mouse move |
| 730 // event. We need to reflect the changed cursor in the frame view as the | 810 // event. We need to reflect the changed cursor in the frame view as the |
| 731 // mouse is moved in the boundaries of the windowless plugin. | 811 // mouse is moved in the boundaries of the windowless plugin. |
| 732 Page* page = parent_view->GetFrame().GetPage(); | 812 Page* page = parent->GetFrame().GetPage(); |
| 733 if (!page) | 813 if (!page) |
| 734 return; | 814 return; |
| 735 page->GetChromeClient().SetCursorForPlugin( | 815 page->GetChromeClient().SetCursorForPlugin( |
| 736 cursor_info, &parent_view->GetFrame().LocalFrameRoot()); | 816 cursor_info, &parent->GetFrame().LocalFrameRoot()); |
| 737 } | 817 } |
| 738 | 818 |
| 739 void WebPluginContainerImpl::HandleDragEvent(MouseEvent* event) { | 819 void WebPluginContainerImpl::HandleDragEvent(MouseEvent* event) { |
| 740 DCHECK(event->IsDragEvent()); | 820 DCHECK(event->IsDragEvent()); |
| 741 | 821 |
| 742 WebDragStatus drag_status = kWebDragStatusUnknown; | 822 WebDragStatus drag_status = kWebDragStatusUnknown; |
| 743 if (event->type() == EventTypeNames::dragenter) | 823 if (event->type() == EventTypeNames::dragenter) |
| 744 drag_status = kWebDragStatusEnter; | 824 drag_status = kWebDragStatusEnter; |
| 745 else if (event->type() == EventTypeNames::dragleave) | 825 else if (event->type() == EventTypeNames::dragleave) |
| 746 drag_status = kWebDragStatusLeave; | 826 drag_status = kWebDragStatusLeave; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 763 | 843 |
| 764 web_plugin_->HandleDragStatusUpdate(drag_status, drag_data, | 844 web_plugin_->HandleDragStatusUpdate(drag_status, drag_data, |
| 765 drag_operation_mask, drag_location, | 845 drag_operation_mask, drag_location, |
| 766 drag_screen_location); | 846 drag_screen_location); |
| 767 } | 847 } |
| 768 | 848 |
| 769 void WebPluginContainerImpl::HandleWheelEvent(WheelEvent* event) { | 849 void WebPluginContainerImpl::HandleWheelEvent(WheelEvent* event) { |
| 770 WebFloatPoint absolute_location = event->NativeEvent().PositionInRootFrame(); | 850 WebFloatPoint absolute_location = event->NativeEvent().PositionInRootFrame(); |
| 771 | 851 |
| 772 // Translate the root frame position to content coordinates. | 852 // Translate the root frame position to content coordinates. |
| 773 if (parent_) { | 853 DCHECK(plugin_state_ == kAttached); |
| 774 absolute_location = parent_->RootFrameToContents(absolute_location); | 854 if (FrameView* parent = ParentFrameView()) |
| 775 } | 855 absolute_location = parent->RootFrameToContents(absolute_location); |
| 776 | 856 |
| 777 IntPoint local_point = | 857 IntPoint local_point = |
| 778 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 858 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 779 absolute_location, kUseTransforms)); | 859 absolute_location, kUseTransforms)); |
| 780 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); | 860 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); |
| 781 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); | 861 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); |
| 782 | 862 |
| 783 WebCursorInfo cursor_info; | 863 WebCursorInfo cursor_info; |
| 784 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), | 864 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 785 cursor_info) != | 865 cursor_info) != |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 cursor_info) != | 990 cursor_info) != |
| 911 WebInputEventResult::kNotHandled) { | 991 WebInputEventResult::kNotHandled) { |
| 912 event->SetDefaultHandled(); | 992 event->SetDefaultHandled(); |
| 913 return; | 993 return; |
| 914 } | 994 } |
| 915 | 995 |
| 916 // FIXME: Can a plugin change the cursor from a touch-event callback? | 996 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 917 } | 997 } |
| 918 | 998 |
| 919 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { | 999 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { |
| 1000 DCHECK(plugin_state_ == kAttached); |
| 1001 FrameView* parent = ParentFrameView(); |
| 920 WebMouseEventBuilder web_event( | 1002 WebMouseEventBuilder web_event( |
| 921 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 1003 parent, LayoutItem(element_->GetLayoutObject()), *event); |
| 922 if (web_event.GetType() == WebInputEvent::kUndefined) | 1004 if (web_event.GetType() == WebInputEvent::kUndefined) |
| 923 return; | 1005 return; |
| 924 | 1006 |
| 925 WebCursorInfo cursor_info; | 1007 WebCursorInfo cursor_info; |
| 926 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), | 1008 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 927 cursor_info) != | 1009 cursor_info) != |
| 928 WebInputEventResult::kNotHandled) | 1010 WebInputEventResult::kNotHandled) |
| 929 event->SetDefaultHandled(); | 1011 event->SetDefaultHandled(); |
| 930 } | 1012 } |
| 931 | 1013 |
| 932 void WebPluginContainerImpl::FocusPlugin() { | 1014 void WebPluginContainerImpl::FocusPlugin() { |
| 933 LocalFrame& containing_frame = parent_->GetFrame(); | 1015 if (Page* current_page = GetFrame()->GetPage()) { |
| 934 if (Page* current_page = containing_frame.GetPage()) | 1016 current_page->GetFocusController().SetFocusedElement(element_, GetFrame()); |
| 935 current_page->GetFocusController().SetFocusedElement(element_, | 1017 } else { |
| 936 &containing_frame); | 1018 GetFrame()->GetDocument()->SetFocusedElement( |
| 937 else | |
| 938 containing_frame.GetDocument()->SetFocusedElement( | |
| 939 element_, FocusParams(SelectionBehaviorOnFocus::kNone, | 1019 element_, FocusParams(SelectionBehaviorOnFocus::kNone, |
| 940 kWebFocusTypeNone, nullptr)); | 1020 kWebFocusTypeNone, nullptr)); |
| 1021 } |
| 941 } | 1022 } |
| 942 | 1023 |
| 943 void WebPluginContainerImpl::IssuePaintInvalidations() { | 1024 void WebPluginContainerImpl::IssuePaintInvalidations() { |
| 944 if (pending_invalidation_rect_.IsEmpty()) | 1025 if (pending_invalidation_rect_.IsEmpty()) |
| 945 return; | 1026 return; |
| 946 | 1027 |
| 947 LayoutBox* layout_object = ToLayoutBox(element_->GetLayoutObject()); | 1028 LayoutBox* layout_object = ToLayoutBox(element_->GetLayoutObject()); |
| 948 if (!layout_object) | 1029 if (!layout_object) |
| 949 return; | 1030 return; |
| 950 | 1031 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 .GetLayoutViewItem() | 1107 .GetLayoutViewItem() |
| 1027 .IsNull()) { | 1108 .IsNull()) { |
| 1028 // Take our element and get the clip rect from the enclosing layer and | 1109 // Take our element and get the clip rect from the enclosing layer and |
| 1029 // frame view. | 1110 // frame view. |
| 1030 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, | 1111 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, |
| 1031 unobscured_rect); | 1112 unobscured_rect); |
| 1032 } | 1113 } |
| 1033 } | 1114 } |
| 1034 | 1115 |
| 1035 } // namespace blink | 1116 } // namespace blink |
| OLD | NEW |