| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 if (throttler) { | 843 if (throttler) { |
| 844 throttler_ = std::move(throttler); | 844 throttler_ = std::move(throttler); |
| 845 throttler_->AddObserver(this); | 845 throttler_->AddObserver(this); |
| 846 } | 846 } |
| 847 | 847 |
| 848 message_channel_ = MessageChannel::Create(this, &message_channel_object_); | 848 message_channel_ = MessageChannel::Create(this, &message_channel_object_); |
| 849 | 849 |
| 850 full_frame_ = full_frame; | 850 full_frame_ = full_frame; |
| 851 | 851 |
| 852 UpdateTouchEventRequest(); | 852 UpdateTouchEventRequest(); |
| 853 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 853 UpdateWheelEventRequest(); |
| 854 | 854 |
| 855 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( | 855 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( |
| 856 render_frame_->render_view()->webkit_preferences())), | 856 render_frame_->render_view()->webkit_preferences())), |
| 857 arg_names, | 857 arg_names, |
| 858 arg_values); | 858 arg_values); |
| 859 | 859 |
| 860 argn_ = arg_names; | 860 argn_ = arg_names; |
| 861 argv_ = arg_values; | 861 argv_ = arg_values; |
| 862 std::unique_ptr<const char* []> argn_array(StringVectorToArgArray(argn_)); | 862 std::unique_ptr<const char* []> argn_array(StringVectorToArgArray(argn_)); |
| 863 std::unique_ptr<const char* []> argv_array(StringVectorToArgArray(argv_)); | 863 std::unique_ptr<const char* []> argv_array(StringVectorToArgArray(argv_)); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 1036 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
| 1037 pp_instance(), event_resource->pp_resource())); | 1037 pp_instance(), event_resource->pp_resource())); |
| 1038 return handled; | 1038 return handled; |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 void PepperPluginInstanceImpl::RequestInputEventsHelper( | 1041 void PepperPluginInstanceImpl::RequestInputEventsHelper( |
| 1042 uint32_t event_classes) { | 1042 uint32_t event_classes) { |
| 1043 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) | 1043 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) |
| 1044 UpdateTouchEventRequest(); | 1044 UpdateTouchEventRequest(); |
| 1045 if (event_classes & PP_INPUTEVENT_CLASS_WHEEL) | 1045 if (event_classes & PP_INPUTEVENT_CLASS_WHEEL) |
| 1046 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 1046 UpdateWheelEventRequest(); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 bool PepperPluginInstanceImpl::HandleCompositionStart( | 1049 bool PepperPluginInstanceImpl::HandleCompositionStart( |
| 1050 const base::string16& text) { | 1050 const base::string16& text) { |
| 1051 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, | 1051 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, |
| 1052 text); | 1052 text); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 bool PepperPluginInstanceImpl::HandleCompositionUpdate( | 1055 bool PepperPluginInstanceImpl::HandleCompositionUpdate( |
| 1056 const base::string16& text, | 1056 const base::string16& text, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 ConvertRectToDIP(&view_data_.clip_rect); | 1285 ConvertRectToDIP(&view_data_.clip_rect); |
| 1286 view_data_.css_scale *= viewport_to_dip_scale_; | 1286 view_data_.css_scale *= viewport_to_dip_scale_; |
| 1287 view_data_.device_scale /= viewport_to_dip_scale_; | 1287 view_data_.device_scale /= viewport_to_dip_scale_; |
| 1288 | 1288 |
| 1289 gfx::Size scroll_offset = gfx::ScaleToRoundedSize( | 1289 gfx::Size scroll_offset = gfx::ScaleToRoundedSize( |
| 1290 container_->document().frame()->scrollOffset(), viewport_to_dip_scale_); | 1290 container_->document().frame()->scrollOffset(), viewport_to_dip_scale_); |
| 1291 | 1291 |
| 1292 view_data_.scroll_offset = PP_MakePoint(scroll_offset.width(), | 1292 view_data_.scroll_offset = PP_MakePoint(scroll_offset.width(), |
| 1293 scroll_offset.height()); | 1293 scroll_offset.height()); |
| 1294 | 1294 |
| 1295 // The view size may have changed and we might need to update |
| 1296 // our registration of event listeners. |
| 1297 UpdateTouchEventRequest(); |
| 1298 UpdateWheelEventRequest(); |
| 1299 |
| 1295 if (desired_fullscreen_state_ || view_data_.is_fullscreen) { | 1300 if (desired_fullscreen_state_ || view_data_.is_fullscreen) { |
| 1296 bool is_fullscreen_element = container_->isFullscreenElement(); | 1301 bool is_fullscreen_element = container_->isFullscreenElement(); |
| 1297 if (!view_data_.is_fullscreen && desired_fullscreen_state_ && | 1302 if (!view_data_.is_fullscreen && desired_fullscreen_state_ && |
| 1298 render_frame()->GetRenderWidget()->is_fullscreen_granted() && | 1303 render_frame()->GetRenderWidget()->is_fullscreen_granted() && |
| 1299 is_fullscreen_element) { | 1304 is_fullscreen_element) { |
| 1300 // Entered fullscreen. Only possible via SetFullscreen(). | 1305 // Entered fullscreen. Only possible via SetFullscreen(). |
| 1301 view_data_.is_fullscreen = true; | 1306 view_data_.is_fullscreen = true; |
| 1302 } else if (view_data_.is_fullscreen && !is_fullscreen_element) { | 1307 } else if (view_data_.is_fullscreen && !is_fullscreen_element) { |
| 1303 // Exited fullscreen. Possible via SetFullscreen() or F11/link, | 1308 // Exited fullscreen. Possible via SetFullscreen() or F11/link, |
| 1304 // so desired_fullscreen_state might be out-of-date. | 1309 // so desired_fullscreen_state might be out-of-date. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 bool has_focus = PluginHasFocus(); | 1633 bool has_focus = PluginHasFocus(); |
| 1629 render_frame_->PepperFocusChanged(this, has_focus); | 1634 render_frame_->PepperFocusChanged(this, has_focus); |
| 1630 | 1635 |
| 1631 // instance_interface_ may have been cleared in Delete() if the | 1636 // instance_interface_ may have been cleared in Delete() if the |
| 1632 // PepperWebPluginImpl is destroyed. | 1637 // PepperWebPluginImpl is destroyed. |
| 1633 if (instance_interface_) | 1638 if (instance_interface_) |
| 1634 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 1639 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); |
| 1635 } | 1640 } |
| 1636 | 1641 |
| 1637 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { | 1642 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { |
| 1643 // If the view has 0 area don't request touch events. |
| 1644 if (view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) { |
| 1645 container_->requestTouchEventType( |
| 1646 blink::WebPluginContainer::TouchEventRequestTypeNone); |
| 1647 return; |
| 1648 } |
| 1638 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 1649 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || |
| 1639 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 1650 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); |
| 1640 container_->requestTouchEventType( | 1651 container_->requestTouchEventType( |
| 1641 raw_touch | 1652 raw_touch |
| 1642 ? blink::WebPluginContainer::TouchEventRequestTypeRaw | 1653 ? blink::WebPluginContainer::TouchEventRequestTypeRaw |
| 1643 : blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | 1654 : blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); |
| 1644 } | 1655 } |
| 1645 | 1656 |
| 1646 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { | 1657 void PepperPluginInstanceImpl::UpdateWheelEventRequest() { |
| 1647 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || | 1658 // If the view has 0 area don't request wheel events. |
| 1648 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); | 1659 if (view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) { |
| 1660 container_->setWantsWheelEvents(false); |
| 1661 return; |
| 1662 } |
| 1663 |
| 1664 bool hasWheelMask = |
| 1665 (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || |
| 1666 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); |
| 1667 container_->setWantsWheelEvents(hasWheelMask); |
| 1649 } | 1668 } |
| 1650 | 1669 |
| 1651 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { | 1670 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { |
| 1652 if (view_change_weak_ptr_factory_.HasWeakPtrs()) | 1671 if (view_change_weak_ptr_factory_.HasWeakPtrs()) |
| 1653 return; // Already scheduled. | 1672 return; // Already scheduled. |
| 1654 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1673 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1655 FROM_HERE, base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, | 1674 FROM_HERE, base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, |
| 1656 view_change_weak_ptr_factory_.GetWeakPtr())); | 1675 view_change_weak_ptr_factory_.GetWeakPtr())); |
| 1657 } | 1676 } |
| 1658 | 1677 |
| (...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 const cc::TextureMailbox& mailbox) const { | 3455 const cc::TextureMailbox& mailbox) const { |
| 3437 auto it = | 3456 auto it = |
| 3438 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3457 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
| 3439 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3458 [&mailbox](const TextureMailboxRefCount& ref_count) { |
| 3440 return ref_count.first.mailbox() == mailbox.mailbox(); | 3459 return ref_count.first.mailbox() == mailbox.mailbox(); |
| 3441 }); | 3460 }); |
| 3442 return it != texture_ref_counts_.end(); | 3461 return it != texture_ref_counts_.end(); |
| 3443 } | 3462 } |
| 3444 | 3463 |
| 3445 } // namespace content | 3464 } // namespace content |
| OLD | NEW |