changeset 1817:97d1312344e8 8.0-b61

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/MASTER/rt
author leifs
date Tue, 16 Oct 2012 13:34:08 -0700
parents a49900764c1d c731a926c171
children dafaa830d4d0 d811a42d75ba
files
diffstat 10 files changed, 155 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/css/StyleHelper.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/StyleHelper.java	Tue Oct 16 13:34:08 2012 -0700
@@ -44,6 +44,8 @@
 import com.sun.javafx.css.converters.FontConverter;
 import com.sun.javafx.css.parser.CSSParser;
 import com.sun.javafx.logging.PlatformLogger;
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleObjectProperty;
 import javafx.scene.Parent;
 
 /**
@@ -862,11 +864,7 @@
                 calculatedValue = lookup(node, styleable, isUserSet, getPseudoClassState(), 
                         inlineStyles, node, cacheEntry, styleList);
 
-                if (fastpath) {
-                    // if userStyles is null and calculatedValue was null,
-                    // then the calculatedValue didn't come from the cache
-                    cacheEntry.put(property, calculatedValue);
-                }
+                cacheEntry.put(property, calculatedValue);
 
             }
             
@@ -1224,9 +1222,9 @@
      * Find the property among the styles that pertain to the Node
      */
     private CascadingStyle resolveRef(Node node, String property, long states,
-            Map<String,CascadingStyle> userStyles) {
+            Map<String,CascadingStyle> inlineStyles) {
         
-        final CascadingStyle style = getStyle(node, property, states, userStyles);
+        final CascadingStyle style = getStyle(node, property, states, inlineStyles);
         if (style != null) {
             return style;
         } else {
@@ -1235,7 +1233,7 @@
             if (states > 0) {
                 // if states > 0, then we need to check this node again,
                 // but without any states.
-                return resolveRef(node,property,0,userStyles);
+                return resolveRef(node,property,0,inlineStyles);
             } else {
                 // TODO: This block was copied from inherit. Both should use same code somehow.
                 Node parent = node.getParent();
@@ -1262,7 +1260,8 @@
             Node node, 
             ParsedValue value, 
             long states,
-            Map<String,CascadingStyle> userStyles, 
+            Map<String,CascadingStyle> inlineStyles,
+            ObjectProperty<Origin> whence,
             List<Style> styleList) {
         
         
@@ -1279,7 +1278,7 @@
                 final String sval = (String)val;
                 
                 CascadingStyle resolved = 
-                    resolveRef(node, sval, states, userStyles);
+                    resolveRef(node, sval, states, inlineStyles);
 
                 if (resolved != null) {
                     
@@ -1290,10 +1289,22 @@
                         }
                     }
                     
+                    // The origin of this parsed value is the greatest of 
+                    // any of the resolved reference. If a resolved reference
+                    // comes from an inline style, for example, then the value
+                    // calculated from the resolved lookup should have inline
+                    // as its origin. Otherwise, an inline style could be 
+                    // stored in shared cache.
+                    final Origin wOrigin = whence.get();
+                    final Origin rOrigin = resolved.getOrigin();
+                    if (rOrigin != null && (wOrigin == null ||  wOrigin.compareTo(rOrigin) < 0)) {
+                        whence.set(rOrigin);
+                    } 
+                    
                     // the resolved value may itself need to be resolved.
                     // For example, if the value "color" resolves to "base",
                     // then "base" will need to be resolved as well.
-                    return resolveLookups(node, resolved.getParsedValue(), states, userStyles, styleList);
+                    return resolveLookups(node, resolved.getParsedValue(), states, inlineStyles, whence, styleList);
                 }
             }
         }
@@ -1311,7 +1322,7 @@
                 for (int ll=0; ll<layers[l].length; ll++) {
                     if (layers[l][ll] == null) continue;
                     layers[l][ll].resolved = 
-                        resolveLookups(node, layers[l][ll], states, userStyles, styleList);
+                        resolveLookups(node, layers[l][ll], states, inlineStyles, whence, styleList);
                 }
             }
 
@@ -1321,7 +1332,7 @@
             for (int l=0; l<layer.length; l++) {
                 if (layer[l] == null) continue;
                 layer[l].resolved =
-                    resolveLookups(node, layer[l], states, userStyles, styleList);
+                    resolveLookups(node, layer[l], states, inlineStyles, whence, styleList);
             }
         }
 
@@ -1414,6 +1425,7 @@
         return sbuf.toString();
     }
     
