Skip to content

Commit

Permalink
Revert all of my patches from today.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19328 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
evan@chromium.org committed Jun 26, 2009
1 parent b6757a4 commit 83d0e2b
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 180 deletions.
13 changes: 0 additions & 13 deletions base/gfx/native_widget_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,6 @@ static inline NativeViewId IdFromNativeView(NativeView view) {
NativeViewId IdFromNativeView(NativeView view);
#endif // defined(OS_LINUX)


// PluginWindowHandle is an abstraction wrapping "the types of windows
// used by NPAPI plugins". On Windows it's an HWND, on X it's an X
// window id.
#if defined(OS_WIN)
typedef HWND PluginWindowHandle;
#elif defined(OS_LINUX)
typedef unsigned long PluginWindowHandle;
#else
// On OS X we don't have windowed plugins.
typedef gfx::NativeView PluginWindowHandle;
#endif

} // namespace gfx

#endif // BASE_GFX_NATIVE_WIDGET_TYPES_H_
19 changes: 0 additions & 19 deletions chrome/common/ipc_message_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,6 @@ struct ParamTraits<long> {
}
};

// unsigned long is used for serializing X window ids.
template <>
struct ParamTraits<unsigned long> {
typedef unsigned long param_type;
static void Write(Message* m, const param_type& p) {
m->WriteLong(p);
}
static bool Read(const Message* m, void** iter, param_type* r) {
long read_output;
if (!m->ReadLong(iter, &read_output))
return false;
*r = static_cast<unsigned long>(read_output);
return true;
}
static void Log(const param_type& p, std::wstring* l) {
l->append(StringPrintf(L"%ul", p));
}
};

