summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/plugin_host.cc156
-rw-r--r--webkit/glue/plugins/plugin_host.h22
-rw-r--r--webkit/glue/plugins/plugin_instance.cc1
-rw-r--r--webkit/glue/plugins/plugin_instance.h9
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc5
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h1
-rw-r--r--webkit/glue/webplugin_delegate.h4
7 files changed, 35 insertions, 163 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 7993048..b793032 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -5,7 +5,6 @@
#include "webkit/glue/plugins/plugin_host.h"
#include "base/logging.h"
-#include "base/message_loop.h"
#include "base/string_util.h"
#include "webkit/default_plugin/default_plugin_shared.h"
#include "webkit/glue/glue_util.h"
@@ -17,29 +16,12 @@
#include "webkit/glue/plugins/plugin_stream_url.h"
#include "third_party/npapi/bindings/npruntime.h"
-extern "C" {
-
-// FindInstance()
-// Finds a PluginInstance from an NPP.
-// The caller must take a reference if needed.
-NPAPI::PluginInstance* FindInstance(NPP id) {
- if (id == NULL) {
- NOTREACHED();
- return NULL;
- }
-
- return (NPAPI::PluginInstance *)id->ndata;
-}
namespace NPAPI
{
scoped_refptr<PluginHost> PluginHost::singleton_;
-static const int kFlashMessageThrottleDelayMs = 10;
-
-PluginHost::PluginHost()
-#pragma warning(suppress: 4355) // can use this
- : throttle_factory_(this) {
+PluginHost::PluginHost() {
InitializeHostFuncs();
}
@@ -151,78 +133,6 @@ void PluginHost::PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides) {
host_funcs_.enumerate = overrides->enumerate;
}
-void PluginHost::InvalidateRect(NPP id, NPRect* invalidRect) {
- if (!invalidRect) {
- NOTREACHED();
- return;
- }
-
- // Invalidates specified drawing area prior to repainting or refreshing a
- // windowless plugin
-
- // Before a windowless plugin can refresh part of its drawing area, it must
- // first invalidate it. This function causes the NPP_HandleEvent method to
- // pass an update event or a paint message to the plug-in. After calling
- // this method, the plug-in recieves a paint message asynchronously.
-
- // The browser redraws invalid areas of the document and any windowless
- // plug-ins at regularly timed intervals. To force a paint message, the
- // plug-in can call NPN_ForceRedraw after calling this method.
-
- scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
- DCHECK(plugin.get() != NULL);
-
- if (plugin.get() && plugin->webplugin()) {
- if (!plugin->windowless()) {
- RECT rect = {0};
- rect.left = invalidRect->left;
- rect.right = invalidRect->right;
- rect.top = invalidRect->top;
- rect.bottom = invalidRect->bottom;
- ::InvalidateRect(plugin->window_handle(), &rect, FALSE);
- return;
- }
-
- if (plugin->throttle_invalidate()) {
- // We need to track plugin invalidates on a per instance basis.
- ThrottledInvalidates plugin_instance_invalidates;
- InstanceThrottledInvalidatesMap::iterator invalidate_index =
- instance_throttled_invalidates_.find(id);
- if (invalidate_index != instance_throttled_invalidates_.end()) {
- plugin_instance_invalidates = (*invalidate_index).second;
- }
-
- bool throttle_active =
- (plugin_instance_invalidates.throttled_invalidates.size() > 0);
-
- gfx::Rect rect(invalidRect->left,
- invalidRect->top,
- invalidRect->right - invalidRect->left,
- invalidRect->bottom - invalidRect->top);
-
- plugin_instance_invalidates.throttled_invalidates.push_back(rect);
-
- if (!throttle_active) {
- // We hold a reference to the plugin instance to avoid race conditions
- // due to the instance being released before the OnInvalidateRect
- // function is invoked.
- plugin->AddRef();
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- throttle_factory_.NewRunnableMethod(&PluginHost::OnInvalidateRect,
- id, plugin.get()),
- kFlashMessageThrottleDelayMs);
- }
- instance_throttled_invalidates_[id] = plugin_instance_invalidates;
- } else {
- gfx::Rect rect(invalidRect->left,
- invalidRect->top,
- invalidRect->right - invalidRect->left,
- invalidRect->bottom - invalidRect->top);
- plugin->webplugin()->InvalidateRect(rect);
- }
- }
-}
-
bool PluginHost::SetPostData(const char *buf,
uint32 length,
std::vector<std::string>* names,
@@ -325,39 +235,22 @@ bool PluginHost::SetPostData(const char *buf,
return !err;
}
-void PluginHost::OnInvalidateRect(NPP id, PluginInstance* instance) {
- if (!instance) {
- NOTREACHED();
- return;
- }
-
- InstanceThrottledInvalidatesMap::iterator invalidate_index =
- instance_throttled_invalidates_.find(id);
- if (invalidate_index == instance_throttled_invalidates_.end()) {
- NOTREACHED();
- instance->Release();
- return;
- }
+} // namespace NPAPI
- ThrottledInvalidates plugin_instance_invalidates =
- (*invalidate_index).second;
+extern "C" {
- if (instance->webplugin()) {
- for (unsigned int throttle_index = 0;
- throttle_index <
- plugin_instance_invalidates.throttled_invalidates.size();
- throttle_index++) {
- instance->webplugin()->InvalidateRect(
- plugin_instance_invalidates.throttled_invalidates[throttle_index]);
- }
+// FindInstance()
+// Finds a PluginInstance from an NPP.
+// The caller must take a reference if needed.
+NPAPI::PluginInstance* FindInstance(NPP id) {
+ if (id == NULL) {
+ NOTREACHED();
+ return NULL;
}
- instance->Release();
- instance_throttled_invalidates_.erase(invalidate_index);
+ return (NPAPI::PluginInstance *)id->ndata;
}
-} // namespace NPAPI
-
// Allocates memory from the host's memory space.
void* NPN_MemAlloc(uint32 size) {
scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton();
@@ -646,9 +539,30 @@ void NPN_Status(NPP id, const char* message) {
}
void NPN_InvalidateRect(NPP id, NPRect *invalidRect) {
- scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton();
- if (host != NULL) {
- host->InvalidateRect(id, invalidRect);
+ // Invalidates specified drawing area prior to repainting or refreshing a
+ // windowless plugin
+
+ // Before a windowless plugin can refresh part of its drawing area, it must
+ // first invalidate it. This function causes the NPP_HandleEvent method to
+ // pass an update event or a paint message to the plug-in. After calling
+ // this method, the plug-in recieves a paint message asynchronously.
+
+ // The browser redraws invalid areas of the document and any windowless
+ // plug-ins at regularly timed intervals. To force a paint message, the
+ // plug-in can call NPN_ForceRedraw after calling this method.
+
+ scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
+ DCHECK(plugin.get() != NULL);
+ if (plugin.get() && plugin->webplugin()) {
+ if (invalidRect) {
+ gfx::Rect rect(invalidRect->left,
+ invalidRect->top,
+ invalidRect->right - invalidRect->left,
+ invalidRect->bottom - invalidRect->top);
+ plugin->webplugin()->InvalidateRect(rect);
+ } else {
+ plugin->webplugin()->Invalidate();
+ }
}
}
diff --git a/webkit/glue/plugins/plugin_host.h b/webkit/glue/plugins/plugin_host.h
index 0a90f29..be12d5e 100644
--- a/webkit/glue/plugins/plugin_host.h
+++ b/webkit/glue/plugins/plugin_host.h
@@ -9,11 +9,8 @@
#include <string>
#include <vector>
-#include <map>
#include "base/ref_counted.h"
-#include "base/gfx/rect.h"
-#include "base/task.h"
#include "webkit/glue/plugins/nphostapi.h"
#include "third_party/npapi/bindings/npapi.h"
@@ -50,31 +47,12 @@ class PluginHost : public base::RefCounted<PluginHost> {
void PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides);
- // Handles invalidateRect requests for windowless plugins.
- void InvalidateRect(NPP id, NPRect* invalidRect);
-
private:
PluginHost();
void InitializeHostFuncs();
- // For certain plugins like flash we need to throttle invalidateRect
- // requests as they are made at a high frequency.
- void OnInvalidateRect(NPP id, PluginInstance* instance);
-
static scoped_refptr<PluginHost> singleton_;
NPNetscapeFuncs host_funcs_;
DISALLOW_EVIL_CONSTRUCTORS(PluginHost);
-
- // This structure keeps track of individual plugin instance invalidates.
- struct ThrottledInvalidates {
- std::vector<gfx::Rect> throttled_invalidates;
- };
-
- // We need to track throttled invalidate rects on a per plugin instance
- // basis.
- typedef std::map<NPP, ThrottledInvalidates> InstanceThrottledInvalidatesMap;
- InstanceThrottledInvalidatesMap instance_throttled_invalidates_;
-
- ScopedRunnableMethodFactory<PluginHost> throttle_factory_;
};
} // namespace NPAPI
diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc
index 0f81412..e6d5087 100644
--- a/webkit/glue/plugins/plugin_instance.cc
+++ b/webkit/glue/plugins/plugin_instance.cc
@@ -36,7 +36,6 @@ PluginInstance::PluginInstance(PluginLib *plugin, const std::string &mime_type)
use_mozilla_user_agent_(false),
message_loop_(MessageLoop::current()),
load_manually_(false),
- throttle_invalidate_(false),
get_notify_data_(NULL),
in_close_streams_(false) {
npp_ = new NPP_t();
diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h
index b6b1465..9765fef 100644
--- a/webkit/glue/plugins/plugin_instance.h
+++ b/webkit/glue/plugins/plugin_instance.h
@@ -142,11 +142,6 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
bool use_mozilla_user_agent() { return use_mozilla_user_agent_; }
void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; }
- bool throttle_invalidate() const { return throttle_invalidate_; }
- void set_throttle_invalidate(bool throttle_invalidate) {
- throttle_invalidate_ = throttle_invalidate;
- }
-
// Helper that implements NPN_PluginThreadAsyncCall semantics
void PluginThreadAsyncCall(void (*func)(void *),
void *userData);
@@ -248,10 +243,6 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// webkit. if false indicates that the plugin should download the data.
bool load_manually_;
- // This flag indicates if the NPN_InvalidateRect calls made by the
- // plugin need to be throttled.
- bool throttle_invalidate_;
-
// Stack indicating if popups are to be enabled for the outgoing
// NPN_GetURL/NPN_GetURLNotify calls.
std::stack<bool> popups_enabled_stack_;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 29c69a87..4e1c713 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -144,7 +144,6 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
// Flash only requests windowless plugins if we return a Mozilla user
// agent.
instance_->set_use_mozilla_user_agent();
- instance_->set_throttle_invalidate(true);
quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE;
} else if (plugin_info.name.find(L"Windows Media Player") !=
std::wstring::npos) {
@@ -304,10 +303,6 @@ int WebPluginDelegateImpl::GetProcessId() {
return ::GetCurrentProcessId();
}
-HWND WebPluginDelegateImpl::GetWindowHandle() {
- return instance()->window_handle();
-}
-
void WebPluginDelegateImpl::SendJavaScriptStream(const std::string& url,
const std::wstring& result,
bool success,
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index dc7374a..fe4743c 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -51,7 +51,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
virtual NPObject* GetPluginScriptableObject();
virtual void DidFinishLoadWithReason(NPReason reason);
virtual int GetProcessId();
- virtual HWND GetWindowHandle();
virtual void FlushGeometryUpdates() {
}
diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h
index 2300986..40419bd 100644
--- a/webkit/glue/webplugin_delegate.h
+++ b/webkit/glue/webplugin_delegate.h
@@ -73,10 +73,6 @@ class WebPluginDelegate {
// Returns the process id of the process that is running the plugin.
virtual int GetProcessId() = 0;
- // Returns the window handle for this plugin if it's a windowed plugin,
- // or NULL otherwise.
- virtual gfx::ViewHandle GetWindowHandle() = 0;
-
virtual void FlushGeometryUpdates() = 0;
// The result of the script execution is returned via this function.