+    
     private CalculatedValue calculateValue(
             final CascadingStyle style, 
             final Node node, 
@@ -1427,8 +1439,9 @@
         final ParsedValue cssValue = style.getParsedValue();
         if (cssValue != null && !("null").equals(cssValue.getValue())) {
 
+            ObjectProperty<Origin> whence = new SimpleObjectProperty<Origin>(style.getOrigin());
             final ParsedValue resolved = 
-                resolveLookups(node, cssValue, states, inlineStyles, styleList);
+                resolveLookups(node, cssValue, states, inlineStyles, whence, styleList);
             
             try {
                 // The computed value
@@ -1519,7 +1532,7 @@
                 else
                     val = styleable.getConverter().convert(resolved, font);
 
-                final Origin origin = style.getOrigin();
+                final Origin origin = whence.get();
                 return new CalculatedValue(val, origin, resolved.isNeedsFont());
                 
             } catch (ClassCastException cce) {
--- a/javafx-ui-common/src/com/sun/javafx/scene/KeyboardShortcutsHandler.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/scene/KeyboardShortcutsHandler.java	Tue Oct 16 13:34:08 2012 -0700
@@ -44,6 +44,13 @@
 import com.sun.javafx.collections.ObservableListWrapper;
 import com.sun.javafx.collections.ObservableMapWrapper;
 import com.sun.javafx.event.BasicEventDispatcher;
+import com.sun.javafx.scene.traversal.Direction;
+
+import static javafx.scene.input.KeyCode.DOWN;
+import static javafx.scene.input.KeyCode.LEFT;
+import static javafx.scene.input.KeyCode.RIGHT;
+import static javafx.scene.input.KeyCode.TAB;
+import static javafx.scene.input.KeyCode.UP;
 
 public final class KeyboardShortcutsHandler extends BasicEventDispatcher {
     private ObservableMap<KeyCombination, Runnable> accelerators;
@@ -93,14 +100,58 @@
         return accelerators;
     }
 
+    public void traverse(Node node, Direction dir) {
+        node.impl_traverse(dir);
+    }
+
+    public void processTraversal(Event event) {
+        if (event instanceof KeyEvent && event.getEventType() == KeyEvent.KEY_PRESSED) {
+            if (!((KeyEvent)event).isMetaDown() && !((KeyEvent)event).isControlDown() && !((KeyEvent)event).isAltDown()) {
+                Object obj = event.getTarget();
+                if (obj instanceof Node) {
+                
+                    switch (((KeyEvent)event).getCode()) {
+                      case TAB :
+                          if (((KeyEvent)event).isShiftDown()) {
+                              traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.PREVIOUS);
+                          }
+                          else {
+                              traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.NEXT);
+                          }
+                          event.consume();
+                          break;
+                      case UP :
+                          traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.UP);
+                          event.consume();
+                          break;
+                      case DOWN :
+                          traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.DOWN);
+                          event.consume();
+                          break;
+                      case LEFT :
+                          traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.LEFT);
+                          event.consume();
+                          break;
+                      case RIGHT :
+                          traverse(((Node)obj), com.sun.javafx.scene.traversal.Direction.RIGHT);
+                          event.consume();
+                          break;
+                      default :
+                          break;
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     public Event dispatchBubblingEvent(Event event) {
         /*
         ** If the key event hasn't been consumed then
         ** we will process global events in the order :
-        **    . Navigation, -> handled by the traversalEngine
         **    . Mnemonics,
-        **    . Accelerators.
+        **    . Accelerators,
+        **    . Navigation.
         ** This processing is extra to that of listeners and
         ** the focus Node.
         */
@@ -118,6 +169,10 @@
             if (!event.isConsumed()) {
                 processAccelerators((KeyEvent)event);
             }
+
+            if (!event.isConsumed()) {
+                processTraversal(event);
+            }
         }
 
         /*
--- a/javafx-ui-common/src/javafx/scene/Parent.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/Parent.java	Tue Oct 16 13:34:08 2012 -0700
@@ -1115,28 +1115,28 @@
         
         styleManager = null;
         
-        final boolean hasStylesheets = (getStylesheets().isEmpty() == false);
+        final Scene scene = getScene();
+        if (scene == null) return null;
+
+        // This Parent's styleManager will chain to the styleManager of 
+        // one of its ancestors, or to the scene styleManager.
+        StyleManager parentStyleManager = null;
+        Parent parent = getParent();
+        while (parent != null && parentStyleManager == null) {
+            parentStyleManager = parent.getStyleManager();
+            parent = parent.getParent();
+        }
         
-        if (hasStylesheets) {
-
-            // This Parent's styleManager will chain to the styleManager of 
-            // one of its ancestors, or to the scene styleManager.
-            StyleManager parentStyleManager = null;
-            Parent parent = getParent();
-            while (parent != null && 
-                    (parentStyleManager = parent.getStyleManager()) == null) {
-                parent = parent.getParent();
-            }
+        if (parentStyleManager == null) parentStyleManager = scene.styleManager;
+        
+        if (getStylesheets().isEmpty() == false) {
             
-            if (parentStyleManager != null) {
-                styleManager = 
-                    StyleManager.createStyleManager(Parent.this, parentStyleManager);
-            } else {
-                final Scene scene = getScene();
-                if (scene != null) {
-                    StyleManager.createStyleManager(Parent.this, scene.styleManager);
-                }
-            } 
+            styleManager = 
+                StyleManager.createStyleManager(Parent.this, parentStyleManager);
+            
+        } else {
+            
+            styleManager = parentStyleManager; 
         
         }
         return styleManager;
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Tue Oct 16 13:34:08 2012 -0700
@@ -1840,6 +1840,8 @@
      * on this scene.
      */
     void registerTraversable(Node n) {
+        initializeInternalEventDispatcher();
+
         final TraversalEngine te = lookupTraversalEngine(n);
         if (te != null) {
             if (traversalRegistry == null) {
--- a/javafx-ui-common/src/javafx/scene/doc-files/cssref.html	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/doc-files/cssref.html	Tue Oct 16 13:34:08 2012 -0700
@@ -2153,9 +2153,9 @@
     <ol>
       <li>background fills</li>
       <li>background images</li>
-      <li>contents</li>
       <li>border strokes</li>
       <li>border images</li>
+      <li>contents</li>
     </ol>
     <p>The background and border mechanisms are patterned after the CSS 3 draft
       backgrounds and borders module. See <a href="#references">[4]</a> for a
--- a/javafx-ui-common/src/javafx/scene/layout/Background.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/layout/Background.java	Tue Oct 16 13:34:08 2012 -0700
@@ -69,7 +69,7 @@
     static final StyleableProperty<Node,Paint[]> BACKGROUND_COLOR =
             new SubStyleableProperty<Paint[]>("-fx-background-color",
                     PaintConverter.SequenceConverter.getInstance(),
-                    new Paint[] {Color.BLACK});
+                    new Paint[] {Color.TRANSPARENT});
 
     static final StyleableProperty<Node,Insets[]> BACKGROUND_RADIUS =
             new SubStyleableProperty<Insets[]>("-fx-background-radius",
--- a/javafx-ui-common/src/javafx/scene/layout/CornerRadii.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/layout/CornerRadii.java	Tue Oct 16 13:34:08 2012 -0700
@@ -371,4 +371,39 @@
     @Override public int hashCode() {
         return hash;
     }
+
+    @Override public String toString() {
+        if (isUniform()) {
+            return "CornerRadii [uniform radius = " + topLeftHorizontalRadius + "]";
+        }
+
+        return "CornerRadii [" +
+                (topLeftHorizontalRadius == topLeftVerticalRadius ?
+                    "topLeft=" + topLeftHorizontalRadius :
+                    "topLeftHorizontalRadius=" + topLeftHorizontalRadius +
+                    ", topLeftVerticalRadius=" + topLeftVerticalRadius) +
+                (topRightHorizontalRadius == topRightVerticalRadius ?
+                    ", topRight=" + topRightHorizontalRadius :
+                    ", topRightVerticalRadius=" + topRightVerticalRadius +
+                    ", topRightHorizontalRadius=" + topRightHorizontalRadius) +
+                (bottomRightHorizontalRadius == bottomRightVerticalRadius ?
+                    ", bottomRight=" + bottomRightHorizontalRadius :
+                    ", bottomRightHorizontalRadius=" + bottomRightHorizontalRadius +
+                    ", bottomRightVerticalRadius=" + bottomRightVerticalRadius) +
+                (bottomLeftHorizontalRadius == bottomLeftVerticalRadius ?
+                    ", bottomLeft=" + bottomLeftHorizontalRadius :
+                    ", bottomLeftVerticalRadius=" + bottomLeftVerticalRadius +
+                    ", bottomLeftHorizontalRadius=" + bottomLeftHorizontalRadius) +
+//                ", topLeftHorizontalRadiusAsPercentage=" + topLeftHorizontalRadiusAsPercentage +
+//                ", topLeftVerticalRadiusAsPercentage=" + topLeftVerticalRadiusAsPercentage +
+//                ", topRightVerticalRadiusAsPercentage=" + topRightVerticalRadiusAsPercentage +
+//                ", topRightHorizontalRadiusAsPercentage=" + topRightHorizontalRadiusAsPercentage +
+//                ", bottomRightHorizontalRadiusAsPercentage=" + bottomRightHorizontalRadiusAsPercentage +
+//                ", bottomRightVerticalRadiusAsPercentage=" + bottomRightVerticalRadiusAsPercentage +
+//                ", bottomLeftVerticalRadiusAsPercentage=" + bottomLeftVerticalRadiusAsPercentage +
+//                ", bottomLeftHorizontalRadiusAsPercentage=" + bottomLeftHorizontalRadiusAsPercentage +
+//                ", hasPercentBasedRadii=" + hasPercentBasedRadii +
+//                ", uniform=" + uniform +
+                ']';
+    }
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/FXVK.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/FXVK.java	Tue Oct 16 13:34:08 2012 -0700
@@ -51,7 +51,7 @@
 
 public class FXVK extends Control {
 
-    public final static String[] VK_TYPE_NAMES = new String[] { "text", "numeric", "url", "email" };
+    final static String[] VK_TYPE_NAMES = new String[] { "text", "numeric", "url", "email" };
     public final static String VK_TYPE_PROP_KEY = "vkType";
 
     String[] chars;
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java	Tue Oct 16 13:34:08 2012 -0700
@@ -29,24 +29,19 @@
 import javafx.beans.value.ObservableValue;
 import javafx.collections.ListChangeListener;
 import javafx.event.ActionEvent;
+import javafx.event.Event;
 import javafx.event.EventHandler;
-import javafx.geometry.HPos;
 import javafx.geometry.Insets;
-import javafx.geometry.VPos;
 import javafx.scene.Scene;
 import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Menu;
 import javafx.scene.control.MenuButton;
 import javafx.scene.control.MenuItem;
 import javafx.scene.control.SkinBase;
 import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.Region;
 import javafx.scene.layout.StackPane;
-
 import com.sun.javafx.scene.control.behavior.MenuButtonBehaviorBase;
-import javafx.event.Event;
-import javafx.event.Event;
-import javafx.event.EventType;
-import javafx.scene.control.Menu;
-import javafx.scene.layout.Region;
 
 /**
  * Base class for MenuButtonSkin and SplitMenuButtonSkin. It consists of the
@@ -239,20 +234,16 @@
 
     @Override protected double computePrefWidth(double height) {
         final Insets padding = getInsets();
-        final Insets arrowButtonPadding = arrowButton.getInsets();
         return padding.getLeft()
                 + label.prefWidth(height)
-                + arrowButtonPadding.getLeft()
-                + arrow.prefWidth(height)
-                + arrowButtonPadding.getRight()
+                + snapSize(arrowButton.prefWidth(height))
                 + padding.getRight();
     }
 
     @Override protected double computePrefHeight(double width) {
         final Insets padding = getInsets();
-        final Insets arrowButtonPadding = arrowButton.getInsets();
         return padding.getTop()
-                + Math.max(label.prefHeight(width), arrowButtonPadding.getTop() + arrow.prefHeight(-1) + arrowButtonPadding.getBottom())
+                + Math.max(label.prefHeight(width), snapSize(arrowButton.prefHeight(-1)))
                 + padding.getBottom();
     }
 
@@ -265,21 +256,10 @@
     }
 
     @Override protected void layoutChildren(final double x, final double y,
-            final double w, final double h) {
-        final Insets padding = getInsets();
-        final Insets arrowButtonPadding = arrowButton.getInsets();
-
-        final double arrowWidth = arrow.prefWidth(-1);
-        final double arrowButtonWidth = arrowButtonPadding.getLeft() + arrowWidth + arrowButtonPadding.getRight();
-
+                                            final double w, final double h) {
+        final double arrowButtonWidth = snapSize(arrowButton.prefWidth(-1));
         label.resizeRelocate(x, y, w - arrowButtonWidth, h);
-
-        arrowButton.resize(arrowButtonWidth, h);
-        positionInArea(arrowButton, getWidth() - padding.getRight() - arrowButtonWidth, y, arrowButtonWidth, h,
-                /*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
-
-        // size popup to its pref size
-//        popup.autosize();
+        arrowButton.resizeRelocate(x+(w-arrowButtonWidth), y, arrowButtonWidth, h);
     }
 
     private void addAccelerators(javafx.collections.ObservableList<javafx.scene.control.MenuItem> mItems) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Tue Oct 16 09:40:28 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Tue Oct 16 13:34:08 2012 -0700
@@ -1834,7 +1834,7 @@
 /* The SplitMenuButton skin uses an inner Label part */
 .split-menu-button > .label {
     -fx-background-color:  -fx-outer-border, -fx-inner-border, -fx-body-color;
-    -fx-background-insets: 0, 1, 2;
+    -fx-background-insets: 0, 1 0 1 1, 2 1 2 2;
     -fx-background-radius: 5 0 0 5, 4 0 0 4, 3 0 0 3;
     -fx-padding: 0.166667em 1.5em 0.25em 0.833333em; /* 2 18 3 10 */
 }
@@ -1850,7 +1850,7 @@
     -fx-color: -fx-hover-base;
 }
 
-.split-menu-button > .arrow-button:armed {
+.split-menu-button > .arrow-button:pressed {
     -fx-color: -fx-pressed-base;
 }