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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 2551493002: Don't request wheel or touch events when the view of pepper has no area. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | 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) 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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
bbudge 2016/12/02 18:38:01 Would you consider refactoring IsAcceptingWheelEve
dtapuska 2016/12/02 19:42:08 Done.
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
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) {
bbudge 2016/12/02 18:38:01 Could you use unobscured_rect_.IsEmpty() here inst
dtapuska 2016/12/02 19:42:07 Although that may be optimal I'd worry that it wou
bbudge 2016/12/02 22:10:29 OK
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 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const {
1658 // If the view has 0 area don't request wheel events.
1659 if (view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0)
1660 return false;
1661
1647 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || 1662 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) ||
1648 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); 1663 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL);
1649 } 1664 }
1650 1665
1651 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { 1666 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() {
1652 if (view_change_weak_ptr_factory_.HasWeakPtrs()) 1667 if (view_change_weak_ptr_factory_.HasWeakPtrs())
1653 return; // Already scheduled. 1668 return; // Already scheduled.
1654 base::ThreadTaskRunnerHandle::Get()->PostTask( 1669 base::ThreadTaskRunnerHandle::Get()->PostTask(
1655 FROM_HERE, base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, 1670 FROM_HERE, base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView,
1656 view_change_weak_ptr_factory_.GetWeakPtr())); 1671 view_change_weak_ptr_factory_.GetWeakPtr()));
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 const cc::TextureMailbox& mailbox) const { 3451 const cc::TextureMailbox& mailbox) const {
3437 auto it = 3452 auto it =
3438 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), 3453 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(),
3439 [&mailbox](const TextureMailboxRefCount& ref_count) { 3454 [&mailbox](const TextureMailboxRefCount& ref_count) {
3440 return ref_count.first.mailbox() == mailbox.mailbox(); 3455 return ref_count.first.mailbox() == mailbox.mailbox();
3441 }); 3456 });
3442 return it != texture_ref_counts_.end(); 3457 return it != texture_ref_counts_.end();
3443 } 3458 }
3444 3459
3445 } // namespace content 3460 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698