changeset 7612:4b2c53c5ac68

RT-37787: Sizing fonts with CSS em can result in wrong size font being displayed
author David Grieve<david.grieve@oracle.com>
date Fri, 01 Aug 2014 10:43:46 -0400
parents abe50f87067a
children 1f4093002756
files modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java	Thu Jul 31 15:59:05 2014 -0700
+++ b/modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java	Fri Aug 01 10:43:46 2014 -0400
@@ -1664,6 +1664,7 @@
 
         CalculatedValue cvFont = cachedFont;
 
+
         Set<PseudoClass> states = styleable instanceof Node ? ((Node)styleable).pseudoClassStates : styleable.getPseudoClassStates();
 
         // RT-20145 - if looking for font size and the node has a font,
@@ -1673,10 +1674,10 @@
         if (cacheContainer.fontProp != null) {
             StyleableProperty<Font> styleableProp = cacheContainer.fontProp.getStyleableProperty(styleable);
             StyleOrigin fpOrigin = styleableProp.getStyleOrigin();
+            Font font = styleableProp.getValue();
+            if (font == null) font = Font.getDefault();
             if (fpOrigin == StyleOrigin.USER) {
                 origin = fpOrigin;
-                Font font = styleableProp.getValue();
-                if (font == null) font = Font.getDefault();
                 family = getFontFamily(font);
                 size = font.getSize();
                 weight = getFontWeight(font);
@@ -1685,6 +1686,9 @@
             }
         }
 
+        CalculatedValue parentCachedFont = getCachedFont(styleable.getStyleableParent());
+        if (parentCachedFont == null) parentCachedFont = new CalculatedValue(Font.getDefault(), null, false);
+
         //
         // Look up the font- properties
         //
@@ -1737,7 +1741,7 @@
 
                 final CalculatedValue cv =
                         calculateValue(fontShorthand, styleable, dummyFontProperty,
-                                styleMap, states, styleable, cvFont);
+                                styleMap, states, styleable, parentCachedFont);
 
                 // cv could be SKIP
                 if (cv.getValue() instanceof Font) {
@@ -1776,9 +1780,10 @@
             // 1) a style matching this node and is more specific than the font shorthand or
             // 2) an inherited style that is more specific than the font shorthand
             // and, therefore, we can use the fontSize style
+
             final CalculatedValue cv =
                     calculateValue(fontSize, styleable, dummyFontProperty,
-                            styleMap, states, styleable, cvFont);
+                            styleMap, states, styleable, parentCachedFont);
 
             if (cv.getValue() instanceof Double) {
                 if (origin == null || origin.compareTo(fontSize.getOrigin()) <= 0) {