changeset 11194:b9d58e42f9f5

Merge
author kcr
date Tue, 12 Feb 2019 07:51:16 -0800
parents 393e3771fe1c 9ad3ee98867c
children d915992a1af9
files .hgtags
diffstat 4 files changed, 119 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jan 31 10:02:35 2019 -0800
+++ b/.hgtags	Tue Feb 12 07:51:16 2019 -0800
@@ -522,3 +522,5 @@
 51364187b4e1b02c07bb2490ca513806ca0fd626 12+9
 20234c4d09b8e50d913f731916abd4af44dd6881 12+10
 b5c27572ab56e5a8df14f4252f90c84532c471dd 13+0
+c8bb215eb1a56a2b71133b5a25f758057f255407 12+11
+d1c7e1786e8793ccbbc5514e19636b6badfaac2c 12+12
--- a/modules/javafx.graphics/src/main/java/javafx/scene/Parent.java	Thu Jan 31 10:02:35 2019 -0800
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/Parent.java	Tue Feb 12 07:51:16 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, 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
@@ -194,7 +194,8 @@
         }
 
         if (isDirty(DirtyBits.PARENT_CHILDREN_VIEW_ORDER)) {
-            computeViewOrderChidrenAndUpdatePeer();
+            computeViewOrderChildren();
+            peer.setViewOrderChildren(viewOrderChildren);
         }
 
         if (Utils.assertionEnabled()) validatePG();
@@ -265,7 +266,7 @@
         NodeHelper.markDirty(this, DirtyBits.PARENT_CHILDREN_VIEW_ORDER);
     }
 
-    private void computeViewOrderChidrenAndUpdatePeer() {
+    private void computeViewOrderChildren() {
         boolean viewOrderSet = false;
         for (Node child : children) {
             double vo = child.getViewOrder();
@@ -284,14 +285,15 @@
                     -> a.getViewOrder() < b.getViewOrder() ? 1
                             : a.getViewOrder() == b.getViewOrder() ? 0 : -1);
         }
-
-        final NGGroup peer = getPeer();
-        peer.setViewOrderChildren(viewOrderChildren);
     }
 
     // Call this method if children view order is needed for picking.
     // The returned list should be treated as read only.
     private List<Node> getOrderedChildren() {
+        if (isDirty(DirtyBits.PARENT_CHILDREN_VIEW_ORDER)) {
+            //Fix for JDK-8205092
+            computeViewOrderChildren();
+        }
         if (!viewOrderChildren.isEmpty()) {
             return viewOrderChildren;
         }
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m	Thu Jan 31 10:02:35 2019 -0800
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m	Tue Feb 12 07:51:16 2019 -0800
@@ -455,9 +455,17 @@
     jdouble rotationY = 0.0;
     if (type == com_sun_glass_events_MouseEvent_WHEEL)
     {
-        rotationX = (jdouble)[theEvent scrollingDeltaX] * 0.1;
-        rotationY = (jdouble)[theEvent scrollingDeltaY] * 0.1;
-
+        if ([theEvent hasPreciseScrollingDeltas])
+        {
+            rotationX = (jdouble)[theEvent scrollingDeltaX] * 0.1;
+            rotationY = (jdouble)[theEvent scrollingDeltaY] * 0.1;
+        }
+        else
+        {
+            rotationX = (jdouble)[theEvent deltaX];
+            rotationY = (jdouble)[theEvent deltaY];
+        }
+        
         //XXX: check for equality for doubles???
         if (rotationX == 0.0 && rotationY == 0.0)
         {
--- a/modules/javafx.graphics/src/test/java/test/javafx/scene/ParentTest.java	Thu Jan 31 10:02:35 2019 -0800
+++ b/modules/javafx.graphics/src/test/java/test/javafx/scene/ParentTest.java	Tue Feb 12 07:51:16 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, 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
@@ -29,6 +29,8 @@
 import test.com.sun.javafx.pgstub.StubToolkit;
 import com.sun.javafx.sg.prism.NGGroup;
 import com.sun.javafx.tk.Toolkit;
+import com.sun.javafx.geom.PickRay;
+import com.sun.javafx.scene.input.PickResultChooser;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javafx.scene.Group;
 import javafx.scene.GroupShim;
@@ -741,6 +743,101 @@
         assertSame(scene, ParentShim.getChildren(child).get(3).getScene());
     }
 
+    @Test
+    public void testPickingChildNode() {
+        Rectangle rect1 = new Rectangle();
+        rect1.setX(10);
+        rect1.setY(10);
+        rect1.setWidth(100);
+        rect1.setHeight(100);
+
+        Rectangle rect2 = new Rectangle();
+        rect2.setX(10);
+        rect2.setY(10);
+        rect2.setWidth(100);
+        rect2.setHeight(100);
+        Group g = new Group();
+
+        // needed since picking doesn't work unless rooted in a scene and visible
+        Scene scene = new Scene(g);
+        stage.setScene(scene);
+        stage.show();
+        ParentShim.getChildren(g).addAll(rect1, rect2);
+        toolkit.fireTestPulse();
+
+        PickResultChooser res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(50, 50, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertSame(rect2, res.getIntersectedNode());
+        res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(0, 0, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertNull(res.getIntersectedNode());
+    }
+
+    @Test
+    public void testPickingChildNodeWithViewOrderSet() {
+        Rectangle rect1 = new Rectangle();
+        rect1.setX(10);
+        rect1.setY(10);
+        rect1.setWidth(100);
+        rect1.setHeight(100);
+        rect1.setViewOrder(-1);
+
+        Rectangle rect2 = new Rectangle();
+        rect2.setX(10);
+        rect2.setY(10);
+        rect2.setWidth(100);
+        rect2.setHeight(100);
+        Group g = new Group();
+
+        // needed since picking doesn't work unless rooted in a scene and visible
+        Scene scene = new Scene(g);
+        stage.setScene(scene);
+        stage.show();
+        ParentShim.getChildren(g).addAll(rect1, rect2);
+        toolkit.fireTestPulse();
+
+        PickResultChooser res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(50, 50, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertSame(rect1, res.getIntersectedNode());
+        res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(0, 0, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertNull(res.getIntersectedNode());
+    }
+
+    @Test
+    public void testPickingChildNodeWithDirtyViewOrder() {
+        //JDK-8205092
+        Rectangle rect1 = new Rectangle();
+        rect1.setX(10);
+        rect1.setY(10);
+        rect1.setWidth(100);
+        rect1.setHeight(100);
+        rect1.setViewOrder(-1);
+
+        Rectangle rect2 = new Rectangle();
+        rect2.setX(10);
+        rect2.setY(10);
+        rect2.setWidth(100);
+        rect2.setHeight(100);
+        Group g = new Group();
+
+        // needed since picking doesn't work unless rooted in a scene and visible
+        Scene scene = new Scene(g);
+        stage.setScene(scene);
+        stage.show();
+        ParentShim.getChildren(g).addAll(rect1, rect2);
+        toolkit.fireTestPulse();
+
+        ParentShim.getChildren(g).remove(rect1);
+
+        PickResultChooser res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(50, 50, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertSame(rect2, res.getIntersectedNode());
+        res = new PickResultChooser();
+        NodeHelper.pickNode(g, new PickRay(0, 0, 1, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), res);
+        assertNull(res.getIntersectedNode());
+    }
+
     public static class MockParent extends Parent {
         public MockParent(Node... children) {
             ParentShim.getChildren(this).addAll(children);