diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 21:30:02 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 21:30:02 +0000 |
commit | 7a4e2538f65fd86518d29a30f5ec02da8cc531fc (patch) | |
tree | 284ea6270bcdf412e0370f809dabe8e30a5516e2 /content/renderer | |
parent | 659087dbebfc61a04874f1d4267b5d96e044d9bf (diff) | |
download | chromium_src-7a4e2538f65fd86518d29a30f5ec02da8cc531fc.zip chromium_src-7a4e2538f65fd86518d29a30f5ec02da8cc531fc.tar.gz chromium_src-7a4e2538f65fd86518d29a30f5ec02da8cc531fc.tar.bz2 |
Start transitioning Pepper plugin code to using RenderFrame instead of RenderView.
This is part of the work in getting rid of RenderView. Since a lot of the code is tightly coupled, I'm added temporary getters on RenderFrame and RenderView to each other. This allows the work to be done in smaller steps.
This is also the proper fix for htt://crbug.com/275447.
BUG=275447, 245126
R=nasko@chromium.org
Review URL: https://codereview.chromium.org/93333002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/npapi/webplugin_delegate_proxy.cc | 9 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 88 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 9 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_webplugin_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/pepper/plugin_module.cc | 4 | ||||
-rw-r--r-- | content/renderer/pepper/plugin_module.h | 3 | ||||
-rw-r--r-- | content/renderer/pepper/ppb_broker_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/pepper/renderer_ppapi_host_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.cc | 306 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.h | 134 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 297 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 86 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 29 | ||||
-rw-r--r-- | content/renderer/text_input_client_observer.cc | 2 |
14 files changed, 561 insertions, 412 deletions
diff --git a/content/renderer/npapi/webplugin_delegate_proxy.cc b/content/renderer/npapi/webplugin_delegate_proxy.cc index 539cc4f..108e292 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.cc +++ b/content/renderer/npapi/webplugin_delegate_proxy.cc @@ -316,7 +316,8 @@ bool WebPluginDelegateProxy::Initialize( // shouldn't happen, since if we got here the plugin should exist) or the // plugin crashed on initialization. if (!info_.path.empty()) { - render_view_->PluginCrashed(info_.path, base::kNullProcessId); + render_view_->main_render_frame()->PluginCrashed( + info_.path, base::kNullProcessId); LOG(ERROR) << "Plug-in crashed on start"; // Return true so that the plugin widget is created and we can paint the @@ -488,8 +489,10 @@ void WebPluginDelegateProxy::OnChannelError() { } plugin_->Invalidate(); } - if (!channel_host_->expecting_shutdown()) - render_view_->PluginCrashed(info_.path, channel_host_->peer_pid()); + if (!channel_host_->expecting_shutdown()) { + render_view_->main_render_frame()->PluginCrashed( + info_.path, channel_host_->peer_pid()); + } #if defined(OS_MACOSX) || defined(OS_WIN) // Ensure that the renderer doesn't think the plugin still has focus. diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 06b1dde..9de0205 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -45,8 +45,10 @@ #include "content/renderer/pepper/renderer_ppapi_host_impl.h" #include "content/renderer/pepper/url_request_info_util.h" #include "content/renderer/pepper/url_response_info_util.h" +#include "content/renderer/render_frame_impl.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/render_view_impl.h" +#include "content/renderer/render_widget.h" #include "content/renderer/render_widget_fullscreen_pepper.h" #include "content/renderer/sad_plugin.h" #include "media/base/audio_hardware_config.h" @@ -394,7 +396,7 @@ class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { // static PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( - RenderViewImpl* render_view, + RenderFrameImpl* render_frame, PluginModule* module, WebPluginContainer* container, const GURL& plugin_url) { @@ -404,7 +406,7 @@ PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( PPP_Instance_Combined::Create(get_plugin_interface_func); if (!ppp_instance_combined) return NULL; - return new PepperPluginInstanceImpl(render_view, module, + return new PepperPluginInstanceImpl(render_frame, module, ppp_instance_combined, container, plugin_url); } @@ -475,12 +477,12 @@ void PepperPluginInstanceImpl::GamepadImpl::Sample( } PepperPluginInstanceImpl::PepperPluginInstanceImpl( - RenderViewImpl* render_view, + RenderFrameImpl* render_frame, PluginModule* module, ppapi::PPP_Instance_Combined* instance_interface, WebPluginContainer* container, const GURL& plugin_url) - : render_view_(render_view), + : render_frame_(render_frame), module_(module), instance_interface_(instance_interface), pp_instance_(0), @@ -534,19 +536,19 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); module_->InstanceCreated(this); - if (render_view) { // NULL in tests - render_view->PepperInstanceCreated(this); - view_data_.is_page_visible = !render_view->is_hidden(); + if (render_frame) { // NULL in tests + render_frame->PepperInstanceCreated(this); + view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); // Set the initial focus. - SetContentAreaFocus(render_view_->has_focus()); + SetContentAreaFocus(render_frame_->GetRenderWidget()->has_focus()); if (!module_->IsProxied()) { PepperBrowserConnection* browser_connection = - PepperBrowserConnection::Get(render_view_); + PepperBrowserConnection::Get(render_frame_->render_view()); browser_connection->DidCreateInProcessInstance( pp_instance(), - render_view_->GetRoutingID(), + render_frame_->render_view()->GetRoutingID(), container_->element().document().url(), GetPluginURL()); } @@ -577,12 +579,12 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { if (TrackedCallback::IsPending(lock_mouse_callback_)) lock_mouse_callback_->Abort(); - if (render_view_) - render_view_->PepperInstanceDeleted(this); + if (render_frame_) + render_frame_->PepperInstanceDeleted(this); - if (!module_->IsProxied() && render_view_) { + if (!module_->IsProxied() && render_frame_) { PepperBrowserConnection* browser_connection = - PepperBrowserConnection::Get(render_view_); + PepperBrowserConnection::Get(render_frame_->render_view()); browser_connection->DidDeleteInProcessInstance(pp_instance()); } @@ -716,7 +718,7 @@ void PepperPluginInstanceImpl::InstanceCrashed() { BindGraphics(pp_instance(), 0); InvalidateRect(gfx::Rect()); - render_view_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); + render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); UnSetAndDeleteLockTargetAdapter(); } @@ -762,8 +764,9 @@ bool PepperPluginInstanceImpl::Initialize( UpdateTouchEventRequest(); container_->setWantsWheelEvents(IsAcceptingWheelEvents()); - SetGPUHistogram(ppapi::Preferences(render_view_->webkit_preferences()), - arg_names, arg_values); + SetGPUHistogram(ppapi::Preferences( + render_frame_->render_view()->webkit_preferences()), + arg_names, arg_values); argn_ = arg_names; argv_ = arg_values; @@ -994,7 +997,7 @@ bool PepperPluginInstanceImpl::HandleInputEvent( TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); if (WebInputEvent::isMouseEventType(event.type)) { - render_view_->PepperDidReceiveMouseEvent(this); + render_frame_->PepperDidReceiveMouseEvent(this); } // Don't dispatch input events to crashed plugins. @@ -1097,7 +1100,8 @@ void PepperPluginInstanceImpl::ViewChanged( WebDocument document = element.document(); bool is_fullscreen_element = (element == document.fullScreenElement()); if (!view_data_.is_fullscreen && desired_fullscreen_state_ && - render_view_->is_fullscreen() && is_fullscreen_element) { + render_frame()->GetRenderWidget()->is_fullscreen() && + is_fullscreen_element) { // Entered fullscreen. Only possible via SetFullscreen(). view_data_.is_fullscreen = true; } else if (view_data_.is_fullscreen && !is_fullscreen_element) { @@ -1446,7 +1450,7 @@ void PepperPluginInstanceImpl::SendFocusChangeNotification() { scoped_refptr<PepperPluginInstanceImpl> ref(this); bool has_focus = PluginHasFocus(); - render_view_->PepperFocusChanged(this, has_focus); + render_frame_->PepperFocusChanged(this, has_focus); // instance_interface_ may have been cleared in Delete() if the // PepperWebPluginImpl is destroyed. @@ -1684,7 +1688,9 @@ bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) { if (fullscreen == IsFullscreenOrPending()) return false; - if (fullscreen && !render_view_->IsPluginFullscreenAllowed()) + if (fullscreen && + !render_frame_->render_view()->renderer_preferences(). + plugin_fullscreen_allowed) return false; // Check whether we are trying to switch while the state is in transition. @@ -2046,7 +2052,7 @@ bool PepperPluginInstanceImpl::SimulateIMEEvent( SimulateImeSetCompositionEvent(input_event); break; case PP_INPUTEVENT_TYPE_IME_TEXT: - render_view_->SimulateImeConfirmComposition( + render_frame_->SimulateImeConfirmComposition( UTF8ToUTF16(input_event.character_text), gfx::Range()); break; default: @@ -2077,7 +2083,7 @@ void PepperPluginInstanceImpl::SimulateImeSetCompositionEvent( underlines.push_back(underline); } - render_view_->SimulateImeSetComposition( + render_frame_->SimulateImeSetComposition( utf16_text, underlines, offsets[0], offsets[1]); } @@ -2255,7 +2261,7 @@ uint32_t PepperPluginInstanceImpl::GetAudioHardwareOutputBufferSize( PP_Var PepperPluginInstanceImpl::GetDefaultCharSet(PP_Instance instance) { return StringVar::StringToPPVar( - render_view_->webkit_preferences().default_encoding); + render_frame_->render_view()->webkit_preferences().default_encoding); } // These PPB_ContentDecryptor_Private calls are responses to @@ -2345,14 +2351,14 @@ void PepperPluginInstanceImpl::NumberOfFindResultsChanged( int32_t total, PP_Bool final_result) { DCHECK_NE(find_identifier_, -1); - render_view_->reportFindInPageMatchCount( + render_frame_->reportFindInPageMatchCount( find_identifier_, total, PP_ToBool(final_result)); } void PepperPluginInstanceImpl::SelectedFindResultChanged(PP_Instance instance, int32_t index) { DCHECK_NE(find_identifier_, -1); - render_view_->reportFindInPageSelection( + render_frame_->reportFindInPageSelection( find_identifier_, index + 1, blink::WebRect()); } @@ -2367,7 +2373,7 @@ PP_Bool PepperPluginInstanceImpl::SetFullscreen(PP_Instance instance, PP_Bool PepperPluginInstanceImpl::GetScreenSize(PP_Instance instance, PP_Size* size) { - blink::WebScreenInfo info = render_view_->screenInfo(); + blink::WebScreenInfo info = render_frame()->GetRenderWidget()->screenInfo(); *size = PP_MakeSize(info.rect.width, info.rect.height); return PP_TRUE; } @@ -2440,7 +2446,8 @@ void PepperPluginInstanceImpl::ZoomLimitsChanged(PP_Instance instance, } double minimum_level = ZoomFactorToZoomLevel(minimum_factor); double maximum_level = ZoomFactorToZoomLevel(maximum_factor); - render_view_->webview()->zoomLimitsChanged(minimum_level, maximum_level); + render_frame_->render_view()->webview()->zoomLimitsChanged( + minimum_level, maximum_level); } void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, @@ -2527,7 +2534,7 @@ void PepperPluginInstanceImpl::SetTextInputType(PP_Instance instance, if (itype < 0 || itype > ui::TEXT_INPUT_TYPE_URL) itype = ui::TEXT_INPUT_TYPE_NONE; text_input_type_ = static_cast<ui::TextInputType>(itype); - render_view_->PepperTextInputTypeChanged(this); + render_frame_->PepperTextInputTypeChanged(this); } void PepperPluginInstanceImpl::UpdateCaretPosition( @@ -2537,11 +2544,11 @@ void PepperPluginInstanceImpl::UpdateCaretPosition( text_input_caret_ = PP_ToGfxRect(caret); text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); text_input_caret_set_ = true; - render_view_->PepperCaretPositionChanged(this); + render_frame_->PepperCaretPositionChanged(this); } void PepperPluginInstanceImpl::CancelCompositionText(PP_Instance instance) { - render_view_->PepperCancelComposition(this); + render_frame_->PepperCancelComposition(this); } void PepperPluginInstanceImpl::SelectionChanged(PP_Instance instance) { @@ -2567,7 +2574,7 @@ void PepperPluginInstanceImpl::UpdateSurroundingText(PP_Instance instance, surrounding_text_ = text; selection_caret_ = caret; selection_anchor_ = anchor; - render_view_->PepperSelectionChanged(this); + render_frame_->PepperSelectionChanged(this); } PP_Var PepperPluginInstanceImpl::ResolveRelativeToDocument( @@ -2735,7 +2742,7 @@ PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) { } RenderView* PepperPluginInstanceImpl::GetRenderView() { - return render_view_; + return render_frame_->render_view(); } blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() { @@ -2803,7 +2810,7 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy( RendererPpapiHostImpl* renderer_ppapi_host = external_plugin_module->CreateOutOfProcessModule( - render_view_, + render_frame_->render_view(), file_path, permissions, channel_handle, @@ -2828,7 +2835,7 @@ void PepperPluginInstanceImpl::DoSetCursor(WebCursorInfo* cursor) { if (fullscreen_container_) { fullscreen_container_->DidChangeCursor(*cursor); } else { - render_view_->PepperDidChangeCursor(this, *cursor); + render_frame_->PepperDidChangeCursor(this, *cursor); } } @@ -2849,14 +2856,17 @@ bool PepperPluginInstanceImpl::FlashSetFullscreen(bool fullscreen, if (fullscreen == FlashIsFullscreenOrPending()) return true; - if (fullscreen && !render_view_->IsPluginFullscreenAllowed()) + if (fullscreen && + !render_frame_->render_view()->renderer_preferences(). + plugin_fullscreen_allowed) return false; // Unbind current 2D or 3D graphics context. VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); if (fullscreen) { DCHECK(!fullscreen_container_); - fullscreen_container_ = render_view_->CreatePepperFullscreenContainer(this); + fullscreen_container_ = + render_frame_->CreatePepperFullscreenContainer(this); UpdateLayer(); } else { DCHECK(fullscreen_container_); @@ -2973,7 +2983,7 @@ void PepperPluginInstanceImpl::KeepSizeAttributesBeforeFullscreen() { } void PepperPluginInstanceImpl::SetSizeAttributesForFullscreen() { - blink::WebScreenInfo info = render_view_->screenInfo(); + blink::WebScreenInfo info = render_frame_->GetRenderWidget()->screenInfo(); screen_size_for_fullscreen_ = gfx::Size(info.rect.width, info.rect.height); std::string width = StringPrintf("%d", screen_size_for_fullscreen_.width()); std::string height = StringPrintf("%d", screen_size_for_fullscreen_.height()); @@ -3028,7 +3038,7 @@ MouseLockDispatcher* PepperPluginInstanceImpl::GetMouseLockDispatcher() { static_cast<RenderWidgetFullscreenPepper*>(fullscreen_container_); return container->mouse_lock_dispatcher(); } else { - return render_view_->mouse_lock_dispatcher(); + return render_frame_->render_view()->mouse_lock_dispatcher(); } } diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 3e3e24e..a3a88c8 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -105,6 +105,7 @@ class PluginObject; class PPB_Graphics3D_Impl; class PPB_ImageData_Impl; class PPB_URLLoader_Impl; +class RenderFrameImpl; class RenderViewImpl; // Represents one time a plugin appears on one web page. @@ -122,11 +123,11 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // get_plugin_interface function. If the plugin does not support any valid // PPP_Instance interface, returns NULL. static PepperPluginInstanceImpl* Create( - RenderViewImpl* render_view, + RenderFrameImpl* render_frame, PluginModule* module, blink::WebPluginContainer* container, const GURL& plugin_url); - RenderViewImpl* render_view() const { return render_view_; } + RenderFrameImpl* render_frame() const { return render_frame_; } PluginModule* module() const { return module_.get(); } MessageChannel& message_channel() { return *message_channel_; } @@ -559,7 +560,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // objects. This constructor is private so that we can hide the // PPP_Instance_Combined details while still having 1 constructor to maintain // for member initialization. - PepperPluginInstanceImpl(RenderViewImpl* render_view, + PepperPluginInstanceImpl(RenderFrameImpl* render_frame, PluginModule* module, ppapi::PPP_Instance_Combined* instance_interface, blink::WebPluginContainer* container, @@ -655,7 +656,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl int pending_host_id, const ppapi::URLResponseInfoData& data); - RenderViewImpl* render_view_; + RenderFrameImpl* render_frame_; scoped_refptr<PluginModule> module_; scoped_ptr<ppapi::PPP_Instance_Combined> instance_interface_; // If this is the NaCl plugin, we create a new module when we switch to the diff --git a/content/renderer/pepper/pepper_webplugin_impl.cc b/content/renderer/pepper/pepper_webplugin_impl.cc index a1a39c3..82b6b24 100644 --- a/content/renderer/pepper/pepper_webplugin_impl.cc +++ b/content/renderer/pepper/pepper_webplugin_impl.cc @@ -85,7 +85,7 @@ blink::WebPluginContainer* PepperWebPluginImpl::container() const { bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { // The plugin delegate may have gone away. instance_ = init_data_->module->CreateInstance( - init_data_->render_view.get(), container, init_data_->url); + init_data_->render_view->main_render_frame(), container, init_data_->url); if (!instance_.get()) return false; diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index 725f199..352be3e 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -551,11 +551,11 @@ bool PluginModule::SupportsInterface(const char* name) { } PepperPluginInstanceImpl* PluginModule::CreateInstance( - RenderViewImpl* render_view, + RenderFrameImpl* render_frame, blink::WebPluginContainer* container, const GURL& plugin_url) { PepperPluginInstanceImpl* instance = PepperPluginInstanceImpl::Create( - render_view, this, container, plugin_url); + render_frame, this, container, plugin_url); if (!instance) { LOG(WARNING) << "Plugin doesn't support instance interface, failing."; return NULL; diff --git a/content/renderer/pepper/plugin_module.h b/content/renderer/pepper/plugin_module.h index a782e3f..5f21879 100644 --- a/content/renderer/pepper/plugin_module.h +++ b/content/renderer/pepper/plugin_module.h @@ -50,6 +50,7 @@ class HostDispatcherWrapper; class PepperPluginInstanceImpl; class PepperBroker; class RendererPpapiHostImpl; +class RenderFrameImpl; class RenderViewImpl; struct WebPluginInfo; @@ -139,7 +140,7 @@ class CONTENT_EXPORT PluginModule : const ppapi::PpapiPermissions& permissions() const { return permissions_; } PepperPluginInstanceImpl* CreateInstance( - RenderViewImpl* render_view, + RenderFrameImpl* render_frame, blink::WebPluginContainer* container, const GURL& plugin_url); diff --git a/content/renderer/pepper/ppb_broker_impl.cc b/content/renderer/pepper/ppb_broker_impl.cc index f68d257..882c5db 100644 --- a/content/renderer/pepper/ppb_broker_impl.cc +++ b/content/renderer/pepper/ppb_broker_impl.cc @@ -84,7 +84,7 @@ int32_t PPB_Broker_Impl::Connect( RenderThreadImpl::current()->Send( new ViewHostMsg_RequestPpapiBrokerPermission( - plugin_instance->render_view()->GetRoutingID(), + plugin_instance->render_frame()->render_view()->GetRoutingID(), routing_id_, GetDocumentUrl(), broker_path)); diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.cc b/content/renderer/pepper/renderer_ppapi_host_impl.cc index 65061cf..e36a40a 100644 --- a/content/renderer/pepper/renderer_ppapi_host_impl.cc +++ b/content/renderer/pepper/renderer_ppapi_host_impl.cc @@ -140,7 +140,7 @@ RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( // Since we're the embedder, we can make assumptions about the helper on // the instance and get back to our RenderView. - return instance_object->render_view(); + return instance_object->render_frame()->render_view(); } bool RendererPpapiHostImpl::IsValidInstance(PP_Instance instance) const { diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 648f83c..ec03a63 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -8,6 +8,7 @@ #include <string> #include "base/command_line.h" +#include "base/i18n/char_iterator.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "content/child/appcache/appcache_dispatcher.h" @@ -25,12 +26,14 @@ #include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/document_state.h" #include "content/public/renderer/navigation_state.h" +#include "content/renderer/accessibility/renderer_accessibility.h" #include "content/renderer/browser_plugin/browser_plugin.h" #include "content/renderer/browser_plugin/browser_plugin_manager.h" #include "content/renderer/internal_document_state_data.h" #include "content/renderer/npapi/plugin_channel_host.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/render_view_impl.h" +#include "content/renderer/render_widget_fullscreen_pepper.h" #include "content/renderer/renderer_webapplicationcachehost_impl.h" #include "content/renderer/websharedworker_proxy.h" #include "net/base/net_errors.h" @@ -52,6 +55,10 @@ #include "third_party/WebKit/public/web/WebView.h" #include "webkit/child/weburlresponse_extradata_impl.h" +#if defined(ENABLE_PLUGINS) +#include "content/renderer/pepper/pepper_plugin_instance_impl.h" +#endif + #if defined(ENABLE_WEBRTC) #include "content/renderer/media/rtc_peer_connection_handler.h" #endif @@ -113,12 +120,309 @@ RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) : render_view_(render_view), routing_id_(routing_id), is_swapped_out_(false), - is_detaching_(false) { + is_detaching_(false) +#if defined(ENABLE_PLUGINS) + , focused_pepper_plugin_(NULL), + pepper_last_mouse_event_target_(NULL) +#endif +{ } RenderFrameImpl::~RenderFrameImpl() { } +RenderWidget* RenderFrameImpl::GetRenderWidget() { + return render_view_; +} + +#if defined(ENABLE_PLUGINS) +void RenderFrameImpl::PepperInstanceCreated( + PepperPluginInstanceImpl* instance) { + active_pepper_instances_.insert(instance); +} + +void RenderFrameImpl::PepperInstanceDeleted( + PepperPluginInstanceImpl* instance) { + active_pepper_instances_.erase(instance); + + if (pepper_last_mouse_event_target_ == instance) + pepper_last_mouse_event_target_ = NULL; + if (focused_pepper_plugin_ == instance) + PepperFocusChanged(instance, false); +} + +void RenderFrameImpl::PepperDidChangeCursor( + PepperPluginInstanceImpl* instance, + const blink::WebCursorInfo& cursor) { + // Update the cursor appearance immediately if the requesting plugin is the + // one which receives the last mouse event. Otherwise, the new cursor won't be + // picked up until the plugin gets the next input event. That is bad if, e.g., + // the plugin would like to set an invisible cursor when there isn't any user + // input for a while. + if (instance == pepper_last_mouse_event_target_) + GetRenderWidget()->didChangeCursor(cursor); +} + +void RenderFrameImpl::PepperDidReceiveMouseEvent( + PepperPluginInstanceImpl* instance) { + pepper_last_mouse_event_target_ = instance; +} + +void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, + bool focused) { + if (focused) + focused_pepper_plugin_ = instance; + else if (focused_pepper_plugin_ == instance) + focused_pepper_plugin_ = NULL; + + GetRenderWidget()->UpdateTextInputType(); + GetRenderWidget()->UpdateSelectionBounds(); +} + +void RenderFrameImpl::PepperTextInputTypeChanged( + PepperPluginInstanceImpl* instance) { + if (instance != focused_pepper_plugin_) + return; + + GetRenderWidget()->UpdateTextInputType(); + if (render_view_->renderer_accessibility()) { + render_view_->renderer_accessibility()->FocusedNodeChanged( + blink::WebNode()); + } +} + +void RenderFrameImpl::PepperCaretPositionChanged( + PepperPluginInstanceImpl* instance) { + if (instance != focused_pepper_plugin_) + return; + GetRenderWidget()->UpdateSelectionBounds(); +} + +void RenderFrameImpl::PepperCancelComposition( + PepperPluginInstanceImpl* instance) { + if (instance != focused_pepper_plugin_) + return; + Send(new ViewHostMsg_ImeCancelComposition(render_view_->GetRoutingID()));; +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) + GetRenderWidget()->UpdateCompositionInfo(true); +#endif +} + +void RenderFrameImpl::PepperSelectionChanged( + PepperPluginInstanceImpl* instance) { + if (instance != focused_pepper_plugin_) + return; + render_view_->SyncSelectionIfRequired(); +} + +RenderWidgetFullscreenPepper* RenderFrameImpl::CreatePepperFullscreenContainer( + PepperPluginInstanceImpl* plugin) { + GURL active_url; + if (render_view_->webview() && render_view_->webview()->mainFrame()) + active_url = GURL(render_view_->webview()->mainFrame()->document().url()); + RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( + GetRenderWidget()->routing_id(), plugin, active_url, + GetRenderWidget()->screenInfo()); + widget->show(blink::WebNavigationPolicyIgnore); + return widget; +} + +bool RenderFrameImpl::GetPepperCaretBounds(gfx::Rect* rect) { + if (!focused_pepper_plugin_) + return false; + *rect = focused_pepper_plugin_->GetCaretBounds(); + return true; +} + +bool RenderFrameImpl::IsPepperAcceptingCompositionEvents() const { + if (!focused_pepper_plugin_) + return false; + return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); +} + +void RenderFrameImpl::PluginCrashed(const base::FilePath& plugin_path, + base::ProcessId plugin_pid) { + // TODO(jam): dispatch this IPC in RenderFrameHost and switch to use + // routing_id_ as a result. + Send(new ViewHostMsg_CrashedPlugin( + render_view_->GetRoutingID(), plugin_path, plugin_pid)); +} + +void RenderFrameImpl::DidInitiatePaint() { + // Notify all instances that we painted. The same caveats apply as for + // ViewFlushedPaint regarding instances closing themselves, so we take + // similar precautions. + PepperPluginSet plugins = active_pepper_instances_; + for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { + if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) + (*i)->ViewInitiatedPaint(); + } +} + +void RenderFrameImpl::DidFlushPaint() { + // Notify all instances that we flushed. This will call into the plugin, and + // we it may ask to close itself as a result. This will, in turn, modify our + // set, possibly invalidating the iterator. So we iterate on a copy that + // won't change out from under us. + PepperPluginSet plugins = active_pepper_instances_; + for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { + // The copy above makes sure our iterator is never invalid if some plugins + // are destroyed. But some plugin may decide to close all of its views in + // response to a paint in one of them, so we need to make sure each one is + // still "current" before using it. + // + // It's possible that a plugin was destroyed, but another one was created + // with the same address. In this case, we'll call ViewFlushedPaint on that + // new plugin. But that's OK for this particular case since we're just + // notifying all of our instances that the view flushed, and the new one is + // one of our instances. + // + // What about the case where a new one is created in a callback at a new + // address and we don't issue the callback? We're still OK since this + // callback is used for flush callbacks and we could not have possibly + // started a new paint for the new plugin while processing a previous paint + // for an existing one. + if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) + (*i)->ViewFlushedPaint(); + } +} + +PepperPluginInstanceImpl* RenderFrameImpl::GetBitmapForOptimizedPluginPaint( + const gfx::Rect& paint_bounds, + TransportDIB** dib, + gfx::Rect* location, + gfx::Rect* clip, + float* scale_factor) { + for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); + i != active_pepper_instances_.end(); ++i) { + PepperPluginInstanceImpl* instance = *i; + // In Flash fullscreen , the plugin contents should be painted onto the + // fullscreen widget instead of the web page. + if (!instance->FlashIsFullscreenOrPending() && + instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, + clip, scale_factor)) + return *i; + } + return NULL; +} + +void RenderFrameImpl::PageVisibilityChanged(bool shown) { + // Inform PPAPI plugins that their page is no longer visible. + for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); + i != active_pepper_instances_.end(); ++i) + (*i)->PageVisibilityChanged(shown); +} + +void RenderFrameImpl::OnSetFocus(bool enable) { + // Notify all Pepper plugins. + for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); + i != active_pepper_instances_.end(); ++i) + (*i)->SetContentAreaFocus(enable); +} + +void RenderFrameImpl::WillHandleMouseEvent(const blink::WebMouseEvent& event) { + // This method is called for every mouse event that the render view receives. + // And then the mouse event is forwarded to WebKit, which dispatches it to the + // event target. Potentially a Pepper plugin will receive the event. + // In order to tell whether a plugin gets the last mouse event and which it + // is, we set |pepper_last_mouse_event_target_| to NULL here. If a plugin gets + // the event, it will notify us via DidReceiveMouseEvent() and set itself as + // |pepper_last_mouse_event_target_|. + pepper_last_mouse_event_target_ = NULL; +} + +void RenderFrameImpl::SimulateImeSetComposition( + const string16& text, + const std::vector<blink::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end) { + render_view_->OnImeSetComposition( + text, underlines, selection_start, selection_end); +} + +void RenderFrameImpl::SimulateImeConfirmComposition( + const string16& text, + const gfx::Range& replacement_range) { + render_view_->OnImeConfirmComposition(text, replacement_range, false); +} + + +void RenderFrameImpl::OnImeSetComposition( + const string16& text, + const std::vector<blink::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end) { + // When a PPAPI plugin has focus, we bypass WebKit. + if (!IsPepperAcceptingCompositionEvents()) { + pepper_composition_text_ = text; + } else { + // TODO(kinaba) currently all composition events are sent directly to + // plugins. Use DOM event mechanism after WebKit is made aware about + // plugins that support composition. + // The code below mimics the behavior of WebCore::Editor::setComposition. + + // Empty -> nonempty: composition started. + if (pepper_composition_text_.empty() && !text.empty()) + focused_pepper_plugin_->HandleCompositionStart(string16()); + // Nonempty -> empty: composition canceled. + if (!pepper_composition_text_.empty() && text.empty()) + focused_pepper_plugin_->HandleCompositionEnd(string16()); + pepper_composition_text_ = text; + // Nonempty: composition is ongoing. + if (!pepper_composition_text_.empty()) { + focused_pepper_plugin_->HandleCompositionUpdate( + pepper_composition_text_, underlines, selection_start, + selection_end); + } + } +} + +void RenderFrameImpl::OnImeConfirmComposition( + const string16& text, + const gfx::Range& replacement_range, + bool keep_selection) { + // When a PPAPI plugin has focus, we bypass WebKit. + // Here, text.empty() has a special meaning. It means to commit the last + // update of composition text (see + // RenderWidgetHost::ImeConfirmComposition()). + const string16& last_text = text.empty() ? pepper_composition_text_ : text; + + // last_text is empty only when both text and pepper_composition_text_ is. + // Ignore it. + if (last_text.empty()) + return; + + if (!IsPepperAcceptingCompositionEvents()) { + base::i18n::UTF16CharIterator iterator(&last_text); + int32 i = 0; + while (iterator.Advance()) { + blink::WebKeyboardEvent char_event; + char_event.type = blink::WebInputEvent::Char; + char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); + char_event.modifiers = 0; + char_event.windowsKeyCode = last_text[i]; + char_event.nativeKeyCode = last_text[i]; + + const int32 char_start = i; + for (; i < iterator.array_pos(); ++i) { + char_event.text[i - char_start] = last_text[i]; + char_event.unmodifiedText[i - char_start] = last_text[i]; + } + + if (GetRenderWidget()->webwidget()) + GetRenderWidget()->webwidget()->handleInputEvent(char_event); + } + } else { + // Mimics the order of events sent by WebKit. + // See WebCore::Editor::setComposition() for the corresponding code. + focused_pepper_plugin_->HandleCompositionEnd(last_text); + focused_pepper_plugin_->HandleTextInput(last_text); + } + pepper_composition_text_.clear(); +} + +#endif // ENABLE_PLUGINS + int RenderFrameImpl::GetRoutingID() const { return routing_id_; } diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 5c81cd1..5596207 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -5,15 +5,38 @@ #ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ +#include <set> +#include <vector> + #include "base/basictypes.h" +#include "base/files/file_path.h" +#include "base/process/process_handle.h" +#include "base/strings/string16.h" #include "content/public/renderer/render_frame.h" #include "ipc/ipc_message.h" #include "third_party/WebKit/public/web/WebDataSource.h" #include "third_party/WebKit/public/web/WebFrameClient.h" +class TransportDIB; + +namespace blink { +class WebMouseEvent; +struct WebCompositionUnderline; +struct WebCursorInfo; +} + +namespace gfx { +class Range; +class Rect; +} + namespace content { +class PepperPluginInstanceImpl; +class RendererPpapiHost; class RenderViewImpl; +class RenderWidget; +class RenderWidgetFullscreenPepper; class CONTENT_EXPORT RenderFrameImpl : public RenderFrame, @@ -30,6 +53,99 @@ class CONTENT_EXPORT RenderFrameImpl virtual ~RenderFrameImpl(); + // TODO(jam): this is a temporary getter until all the code is transitioned + // to using RenderFrame instead of RenderView. + RenderViewImpl* render_view() { return render_view_; } + + // Returns the RenderWidget associated with this frame. + RenderWidget* GetRenderWidget(); + +#if defined(ENABLE_PLUGINS) + // Indicates that the given instance has been created. + void PepperInstanceCreated(PepperPluginInstanceImpl* instance); + + // Indicates that the given instance is being destroyed. This is called from + // the destructor, so it's important that the instance is not dereferenced + // from this call. + void PepperInstanceDeleted(PepperPluginInstanceImpl* instance); + + // Notifies that |instance| has changed the cursor. + // This will update the cursor appearance if it is currently over the plugin + // instance. + void PepperDidChangeCursor(PepperPluginInstanceImpl* instance, + const blink::WebCursorInfo& cursor); + + // Notifies that |instance| has received a mouse event. + void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance); + + // Notification that the given plugin is focused or unfocused. + void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused); + + // Informs the render view that a PPAPI plugin has changed text input status. + void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance); + void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance); + + // Cancels current composition. + void PepperCancelComposition(PepperPluginInstanceImpl* instance); + + // Informs the render view that a PPAPI plugin has changed selection. + void PepperSelectionChanged(PepperPluginInstanceImpl* instance); + + // Creates a fullscreen container for a pepper plugin instance. + RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( + PepperPluginInstanceImpl* plugin); + + // Retrieves the current caret position if a PPAPI plugin has focus. + bool GetPepperCaretBounds(gfx::Rect* rect); + + bool IsPepperAcceptingCompositionEvents() const; + + // Notification that the given plugin has crashed. + void PluginCrashed(const base::FilePath& plugin_path, + base::ProcessId plugin_pid); + + // These map to virtual methods on RenderWidget that are used to call out to + // RenderView. + // TODO(jam): once we get rid of RenderView, RenderFrame will own RenderWidget + // and methods would be on a delegate interface. + void DidInitiatePaint(); + void DidFlushPaint(); + PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( + const gfx::Rect& paint_bounds, + TransportDIB** dib, + gfx::Rect* location, + gfx::Rect* clip, + float* scale_factor); + void PageVisibilityChanged(bool shown); + void OnSetFocus(bool enable); + void WillHandleMouseEvent(const blink::WebMouseEvent& event); + + // Simulates IME events for testing purpose. + void SimulateImeSetComposition( + const string16& text, + const std::vector<blink::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end); + void SimulateImeConfirmComposition(const string16& text, + const gfx::Range& replacement_range); + + // TODO(jam): remove these once the IPC handler moves from RenderView to + // RenderFrame. + void OnImeSetComposition( + const string16& text, + const std::vector<blink::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end); + void OnImeConfirmComposition( + const string16& text, + const gfx::Range& replacement_range, + bool keep_selection); + + PepperPluginInstanceImpl* focused_pepper_plugin() { + return focused_pepper_plugin_; + } +#endif // ENABLE_PLUGINS + // IPC::Sender virtual bool Send(IPC::Message* msg) OVERRIDE; @@ -192,6 +308,24 @@ class CONTENT_EXPORT RenderFrameImpl bool is_swapped_out_; bool is_detaching_; +#if defined(ENABLE_PLUGINS) + typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet; + PepperPluginSet active_pepper_instances_; + + // Whether or not the focus is on a PPAPI plugin + PepperPluginInstanceImpl* focused_pepper_plugin_; + + // Current text input composition text. Empty if no composition is in + // progress. + string16 pepper_composition_text_; + + // The plugin instance that received the last mouse event. It is set to NULL + // if the last mouse event went to elements other than Pepper plugins. + // |pepper_last_mouse_event_target_| is not owned by this class. We can know + // about when it is destroyed via InstanceDeleted(). + PepperPluginInstanceImpl* pepper_last_mouse_event_target_; +#endif + DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); }; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 2d5e6a4..9f9c7e8 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -15,7 +15,6 @@ #include "base/debug/alias.h" #include "base/debug/trace_event.h" #include "base/files/file_path.h" -#include "base/i18n/char_iterator.h" #include "base/json/json_writer.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" @@ -871,10 +870,6 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) #if defined(OS_WIN) focused_plugin_id_(-1), #endif -#if defined(ENABLE_PLUGINS) - focused_pepper_plugin_(NULL), - pepper_last_mouse_event_target_(NULL), -#endif enumeration_completion_id_(0), load_progress_tracker_(new LoadProgressTracker(this)), session_storage_namespace_id_(params->session_storage_namespace_id), @@ -1163,115 +1158,11 @@ blink::WebView* RenderViewImpl::webview() const { } #if defined(ENABLE_PLUGINS) -void RenderViewImpl::PepperInstanceCreated(PepperPluginInstanceImpl* instance) { - active_pepper_instances_.insert(instance); -} - -void RenderViewImpl::PepperInstanceDeleted(PepperPluginInstanceImpl* instance) { - active_pepper_instances_.erase(instance); - - if (pepper_last_mouse_event_target_ == instance) - pepper_last_mouse_event_target_ = NULL; - if (focused_pepper_plugin_ == instance) - PepperFocusChanged(instance, false); -} - -void RenderViewImpl::PepperDidChangeCursor( - PepperPluginInstanceImpl* instance, - const blink::WebCursorInfo& cursor) { - // Update the cursor appearance immediately if the requesting plugin is the - // one which receives the last mouse event. Otherwise, the new cursor won't be - // picked up until the plugin gets the next input event. That is bad if, e.g., - // the plugin would like to set an invisible cursor when there isn't any user - // input for a while. - if (instance == pepper_last_mouse_event_target_) - didChangeCursor(cursor); -} - -void RenderViewImpl::PepperDidReceiveMouseEvent( - PepperPluginInstanceImpl* instance) { - pepper_last_mouse_event_target_ = instance; -} - -void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, - bool focused) { - if (focused) - focused_pepper_plugin_ = instance; - else if (focused_pepper_plugin_ == instance) - focused_pepper_plugin_ = NULL; - - UpdateTextInputType(); - UpdateSelectionBounds(); -} - -void RenderViewImpl::PepperTextInputTypeChanged( - PepperPluginInstanceImpl* instance) { - if (instance != focused_pepper_plugin_) - return; - - UpdateTextInputType(); - if (renderer_accessibility_) - renderer_accessibility_->FocusedNodeChanged(WebNode()); -} - -void RenderViewImpl::PepperCaretPositionChanged( - PepperPluginInstanceImpl* instance) { - if (instance != focused_pepper_plugin_) - return; - UpdateSelectionBounds(); -} - -void RenderViewImpl::PepperCancelComposition( - PepperPluginInstanceImpl* instance) { - if (instance != focused_pepper_plugin_) - return; - Send(new ViewHostMsg_ImeCancelComposition(routing_id()));; -#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) - UpdateCompositionInfo(true); -#endif -} - -void RenderViewImpl::PepperSelectionChanged( - PepperPluginInstanceImpl* instance) { - if (instance != focused_pepper_plugin_) - return; - SyncSelectionIfRequired(); -} - -RenderWidgetFullscreenPepper* RenderViewImpl::CreatePepperFullscreenContainer( - PepperPluginInstanceImpl* plugin) { - GURL active_url; - if (webview() && webview()->mainFrame()) - active_url = GURL(webview()->mainFrame()->document().url()); - RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( - routing_id_, plugin, active_url, screen_info_); - widget->show(blink::WebNavigationPolicyIgnore); - return widget; -} - void RenderViewImpl::PepperPluginCreated(RendererPpapiHost* host) { FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCreatePepperPlugin(host)); } -bool RenderViewImpl::GetPepperCaretBounds(gfx::Rect* rect) { - if (!focused_pepper_plugin_) - return false; - *rect = focused_pepper_plugin_->GetCaretBounds(); - return true; -} - -bool RenderViewImpl::IsPepperAcceptingCompositionEvents() const { - if (!focused_pepper_plugin_) - return false; - return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); -} - -void RenderViewImpl::PluginCrashed(const base::FilePath& plugin_path, - base::ProcessId plugin_pid) { - Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path, plugin_pid)); -} - void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { plugin_delegates_.insert(delegate); // If the renderer is visible, set initial visibility and focus state. @@ -1305,20 +1196,6 @@ bool RenderViewImpl::GetPluginInfo(const GURL& url, return found; } -void RenderViewImpl::SimulateImeSetComposition( - const string16& text, - const std::vector<blink::WebCompositionUnderline>& underlines, - int selection_start, - int selection_end) { - OnImeSetComposition(text, underlines, selection_start, selection_end); -} - -void RenderViewImpl::SimulateImeConfirmComposition( - const string16& text, - const gfx::Range& replacement_range) { - OnImeConfirmComposition(text, replacement_range, false); -} - #if defined(OS_WIN) void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { if (focused) @@ -4252,17 +4129,13 @@ bool RenderViewImpl::ShouldUpdateSelectionTextFromContextMenuParams( void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, bool final_update) { - // TODO(jam): switch PepperPluginInstanceImpl to take a RenderFrame - main_render_frame_->reportFindInPageMatchCount( - request_id, count, final_update); + NOTREACHED(); } void RenderViewImpl::reportFindInPageSelection(int request_id, int active_match_ordinal, const WebRect& selection_rect) { - // TODO(jam): switch PepperPluginInstanceImpl to take a RenderFrame - main_render_frame_->reportFindInPageSelection( - request_id, active_match_ordinal, selection_rect); + NOTREACHED(); } void RenderViewImpl::requestStorageQuota( @@ -4575,8 +4448,9 @@ void RenderViewImpl::SyncSelectionIfRequired() { size_t offset; gfx::Range range; #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { - focused_pepper_plugin_->GetSurroundingText(&text, &range); + if (main_render_frame_->focused_pepper_plugin()) { + main_render_frame_->focused_pepper_plugin()->GetSurroundingText( + &text, &range); offset = 0; // Pepper API does not support offset reporting. // TODO(kinaba): cut as needed. } else @@ -5550,44 +5424,13 @@ void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { void RenderViewImpl::DidInitiatePaint() { #if defined(ENABLE_PLUGINS) - // Notify all instances that we painted. The same caveats apply as for - // ViewFlushedPaint regarding instances closing themselves, so we take - // similar precautions. - PepperPluginSet plugins = active_pepper_instances_; - for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { - if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) - (*i)->ViewInitiatedPaint(); - } + main_render_frame_->DidInitiatePaint(); #endif } void RenderViewImpl::DidFlushPaint() { #if defined(ENABLE_PLUGINS) - // Notify all instances that we flushed. This will call into the plugin, and - // we it may ask to close itself as a result. This will, in turn, modify our - // set, possibly invalidating the iterator. So we iterate on a copy that - // won't change out from under us. - PepperPluginSet plugins = active_pepper_instances_; - for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { - // The copy above makes sure our iterator is never invalid if some plugins - // are destroyed. But some plugin may decide to close all of its views in - // response to a paint in one of them, so we need to make sure each one is - // still "current" before using it. - // - // It's possible that a plugin was destroyed, but another one was created - // with the same address. In this case, we'll call ViewFlushedPaint on that - // new plugin. But that's OK for this particular case since we're just - // notifying all of our instances that the view flushed, and the new one is - // one of our instances. - // - // What about the case where a new one is created in a callback at a new - // address and we don't issue the callback? We're still OK since this - // callback is used for flush callbacks and we could not have possibly - // started a new paint for the new plugin while processing a previous paint - // for an existing one. - if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) - (*i)->ViewFlushedPaint(); - } + main_render_frame_->DidFlushPaint(); #endif // If the RenderWidget is closing down then early-exit, otherwise we'll crash. @@ -5631,16 +5474,8 @@ PepperPluginInstanceImpl* RenderViewImpl::GetBitmapForOptimizedPluginPaint( gfx::Rect* clip, float* scale_factor) { #if defined(ENABLE_PLUGINS) - for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); - i != active_pepper_instances_.end(); ++i) { - PepperPluginInstanceImpl* instance = *i; - // In Flash fullscreen , the plugin contents should be painted onto the - // fullscreen widget instead of the web page. - if (!instance->FlashIsFullscreenOrPending() && - instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, - clip, scale_factor)) - return *i; - } + return main_render_frame_->GetBitmapForOptimizedPluginPaint( + paint_bounds, dib, location, clip, scale_factor); #endif return NULL; } @@ -5749,14 +5584,7 @@ bool RenderViewImpl::WillHandleMouseEvent(const blink::WebMouseEvent& event) { gfx::Point(event.globalX, event.globalY); #if defined(ENABLE_PLUGINS) - // This method is called for every mouse event that the render view receives. - // And then the mouse event is forwarded to WebKit, which dispatches it to the - // event target. Potentially a Pepper plugin will receive the event. - // In order to tell whether a plugin gets the last mouse event and which it - // is, we set |pepper_last_mouse_event_target_| to NULL here. If a plugin gets - // the event, it will notify us via DidReceiveMouseEvent() and set itself as - // |pepper_last_mouse_event_target_|. - pepper_last_mouse_event_target_ = NULL; + main_render_frame_->WillHandleMouseEvent(event); #endif // If the mouse is locked, only the current owner of the mouse lock can @@ -5805,10 +5633,7 @@ void RenderViewImpl::OnWasHidden() { webview()->setVisibilityState(visibilityState(), false); #if defined(ENABLE_PLUGINS) - // Inform PPAPI plugins that their page is no longer visible. - for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); - i != active_pepper_instances_.end(); ++i) - (*i)->PageVisibilityChanged(false); + main_render_frame_->PageVisibilityChanged(false); #if defined(OS_MACOSX) // Inform NPAPI plugins that their container is no longer visible. @@ -5833,10 +5658,7 @@ void RenderViewImpl::OnWasShown(bool needs_repainting) { webview()->setVisibilityState(visibilityState(), false); #if defined(ENABLE_PLUGINS) - // Inform PPAPI plugins that their page is visible. - for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); - i != active_pepper_instances_.end(); ++i) - (*i)->PageVisibilityChanged(true); + main_render_frame_->PageVisibilityChanged(true); #if defined(OS_MACOSX) // Inform NPAPI plugins that their container is now visible. @@ -5879,10 +5701,7 @@ void RenderViewImpl::OnSetFocus(bool enable) { (*plugin_it)->SetContentAreaFocus(enable); } } - // Notify all Pepper plugins. - for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); - i != active_pepper_instances_.end(); ++i) - (*i)->SetContentAreaFocus(enable); + main_render_frame_->OnSetFocus(enable); #endif // Notify all BrowserPlugins of the RenderView's focus state. if (browser_plugin_manager_.get()) @@ -5895,30 +5714,9 @@ void RenderViewImpl::OnImeSetComposition( int selection_start, int selection_end) { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { - // When a PPAPI plugin has focus, we bypass WebKit. - if (!IsPepperAcceptingCompositionEvents()) { - pepper_composition_text_ = text; - } else { - // TODO(kinaba) currently all composition events are sent directly to - // plugins. Use DOM event mechanism after WebKit is made aware about - // plugins that support composition. - // The code below mimics the behavior of WebCore::Editor::setComposition. - - // Empty -> nonempty: composition started. - if (pepper_composition_text_.empty() && !text.empty()) - focused_pepper_plugin_->HandleCompositionStart(string16()); - // Nonempty -> empty: composition canceled. - if (!pepper_composition_text_.empty() && text.empty()) - focused_pepper_plugin_->HandleCompositionEnd(string16()); - pepper_composition_text_ = text; - // Nonempty: composition is ongoing. - if (!pepper_composition_text_.empty()) { - focused_pepper_plugin_->HandleCompositionUpdate( - pepper_composition_text_, underlines, selection_start, - selection_end); - } - } + if (main_render_frame_->focused_pepper_plugin()) { + main_render_frame_->OnImeSetComposition( + text, underlines, selection_start, selection_end); return; } @@ -5959,45 +5757,9 @@ void RenderViewImpl::OnImeConfirmComposition( const gfx::Range& replacement_range, bool keep_selection) { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { - // When a PPAPI plugin has focus, we bypass WebKit. - // Here, text.empty() has a special meaning. It means to commit the last - // update of composition text (see - // RenderWidgetHost::ImeConfirmComposition()). - const string16& last_text = text.empty() ? pepper_composition_text_ : text; - - // last_text is empty only when both text and pepper_composition_text_ is. - // Ignore it. - if (last_text.empty()) - return; - - if (!IsPepperAcceptingCompositionEvents()) { - base::i18n::UTF16CharIterator iterator(&last_text); - int32 i = 0; - while (iterator.Advance()) { - blink::WebKeyboardEvent char_event; - char_event.type = blink::WebInputEvent::Char; - char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); - char_event.modifiers = 0; - char_event.windowsKeyCode = last_text[i]; - char_event.nativeKeyCode = last_text[i]; - - const int32 char_start = i; - for (; i < iterator.array_pos(); ++i) { - char_event.text[i - char_start] = last_text[i]; - char_event.unmodifiedText[i - char_start] = last_text[i]; - } - - if (webwidget()) - webwidget()->handleInputEvent(char_event); - } - } else { - // Mimics the order of events sent by WebKit. - // See WebCore::Editor::setComposition() for the corresponding code. - focused_pepper_plugin_->HandleCompositionEnd(last_text); - focused_pepper_plugin_->HandleTextInput(last_text); - } - pepper_composition_text_.clear(); + if (main_render_frame_->focused_pepper_plugin()) { + main_render_frame_->OnImeConfirmComposition( + text, replacement_range, keep_selection); return; } #if defined(OS_WIN) @@ -6058,20 +5820,21 @@ void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { ui::TextInputType RenderViewImpl::GetTextInputType() { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) - return focused_pepper_plugin_->text_input_type(); + if (main_render_frame_->focused_pepper_plugin()) + return main_render_frame_->focused_pepper_plugin()->text_input_type(); #endif return RenderWidget::GetTextInputType(); } void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { + if (main_render_frame_->focused_pepper_plugin()) { // TODO(kinaba) http://crbug.com/101101 // Current Pepper IME API does not handle selection bounds. So we simply // use the caret position as an empty range for now. It will be updated // after Pepper API equips features related to surrounding text retrieval. - gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); + gfx::Rect caret = + main_render_frame_->focused_pepper_plugin()->GetCaretBounds(); *start = caret; *end = caret; return; @@ -6087,7 +5850,7 @@ void RenderViewImpl::GetCompositionCharacterBounds( bounds->clear(); #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { + if (main_render_frame_->focused_pepper_plugin()) { return; } #endif @@ -6119,7 +5882,7 @@ void RenderViewImpl::GetCompositionCharacterBounds( void RenderViewImpl::GetCompositionRange(gfx::Range* range) { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) { + if (main_render_frame_->focused_pepper_plugin()) { return; } #endif @@ -6129,8 +5892,8 @@ void RenderViewImpl::GetCompositionRange(gfx::Range* range) { bool RenderViewImpl::CanComposeInline() { #if defined(ENABLE_PLUGINS) - if (focused_pepper_plugin_) - return IsPepperAcceptingCompositionEvents(); + if (main_render_frame_->focused_pepper_plugin()) + return main_render_frame_->IsPepperAcceptingCompositionEvents(); #endif return true; } @@ -6661,10 +6424,6 @@ void RenderViewImpl::SetMediaStreamClientForTesting( media_stream_client_ = media_stream_client; } -bool RenderViewImpl::IsPluginFullscreenAllowed() { - return renderer_preferences_.plugin_fullscreen_allowed; -} - void RenderViewImpl::OnReleaseDisambiguationPopupDIB( TransportDIB::Handle dib_handle) { TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index c8f2d49..b5acbab 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -111,7 +111,6 @@ class WebTouchEvent; class WebURLRequest; class WebUserMediaClient; struct WebActiveWheelFlingParameters; -struct WebCursorInfo; struct WebDateTimeChooserParams; struct WebFileChooserParams; struct WebFindOptions; @@ -153,9 +152,7 @@ class RenderViewObserver; class RenderViewTest; class RendererAccessibility; class RendererDateTimePicker; -class RendererPpapiHost; class RendererWebColorChooserImpl; -class RenderWidgetFullscreenPepper; class SpeechRecognitionDispatcher; class StatsCollectionController; class WebPluginDelegateProxy; @@ -222,14 +219,24 @@ class CONTENT_EXPORT RenderViewImpl return webkit_preferences_; } + const RendererPreferences& renderer_preferences() const { + return renderer_preferences_; + } + void set_send_content_state_immediately(bool value) { send_content_state_immediately_ = value; } + RenderFrameImpl* main_render_frame() { return main_render_frame_.get(); } + MediaStreamDispatcher* media_stream_dispatcher() { return media_stream_dispatcher_; } + RendererAccessibility* renderer_accessibility() { + return renderer_accessibility_; + } + MouseLockDispatcher* mouse_lock_dispatcher() { return mouse_lock_dispatcher_; } @@ -268,61 +275,9 @@ class CONTENT_EXPORT RenderViewImpl // Plugin-related functions -------------------------------------------------- #if defined(ENABLE_PLUGINS) - // Indicates that the given instance has been created. - void PepperInstanceCreated(PepperPluginInstanceImpl* instance); - - // Indicates that the given instance is being destroyed. This is called from - // the destructor, so it's important that the instance is not dereferenced - // from this call. - void PepperInstanceDeleted(PepperPluginInstanceImpl* instance); - - // Notifies that |instance| has changed the cursor. - // This will update the cursor appearance if it is currently over the plugin - // instance. - void PepperDidChangeCursor(PepperPluginInstanceImpl* instance, - const blink::WebCursorInfo& cursor); - - // Notifies that |instance| has received a mouse event. - void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance); - - // Notification that the given plugin is focused or unfocused. - void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused); - - // Informs the render view that a PPAPI plugin has changed text input status. - void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance); - void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance); - - // Cancels current composition. - void PepperCancelComposition(PepperPluginInstanceImpl* instance); - - // Informs the render view that a PPAPI plugin has changed selection. - void PepperSelectionChanged(PepperPluginInstanceImpl* instance); - - // Creates a fullscreen container for a pepper plugin instance. - RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( - PepperPluginInstanceImpl* plugin); - // Notification that a PPAPI plugin has been created. void PepperPluginCreated(RendererPpapiHost* host); - // Retrieves the current caret position if a PPAPI plugin has focus. - bool GetPepperCaretBounds(gfx::Rect* rect); - - bool IsPepperAcceptingCompositionEvents() const; - - // Notification that the given plugin has crashed. - void PluginCrashed(const base::FilePath& plugin_path, - base::ProcessId plugin_pid); - - // Simulates IME events for testing purpose. - void SimulateImeSetComposition( - const string16& text, - const std::vector<blink::WebCompositionUnderline>& underlines, - int selection_start, - int selection_end); - void SimulateImeConfirmComposition(const string16& text, - const gfx::Range& replacement_range); - #if defined(OS_MACOSX) || defined(OS_WIN) // Informs the render view that the given plugin has gained or lost focus. void PluginFocusChanged(bool focused, int plugin_id); @@ -395,9 +350,6 @@ class CONTENT_EXPORT RenderViewImpl // Must be called before any players are created. void SetMediaStreamClientForTesting(MediaStreamClient* media_stream_client); - // Determines whether plugins are allowed to enter fullscreen mode. - bool IsPluginFullscreenAllowed(); - // IPC::Listener implementation ---------------------------------------------- virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; @@ -1468,24 +1420,6 @@ class CONTENT_EXPORT RenderViewImpl int focused_plugin_id_; #endif -#if defined(ENABLE_PLUGINS) - typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet; - PepperPluginSet active_pepper_instances_; - - // Whether or not the focus is on a PPAPI plugin - PepperPluginInstanceImpl* focused_pepper_plugin_; - - // Current text input composition text. Empty if no composition is in - // progress. - string16 pepper_composition_text_; - - // The plugin instance that received the last mouse event. It is set to NULL - // if the last mouse event went to elements other than Pepper plugins. - // |pepper_last_mouse_event_target_| is not owned by this class. We can know - // about when it is destroyed via InstanceDeleted(). - PepperPluginInstanceImpl* pepper_last_mouse_event_target_; -#endif - // Misc ---------------------------------------------------------------------- // The current and pending file chooser completion objects. If the queue is diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index f355732..9cc1b98 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -233,6 +233,22 @@ class CONTENT_EXPORT RenderWidget void OnSwapBuffersComplete(); void OnSwapBuffersAborted(); + // Checks if the text input state and compose inline mode have been changed. + // If they are changed, the new value will be sent to the browser process. + void UpdateTextInputType(); + + // Checks if the selection bounds have been changed. If they are changed, + // the new value will be sent to the browser process. + void UpdateSelectionBounds(); + + +#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) + // Checks if the composition range or composition character bounds have been + // changed. If they are changed, the new value will be sent to the browser + // process. + void UpdateCompositionInfo(bool should_update_range); +#endif + protected: // Friend RefCounted so that the dtor can be non-public. Using this class // without ref-counting is an error. @@ -428,10 +444,6 @@ class CONTENT_EXPORT RenderWidget void set_next_paint_is_restore_ack(); void set_next_paint_is_repaint_ack(); - // Checks if the text input state and compose inline mode have been changed. - // If they are changed, the new value will be sent to the browser process. - void UpdateTextInputType(); - #if defined(OS_ANDROID) // |show_ime_if_needed| should be true iff the update may cause the ime to be // displayed, e.g. after a tap on an input field on mobile. @@ -442,10 +454,6 @@ class CONTENT_EXPORT RenderWidget void UpdateTextInputState(bool show_ime_if_needed, bool send_ime_ack); #endif - // Checks if the selection bounds have been changed. If they are changed, - // the new value will be sent to the browser process. - virtual void UpdateSelectionBounds(); - // Override point to obtain that the current input method state and caret // position. virtual ui::TextInputType GetTextInputType(); @@ -454,11 +462,6 @@ class CONTENT_EXPORT RenderWidget blink::WebTextInputType type); #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) - // Checks if the composition range or composition character bounds have been - // changed. If they are changed, the new value will be sent to the browser - // process. - void UpdateCompositionInfo(bool should_update_range); - // Override point to obtain that the current composition character bounds. // In the case of surrogate pairs, the character is treated as two characters: // the bounds for first character is actual one, and the bounds for second diff --git a/content/renderer/text_input_client_observer.cc b/content/renderer/text_input_client_observer.cc index 6d89203..d15d1d4 100644 --- a/content/renderer/text_input_client_observer.cc +++ b/content/renderer/text_input_client_observer.cc @@ -52,7 +52,7 @@ void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) { gfx::Rect rect; #if defined(ENABLE_PLUGINS) - if (!render_view_impl_->GetPepperCaretBounds(&rect)) + if (!render_view_impl_->main_render_frame()->GetPepperCaretBounds(&rect)) #endif { blink::WebFrame* frame = webview()->focusedFrame(); |