diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/plugins | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/plugins')
-rw-r--r-- | Source/WebCore/plugins/PluginView.cpp | 12 | ||||
-rw-r--r-- | Source/WebCore/plugins/PluginView.h | 10 | ||||
-rw-r--r-- | Source/WebCore/plugins/PluginViewNone.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/plugins/gtk/PluginPackageGtk.cpp | 13 | ||||
-rw-r--r-- | Source/WebCore/plugins/gtk/PluginViewGtk.cpp | 86 | ||||
-rw-r--r-- | Source/WebCore/plugins/npfunctions.h | 10 | ||||
-rw-r--r-- | Source/WebCore/plugins/qt/PluginViewQt.cpp | 17 |
7 files changed, 101 insertions, 51 deletions
diff --git a/Source/WebCore/plugins/PluginView.cpp b/Source/WebCore/plugins/PluginView.cpp index 1fefe19..59d01fa 100644 --- a/Source/WebCore/plugins/PluginView.cpp +++ b/Source/WebCore/plugins/PluginView.cpp @@ -493,15 +493,15 @@ void PluginView::performRequest(PluginRequest* request) // and this has been made sure in ::load. ASSERT(targetFrameName.isEmpty() || m_parentFrame->tree()->find(targetFrameName) == m_parentFrame); - // Executing a script can cause the plugin view to be destroyed, so we keep a reference to the parent frame. - RefPtr<Frame> parentFrame = m_parentFrame; + // Executing a script can cause the plugin view to be destroyed, so we keep a reference to it. + RefPtr<PluginView> protector(this); ScriptValue result = m_parentFrame->script()->executeScript(jsString, request->shouldAllowPopups()); if (targetFrameName.isNull()) { String resultString; #if USE(JSC) - ScriptState* scriptState = parentFrame->script()->globalObject(pluginWorld())->globalExec(); + ScriptState* scriptState = m_parentFrame->script()->globalObject(pluginWorld())->globalExec(); #elif USE(V8) ScriptState* scriptState = 0; // Not used with V8 #endif @@ -1030,9 +1030,9 @@ void PluginView::didFail(const ResourceError& error) return; ASSERT(m_loadManually); - ASSERT(m_manualStream); - - m_manualStream->didFail(0, error); + + if (m_manualStream) + m_manualStream->didFail(0, error); } void PluginView::setCallingPlugin(bool b) const diff --git a/Source/WebCore/plugins/PluginView.h b/Source/WebCore/plugins/PluginView.h index 03e7189..9321a86 100644 --- a/Source/WebCore/plugins/PluginView.h +++ b/Source/WebCore/plugins/PluginView.h @@ -72,6 +72,9 @@ QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE #endif +#if PLATFORM(GTK) +typedef struct _GtkSocket GtkSocket; +#endif #if USE(JSC) namespace JSC { @@ -480,6 +483,13 @@ private: #endif #endif // PLATFORM(QT) +#if PLATFORM(GTK) + static gboolean plugRemovedCallback(GtkSocket*, PluginView*); + static void plugAddedCallback(GtkSocket*, PluginView*); + bool m_plugAdded; + IntRect m_delayedAllocation; +#endif + IntRect m_clipRect; // The clip rect to apply to a windowed plug-in IntRect m_windowRect; // Our window rect. #ifdef ANDROID_PLUGINS diff --git a/Source/WebCore/plugins/PluginViewNone.cpp b/Source/WebCore/plugins/PluginViewNone.cpp index 978e5ee..c0d0e4a 100644 --- a/Source/WebCore/plugins/PluginViewNone.cpp +++ b/Source/WebCore/plugins/PluginViewNone.cpp @@ -28,6 +28,10 @@ #if USE(JSC) #include "BridgeJSC.h" +<<<<<<< HEAD +======= +#include <runtime/ScopeChain.h> +>>>>>>> WebKit at r80534 #endif using namespace WTF; diff --git a/Source/WebCore/plugins/gtk/PluginPackageGtk.cpp b/Source/WebCore/plugins/gtk/PluginPackageGtk.cpp index 26409a7..21d3c9e 100644 --- a/Source/WebCore/plugins/gtk/PluginPackageGtk.cpp +++ b/Source/WebCore/plugins/gtk/PluginPackageGtk.cpp @@ -29,14 +29,13 @@ #include "config.h" #include "PluginPackage.h" -#include <gio/gio.h> -#include <stdio.h> - -#include "GOwnPtr.h" +#include "GOwnPtrGtk.h" +#include "GRefPtrGtk.h" #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "npruntime_impl.h" #include "PluginDebug.h" +#include <gio/gio.h> #include <wtf/text/CString.h> namespace WebCore { @@ -129,10 +128,10 @@ bool PluginPackage::load() GOwnPtr<gchar> finalPath(g_strdup(m_path.utf8().data())); while (g_file_test(finalPath.get(), G_FILE_TEST_IS_SYMLINK)) { - GOwnPtr<GFile> file(g_file_new_for_path(finalPath.get())); - GOwnPtr<GFile> dir(g_file_get_parent(file.get())); + GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(finalPath.get())); + GRefPtr<GFile> dir = adoptGRef(g_file_get_parent(file.get())); GOwnPtr<gchar> linkPath(g_file_read_link(finalPath.get(), 0)); - GOwnPtr<GFile> resolvedFile(g_file_resolve_relative_path(dir.get(), linkPath.get())); + GRefPtr<GFile> resolvedFile = adoptGRef(g_file_resolve_relative_path(dir.get(), linkPath.get())); finalPath.set(g_file_get_path(resolvedFile.get())); } diff --git a/Source/WebCore/plugins/gtk/PluginViewGtk.cpp b/Source/WebCore/plugins/gtk/PluginViewGtk.cpp index 5166151..75a51c5 100644 --- a/Source/WebCore/plugins/gtk/PluginViewGtk.cpp +++ b/Source/WebCore/plugins/gtk/PluginViewGtk.cpp @@ -322,12 +322,14 @@ void PluginView::initXEvent(XEvent* xEvent) xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server xEvent->xany.send_event = false; - xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); - // NOTE: event->xany.window doesn't always correspond to the .window property of other XEvent's - // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify - // events; thus, this is right: GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient(); - xEvent->xany.window = widget ? GDK_WINDOW_XWINDOW(gtk_widget_get_window(widget)) : 0; + xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget)); + + // Mozilla also sends None here for windowless plugins. See nsObjectFrame.cpp in the Mozilla sources. + // This method also sets up FocusIn and FocusOut events for windows plugins, but Mozilla doesn't + // even send these types of events to windowed plugins. In the future, it may be good to only + // send them to windowless plugins. + xEvent->xany.window = None; } static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos, Frame* parentFrame) @@ -415,8 +417,14 @@ void PluginView::handleMouseEvent(MouseEvent* event) setXButtonEventSpecificFields(&xEvent, event, postZoomPos, m_parentFrame.get()); else if (event->type() == eventNames().mousemoveEvent) setXMotionEventSpecificFields(&xEvent, event, postZoomPos, m_parentFrame.get()); - else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent) + else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent) { setXCrossingEventSpecificFields(&xEvent, event, postZoomPos, m_parentFrame.get()); + + // This is a work-around for plugins which change the cursor. When that happens we + // get out of sync with GDK somehow. Resetting the cursor here seems to fix the issue. + if (event->type() == eventNames().mouseoutEvent) + gdk_window_set_cursor(gtk_widget_get_window(m_parentFrame->view()->hostWindow()->platformPageClient()), 0); + } else return; #endif @@ -513,16 +521,27 @@ void PluginView::setNPWindowIfNeeded() setCallingPlugin(false); PluginView::setCurrentPluginView(0); - if (m_isWindowed) { - GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() }; - gtk_widget_size_allocate(platformPluginWidget(), &allocation); + if (!m_isWindowed) + return; + #if defined(XP_UNIX) - if (!m_needsXEmbed) { - gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y()); - gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height()); - } + // GtkXtBin will call gtk_widget_size_allocate, so we don't need to do it here. + if (!m_needsXEmbed) { + gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y()); + gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height()); + return; + } #endif + + GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() }; + + // If the window has not been embedded yet (the plug added), we delay setting its allocation until + // that point. This fixes issues with some Java plugin instances not rendering immediately. + if (!m_plugAdded) { + m_delayedAllocation = allocation; + return; } + gtk_widget_size_allocate(platformPluginWidget(), &allocation); } void PluginView::setParentVisible(bool visible) @@ -636,15 +655,11 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re #endif case NPNVnetscapeWindow: { + GdkWindow* gdkWindow = gtk_widget_get_window(m_parentFrame->view()->hostWindow()->platformPageClient()); #if defined(XP_UNIX) - void* w = reinterpret_cast<void*>(value); - GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient(); - *((XID *)w) = GDK_WINDOW_XWINDOW(gtk_widget_get_window(widget)); -#endif -#ifdef GDK_WINDOWING_WIN32 - HGDIOBJ* w = reinterpret_cast<HGDIOBJ*>(value); - GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient(); - *w = GDK_WINDOW_HWND(gtk_widget_get_window(widget)); + *static_cast<Window*>(value) = GDK_WINDOW_XWINDOW(gdk_window_get_toplevel(gdkWindow)); +#elif defined(GDK_WINDOWING_WIN32) + *static_cast<HGIOBJ*>(value) = GDK_WINDOW_HWND(gdkWindow); #endif *result = NPERR_NO_ERROR; return true; @@ -743,25 +758,23 @@ static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap) } #endif -static gboolean plugRemovedCallback(GtkSocket* socket, gpointer) +gboolean PluginView::plugRemovedCallback(GtkSocket* socket, PluginView* view) { + view->m_plugAdded = false; return TRUE; } -static void plugAddedCallback(GtkSocket* socket, PluginView* view) +void PluginView::plugAddedCallback(GtkSocket* socket, PluginView* view) { - if (!socket || !view) - return; + ASSERT(socket); + ASSERT(view); - // FIXME: Java Plugins do not seem to draw themselves properly the - // first time unless we do a size-allocate after they have done - // the plug operation on their side, which in general does not - // happen since we do size-allocates before setting the - // NPWindow. Apply this workaround until we figure out a better - // solution, if any. - IntRect rect = view->frameRect(); - GtkAllocation allocation = { rect.x(), rect.y(), rect.width(), rect.height() }; - gtk_widget_size_allocate(GTK_WIDGET(socket), &allocation); + view->m_plugAdded = true; + if (!view->m_delayedAllocation.isEmpty()) { + GtkAllocation allocation(view->m_delayedAllocation); + gtk_widget_size_allocate(GTK_WIDGET(socket), &allocation); + view->m_delayedAllocation.setSize(IntSize()); + } } bool PluginView::platformStart() @@ -790,10 +803,11 @@ bool PluginView::platformStart() if (!gtk_widget_get_parent(pageClient)) return false; + m_plugAdded = false; setPlatformWidget(gtk_socket_new()); gtk_container_add(GTK_CONTAINER(pageClient), platformPluginWidget()); - g_signal_connect(platformPluginWidget(), "plug-added", G_CALLBACK(plugAddedCallback), this); - g_signal_connect(platformPluginWidget(), "plug-removed", G_CALLBACK(plugRemovedCallback), NULL); + g_signal_connect(platformPluginWidget(), "plug-added", G_CALLBACK(PluginView::plugAddedCallback), this); + g_signal_connect(platformPluginWidget(), "plug-removed", G_CALLBACK(PluginView::plugRemovedCallback), this); } else setPlatformWidget(gtk_xtbin_new(pageClient, 0)); #else diff --git a/Source/WebCore/plugins/npfunctions.h b/Source/WebCore/plugins/npfunctions.h index 675ccb9..6236e47 100644 --- a/Source/WebCore/plugins/npfunctions.h +++ b/Source/WebCore/plugins/npfunctions.h @@ -112,6 +112,11 @@ typedef int16_t (*NPP_HandleEventProcPtr)(NPP instance, void* event); typedef void (*NPP_URLNotifyProcPtr)(NPP instance, const char* URL, NPReason reason, void* notifyData); typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value); typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value); +typedef NPBool (*NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction); +typedef void (*NPP_LostFocusPtr)(NPP instance); +typedef void (*NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData); +typedef NPError (*NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge); +typedef char** (*NPP_GetSitesWithDataPtr)(void); typedef void *(*NPP_GetJavaClassProcPtr)(void); typedef void* JRIGlobalRef; //not using this right now @@ -192,6 +197,11 @@ typedef struct _NPPluginFuncs { JRIGlobalRef javaClass; NPP_GetValueProcPtr getvalue; NPP_SetValueProcPtr setvalue; + NPP_GotFocusPtr gotfocus; + NPP_LostFocusPtr lostfocus; + NPP_URLRedirectNotifyPtr urlredirectnotify; + NPP_ClearSiteDataPtr clearsitedata; + NPP_GetSitesWithDataPtr getsiteswithdata; } NPPluginFuncs; typedef EXPORTED_CALLBACK(NPError, NP_GetEntryPointsFuncPtr)(NPPluginFuncs*); diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp index 4dc4e15..611abb9 100644 --- a/Source/WebCore/plugins/qt/PluginViewQt.cpp +++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp @@ -68,7 +68,9 @@ #include "Settings.h" #include "npruntime_impl.h" #include "qwebpage_p.h" +#if USE(JSC) #include "runtime_root.h" +#endif #include <QApplication> #include <QDesktopWidget> @@ -88,7 +90,9 @@ #include <runtime/JSValue.h> using JSC::ExecState; +#if USE(JSC) using JSC::Interpreter; +#endif using JSC::JSLock; using JSC::JSObject; using JSC::UString; @@ -137,6 +141,10 @@ void PluginView::updatePluginWidget() if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect) return; + // The plugin had a zero width or height before but was resized, we need to show it again. + if (oldWindowRect.isEmpty()) + show(); + if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) { #if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5) // On Maemo5, Flash always renders to 16-bit buffer @@ -171,7 +179,10 @@ void PluginView::updatePluginWidget() if (!m_platformLayer) { // Make sure we get repainted afterwards. This is necessary for downward // scrolling to move the plugin widget properly. - invalidate(); + // Note that we don't invalidate the frameRect() here. This is because QWebFrame::renderRelativeCoords() + // imitates ScrollView and adds the scroll offset back on to the rect we damage here (making the co-ordinates absolute + // to the frame again) before passing it to FrameView. + frameView->invalidateRect(m_windowRect); } } @@ -938,7 +949,9 @@ bool PluginView::platformStart() #endif } - show(); + // If the width and the height are not zero we show the PluginView. + if (!frameRect().isEmpty()) + show(); NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct(); wsi->type = 0; |