changeset 1774:44b111529375 2.2.60-b15

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/2.2.55/MASTER/jfx/rt
author kcr
date Tue, 15 Apr 2014 08:17:15 -0700
parents 077b2b93d5fa acba90833e71
children 17803d04ebc3
files .hgtags
diffstat 3 files changed, 101 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Mar 18 09:30:58 2014 -0700
+++ b/.hgtags	Tue Apr 15 08:17:15 2014 -0700
@@ -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
@@ -184,6 +186,18 @@
 23ad7db99131369da63137eb19cf6db1320bd471 2.2.51-b12
 57090adf4c425fde3ea61fb5f2de5ca6008b819b 2.2.55-b01
 57090adf4c425fde3ea61fb5f2de5ca6008b819b 2.2.51-b13
+fc533ffc22964e9cb45e396aeb363fc0ba22a20e 2.2.60-b03
+b8fcc422cc09255c80f13ec121f78bfcc52e0d75 2.2.60-b04
+aaecdf1fc0c3bac652ec1ea3d7ff5587b9dd8aab 2.2.60-b05
+ad8835ef13dbfa971b19d5620350fe07fbef1c7e 2.2.60-b06
+9ede406abdfb376e49b57c50ca952f3c95c293ef 2.2.60-b07
+4cfc306b90a1c090ab3fc838238fdd7dcc9f63d8 2.2.60-b08
+53d0f8119d8cf2a4ed9f604eb179f5ed01f60880 2.2.60-b09
+143b27648d9676132d054ca644c2e8fd5e6c1845 2.2.60-b10
+350a698900e9fff03533c639e70cb975dd2de35b 2.2.60-b11
+c1541c2d6a96524370e6af58021cf0b032a12ec0 2.2.60-b12
+ad9fa39517dafbbef092e8c6fb338447ce685a66 2.2.60-b13
+1c9d2c577088140a049a5e96751847ee915ca092 2.2.60-b14
 3dc253847a2c77f1ec8e8acb5ed35709902d5649 2.2.55-b02
 45a13255bc8e26a99d445c5a70bfe52e33808c56 2.2.55-b03
 f4a628d009e0ec85c53bf2cbc63d90965b232506 2.2.55-b04
--- a/javafx-ui-common/src/javafx/scene/Node.java	Tue Mar 18 09:30:58 2014 -0700
+++ b/javafx-ui-common/src/javafx/scene/Node.java	Tue Apr 15 08:17:15 2014 -0700
@@ -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/test/unit/javafx/scene/Parent_recomputeBounds_Test.java	Tue Mar 18 09:30:58 2014 -0700
+++ b/javafx-ui-common/test/unit/javafx/scene/Parent_recomputeBounds_Test.java	Tue Apr 15 08:17:15 2014 -0700
@@ -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;
+    }
 }