changeset 117:2b7512af4dcc

Fix applet rezising issue seen with some browsers (Midori)
author Deepak Bhole <dbhole@redhat.com>
date Mon, 18 Apr 2011 13:16:39 -0400
parents 4169f6296ed7
children bb091ba157f2
files ChangeLog plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
diffstat 2 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Apr 18 11:36:52 2011 -0400
+++ b/ChangeLog	Mon Apr 18 13:16:39 2011 -0400
@@ -1,3 +1,10 @@
+2011-04-18  Deepak Bhole <dbhole@redhat.com>
+
+	* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+	(PluginAppletPanelFactory::createPanel): Make the NetxPanel variable
+	final. Resize frame to work around problem whereby AppletViewerPanel
+	doesn't always set the right size initially.
+
 2011-04-18  Deepak Bhole <dbhole@redhat.com>
 
 	RH691259: Midori sends a SIGSEGV with the IcedTea NP Plugin
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Mon Apr 18 11:36:52 2011 -0400
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Mon Apr 18 13:16:39 2011 -0400
@@ -126,7 +126,7 @@
                                     long handle, int x, int y,
                                     final URL doc,
                                     final Hashtable<String, String> atts) {
-        AppletViewerPanel panel = AccessController.doPrivileged(new PrivilegedAction<AppletViewerPanel>() {
+        final AppletViewerPanel panel = AccessController.doPrivileged(new PrivilegedAction<AppletViewerPanel>() {
             public AppletViewerPanel run() {
                 try {
                     AppletViewerPanel panel = new NetxPanel(doc, atts, false);
@@ -192,6 +192,30 @@
         PluginDebug.debug("Applet " + a.getClass() + " initialized");
         streamhandler.write("instance " + identifier + " reference 0 initialized");
 
+        /* AppletViewerPanel sometimes doesn't set size right initially. This 
+         * causes the parent frame to be the default (10x10) size.
+         *  
+         * Normally it goes unnoticed since browsers like Firefox make a resize 
+         * call after init. However some browsers (e.g. Midori) don't.
+         * 
+         * We therefore manually set the parent to the right size.
+         */
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    panel.getParent().setSize(Integer.valueOf(atts.get("width")), Integer.valueOf(atts.get("height")));
+                }
+            });
+        } catch (InvocationTargetException ite) {
+            // Not being able to resize is non-fatal
+            PluginDebug.debug("Unable to resize panel: ");
+            ite.printStackTrace();
+        } catch (InterruptedException ie) {
+            // Not being able to resize is non-fatal
+            PluginDebug.debug("Unable to resize panel: ");
+            ie.printStackTrace();
+        }
+
         AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
         AppletSecurityContextManager.getSecurityContext(0).associateInstance(identifier, ((NetxPanel) panel).getAppletClassLoader());