changeset 9705:7b47981a125c

Merge
author kcr
date Fri, 15 Apr 2016 08:55:39 -0700
parents 9c22f42c90ea e83368aa933b
children fb7b4d9db9cb 26965b16c5f8
files modules/controls/src/main/java/javafx/scene/control/Control.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/GlassViewEventHandler.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
diffstat 6 files changed, 100 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/Control.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/Control.java	Fri Apr 15 08:55:39 2016 -0700
@@ -103,17 +103,18 @@
      * @return The class. Cannot return null
      * @throws ClassNotFoundException If the class cannot be found using any technique.
      */
-    static Class<?> loadClass(final String className, final Object instance)
+    private static Class<?> loadClass(final String className, final Object instance)
             throws ClassNotFoundException
     {
         try {
             // Try just loading the class
-            return Class.forName(className);
+            return Class.forName(className, false, Control.class.getClassLoader());
         } catch (ClassNotFoundException ex) {
             // RT-17525 : Use context class loader only if Class.forName fails.
             if (Thread.currentThread().getContextClassLoader() != null) {
                 try {
-                    return Thread.currentThread().getContextClassLoader().loadClass(className);
+                    final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+                    return Class.forName(className, false, ccl);
                 } catch (ClassNotFoundException ex2) {
                     // Do nothing, just fall through
                 }
@@ -127,7 +128,8 @@
                 Class<?> currentType = instance.getClass();
                 while (currentType != null) {
                     try {
-                        return currentType.getClassLoader().loadClass(className);
+                        final ClassLoader loader = currentType.getClassLoader();
+                        return Class.forName(className, false, loader);
                     } catch (ClassNotFoundException ex2) {
                         currentType = currentType.getSuperclass();
                     }
@@ -701,6 +703,17 @@
 
         try {
             final Class<?> skinClass = Control.loadClass(skinClassName, control);
+            if (!Skin.class.isAssignableFrom(skinClass)) {
+                final String msg =
+                    "'" + skinClassName + "' is not a valid Skin class for control " + control;
+                final List<CssParser.ParseError> errors = StyleManager.getErrors();
+                if (errors != null) {
+                    CssParser.ParseError error = new CssParser.ParseError(msg);
+                    errors.add(error); // RT-19884
+                }
+                Logging.getControlsLogger().severe(msg);
+                return;
+            }
             Constructor<?>[] constructors = skinClass.getConstructors();
             Constructor<?> skinConstructor = null;
             for (Constructor<?> c : constructors) {
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatformFactory.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/NativePlatformFactory.java	Fri Apr 15 08:55:39 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -99,9 +99,13 @@
                                              factoryName, factoryClassName);
                 }
                 try {
-                    NativePlatformFactory npf = (NativePlatformFactory)
-                            Class.forName(factoryClassName)
-                            .newInstance();
+                    final ClassLoader loader = NativePlatformFactory.class.getClassLoader();
+                    final Class<?> clazz = Class.forName(factoryClassName, false, loader);
+                    if (!NativePlatformFactory.class.isAssignableFrom(clazz)) {
+                        throw new IllegalArgumentException("Unrecognized Monocle platform: "
+                                + factoryClassName);
+                    }
+                    NativePlatformFactory npf = (NativePlatformFactory) clazz.newInstance();
                     if (npf.matches() &&
                         npf.getMajorVersion() == majorVersion &&
                         npf.getMinorVersion() == minorVersion) {
--- a/modules/graphics/src/main/java/com/sun/javafx/jmx/MXExtension.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/jmx/MXExtension.java	Fri Apr 15 08:55:39 2016 -0700
@@ -36,10 +36,14 @@
 
     public static void initializeIfAvailable() {
         try {
-            final Class<MXExtension> mxExtensionClass =
-                    (Class<MXExtension>) Class.forName(EXTENSION_CLASS_NAME);
-
-            final MXExtension mxExtension = mxExtensionClass.newInstance();
+            final ClassLoader loader = MXExtension.class.getClassLoader();
+            final Class<?> mxExtensionClass =
+                    Class.forName(EXTENSION_CLASS_NAME, false, loader);
+            if (!MXExtension.class.isAssignableFrom(mxExtensionClass)) {
+                throw new IllegalArgumentException("Unrecognized MXExtension class: "
+                        + EXTENSION_CLASS_NAME);
+            }
+            final MXExtension mxExtension = (MXExtension)mxExtensionClass.newInstance();
             mxExtension.intialize();
         } catch (final Exception e) {
             Logging.getJavaFXLogger().info(
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/GlassViewEventHandler.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/GlassViewEventHandler.java	Fri Apr 15 08:55:39 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -50,6 +50,7 @@
 import javafx.scene.input.InputMethodEvent;
 import javafx.scene.input.InputMethodHighlight;
 import javafx.scene.input.InputMethodTextRun;
+import javafx.scene.input.KeyCode;
 import javafx.scene.input.MouseButton;
 import javafx.scene.input.RotateEvent;
 import javafx.scene.input.ScrollEvent;
@@ -152,6 +153,8 @@
         char[] chars;
         int modifiers;
 
+        private KeyCode lastKeyCode;
+
         @Override
         public Void run() {
             if (PULSE_LOGGING_ENABLED) {
@@ -159,10 +162,6 @@
             }
             WindowStage stage = scene.getWindowStage();
             try {
-                if (stage != null) {
-                    stage.setInEventHandler(true);
-                }
-
                 boolean shiftDown = (modifiers & KeyEvent.MODIFIER_SHIFT) != 0;
                 boolean controlDown = (modifiers & KeyEvent.MODIFIER_CONTROL) != 0;
                 boolean altDown = (modifiers & KeyEvent.MODIFIER_ALT) != 0;
@@ -177,6 +176,26 @@
                         KeyCodeMap.valueOf(key) ,
                         shiftDown, controlDown, altDown, metaDown);
 
+                KeyCode keyCode = KeyCodeMap.valueOf(key);
+                switch (type) {
+                    case com.sun.glass.events.KeyEvent.PRESS:
+                    case com.sun.glass.events.KeyEvent.RELEASE:
+                        lastKeyCode = keyCode;
+                        break;
+
+                    case com.sun.glass.events.KeyEvent.TYPED:
+                        keyCode = lastKeyCode;
+                        break;
+                }
+
+                if (stage != null) {
+                    if (keyCode == KeyCode.ESCAPE) {
+                        stage.setInAllowedEventHandler(false);
+                    } else {
+                        stage.setInAllowedEventHandler(true);
+                    }
+                }
+
                 switch (type) {
                     case com.sun.glass.events.KeyEvent.PRESS:
                         if (view.isInFullscreen() && stage != null) {
@@ -204,7 +223,7 @@
                 }
             } finally {
                 if (stage != null) {
-                    stage.setInEventHandler(false);
+                    stage.setInAllowedEventHandler(false);
                 }
                 if (PULSE_LOGGING_ENABLED) {
                     PulseLogger.newInput(null);
@@ -336,8 +355,17 @@
             WindowStage stage = scene.getWindowStage();
             try {
                 if (stage != null) {
-                    stage.setInEventHandler(true);
+                    switch (type) {
+                        case MouseEvent.UP:
+                        case MouseEvent.DOWN:
+                            stage.setInAllowedEventHandler(true);
+                            break;
+                        default:
+                            stage.setInAllowedEventHandler(false);
+                            break;
+                    }
                 }
+
                 if (scene.sceneListener != null) {
                     boolean shiftDown = (modifiers & KeyEvent.MODIFIER_SHIFT) != 0;
                     boolean controlDown = (modifiers & KeyEvent.MODIFIER_CONTROL) != 0;
@@ -358,7 +386,7 @@
                 }
             } finally {
                 if (stage != null) {
-                    stage.setInEventHandler(false);
+                    stage.setInAllowedEventHandler(false);
                 }
                 if (PULSE_LOGGING_ENABLED) {
                     PulseLogger.newInput(null);
@@ -400,7 +428,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(true);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -417,7 +445,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -438,7 +466,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(false);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -464,7 +492,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -543,7 +571,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(true);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -561,7 +589,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -852,7 +880,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(false);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -894,7 +922,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -916,7 +944,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(false);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -955,7 +983,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -976,7 +1004,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(false);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -1014,7 +1042,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -1034,7 +1062,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(false);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -1075,7 +1103,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -1093,7 +1121,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(true);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -1110,7 +1138,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -1130,7 +1158,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(true);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                     return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -1163,7 +1191,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
@@ -1180,7 +1208,7 @@
         WindowStage stage = scene.getWindowStage();
         try {
             if (stage != null) {
-                stage.setInEventHandler(true);
+                stage.setInAllowedEventHandler(true);
             }
             QuantumToolkit.runWithoutRenderLock(() -> {
                 return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -1192,7 +1220,7 @@
             });
         } finally {
             if (stage != null) {
-                stage.setInEventHandler(false);
+                stage.setInAllowedEventHandler(false);
             }
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.newInput(null);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Fri Apr 15 08:55:39 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, 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
@@ -75,8 +75,8 @@
     private boolean isInFullScreen = false;
 
     // A flag to indicate whether a call was generated from
-    // an input event handler.
-    private boolean inEventHandler = false;
+    // an allowed input event handler.
+    private boolean inAllowedEventHandler = false;
 
     // An active window is visible && enabled && focusable.
     // The list is maintained in the z-order, so that the last element
@@ -775,8 +775,8 @@
         }
 
        // Set a flag indicating whether this method was called from
-        // an input event handler.
-        if (isInEventHandler()) {
+        // an allowed input event handler.
+        if (isInAllowedEventHandler()) {
             fullScreenFromUserEvent = true;
         }
 
@@ -937,12 +937,12 @@
         }
     }
 
-    public void setInEventHandler(boolean inEventHandler) {
-        this.inEventHandler = inEventHandler;
+    public void setInAllowedEventHandler(boolean inAllowedEventHandler) {
+        this.inAllowedEventHandler = inAllowedEventHandler;
     }
 
-    public boolean isInEventHandler() {
-        return inEventHandler;
+    private boolean isInAllowedEventHandler() {
+        return inAllowedEventHandler;
     }
 
     @Override
--- a/modules/graphics/src/main/java/javafx/application/Application.java	Thu Apr 14 01:01:09 2016 -0700
+++ b/modules/graphics/src/main/java/javafx/application/Application.java	Fri Apr 15 08:55:39 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, 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
@@ -245,7 +245,7 @@
         }
 
         try {
-            Class theClass = Class.forName(callingClassName, true,
+            Class theClass = Class.forName(callingClassName, false,
                                Thread.currentThread().getContextClassLoader());
             if (Application.class.isAssignableFrom(theClass)) {
                 Class<? extends Application> appClass = theClass;