changeset 1742:fc533ffc2296 2.2.60-b03

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/2.2.51/MASTER/jfx/rt
author kcr
date Wed, 15 Jan 2014 09:46:13 -0800
parents 9d40b8b2d14f 6354c74e361f
children b8fcc422cc09
files .hgtags
diffstat 8 files changed, 132 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Dec 19 07:57:07 2013 -0800
+++ b/.hgtags	Wed Jan 15 09:46:13 2014 -0800
@@ -171,6 +171,8 @@
 ba64e43a17afbe710e3ad0a7f52aba8071c3e802 2.2.45-b16
 4b0151651241c5574ac6312e1a6dd4177c02566c 2.2.45-b17
 28bf72b54f55313dfd99c0632bedbc0c3a41772f 2.2.45-b18
+8fd11d02dec6bb4cf5e7de6da952336c1b1b59e8 2.2.60-b01
+ef43e02f07a38cc9265449d9a564f15955b96265 2.2.60-b02
 c8ac58353fd35bcd24df9348ccd6da9a69a52966 2.2.51-b02
 0e5000464f6e304ec0bde900b723c6fc02988014 2.2.51-b03
 aac7bff2d264bb33375acb070753918172f326c7 2.2.51-b04
--- a/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Wed Jan 15 09:46:13 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -808,6 +808,21 @@
     }
 
     /**
+     * Removes the objects related to the scene from the cache.
+     * Called from Window when the scene is closed.
+     *
+     * @param scene the scene
+     */
+    public void forget(Scene scene) {
+        if (containerMap != null) {
+            final StylesheetContainer container = remove(containerMap, scene);
+            if (container != null) {
+                container.destroy();
+            }
+        }
+    }
+
+    /**
      * Creates stylesheets and associates them with the given scene.
      *
      * Called from Scene.stylesheets on replace. Attempts to reuse existing
@@ -850,9 +865,6 @@
             }
         }
 
-        // if there are no stylesheets, then they were probably all removed.
-        if (scene.getStylesheets().size() == 0) return;
-
         // RT-20643
         CssError.setCurrentScene(scene);
         
--- a/javafx-ui-common/src/javafx/scene/Node.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-common/src/javafx/scene/Node.java	Wed Jan 15 09:46:13 2014 -0800
@@ -3345,16 +3345,15 @@
      * clipParent) that this child Node's bounds have changed.
      */
     void transformedBoundsChanged() {
-        if (txBoundsInvalid) {
-            return;
-        }
-        txBounds.makeEmpty();
-        txBoundsInvalid = true;
-        invalidateBoundsInParent();
+        if (!txBoundsInvalid) {
+            txBounds.makeEmpty();
+            txBoundsInvalid = true;
+            invalidateBoundsInParent();
+            impl_markDirty(DirtyBits.NODE_BOUNDS);
+        }
         if (isVisible()) {
             notifyParentOfBoundsChange();
         }
-        impl_markDirty(DirtyBits.NODE_BOUNDS);
     }
 
     /**
--- a/javafx-ui-common/src/javafx/stage/Window.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-common/src/javafx/stage/Window.java	Wed Jan 15 09:46:13 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -396,6 +396,7 @@
                 // will also trigger scene's peer disposal.
                 if (oldScene != null) {
                     oldScene.impl_setWindow(null);
+                    StyleManager.getInstance().forget(oldScene);
                 }
                 if (newScene != null) {
                     final Window oldWindow = newScene.getWindow();
@@ -747,6 +748,7 @@
                     if (getScene() != null) {
                         impl_peer.setScene(null);
                         getScene().impl_disposePeer();
+                        StyleManager.getInstance().forget(getScene());
                     }
 
                     // Remove toolkit pulse listener
--- a/javafx-ui-common/test/unit/javafx/scene/Parent_recomputeBounds_Test.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-common/test/unit/javafx/scene/Parent_recomputeBounds_Test.java	Wed Jan 15 09:46:13 2014 -0800
@@ -25,11 +25,15 @@
 
 package javafx.scene;
 
+import com.sun.javafx.test.TestHelper;
+import javafx.geometry.BoundingBox;
 import javafx.scene.transform.Rotate;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import javafx.geometry.Bounds;
+import javafx.geometry.Point2D;
 import javafx.scene.shape.Rectangle;
+import javafx.scene.transform.Translate;
 
 import org.junit.Test;
 
@@ -375,4 +379,81 @@
         assertEquals(300, b.getWidth(), 0.0001);
         assertEquals(300, b.getHeight(), 0.0001);
     }
+
+    @Test
+    public void nodeShouldNotifyParentEvenIfItsTransformedBoundsAreDirty() {
+        final Rectangle child = new Rectangle(0, 0, 100, 100);
+        final Group parent = new Group(child);
+
+        // ensures that child's getTransformedBounds will be called with
+        // a non-identity transform argument during parent's bounds calculations
+        parent.getTransforms().add(new Rotate(-45));
+
+        // make the cached child's transformed bounds dirty
+        child.getTransforms().add(new Translate(50, 0));
+
+        // the cached child's transformed bounds will remain dirty because
+        // of a non-trivial parent transformation
+        TestHelper.assertSimilar(
+                boundsOfRotatedRect(50, 0, 100, 100, -45),
+                parent.getBoundsInParent());
+
+        // during the following call the child bounds changed notification
+        // should still be generated even though the child's cached transformed
+        // bounds are already dirty
+        child.getTransforms().add(new Translate(50, 0));
+
+        TestHelper.assertSimilar(
+                boundsOfRotatedRect(100, 0, 100, 100, -45),
+                parent.getBoundsInParent());
+    }
+
+    private static Bounds boundsOfRotatedRect(
+            final double x, final double y,
+            final double width, final double height,
+            final double angle) {
+        final Point2D p1 = rotatePoint(x, y, angle);
+        final Point2D p2 = rotatePoint(x + width, y, angle);
+        final Point2D p3 = rotatePoint(x, y + height, angle);
+        final Point2D p4 = rotatePoint(x + width, y + height, angle);
+
+        final double minx = min(p1.getX(), p2.getX(), p3.getX(), p4.getX());
+        final double miny = min(p1.getY(), p2.getY(), p3.getY(), p4.getY());
+        final double maxx = max(p1.getX(), p2.getX(), p3.getX(), p4.getX());
+        final double maxy = max(p1.getY(), p2.getY(), p3.getY(), p4.getY());
+
+        return new BoundingBox(minx, miny, maxx - minx, maxy - miny);
+    }
+
+    private static Point2D rotatePoint(final double x, final double y,
+                                       final double angle) {
+        final double rada = Math.toRadians(angle);
+        final double sina = Math.sin(rada);
+        final double cosa = Math.cos(rada);
+
+        return new Point2D(x * cosa - y * sina,
+                           x * sina + y * cosa);
+    }
+
+    private static double min(final double... values) {
+        double result = values[0];
+        for (int i = 1; i < values.length; ++i) {
+            if (result > values[i]) {
+                result = values[i];
+            }
+        }
+
+        return result;
+    }
+
+    private static double max(final double... values) {
+        double result = values[0];
+        for (int i = 1; i < values.length; ++i) {
+            if (result < values[i]) {
+                result = values[i];
+            }
+        }
+
+        return result;
+    }
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Wed Jan 15 09:46:13 2014 -0800
@@ -164,6 +164,7 @@
     @Override public void mouseReleased(MouseEvent e) {
         super.mousePressed(e);
         
+	boolean wasArmed = getControl().isArmed();
         disarm();
         
         // The wasComboBoxButtonClickedForAutoHide boolean was added to resolve
@@ -173,7 +174,9 @@
         // appears below in the autoHide() method.
         if (getControl().isShowing()) {
             hide();
-        } else if (! wasComboBoxButtonClickedForAutoHide && getControl().contains(e.getX(), e.getY())) {
+        } else if (! wasComboBoxButtonClickedForAutoHide 
+		&& getControl().contains(e.getX(), e.getY())
+		&& wasArmed) {
             show();
         } else {
             wasComboBoxButtonClickedForAutoHide = false;
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressBarSkin.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressBarSkin.java	Wed Jan 15 09:46:13 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -33,6 +33,8 @@
 import javafx.animation.Timeline;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
+import javafx.beans.binding.Bindings;
+import javafx.beans.binding.BooleanBinding;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.event.ActionEvent;
@@ -196,6 +198,8 @@
     private Timeline indeterminateTimeline;
     private boolean timelineNulled = false;
 
+    private BooleanBinding windowIsShowingBinding;
+
     /***************************************************************************
      *                                                                         *
      * Constructors                                                            *
@@ -212,6 +216,8 @@
         };
         control.indeterminateProperty().addListener(indeterminateListener);
 
+        windowIsShowingBinding = Bindings.selectBoolean(getSkinnable().sceneProperty(), "window", "showing");
+
         InvalidationListener visibilityListener = new InvalidationListener() {
             @Override public void invalidated(Observable valueModel) {
                 if (getSkinnable().isIndeterminate() && timelineNulled && indeterminateTimeline == null) {
@@ -220,7 +226,8 @@
                 }
                 
                 if (indeterminateTimeline != null) {
-                    if (getSkinnable().isVisible() && getSkinnable().getScene() != null) {
+                    if (getSkinnable().isVisible() && getSkinnable().getScene() != null
+                            && windowIsShowingBinding.get()) {
                         indeterminateTimeline.play();
                     }
                     else {
@@ -233,6 +240,7 @@
         };
         control.visibleProperty().addListener(visibilityListener);
         control.parentProperty().addListener(visibilityListener);
+        windowIsShowingBinding.addListener(visibilityListener);
 
         InvalidationListener sceneListener = new InvalidationListener() {
             @Override public void invalidated(Observable valueModel) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java	Thu Dec 19 07:57:07 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java	Wed Jan 15 09:46:13 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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,8 @@
 import javafx.animation.Timeline;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
+import javafx.beans.binding.Bindings;
+import javafx.beans.binding.BooleanBinding;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.event.ActionEvent;
@@ -89,6 +91,8 @@
     private DeterminateIndicator determinateIndicator;
     private boolean timelineNulled = false;
 
+    private BooleanBinding windowIsShowingBinding;
+
     /***************************************************************************
      *                                                                         *
      * Constructors                                                            *
@@ -105,6 +109,8 @@
         };
         control.indeterminateProperty().addListener(indeterminateListener);
 
+        windowIsShowingBinding = Bindings.selectBoolean(getSkinnable().sceneProperty(), "window", "showing");
+
         InvalidationListener visibilityListener = new InvalidationListener() {
             @Override public void invalidated(Observable valueModel) {
                 if (getSkinnable().isIndeterminate() && timelineNulled && spinner == null) {
@@ -114,7 +120,8 @@
                 }
                 
                 if (spinner != null) {
-                    if (getSkinnable().isVisible() && getSkinnable().getScene() != null) {
+                    if (getSkinnable().isVisible() && getSkinnable().getScene() != null &&
+                            windowIsShowingBinding.get()) {
                         spinner.indeterminateTimeline.play();
                     }
                     else {
@@ -128,6 +135,7 @@
         };
         control.visibleProperty().addListener(visibilityListener);
         control.parentProperty().addListener(visibilityListener);
+        windowIsShowingBinding.addListener(visibilityListener);
 
         InvalidationListener sceneListener = new InvalidationListener() {
             @Override public void invalidated(Observable valueModel) {