template <>
struct ParamTraits<size_t> {
typedef size_t param_type;
Expand Down
10 changes: 2 additions & 8 deletions chrome/plugin/webplugin_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,15 @@ bool WebPluginProxy::Send(IPC::Message* msg) {
return channel_->Send(msg);
}

void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) {
#if defined(OS_WIN)
void WebPluginProxy::SetWindow(gfx::NativeView window) {
Send(new PluginHostMsg_SetWindow(route_id_, gfx::IdFromNativeView(window)));
#else
NOTIMPLEMENTED();
#endif
}

void WebPluginProxy::WillDestroyWindow(gfx::PluginWindowHandle window) {
void WebPluginProxy::WillDestroyWindow(gfx::NativeView window) {
#if defined(OS_WIN)
PluginThread::current()->Send(
new PluginProcessHostMsg_PluginWindowDestroyed(
window, ::GetParent(window)));
#else
NOTIMPLEMENTED();
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/plugin/webplugin_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class WebPluginProxy : public WebPlugin {
~WebPluginProxy();

// WebPlugin overrides
void SetWindow(gfx::PluginWindowHandle window);
void WillDestroyWindow(gfx::PluginWindowHandle window);
void SetWindow(gfx::NativeView window);
void WillDestroyWindow(gfx::NativeView window);
#if defined(OS_WIN)
void SetWindowlessPumpEvent(HANDLE pump_messages_event);
// Returns true on success.
Expand Down
16 changes: 15 additions & 1 deletion webkit/glue/plugins/gtk_plugin_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace {
// through GLib's object management.
class GtkPluginContainer : public GtkSocket {
public:
static GtkWidget* CreateNewWidget() {
GtkWidget* container = GTK_WIDGET(g_object_new(GetType(), NULL));
g_signal_connect(GTK_SOCKET(container), "plug-removed",
G_CALLBACK(OnPlugRemoved), NULL);
return container;
}

// Sets the requested size of the widget.
void set_size(int width, int height) {
width_ = width;
Expand All @@ -26,6 +33,7 @@ class GtkPluginContainer : public GtkSocket {
return G_TYPE_CHECK_INSTANCE_CAST(instance, GetType(), GtkPluginContainer);
}

private:
// Create and register our custom container type with GTK.
static GType GetType() {
static GType type = 0; // We only want to register our type once.
Expand Down Expand Up @@ -66,6 +74,12 @@ class GtkPluginContainer : public GtkSocket {
requisition->height = container->height_;
}

static gboolean OnPlugRemoved(GtkSocket* socket) {
// This is called when the other side of the socket goes away.
// We return TRUE to indicate that we don't want to destroy our side.
return TRUE;
}

int width_;
int height_;
DISALLOW_IMPLICIT_CONSTRUCTORS(GtkPluginContainer);
Expand All @@ -75,7 +89,7 @@ class GtkPluginContainer : public GtkSocket {

// Create a new instance of our GTK widget object.
GtkWidget* gtk_plugin_container_new() {
return GTK_WIDGET(g_object_new(GtkPluginContainer::GetType(), NULL));
return GtkPluginContainer::CreateNewWidget();
}

void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height) {
Expand Down
2 changes: 1 addition & 1 deletion webkit/glue/plugins/plugin_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
{
#if defined(OS_WIN) || defined(OS_LINUX)
scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
gfx::PluginWindowHandle handle = plugin->window_handle();
gfx::NativeView handle = plugin->window_handle();
*((void**)value) = (void*)handle;
rv = NPERR_NO_ERROR;
#else
Expand Down
8 changes: 3 additions & 5 deletions webkit/glue/plugins/plugin_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> {
NPP npp() { return npp_; }

// Get/Set for the instance's window handle.
gfx::PluginWindowHandle window_handle() const { return window_handle_; }
void set_window_handle(gfx::PluginWindowHandle value) {
window_handle_ = value;
}
gfx::NativeView window_handle() { return window_handle_; }
void set_window_handle(gfx::NativeView value) { window_handle_ = value; }

// Get/Set whether this instance is in Windowless mode.
// Default is false.
Expand Down Expand Up @@ -225,7 +223,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> {
scoped_refptr<PluginHost> host_;
NPPluginFuncs* npp_functions_;
std::vector<scoped_refptr<PluginStream> > open_streams_;
gfx::PluginWindowHandle window_handle_;
gfx::NativeView window_handle_;
bool windowless_;
bool transparent_;
WebPlugin* webplugin_;
Expand Down
4 changes: 2 additions & 2 deletions webkit/glue/plugins/webplugin_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor(
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::PluginWindowHandle containing_view) {
gfx::NativeView containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
Expand Down Expand Up @@ -140,7 +140,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook(
}

WebPluginDelegateImpl::WebPluginDelegateImpl(
gfx::PluginWindowHandle containing_view,
gfx::NativeView containing_view,
NPAPI::PluginInstance *instance)
: parent_(containing_view),
instance_(instance),
Expand Down
6 changes: 3 additions & 3 deletions webkit/glue/plugins/webplugin_delegate_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
private:
friend class DeleteTask<WebPluginDelegateImpl>;

WebPluginDelegateImpl(gfx::PluginWindowHandle containing_view,
WebPluginDelegateImpl(gfx::NativeView containing_view,
NPAPI::PluginInstance *instance);
~WebPluginDelegateImpl();

Expand Down Expand Up @@ -154,7 +154,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
void DestroyInstance();

// used for windowed plugins
gfx::PluginWindowHandle windowed_handle_;
gfx::NativeView windowed_handle_;
bool windowed_did_set_window_;
#if defined(OS_WIN)
gfx::Rect windowed_last_pos_;
Expand Down Expand Up @@ -190,7 +190,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
void EnsurePixmapAtLeastSize(int width, int height);
#endif

gfx::PluginWindowHandle parent_;
gfx::NativeView parent_;
NPWindow window_;
#if defined(OS_MACOSX)
NP_CGContext cg_context_;
Expand Down
55 changes: 39 additions & 16 deletions webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using WebKit::WebMouseEvent;
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::PluginWindowHandle containing_view) {
gfx::NativeView containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
Expand All @@ -54,7 +54,7 @@ WebPluginDelegate* WebPluginDelegate::Create(
}

WebPluginDelegateImpl::WebPluginDelegateImpl(
gfx::PluginWindowHandle containing_view,
gfx::NativeView containing_view,
NPAPI::PluginInstance *instance)
:
windowed_handle_(0),
Expand Down Expand Up @@ -263,40 +263,63 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
return false;
}

window_.window = reinterpret_cast<void*>(parent_);
// The remainder of the code expects windowed_handle_ to exist for
// windowed mode, despite not actually ever reaching through
// windowed_handle_. So let's set it to the one window handle we
// actually have available.
windowed_handle_ = parent_;
windowed_handle_ = gtk_plugin_container_new();
gtk_container_add(GTK_CONTAINER(parent_), windowed_handle_);
gtk_widget_show(windowed_handle_);
gtk_widget_realize(windowed_handle_);

window_.window = GINT_TO_POINTER(
gtk_socket_get_id(GTK_SOCKET(windowed_handle_)));

if (!window_.ws_info)
window_.ws_info = new NPSetWindowCallbackStruct;
NPSetWindowCallbackStruct* extra =
static_cast<NPSetWindowCallbackStruct*>(window_.ws_info);
extra->display = GDK_DISPLAY();
extra->visual = DefaultVisual(GDK_DISPLAY(), 0);
extra->depth = DefaultDepth(GDK_DISPLAY(), 0);
extra->colormap = DefaultColormap(GDK_DISPLAY(), 0);
extra->display = GDK_WINDOW_XDISPLAY(windowed_handle_->window);
GdkVisual* visual = gdk_drawable_get_visual(windowed_handle_->window);
extra->visual = GDK_VISUAL_XVISUAL(visual);
extra->depth = visual->depth;
extra->colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(windowed_handle_->window));

return true;
}

void WebPluginDelegateImpl::WindowedDestroyWindow() {
// We have no window to destroy; see comment in WindowedCreatePlugin
// where windowed_handle_ is set.
windowed_handle_ = 0;
if (windowed_handle_ != NULL) {
gtk_widget_destroy(windowed_handle_);
windowed_handle_ = NULL;
}
}

bool WebPluginDelegateImpl::WindowedReposition(
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect) {
if (window_rect == window_rect_ && clip_rect == clip_rect_)
if (!windowed_handle_) {
NOTREACHED();
return false;
}

if (window_rect_ == window_rect && clip_rect_ == clip_rect)
return false;

// We only set the plugin's size here. Its position is moved elsewhere, which
// allows the window moves/scrolling/clipping to be synchronized with the page
// and other windows.
if (window_rect.size() != window_rect_.size()) {
gtk_plugin_container_set_size(windowed_handle_, window_rect.width(),
window_rect.height());
GtkAllocation allocation = { 0, 0,
window_rect.width(), window_rect.height() };
gtk_widget_size_allocate(windowed_handle_, &allocation);
}

window_rect_ = window_rect;
clip_rect_ = clip_rect;

// TODO(deanm): Is this really needed?
// Ensure that the entire window gets repainted.
gtk_widget_queue_draw(windowed_handle_);

return true;
}

Expand Down
7 changes: 4 additions & 3 deletions webkit/glue/plugins/webplugin_delegate_impl_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
gfx::NativeView containing_view) {
gfx::PluginWindowHandle containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
Expand All @@ -73,12 +73,13 @@
return new WebPluginDelegateImpl(containing_view, instance.get());
}

bool WebPluginDelegateImpl::IsPluginDelegateWindow(gfx::NativeWindow window) {
bool WebPluginDelegateImpl::IsPluginDelegateWindow(
gfx::PluginNativeView window) {
return false;
}

bool WebPluginDelegateImpl::GetPluginNameFromWindow(
gfx::NativeWindow window, std::wstring *plugin_name) {
gfx::PluginNativeView window, std::wstring *plugin_name) {
if (NULL == plugin_name) {
return false;
}
Expand Down
8 changes: 3 additions & 5 deletions webkit/glue/webplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ struct NPObject;

// Describes the new location for a plugin window.
struct WebPluginGeometry {
// On Windows, this is the plugin window in the plugin process.
// On X11, this is the browser process's hosting window (the GtkSocket).
gfx::PluginWindowHandle window;
gfx::NativeView window;
gfx::Rect window_rect;
// Clip rect (include) and cutouts (excludes), relative to
// window_rect origin.
Expand Down Expand Up @@ -56,11 +54,11 @@ class WebPlugin {
// windowed (i.e. handle is not NULL) or windowless (handle is NULL). This
// tells the WebPlugin to send mouse/keyboard events to the plugin delegate,
// as well as the information about the HDC for paint operations.
virtual void SetWindow(gfx::PluginWindowHandle window) = 0;
virtual void SetWindow(gfx::NativeView window) = 0;

// Called by the plugin delegate to let it know that the window is being
// destroyed.
virtual void WillDestroyWindow(gfx::PluginWindowHandle window) = 0;
virtual void WillDestroyWindow(gfx::NativeView window) = 0;
#if defined(OS_WIN)
// The pump_messages_event is a event handle which is valid only for
// windowless plugins and is used in NPP_HandleEvent calls to pump messages
Expand Down
5 changes: 3 additions & 2 deletions webkit/glue/webplugin_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <string>

#include "base/gfx/native_widget_types.h"
#include "build/build_config.h"
#include "third_party/npapi/bindings/npapi.h"

// TODO(port): put in OS_WIN check.
typedef struct HDC__* HDC;
struct NPObject;

class FilePath;
Expand Down Expand Up @@ -47,7 +48,7 @@ class WebPluginDelegate {

static WebPluginDelegate* Create(const FilePath& filename,
const std::string& mime_type,
gfx::PluginWindowHandle containing_view);
gfx::NativeView containing_view);

// Initializes the plugin implementation with the given (UTF8) arguments.
// Note that the lifetime of WebPlugin must be longer than this delegate.
Expand Down
2 changes: 1 addition & 1 deletion webkit/glue/webplugin_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ WebPluginImpl::WebPluginImpl(WebCore::HTMLPlugInElement* element,
WebPluginImpl::~WebPluginImpl() {
}

void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) {
void WebPluginImpl::SetWindow(gfx::NativeView window) {
if (window) {
DCHECK(!windowless_); // Make sure not called twice.
window_ = window;
Expand Down
6 changes: 3 additions & 3 deletions webkit/glue/webplugin_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class WebPluginImpl : public WebPlugin,
int arg_count, char** arg_names, char** arg_values);

// WebPlugin implementation:
void SetWindow(gfx::PluginWindowHandle window);
void WillDestroyWindow(gfx::PluginWindowHandle window) { }
void SetWindow(gfx::NativeView window);
void WillDestroyWindow(gfx::NativeView window) { }
#if defined(OS_WIN)
void SetWindowlessPumpEvent(HANDLE pump_messages_event) { }
#endif
Expand Down Expand Up @@ -333,7 +333,7 @@ class WebPluginImpl : public WebPlugin,
std::vector<ClientInfo> clients_;

bool windowless_;
gfx::PluginWindowHandle window_;
gfx::NativeView window_;
WebCore::HTMLPlugInElement* element_;
WebFrameImpl* webframe_;

Expand Down
Loading

0 comments on commit 83d0e2b

Please sign in to comment.