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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 11312195: webkit/ppapi: Notify the container when a plugin is accepting wheel events just like r143871. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, address feedback Created 8 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 bool PluginInstance::Initialize(WebPluginContainer* container, 556 bool PluginInstance::Initialize(WebPluginContainer* container,
557 const std::vector<std::string>& arg_names, 557 const std::vector<std::string>& arg_names,
558 const std::vector<std::string>& arg_values, 558 const std::vector<std::string>& arg_values,
559 const GURL& plugin_url, 559 const GURL& plugin_url,
560 bool full_frame) { 560 bool full_frame) {
561 container_ = container; 561 container_ = container;
562 plugin_url_ = plugin_url; 562 plugin_url_ = plugin_url;
563 full_frame_ = full_frame; 563 full_frame_ = full_frame;
564 564
565 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); 565 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
566 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
566 567
567 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); 568 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values);
568 569
569 argn_ = arg_names; 570 argn_ = arg_names;
570 argv_ = arg_values; 571 argv_ = arg_values;
571 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); 572 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_));
572 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_)); 573 scoped_array<const char*> argv_array(StringVectorToArgArray(argv_));
573 return PP_ToBool(instance_interface_->DidCreate(pp_instance(), 574 return PP_ToBool(instance_interface_->DidCreate(pp_instance(),
574 argn_.size(), 575 argn_.size(),
575 argn_array.get(), 576 argn_array.get(),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 event.is_filtered = true; 663 event.is_filtered = true;
663 else 664 else
664 handled = true; // Unfiltered events are assumed to be handled. 665 handled = true; // Unfiltered events are assumed to be handled.
665 scoped_refptr<PPB_InputEvent_Shared> event_resource( 666 scoped_refptr<PPB_InputEvent_Shared> event_resource(
666 new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, pp_instance(), event)); 667 new PPB_InputEvent_Shared(::ppapi::OBJECT_IS_IMPL, pp_instance(), event));
667 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( 668 handled |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent(
668 pp_instance(), event_resource->pp_resource())); 669 pp_instance(), event_resource->pp_resource()));
669 return handled; 670 return handled;
670 } 671 }
671 672
673 void PluginInstance::RequestInputEventsHelper(uint32_t event_classes) {
674 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH)
675 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
676 if (event_classes & PP_INPUTEVENT_CLASS_WHEEL)
677 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
678 }
679
672 bool PluginInstance::HandleCompositionStart(const string16& text) { 680 bool PluginInstance::HandleCompositionStart(const string16& text) {
673 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, 681 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_START,
674 text); 682 text);
675 } 683 }
676 684
677 bool PluginInstance::HandleCompositionUpdate( 685 bool PluginInstance::HandleCompositionUpdate(
678 const string16& text, 686 const string16& text,
679 const std::vector<WebKit::WebCompositionUnderline>& underlines, 687 const std::vector<WebKit::WebCompositionUnderline>& underlines,
680 int selection_start, 688 int selection_start,
681 int selection_end) { 689 int selection_end) {
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 bool has_focus = PluginHasFocus(); 1177 bool has_focus = PluginHasFocus();
1170 delegate()->PluginFocusChanged(this, has_focus); 1178 delegate()->PluginFocusChanged(this, has_focus);
1171 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); 1179 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus));
1172 } 1180 }
1173 1181
1174 bool PluginInstance::IsAcceptingTouchEvents() const { 1182 bool PluginInstance::IsAcceptingTouchEvents() const {
1175 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || 1183 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) ||
1176 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); 1184 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH);
1177 } 1185 }
1178 1186
1187 bool PluginInstance::IsAcceptingWheelEvents() const {
1188 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) ||
1189 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL);
1190 }
1191
1179 void PluginInstance::ScheduleAsyncDidChangeView() { 1192 void PluginInstance::ScheduleAsyncDidChangeView() {
1180 if (view_change_weak_ptr_factory_.HasWeakPtrs()) 1193 if (view_change_weak_ptr_factory_.HasWeakPtrs())
1181 return; // Already scheduled. 1194 return; // Already scheduled.
1182 MessageLoop::current()->PostTask( 1195 MessageLoop::current()->PostTask(
1183 FROM_HERE, base::Bind(&PluginInstance::SendAsyncDidChangeView, 1196 FROM_HERE, base::Bind(&PluginInstance::SendAsyncDidChangeView,
1184 view_change_weak_ptr_factory_.GetWeakPtr())); 1197 view_change_weak_ptr_factory_.GetWeakPtr()));
1185 } 1198 }
1186 1199
1187 void PluginInstance::SendAsyncDidChangeView() { 1200 void PluginInstance::SendAsyncDidChangeView() {
1188 // The bound callback that owns the weak pointer is still valid until after 1201 // The bound callback that owns the weak pointer is still valid until after
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 2144
2132 ::ppapi::thunk::PPB_Gamepad_API* PluginInstance::GetGamepadAPI( 2145 ::ppapi::thunk::PPB_Gamepad_API* PluginInstance::GetGamepadAPI(
2133 PP_Instance /* instance */) { 2146 PP_Instance /* instance */) {
2134 return &gamepad_impl_; 2147 return &gamepad_impl_;
2135 } 2148 }
2136 2149
2137 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, 2150 int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
2138 uint32_t event_classes) { 2151 uint32_t event_classes) {
2139 input_event_mask_ |= event_classes; 2152 input_event_mask_ |= event_classes;
2140 filtered_input_event_mask_ &= ~(event_classes); 2153 filtered_input_event_mask_ &= ~(event_classes);
2141 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) 2154 RequestInputEventsHelper(event_classes);
2142 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
2143 return ValidateRequestInputEvents(false, event_classes); 2155 return ValidateRequestInputEvents(false, event_classes);
2144 } 2156 }
2145 2157
2146 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, 2158 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
2147 uint32_t event_classes) { 2159 uint32_t event_classes) {
2148 filtered_input_event_mask_ |= event_classes; 2160 filtered_input_event_mask_ |= event_classes;
2149 input_event_mask_ &= ~(event_classes); 2161 input_event_mask_ &= ~(event_classes);
2150 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) 2162 RequestInputEventsHelper(event_classes);
2151 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
2152 return ValidateRequestInputEvents(true, event_classes); 2163 return ValidateRequestInputEvents(true, event_classes);
2153 } 2164 }
2154 2165
2155 void PluginInstance::ClearInputEventRequest(PP_Instance instance, 2166 void PluginInstance::ClearInputEventRequest(PP_Instance instance,
2156 uint32_t event_classes) { 2167 uint32_t event_classes) {
2157 input_event_mask_ &= ~(event_classes); 2168 input_event_mask_ &= ~(event_classes);
2158 filtered_input_event_mask_ &= ~(event_classes); 2169 filtered_input_event_mask_ &= ~(event_classes);
2159 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) 2170 RequestInputEventsHelper(event_classes);
2160 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
2161 } 2171 }
2162 2172
2163 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) { 2173 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) {
2164 // We only want to tell the page to change its zoom if the whole page is the 2174 // We only want to tell the page to change its zoom if the whole page is the
2165 // plugin. If we're in an iframe, then don't do anything. 2175 // plugin. If we're in an iframe, then don't do anything.
2166 if (!IsFullPagePlugin()) 2176 if (!IsFullPagePlugin())
2167 return; 2177 return;
2168 container()->zoomLevelChanged(WebView::zoomFactorToZoomLevel(factor)); 2178 container()->zoomLevelChanged(WebView::zoomFactorToZoomLevel(factor));
2169 } 2179 }
2170 2180
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 screen_size_for_fullscreen_ = gfx::Size(); 2480 screen_size_for_fullscreen_ = gfx::Size();
2471 WebElement element = container_->element(); 2481 WebElement element = container_->element();
2472 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2482 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2473 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2483 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2474 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2484 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2475 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2485 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2476 } 2486 }
2477 2487
2478 } // namespace ppapi 2488 } // namespace ppapi
2479 } // namespace webkit 2489 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698