Commit af28142c authored by koz@chromium.org's avatar koz@chromium.org

Reimplement the Pepper fullscreen API to use webkitRequestFullScreen and friends.

This depends on https://bugs.webkit.org/show_bug.cgi?id=66746 and http://codereview.chromium.org/7461059/, neither of which have been landed. So this should be considered a preliminary review at this stage :)

BUG=
TEST=

Review URL: http://codereview.chromium.org/7714017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98767 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f7f18d0
...@@ -1299,13 +1299,6 @@ int32_t PepperPluginDelegateImpl::ShowContextMenu( ...@@ -1299,13 +1299,6 @@ int32_t PepperPluginDelegateImpl::ShowContextMenu(
webkit::ppapi::PPB_Flash_Menu_Impl* menu, webkit::ppapi::PPB_Flash_Menu_Impl* menu,
const gfx::Point& position) { const gfx::Point& position) {
int32 render_widget_id = render_view_->routing_id(); int32 render_widget_id = render_view_->routing_id();
if (instance->IsFullscreen(instance->pp_instance())) {
webkit::ppapi::FullscreenContainer* container =
instance->fullscreen_container();
DCHECK(container);
render_widget_id =
static_cast<RenderWidgetFullscreenPepper*>(container)->routing_id();
}
int request_id = pending_context_menus_.Add( int request_id = pending_context_menus_.Add(
new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu)); new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu));
...@@ -1369,12 +1362,6 @@ void PepperPluginDelegateImpl::OnCustomContextMenuAction( ...@@ -1369,12 +1362,6 @@ void PepperPluginDelegateImpl::OnCustomContextMenuAction(
saved_context_menu_action_ = action; saved_context_menu_action_ = action;
} }
webkit::ppapi::FullscreenContainer*
PepperPluginDelegateImpl::CreateFullscreenContainer(
webkit::ppapi::PluginInstance* instance) {
return render_view_->CreatePepperFullscreenContainer(instance);
}
gfx::Size PepperPluginDelegateImpl::GetScreenSize() { gfx::Size PepperPluginDelegateImpl::GetScreenSize() {
WebKit::WebScreenInfo info = render_view_->screenInfo(); WebKit::WebScreenInfo info = render_view_->screenInfo();
return gfx::Size(info.rect.width, info.rect.height); return gfx::Size(info.rect.width, info.rect.height);
......
...@@ -281,9 +281,6 @@ class PepperPluginDelegateImpl ...@@ -281,9 +281,6 @@ class PepperPluginDelegateImpl
void CompleteShowContextMenu(int request_id, void CompleteShowContextMenu(int request_id,
bool did_select, bool did_select,
unsigned action); unsigned action);
virtual webkit::ppapi::FullscreenContainer*
CreateFullscreenContainer(
webkit::ppapi::PluginInstance* instance) OVERRIDE;
virtual gfx::Size GetScreenSize() OVERRIDE; virtual gfx::Size GetScreenSize() OVERRIDE;
virtual std::string GetDefaultEncoding() OVERRIDE; virtual std::string GetDefaultEncoding() OVERRIDE;
virtual void ZoomLimitsChanged(double minimum_factor, double maximum_factor) virtual void ZoomLimitsChanged(double minimum_factor, double maximum_factor)
......
...@@ -223,11 +223,6 @@ int32_t MockPluginDelegate::ShowContextMenu( ...@@ -223,11 +223,6 @@ int32_t MockPluginDelegate::ShowContextMenu(
return PP_ERROR_FAILED; return PP_ERROR_FAILED;
} }
FullscreenContainer* MockPluginDelegate::CreateFullscreenContainer(
PluginInstance* instance) {
return NULL;
}
gfx::Size MockPluginDelegate::GetScreenSize() { gfx::Size MockPluginDelegate::GetScreenSize() {
return gfx::Size(1024, 768); return gfx::Size(1024, 768);
} }
......
...@@ -100,8 +100,6 @@ class MockPluginDelegate : public PluginDelegate { ...@@ -100,8 +100,6 @@ class MockPluginDelegate : public PluginDelegate {
PluginInstance* instance, PluginInstance* instance,
webkit::ppapi::PPB_Flash_Menu_Impl* menu, webkit::ppapi::PPB_Flash_Menu_Impl* menu,
const gfx::Point& position); const gfx::Point& position);
virtual FullscreenContainer* CreateFullscreenContainer(
PluginInstance* instance);
virtual gfx::Size GetScreenSize(); virtual gfx::Size GetScreenSize();
virtual std::string GetDefaultEncoding(); virtual std::string GetDefaultEncoding();
virtual void ZoomLimitsChanged(double minimum_factor, virtual void ZoomLimitsChanged(double minimum_factor,
......
...@@ -79,7 +79,6 @@ namespace webkit { ...@@ -79,7 +79,6 @@ namespace webkit {
namespace ppapi { namespace ppapi {
class FileIO; class FileIO;
class FullscreenContainer;
class PepperFilePath; class PepperFilePath;
class PluginInstance; class PluginInstance;
class PluginModule; class PluginModule;
...@@ -390,11 +389,6 @@ class PluginDelegate { ...@@ -390,11 +389,6 @@ class PluginDelegate {
webkit::ppapi::PPB_Flash_Menu_Impl* menu, webkit::ppapi::PPB_Flash_Menu_Impl* menu,
const gfx::Point& position) = 0; const gfx::Point& position) = 0;
// Create a fullscreen container for a plugin instance. This effectively
// switches the plugin to fullscreen.
virtual FullscreenContainer* CreateFullscreenContainer(
PluginInstance* instance) = 0;
// Gets the size of the screen. The fullscreen window will be created at that // Gets the size of the screen. The fullscreen window will be created at that
// size. // size.
virtual gfx::Size GetScreenSize() = 0; virtual gfx::Size GetScreenSize() = 0;
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/event_conversion.h" #include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
#include "webkit/plugins/ppapi/message_channel.h" #include "webkit/plugins/ppapi/message_channel.h"
#include "webkit/plugins/ppapi/npapi_glue.h" #include "webkit/plugins/ppapi/npapi_glue.h"
#include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_delegate.h"
...@@ -233,7 +232,7 @@ PluginInstance::PluginInstance( ...@@ -233,7 +232,7 @@ PluginInstance::PluginInstance(
plugin_print_interface_(NULL), plugin_print_interface_(NULL),
plugin_graphics_3d_interface_(NULL), plugin_graphics_3d_interface_(NULL),
always_on_top_(false), always_on_top_(false),
fullscreen_container_(NULL), desired_fullscreen_state_(false),
fullscreen_(false), fullscreen_(false),
message_channel_(NULL), message_channel_(NULL),
sad_plugin_(NULL), sad_plugin_(NULL),
...@@ -277,10 +276,6 @@ void PluginInstance::Delete() { ...@@ -277,10 +276,6 @@ void PluginInstance::Delete() {
scoped_refptr<PluginInstance> ref(this); scoped_refptr<PluginInstance> ref(this);
instance_interface_->DidDestroy(pp_instance()); instance_interface_->DidDestroy(pp_instance());
if (fullscreen_container_) {
fullscreen_container_->Destroy();
fullscreen_container_ = NULL;
}
container_ = NULL; container_ = NULL;
} }
...@@ -301,32 +296,21 @@ void PluginInstance::Paint(WebCanvas* canvas, ...@@ -301,32 +296,21 @@ void PluginInstance::Paint(WebCanvas* canvas,
} }
void PluginInstance::InvalidateRect(const gfx::Rect& rect) { void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
if (fullscreen_container_) { if (!container_ || position_.IsEmpty())
if (rect.IsEmpty()) return; // Nothing to do.
fullscreen_container_->Invalidate(); if (rect.IsEmpty())
else container_->invalidate();
fullscreen_container_->InvalidateRect(rect); else
} else { container_->invalidateRect(rect);
if (!container_ || position_.IsEmpty())
return; // Nothing to do.
if (rect.IsEmpty())
container_->invalidate();
else
container_->invalidateRect(rect);
}
} }
void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) { void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) {
if (fullscreen_container_) { if (full_frame_) {
fullscreen_container_->ScrollRect(dx, dy, rect); container_->scrollRect(dx, dy, rect);
} else { } else {
if (full_frame_) { // Can't do optimized scrolling since there could be other elements on top
container_->scrollRect(dx, dy, rect); // of us.
} else { InvalidateRect(rect);
// Can't do optimized scrolling since there could be other elements on top
// of us.
InvalidateRect(rect);
}
} }
} }
...@@ -340,10 +324,7 @@ unsigned PluginInstance::GetBackingTextureId() { ...@@ -340,10 +324,7 @@ unsigned PluginInstance::GetBackingTextureId() {
} }
void PluginInstance::CommitBackingTexture() { void PluginInstance::CommitBackingTexture() {
if (fullscreen_container_) container_->commitBackingTexture();
fullscreen_container_->Invalidate();
else
container_->commitBackingTexture();
} }
void PluginInstance::InstanceCrashed() { void PluginInstance::InstanceCrashed() {
...@@ -505,7 +486,7 @@ PP_Var PluginInstance::GetInstanceObject() { ...@@ -505,7 +486,7 @@ PP_Var PluginInstance::GetInstanceObject() {
void PluginInstance::ViewChanged(const gfx::Rect& position, void PluginInstance::ViewChanged(const gfx::Rect& position,
const gfx::Rect& clip) { const gfx::Rect& clip) {
fullscreen_ = (fullscreen_container_ != NULL); fullscreen_ = desired_fullscreen_state_;
position_ = position; position_ = position;
if (clip.IsEmpty()) { if (clip.IsEmpty()) {
...@@ -779,10 +760,7 @@ bool PluginInstance::PluginHasFocus() const { ...@@ -779,10 +760,7 @@ bool PluginInstance::PluginHasFocus() const {
} }
void PluginInstance::ReportGeometry() { void PluginInstance::ReportGeometry() {
// If this call was delayed, we may have transitioned back to fullscreen in if (container_)
// the mean time, so only report the geometry if we are actually in normal
// mode.
if (container_ && !fullscreen_container_)
container_->reportGeometry(); container_->reportGeometry();
} }
...@@ -958,7 +936,7 @@ void PluginInstance::PrintEnd() { ...@@ -958,7 +936,7 @@ void PluginInstance::PrintEnd() {
} }
bool PluginInstance::IsFullscreenOrPending() { bool PluginInstance::IsFullscreenOrPending() {
return fullscreen_container_ != NULL; return desired_fullscreen_state_;
} }
void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
...@@ -971,22 +949,16 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { ...@@ -971,22 +949,16 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
if (fullscreen == IsFullscreenOrPending()) if (fullscreen == IsFullscreenOrPending())
return; return;
BindGraphics(pp_instance(), 0); desired_fullscreen_state_ = fullscreen;
VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); if (fullscreen)
if (fullscreen) { container_->element().requestFullScreen();
DCHECK(!fullscreen_container_); else
fullscreen_container_ = delegate_->CreateFullscreenContainer(this); container_->element().document().cancelFullScreen();
if (!delay_report) {
ReportGeometry();
} else { } else {
DCHECK(fullscreen_container_); MessageLoop::current()->PostTask(
fullscreen_container_->Destroy();
fullscreen_container_ = NULL;
fullscreen_ = false;
if (!delay_report) {
ReportGeometry();
} else {
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry)); FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
}
} }
} }
...@@ -1033,10 +1005,7 @@ int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, ...@@ -1033,10 +1005,7 @@ int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request,
} }
PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() {
if (fullscreen_container_) return delegate_->CreateContext3D();
return fullscreen_container_->CreateContext3D();
else
return delegate_->CreateContext3D();
} }
bool PluginInstance::PrintPDFOutput(PP_Resource print_output, bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
...@@ -1306,16 +1275,6 @@ PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const { ...@@ -1306,16 +1275,6 @@ PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const {
} }
void PluginInstance::setBackingTextureId(unsigned int id) { void PluginInstance::setBackingTextureId(unsigned int id) {
// If we have a full-screen container_ then the plugin is fullscreen,
// and the parent context is not the one for the browser page, but for the
// full-screen window, and so the parent texture ID doesn't correspond to
// anything in the page's context.
//
// TODO(alokp): It would be better at some point to have the equivalent
// in the FullscreenContainer so that we don't need to poll
if (fullscreen_container_)
return;
if (container_) if (container_)
container_->setBackingTextureId(id); container_->setBackingTextureId(id);
} }
...@@ -1361,10 +1320,6 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, ...@@ -1361,10 +1320,6 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
return PP_TRUE; return PP_TRUE;
} }
// Refuse to bind if we're transitioning to fullscreen.
if (fullscreen_container_ && !fullscreen_)
return PP_FALSE;
EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ?
static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL;
...@@ -1552,8 +1507,6 @@ void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) { ...@@ -1552,8 +1507,6 @@ void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) {
void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
cursor_.reset(cursor); cursor_.reset(cursor);
if (fullscreen_container_)
fullscreen_container_->DidChangeCursor(*cursor);
} }
} // namespace ppapi } // namespace ppapi
......
...@@ -64,7 +64,6 @@ class Resource; ...@@ -64,7 +64,6 @@ class Resource;
namespace webkit { namespace webkit {
namespace ppapi { namespace ppapi {
class FullscreenContainer;
class MessageChannel; class MessageChannel;
class ObjectVar; class ObjectVar;
class PluginDelegate; class PluginDelegate;
...@@ -242,10 +241,6 @@ class PluginInstance : public base::RefCounted<PluginInstance>, ...@@ -242,10 +241,6 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// embedded in a page). // embedded in a page).
bool IsFullPagePlugin() const; bool IsFullPagePlugin() const;
FullscreenContainer* fullscreen_container() const {
return fullscreen_container_;
}
// FunctionGroupBase overrides. // FunctionGroupBase overrides.
virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI()
OVERRIDE; OVERRIDE;
...@@ -467,10 +462,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>, ...@@ -467,10 +462,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// to use a more optimized painting path in some cases. // to use a more optimized painting path in some cases.
bool always_on_top_; bool always_on_top_;
// Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: // Since entering fullscreen mode is an asynchronous operation, we set this
// there is a transition state where fullscreen_container_ is non-NULL but // variable to the desired state at the time we issue the fullscreen change
// fullscreen_ is false (see above). // request. The plugin will receive a DidChangeView event when it goes
FullscreenContainer* fullscreen_container_; // fullscreen.
bool desired_fullscreen_state_;
// True if we are in fullscreen mode. Note: it is false during the transition. // True if we are in fullscreen mode. Note: it is false during the transition.
bool fullscreen_; bool fullscreen_;
......
...@@ -118,8 +118,7 @@ bool WebPluginImpl::getFormValue(WebString* value) { ...@@ -118,8 +118,7 @@ bool WebPluginImpl::getFormValue(WebString* value) {
} }
void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) {
if (!instance_->IsFullscreenOrPending()) instance_->Paint(canvas, plugin_rect_, rect);
instance_->Paint(canvas, plugin_rect_, rect);
} }
void WebPluginImpl::updateGeometry( void WebPluginImpl::updateGeometry(
...@@ -128,8 +127,7 @@ void WebPluginImpl::updateGeometry( ...@@ -128,8 +127,7 @@ void WebPluginImpl::updateGeometry(
const WebVector<WebRect>& cut_outs_rects, const WebVector<WebRect>& cut_outs_rects,
bool is_visible) { bool is_visible) {
plugin_rect_ = window_rect; plugin_rect_ = window_rect;
if (!instance_->IsFullscreenOrPending()) instance_->ViewChanged(plugin_rect_, clip_rect);
instance_->ViewChanged(plugin_rect_, clip_rect);
} }
void WebPluginImpl::updateFocus(bool focused) { void WebPluginImpl::updateFocus(bool focused) {
...@@ -145,8 +143,6 @@ bool WebPluginImpl::acceptsInputEvents() { ...@@ -145,8 +143,6 @@ bool WebPluginImpl::acceptsInputEvents() {
bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event, bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo& cursor_info) { WebKit::WebCursorInfo& cursor_info) {
if (instance_->IsFullscreenOrPending())
return false;
return instance_->HandleInputEvent(event, &cursor_info); return instance_->HandleInputEvent(event, &cursor_info);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment