summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 17:43:36 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 17:43:36 +0000
commite8f07ac77c1b27633eb7c6c2793d5b465e023f9f (patch)
tree6b1aa7de84dcb5f18adac114bba01c4f77a71e6b /webkit
parent08d9dfe8c279ec894cdacdf5f0a89bd8c85a92fc (diff)
downloadchromium_src-e8f07ac77c1b27633eb7c6c2793d5b465e023f9f.zip
chromium_src-e8f07ac77c1b27633eb7c6c2793d5b465e023f9f.tar.gz
chromium_src-e8f07ac77c1b27633eb7c6c2793d5b465e023f9f.tar.bz2
Change the DidChangeView update to take a new ViewChanged resource.
This will allow us to be more flexible about adding data to view changed updates in the future. For now, I've incorporated fullscreen and tab foreground state into the view state. BUG= TEST= Review URL: http://codereview.chromium.org/8951014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_glue.gypi1
-rw-r--r--webkit/plugins/ppapi/gfx_conversion.h48
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc9
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc139
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h47
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc4
7 files changed, 174 insertions, 78 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index ca2bae9..e46f135 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -231,6 +231,7 @@
'../plugins/ppapi/file_path.cc',
'../plugins/ppapi/file_path.h',
'../plugins/ppapi/fullscreen_container.h',
+ '../plugins/ppapi/gfx_conversion.h',
'../plugins/ppapi/host_array_buffer_var.cc',
'../plugins/ppapi/host_array_buffer_var.h',
'../plugins/ppapi/host_globals.cc',
diff --git a/webkit/plugins/ppapi/gfx_conversion.h b/webkit/plugins/ppapi/gfx_conversion.h
new file mode 100644
index 0000000..ad4006b
--- /dev/null
+++ b/webkit/plugins/ppapi/gfx_conversion.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_PLUGINS_PPAPI_GFX_CONVERSION_H_
+#define WEBKIT_PLUGINS_PPAPI_GFX_CONVERSION_H_
+
+#include "ppapi/c/pp_point.h"
+#include "ppapi/c/pp_rect.h"
+#include "ppapi/c/pp_size.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
+
+// Conversions for graphics types between our gfx library and PPAPI.
+// The style of naming is to match the PP_Bool conversions.
+
+namespace webkit {
+namespace ppapi {
+
+inline gfx::Point PP_ToGfxPoint(const PP_Point& p) {
+ return gfx::Point(p.x, p.y);
+}
+
+inline PP_Point PP_FromGfxPoint(const gfx::Point& p) {
+ return PP_MakePoint(p.x(), p.y());
+}
+
+inline gfx::Rect PP_ToGfxRect(const PP_Rect& r) {
+ return gfx::Rect(r.point.x, r.point.y, r.size.width, r.size.height);
+}
+
+inline PP_Rect PP_FromGfxRect(const gfx::Rect& r) {
+ return PP_MakeRectFromXYWH(r.x(), r.y(), r.width(), r.height());
+}
+
+inline gfx::Size PP_ToGfxSize(const PP_Size& s) {
+ return gfx::Size(s.width, s.height);
+}
+
+inline PP_Size PP_FromGfxSize(const gfx::Size& s) {
+ return PP_MakeSize(s.width(), s.height());
+}
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_GFX_CONVERSION_H_
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 3e08385d..2340200 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -60,6 +60,7 @@
#include "ppapi/c/ppb_url_request_info.h"
#include "ppapi/c/ppb_url_response_info.h"
#include "ppapi/c/ppb_var.h"
+#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppp.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/private/ppb_file_ref_private.h"
@@ -513,10 +514,14 @@ PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() {
PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) {
PluginInstance* instance(NULL);
- const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_1_0);
+ const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_1_1);
if (ppp_instance) {
+ instance = PluginInstance::Create1_1(delegate, this, ppp_instance);
+ } else if ((ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE_1_0))) {
instance = PluginInstance::Create1_0(delegate, this, ppp_instance);
- } if (!instance) {
+ }
+
+ if (!instance) {
LOG(WARNING) << "Plugin doesn't support instance interface, failing.";
return NULL;
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 9229d10..c5c52ce 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -27,7 +27,10 @@
#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/shared_impl/ppb_input_event_shared.h"
#include "ppapi/shared_impl/ppb_url_util_shared.h"
+#include "ppapi/shared_impl/ppb_view_shared.h"
#include "ppapi/shared_impl/ppp_instance_combined.h"
+#include "ppapi/shared_impl/resource.h"
+#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
@@ -52,6 +55,7 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
+#include "webkit/plugins/ppapi/gfx_conversion.h"
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/message_channel.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
@@ -91,6 +95,8 @@ using base::StringPrintf;
using ppapi::InputEventData;
using ppapi::PPB_InputEvent_Shared;
using ppapi::PpapiGlobals;
+using ppapi::PPB_View_Shared;
+using ppapi::ScopedPPResource;
using ppapi::StringVar;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Buffer_API;
@@ -99,6 +105,7 @@ using ppapi::thunk::PPB_Graphics3D_API;
using ppapi::thunk::PPB_ImageData_API;
using ppapi::thunk::PPB_Instance_FunctionAPI;
using ppapi::Var;
+using ppapi::ViewData;
using WebKit::WebBindings;
using WebKit::WebCanvas;
using WebKit::WebConsoleMessage;
@@ -219,11 +226,6 @@ COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_CURSORTYPE_GRABBING);
// Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM;
// PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types.
-void RectToPPRect(const gfx::Rect& input, PP_Rect* output) {
- *output = PP_MakeRectFromXYWH(input.x(), input.y(),
- input.width(), input.height());
-}
-
// Sets |*security_origin| to be the WebKit security origin associated with the
// document containing the given plugin instance. On success, returns true. If
// the instance is invalid, returns false and |*security_origin| will be
@@ -253,6 +255,18 @@ PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate,
new ::ppapi::PPP_Instance_Combined(*instance));
}
+// static
+PluginInstance* PluginInstance::Create1_1(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_1_1) {
+ const PPP_Instance_1_1* instance =
+ static_cast<const PPP_Instance_1_1*>(ppp_instance_if_1_1);
+ return new PluginInstance(
+ delegate,
+ module,
+ new ::ppapi::PPP_Instance_Combined(*instance));
+}
+
PluginInstance::PluginInstance(
PluginDelegate* delegate,
PluginModule* module,
@@ -263,7 +277,8 @@ PluginInstance::PluginInstance(
pp_instance_(0),
container_(NULL),
full_frame_(false),
- sent_did_change_view_(false),
+ sent_initial_did_change_view_(false),
+ suppress_did_change_view_(false),
has_webkit_focus_(false),
has_content_area_focus_(false),
find_identifier_(-1),
@@ -283,7 +298,6 @@ PluginInstance::PluginInstance(
fullscreen_container_(NULL),
flash_fullscreen_(false),
desired_fullscreen_state_(false),
- fullscreen_(false),
message_channel_(NULL),
sad_plugin_(NULL),
input_event_mask_(0),
@@ -368,7 +382,8 @@ void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
else
fullscreen_container_->InvalidateRect(rect);
} else {
- if (!container_ || position_.IsEmpty())
+ if (!container_ ||
+ view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0)
return; // Nothing to do.
if (rect.IsEmpty())
container_->invalidate();
@@ -630,7 +645,9 @@ bool PluginInstance::IsPluginAcceptingCompositionEvents() const {
gfx::Rect PluginInstance::GetCaretBounds() const {
if (!text_input_caret_set_) {
// If it is never set by the plugin, use the bottom left corner.
- return gfx::Rect(position().x(), position().y()+position().height(), 0, 0);
+ return gfx::Rect(view_data_.rect.point.x,
+ view_data_.rect.point.y + view_data_.rect.size.height,
+ 0, 0);
}
// TODO(kinaba) Take CSS transformation into accont.
@@ -639,7 +656,7 @@ gfx::Rect PluginInstance::GetCaretBounds() const {
// passed to IME. Currently, we pass only the caret rectangle because
// it is the only information supported uniformly in Chromium.
gfx::Rect caret(text_input_caret_);
- caret.Offset(position().origin());
+ caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
return caret;
}
@@ -720,41 +737,41 @@ void PluginInstance::ViewChanged(const gfx::Rect& position,
if (!clip.IsEmpty())
new_clip = clip;
- // Don't notify the plugin if we've already sent these same params before.
- if (sent_did_change_view_ && position == position_ && new_clip == clip_)
- return;
+ ViewData previous_view = view_data_;
+
+ view_data_.rect = PP_FromGfxRect(position);
+ view_data_.clip_rect = PP_FromGfxRect(clip);
- if (desired_fullscreen_state_ || fullscreen_) {
+ if (desired_fullscreen_state_ || view_data_.is_fullscreen) {
WebElement element = container_->element();
WebDocument document = element.document();
bool is_fullscreen_element = (element == document.fullScreenElement());
- if (!fullscreen_ && desired_fullscreen_state_ &&
+ if (!view_data_.is_fullscreen && desired_fullscreen_state_ &&
delegate()->IsInFullscreenMode() && is_fullscreen_element) {
// Entered fullscreen. Only possible via SetFullscreen().
- fullscreen_ = true;
- } else if (fullscreen_ && !is_fullscreen_element) {
+ view_data_.is_fullscreen = true;
+ } else if (view_data_.is_fullscreen && !is_fullscreen_element) {
// Exited fullscreen. Possible via SetFullscreen() or F11/link,
// so desired_fullscreen_state might be out-of-date.
desired_fullscreen_state_ = false;
- fullscreen_ = false;
+ view_data_.is_fullscreen = false;
+
+ // This operation will cause the plugin to re-layout which will send more
+ // DidChangeView updates. Schedule an asynchronous update and suppress
+ // notifications until that completes to avoid sending intermediate sizes
+ // to the plugins.
+ ScheduleAsyncDidChangeView(previous_view);
+
// Reset the size attributes that we hacked to fill in the screen and
// retrigger ViewChanged. Make sure we don't forward duplicates of
// this view to the plugin.
ResetSizeAttributesAfterFullscreen();
- SetSentDidChangeView(position, new_clip);
- MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this));
return;
}
}
- SetSentDidChangeView(position, new_clip);
flash_fullscreen_ = (fullscreen_container_ != NULL);
-
- PP_Rect pp_position, pp_clip;
- RectToPPRect(position_, &pp_position);
- RectToPPRect(clip_, &pp_clip);
- instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip);
+ SendDidChangeView(previous_view);
}
void PluginInstance::SetWebKitFocus(bool has_focus) {
@@ -812,11 +829,12 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
// store when seeing if we cover the given paint bounds, since the backing
// store could be smaller than the declared plugin area.
PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data();
- gfx::Rect plugin_backing_store_rect(position_.origin(),
- gfx::Size(image_data->width(),
- image_data->height()));
- gfx::Rect clip_page(clip_);
- clip_page.Offset(position_.origin());
+ gfx::Rect plugin_backing_store_rect(
+ PP_ToGfxPoint(view_data_.rect.point),
+ gfx::Size(image_data->width(), image_data->height()));
+
+ gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect);
+ clip_page.Offset(PP_ToGfxPoint(view_data_.rect.point));
gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page);
if (!plugin_paint_rect.Contains(paint_bounds))
return false;
@@ -993,6 +1011,38 @@ bool PluginInstance::PluginHasFocus() const {
return has_webkit_focus_ && has_content_area_focus_;
}
+void PluginInstance::ScheduleAsyncDidChangeView(
+ const ::ppapi::ViewData& previous_view) {
+ if (suppress_did_change_view_)
+ return; // Already scheduled.
+ suppress_did_change_view_ = true;
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&PluginInstance::SendAsyncDidChangeView,
+ this, previous_view));
+}
+
+void PluginInstance::SendAsyncDidChangeView(const ViewData& previous_view) {
+ DCHECK(suppress_did_change_view_);
+ suppress_did_change_view_ = false;
+ SendDidChangeView(previous_view);
+}
+
+void PluginInstance::SendDidChangeView(const ViewData& previous_view) {
+ if (suppress_did_change_view_ ||
+ (sent_initial_did_change_view_ && previous_view.Equals(view_data_)))
+ return; // Nothing to update.
+
+ sent_initial_did_change_view_ = true;
+ ScopedPPResource resource(
+ ScopedPPResource::PassRef(),
+ (new PPB_View_Shared(PPB_View_Shared::InitAsImpl(),
+ pp_instance(), view_data_))->GetReference());
+
+ instance_interface_->DidChangeView(pp_instance(), resource,
+ &view_data_.rect,
+ &view_data_.clip_rect);
+}
+
void PluginInstance::ReportGeometry() {
// If this call was delayed, we may have transitioned back to fullscreen in
// the mean time, so only report the geometry if we are actually in normal
@@ -1045,7 +1095,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
int num_pages = 0;
PP_PrintSettings_Dev print_settings;
- RectToPPRect(printable_area, &print_settings.printable_area);
+ print_settings.printable_area = PP_FromGfxRect(printable_area);
print_settings.dpi = printer_dpi;
print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
print_settings.grayscale = PP_FALSE;
@@ -1151,7 +1201,7 @@ bool PluginInstance::SetFullscreen(bool fullscreen) {
// Check whether we are trying to switch while the state is in transition.
// The 2nd request gets dropped while messing up the internal state, so
// disallow this.
- if (fullscreen_ != desired_fullscreen_state_)
+ if (view_data_.is_fullscreen != desired_fullscreen_state_)
return false;
// The browser will allow us to go into fullscreen mode only when processing
@@ -1582,8 +1632,8 @@ void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
std::vector<linked_ptr<WebInputEvent> > events =
CreateSimulatedWebInputEvents(
input_event,
- position().x() + position().width() / 2,
- position().y() + position().height() / 2);
+ view_data_.rect.point.x + view_data_.rect.size.width / 2,
+ view_data_.rect.point.y + view_data_.rect.size.height / 2);
for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin();
it != events.end(); ++it) {
web_view->handleInputEvent(*it->get());
@@ -1615,7 +1665,7 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
// Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
// to/from fullscreen with PPB_Fullscreen.
if ((fullscreen_container_ && !flash_fullscreen_) ||
- desired_fullscreen_state_ != fullscreen_)
+ desired_fullscreen_state_ != view_data_.is_fullscreen)
return PP_FALSE;
EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
@@ -1656,6 +1706,10 @@ PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) {
return PP_FromBool(full_frame());
}
+const ViewData* PluginInstance::GetViewData(PP_Instance instance) {
+ return &view_data_;
+}
+
PP_Var PluginInstance::GetWindowObject(PP_Instance instance) {
if (!container_)
return PP_MakeUndefined();
@@ -1779,10 +1833,6 @@ void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
delegate_->SelectedFindResultChanged(find_identifier_, index);
}
-PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
- return PP_FromBool(fullscreen_);
-}
-
PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
return PP_FromBool(flash_fullscreen_);
}
@@ -1957,13 +2007,6 @@ bool PluginInstance::CanAccessMainFrame() const {
main_document.securityOrigin());
}
-void PluginInstance::SetSentDidChangeView(const gfx::Rect& position,
- const gfx::Rect& clip) {
- sent_did_change_view_ = true;
- position_ = position;
- clip_ = clip;
-}
-
void PluginInstance::KeepSizeAttributesBeforeFullscreen() {
WebElement element = container_->element();
width_before_fullscreen_ = element.getAttribute(WebString::fromUTF8(kWidth));
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 2dfc21d..bb43a9d 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -24,6 +24,7 @@
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/ppb_instance_shared.h"
+#include "ppapi/shared_impl/ppb_view_shared.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
@@ -85,10 +86,13 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
public ::ppapi::PPB_Instance_Shared {
public:
// Create and return a PluginInstance object which supports the
- // PPP_Instance_1_0 interface.
+ // given version.
static PluginInstance* Create1_0(PluginDelegate* delegate,
PluginModule* module,
const void* ppp_instance_if_1_0);
+ static PluginInstance* Create1_1(PluginDelegate* delegate,
+ PluginModule* module,
+ const void* ppp_instance_if_1_1);
// Delete should be called by the WebPlugin before this destructor.
virtual ~PluginInstance();
@@ -99,9 +103,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
WebKit::WebPluginContainer* container() const { return container_; }
- const gfx::Rect& position() const { return position_; }
- const gfx::Rect& clip() const { return clip_; }
-
void set_always_on_top(bool on_top) { always_on_top_ = on_top; }
// Returns the PP_Instance uniquely identifying this instance. Guaranteed
@@ -144,6 +145,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// PPB_Instance and PPB_Instance_Private implementation.
const GURL& plugin_url() const { return plugin_url_; }
bool full_frame() const { return full_frame_; }
+ const ::ppapi::ViewData& view_data() const { return view_data_; }
// If |type| is not PP_CURSORTYPE_CUSTOM, |custom_image| and |hot_spot| are
// ignored.
bool SetCursor(PP_CursorType_Dev type,
@@ -306,6 +308,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
virtual PP_Bool BindGraphics(PP_Instance instance,
PP_Resource device) OVERRIDE;
virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE;
+ virtual const ::ppapi::ViewData* GetViewData(PP_Instance instance) OVERRIDE;
virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE;
virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE;
virtual PP_Var ExecuteScript(PP_Instance instance,
@@ -329,7 +332,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool FlashGetScreenSize(PP_Instance instance,
PP_Size* size) OVERRIDE;
- virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE;
virtual PP_Bool SetFullscreen(PP_Instance instance,
PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size)
@@ -384,6 +386,10 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// (see has_webkit_focus_ below).
bool PluginHasFocus() const;
+ void ScheduleAsyncDidChangeView(const ::ppapi::ViewData& previous_view);
+ void SendAsyncDidChangeView(const ::ppapi::ViewData& previous_view);
+ void SendDidChangeView(const ::ppapi::ViewData& previous_view);
+
// Reports the current plugin geometry to the plugin by calling
// DidChangeView.
void ReportGeometry();
@@ -444,9 +450,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// compositing path.
bool IsViewAccelerated();
- // Remember view parameters that were sent to the plugin.
- void SetSentDidChangeView(const gfx::Rect& position, const gfx::Rect& clip);
-
// Track, set and reset size attributes to control the size of the plugin
// in and out of fullscreen mode.
void KeepSizeAttributesBeforeFullscreen();
@@ -469,20 +472,19 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// an entire document rather than an embed tag.
bool full_frame_;
+ // Stores the current state of the plugin view.
+ ::ppapi::ViewData view_data_;
+
// Indicates if we've ever sent a didChangeView to the plugin. This ensure we
// always send an initial notification, even if the position and clip are the
// same as the default values.
- bool sent_did_change_view_;
-
- // Position in the viewport (which moves as the page is scrolled) of this
- // plugin. This will be a 0-sized rectangle if the plugin has not yet been
- // laid out.
- gfx::Rect position_;
+ bool sent_initial_did_change_view_;
- // Current clip rect. This will be empty if the plugin is not currently
- // visible. This is in the plugin's coordinate system, so fully visible will
- // be (0, 0, w, h) regardless of scroll position.
- gfx::Rect clip_;
+ // Set to true when we've scheduled an asynchronous DidChangeView update for
+ // the purposes of consolidating updates. When this is set, code should
+ // update the view_data_ but not send updates. It will be cleared once the
+ // asynchronous update has been sent out.
+ bool suppress_did_change_view_;
// The current device context for painting in 2D or 3D.
scoped_refptr< ::ppapi::Resource> bound_graphics_;
@@ -556,8 +558,9 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// flash_fullscreen_ is false (see above).
FullscreenContainer* fullscreen_container_;
- // True if we are in fullscreen mode. False if we are in normal mode or
- // in transition to fullscreen.
+ // True if we are in "flash" fullscreen mode. False if we are in normal mode
+ // or in transition to fullscreen. Normal fullscreen mode is indicated in
+ // the ViewData.
bool flash_fullscreen_;
// Implementation of PPB_Fullscreen.
@@ -568,10 +571,6 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// fullscreen.
bool desired_fullscreen_state_;
- // True if we are in fullscreen mode. False if we are in normal mode.
- // It reflects the previous state when in transition.
- bool fullscreen_;
-
// WebKit does not resize the plugin when going into fullscreen mode, so we do
// this here by modifying the various plugin attributes and then restoring
// them on exit.
diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index d2bc625..e245727 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -38,9 +38,7 @@ PP_Bool Instance_DidCreate(PP_Instance pp_instance,
void Instance_DidDestroy(PP_Instance instance) {
}
-void Instance_DidChangeView(PP_Instance pp_instance,
- const PP_Rect* position,
- const PP_Rect* clip) {
+void Instance_DidChangeView(PP_Instance pp_instance, PP_Resource view) {
}
void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) {
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index a209e1f..dec85d0 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -22,6 +22,7 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/gfx_conversion.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
@@ -330,7 +331,8 @@ int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) {
// ViewInitiatedPaint/ViewFlushedPaint calls, leaving our callback stranded.
gfx::Rect visible_changed_rect;
if (bound_instance_ && !op_rect.IsEmpty())
- visible_changed_rect = bound_instance_->clip().Intersect(op_rect);
+ visible_changed_rect =PP_ToGfxRect(bound_instance_->view_data().clip_rect).
+ Intersect(op_rect);
if (bound_instance_ && !visible_changed_rect.IsEmpty()) {
if (operation.type == QueuedOperation::SCROLL) {