diff --git a/make/sun/awt/mapfile-vers b/make/sun/awt/mapfile-vers index 5c6cfea808bb560247ecb0239c772bfa2e307573..f68ef5cfb9d98628ef4a1ce9718e2696f0836a93 100644 --- a/make/sun/awt/mapfile-vers +++ b/make/sun/awt/mapfile-vers @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/make/sun/awt/mapfile-vers-bsd b/make/sun/awt/mapfile-vers-bsd index f606b3fbbb0ad921e004cca1da8179dc24f6eeb4..dcc59f09e0eff5a96447c92bf76d6a042cf6b881 100644 --- a/make/sun/awt/mapfile-vers-bsd +++ b/make/sun/awt/mapfile-vers-bsd @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/make/sun/awt/mapfile-vers-linux b/make/sun/awt/mapfile-vers-linux index b7033b89fa89e789196a29550d9e9b7859954f2d..03f0cc07e47de8659d948fbb4938fd7f6dbb81c0 100644 --- a/make/sun/awt/mapfile-vers-linux +++ b/make/sun/awt/mapfile-vers-linux @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/makefiles/mapfiles/libawt/mapfile-vers b/makefiles/mapfiles/libawt/mapfile-vers index 924a2827a99bd822a55237ca2208d178deb2cdcb..8af9d14dd57050340cc1162f862587b58f225133 100644 --- a/makefiles/mapfiles/libawt/mapfile-vers +++ b/makefiles/mapfiles/libawt/mapfile-vers @@ -86,6 +86,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_setRule; Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_Choice_initIDs; Java_java_awt_Dimension_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; diff --git a/makefiles/mapfiles/libawt/mapfile-vers-linux b/makefiles/mapfiles/libawt/mapfile-vers-linux index 2514670ea3eb3875ac18b8906db1fff7da37eb0d..b0bfb1ca91af8a0532984a07f306cf31349a7401 100644 --- a/makefiles/mapfiles/libawt/mapfile-vers-linux +++ b/makefiles/mapfiles/libawt/mapfile-vers-linux @@ -86,6 +86,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_setRule; Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_Choice_initIDs; Java_java_awt_Dimension_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; diff --git a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java index dff48a4caa333bdc90e2e1e64007349cb3174c4a..f5cb0d576e61e410a32bf0814110e57c4b30c0d8 100644 --- a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java +++ b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,8 @@ final class LWScrollBarPeer extends LWComponentPeer void initializeImpl() { super.initializeImpl(); final Scrollbar target = getTarget(); + setLineIncrement(target.getUnitIncrement()); + setPageIncrement(target.getBlockIncrement()); setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum()); diff --git a/src/macosx/classes/sun/lwawt/LWToolkit.java b/src/macosx/classes/sun/lwawt/LWToolkit.java index cad6e4353bafabe0b4fb6eaa084826b1c21b3cdf..6ff3530db769ca715a14f51e2c024c28ab6fb943 100644 --- a/src/macosx/classes/sun/lwawt/LWToolkit.java +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java @@ -53,7 +53,12 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { private Clipboard clipboard; private MouseInfoPeer mouseInfoPeer; - public LWToolkit() { + /** + * Dynamic Layout Resize client code setting. + */ + private volatile boolean dynamicLayoutSetting = true; + + protected LWToolkit() { } /* @@ -561,4 +566,37 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { ((LWWindowPeer)w.getPeer()).ungrab(false); } } + + @Override + protected final Object lazilyLoadDesktopProperty(final String name) { + if (name.equals("awt.dynamicLayoutSupported")) { + return isDynamicLayoutSupported(); + } + return super.lazilyLoadDesktopProperty(name); + } + + @Override + public final void setDynamicLayout(final boolean dynamic) { + dynamicLayoutSetting = dynamic; + } + + @Override + protected final boolean isDynamicLayoutSet() { + return dynamicLayoutSetting; + } + + @Override + public final boolean isDynamicLayoutActive() { + // "Live resizing" is active by default and user's data is ignored. + return isDynamicLayoutSupported(); + } + + /** + * Returns true if dynamic layout of Containers on resize is supported by + * the underlying operating system and/or window manager. + */ + protected final boolean isDynamicLayoutSupported() { + // "Live resizing" is supported by default. + return true; + } } diff --git a/src/macosx/native/sun/awt/AWTSurfaceLayers.m b/src/macosx/native/sun/awt/AWTSurfaceLayers.m index 6e9fbbca5abaa50e54a4955906326b33cc6a26bd..d12908c83a3ce7dcfb3fc8eff5707d342fc705b1 100644 --- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m +++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ #import "LWCToolkit.h" #import +#import @implementation AWTSurfaceLayers @@ -74,14 +75,12 @@ } - (void) setBounds:(CGRect)rect { - layer.anchorPoint = CGPointMake(0, 0); - // translates values to the coordinate system of the "root" layer - CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height; - CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height); - - layer.frame = newRect; - + rect.origin.y = windowLayer.bounds.size.height - rect.origin.y - rect.size.height; + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + layer.frame = rect; + [CATransaction commit]; [AWTSurfaceLayers repaintLayersRecursively:layer]; } diff --git a/src/macosx/native/sun/java2d/opengl/CGLLayer.m b/src/macosx/native/sun/java2d/opengl/CGLLayer.m index e0074eb4ef3d68355c75dbdd2632087fca11b53c..f300ea404c462266d2f11cff06d619b0f1e1e709 100644 --- a/src/macosx/native/sun/java2d/opengl/CGLLayer.m +++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,11 +64,13 @@ AWT_ASSERT_APPKIT_THREAD; //Disable CALayer's default animation NSMutableDictionary * actions = [[NSMutableDictionary alloc] initWithObjectsAndKeys: + [NSNull null], @"anchorPoint", [NSNull null], @"bounds", [NSNull null], @"contents", [NSNull null], @"contentsScale", [NSNull null], @"onOrderIn", [NSNull null], @"onOrderOut", + [NSNull null], @"position", [NSNull null], @"sublayers", nil]; self.actions = actions; diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index 0dfb99996db5c8fe159040ef043351539af0da62..846ea97645055418b089578c7d8ef2da4f3fc06b 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -1671,6 +1671,15 @@ public abstract class Component implements ImageObserver, MenuContainer, /* do nothing */ } + /* + * Delete references from LightweithDispatcher of a heavyweight parent + */ + void clearLightweightDispatcherOnRemove(Component removedComponent) { + if (parent != null) { + parent.clearLightweightDispatcherOnRemove(removedComponent); + } + } + /** * @deprecated As of JDK version 1.1, * replaced by setVisible(boolean). @@ -6974,6 +6983,8 @@ public abstract class Component implements ImageObserver, MenuContainer, } synchronized (getTreeLock()) { + clearLightweightDispatcherOnRemove(this); + if (isFocusOwner() && KeyboardFocusManager.isAutoFocusTransferEnabledFor(this)) { transferFocus(true); } diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index 1118852f0e9dc3e2d4f8a834ec1e87450ff1de20..1525a7497c22d056fbe308d3b532b024198574e4 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -3306,6 +3306,16 @@ public class Container extends Component { } } + @Override + void clearLightweightDispatcherOnRemove(Component removedComponent) { + if (dispatcher != null) { + dispatcher.removeReferences(removedComponent); + } else { + //It is a Lightweight Container, should clear parent`s Dispatcher + super.clearLightweightDispatcherOnRemove(removedComponent); + } + } + final Container getTraversalRoot() { if (isFocusCycleRoot()) { return findTraversalRoot(); @@ -4411,6 +4421,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { //System.out.println("Disposing lw dispatcher"); stopListeningForOtherDrags(); mouseEventTarget = null; + targetLastEntered = null; } /** @@ -4502,6 +4513,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { // MOUSE_CLICKED. if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) { mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null; + isCleaned = false; } if (mouseEventTarget != null) { @@ -4545,10 +4557,14 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { retargetMouseEvent(mouseOver, id, e); break; } - //Consuming of wheel events is implemented in "retargetMouseEvent". - if (id != MouseEvent.MOUSE_WHEEL) { - e.consume(); - } + //Consuming of wheel events is implemented in "retargetMouseEvent". + if (id != MouseEvent.MOUSE_WHEEL) { + e.consume(); + } + } else if (isCleaned && id != MouseEvent.MOUSE_WHEEL) { + //After mouseEventTarget was removed and cleaned should consume all events + //until new mouseEventTarget is found + e.consume(); } return e.isConsumed(); } @@ -4891,6 +4907,11 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { */ private transient Component targetLastEntered; + /** + * Indicates whether {@code mouseEventTarget} was removed and nulled + */ + private transient boolean isCleaned; + /** * Is the mouse over the native container */ @@ -4925,4 +4946,14 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK; + + void removeReferences(Component removedComponent) { + if (mouseEventTarget == removedComponent) { + isCleaned = true; + mouseEventTarget = null; + } + if (targetLastEntered == removedComponent) { + targetLastEntered = null; + } + } } diff --git a/src/share/classes/sun/swing/JLightweightFrame.java b/src/share/classes/sun/swing/JLightweightFrame.java index 162186f4ce38a89e553bf8f9b3b816aa711fa5b1..a9ac4371cc131c4c0b35e2616507d9f339e38ab7 100644 --- a/src/share/classes/sun/swing/JLightweightFrame.java +++ b/src/share/classes/sun/swing/JLightweightFrame.java @@ -35,6 +35,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; +import java.security.AccessController; import javax.swing.JLayeredPane; import javax.swing.JPanel; @@ -43,6 +44,7 @@ import javax.swing.LayoutFocusTraversalPolicy; import javax.swing.RootPaneContainer; import sun.awt.LightweightFrame; +import sun.security.action.GetPropertyAction; /** * The frame serves as a lightweight container which paints its content @@ -65,12 +67,28 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan private BufferedImage bbImage; + /** + * {@code copyBufferEnabled}, true by default, defines the following strategy. + * A duplicating (copy) buffer is created for the original pixel buffer. + * The copy buffer is synchronized with the original buffer every time the + * latter changes. {@code JLightweightFrame} passes the copy buffer array + * to the {@link LightweightContent#imageBufferReset} method. The code spot + * which synchronizes two buffers becomes the only critical section guarded + * by the lock (managed with the {@link LightweightContent#paintLock()}, + * {@link LightweightContent#paintUnlock()} methods). + */ + private boolean copyBufferEnabled; + private int[] copyBuffer; + /** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. */ public JLightweightFrame() { super(); + copyBufferEnabled = "true".equals(AccessController. + doPrivileged(new GetPropertyAction("jlf.copyBufferEnabled", "true"))); + add(rootPane, BorderLayout.CENTER); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); if (getGraphicsConfiguration().isTranslucencyCapable()) { @@ -124,16 +142,37 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan if (content != null) content.focusUngrabbed(); } + private void syncCopyBuffer(boolean reset, int x, int y, int w, int h) { + content.paintLock(); + try { + int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData(); + if (reset) { + copyBuffer = new int[srcBuffer.length]; + } + int linestride = bbImage.getWidth(); + + for (int i=0; i button; + private static WeakReference p; + + public static void init() throws Throwable { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame = new JFrame(); + frame.setLayout(new FlowLayout()); + button = new WeakReference(new JButton("Text")); + p = new WeakReference(new JPanel(new FlowLayout())); + p.get().add(button.get()); + frame.add(p.get()); + + frame.setBounds(500, 400, 200, 200); + frame.setVisible(true); + } + }); + + Util.waitTillShown(button.get()); + Util.clickOnComp(button.get(), new Robot()); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.remove(p.get()); + } + }); + + Util.waitForIdle(null); + assertGC(); + } + + public static void assertGC() throws Throwable { + List alloc = new ArrayList(); + int size = 10 * 1024; + while (true) { + try { + alloc.add(new byte[size]); + } catch (OutOfMemoryError err) { + break; + } + } + alloc = null; + if (button.get() != null) { + throw new Exception("Test failed: JButton was not collected"); + } + } + + public static void main(String args[]) throws Throwable { + init(); + } +} diff --git a/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java b/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java index ddd01236cb3c3c3088e891a08465557e82f4a6c7..8a669c82e7045b5d4b47f16089236c7e7e10ec7f 100644 --- a/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java +++ b/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,6 +64,21 @@ public class DragEventSource } private static void init() { + + boolean isSupported = SystemTray.isSupported(); + System.out.println("is SysTray Supported: " + isSupported); + + if (!isSupported) { + String[] instructions = + { + "The test cannot be run because SystemTray is not supported.", + "Simply press PASS button." + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + return; + } + String[] instructions = { "Use see a Frame with a button in it.", @@ -79,8 +94,8 @@ public class DragEventSource frame.setLayout(new FlowLayout()); tray = SystemTray.getSystemTray(); - boolean isSupported = tray.isSupported(); - System.out.println("is SysTray Supported: " + isSupported); + + TrayIcon icons[] = tray.getTrayIcons(); System.out.println(icons.length); diff --git a/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java b/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java index fa2206b142d552864e61a371654ce611fad2f332..1fe616abbc51cdfbabcc3d1d611b4295532bcf83 100644 --- a/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java +++ b/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java @@ -43,6 +43,11 @@ public class HTMLDataFlavorTest { public static void main(String[] args) throws IOException, UnsupportedFlavorException { + if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.WINDOWS) { + System.err.println("This test is for MS Windows only. Considered passed."); + return; + } + dataFlavors.put(DataFlavor.allHtmlFlavor, HtmlTransferable.ALL_HTML_AS_STRING); dataFlavors.put(DataFlavor.fragmentHtmlFlavor, HtmlTransferable.FRAGMENT_HTML_AS_STRING); dataFlavors.put(DataFlavor.selectionHtmlFlavor, HtmlTransferable.SELECTION_HTML_AS_STRING);