Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
Expand Down Expand Up @@ -612,20 +612,7 @@ void transitionToState(final Node node) {
}

final Set<PseudoClass>[] transitionStates = getTransitionStates(node);

final StyleCacheEntry.Key fontCacheKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
CalculatedValue cachedFont = cacheContainer.fontSizeCache.get(fontCacheKey);

if (cachedFont == null) {

cachedFont = lookupFont(node, "-fx-font", styleMap, cachedFont);

if (cachedFont == SKIP) cachedFont = getCachedFont(node.getStyleableParent());
if (cachedFont == null) cachedFont = new CalculatedValue(Font.getDefault(), null, false);

cacheContainer.fontSizeCache.put(fontCacheKey,cachedFont);

}
CalculatedValue cachedFont = getCachedFont(node, styleMap, transitionStates);

final Font fontForRelativeSizes = (Font)cachedFont.getValue();

Expand Down Expand Up @@ -1402,7 +1389,7 @@ private CalculatedValue calculateValue(
CalculatedValue childsCachedFont = fontFromCacheEntry;
do {

CalculatedValue parentsCachedFont = getCachedFont(parent.getStyleableParent());
CalculatedValue parentsCachedFont = getFont(parent.getStyleableParent());

if (parentsCachedFont != null) {

Expand Down Expand Up @@ -1526,43 +1513,47 @@ public StyleableProperty<Font> getStyleableProperty(Node node) {
}
};

private CalculatedValue getCachedFont(final Styleable styleable) {

if (styleable instanceof Node == false) return null;

CalculatedValue cachedFont = null;

Node parent = (Node)styleable;

final CssStyleHelper parentHelper = parent.styleHelper;

// if there is no parentHelper,
// or there is a parentHelper but no cacheContainer,
// then look to the next parent
if (parentHelper == null || parentHelper.cacheContainer == null) {

cachedFont = getCachedFont(parent.getStyleableParent());
private CalculatedValue getCachedFont(final Node node, final StyleMap styleMap, final Set<PseudoClass>[] transitionStates) {
if (node.styleHelper != this) {
return node.styleHelper.getCachedFont(node, styleMap, transitionStates);
}
final StyleCacheEntry.Key fontCacheKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
CalculatedValue cachedFont = cacheContainer.fontSizeCache.get(fontCacheKey);

// there is a parent helper and a cacheContainer,
} else {
if (cachedFont == null) {

CacheContainer parentCacheContainer = parentHelper.cacheContainer;
if ( parentCacheContainer != null
&& parentCacheContainer.fontSizeCache != null
&& parentCacheContainer.fontSizeCache.isEmpty() == false) {
cachedFont = lookupFont(node, "-fx-font", styleMap, null);

Set<PseudoClass>[] transitionStates = parentHelper.getTransitionStates(parent);
StyleCacheEntry.Key parentCacheEntryKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
cachedFont = parentCacheContainer.fontSizeCache.get(parentCacheEntryKey);
if (cachedFont == SKIP) {
Styleable parent = node.getStyleableParent();
while (parent instanceof Node && (((Node)parent).styleHelper == null || ((Node)parent).styleHelper.cacheContainer == null)) {
parent = (Node)parent.getStyleableParent();
}
if (parent instanceof Node && (((Node)parent).styleHelper != null && ((Node)parent).styleHelper.cacheContainer != null)) {
Node parentNode = (Node)parent;
Set<PseudoClass>[] parentTransitionStates = parentNode.styleHelper.getTransitionStates(parentNode);
StyleMap parentStyleMap = parentNode.styleHelper.getStyleMap(parentNode);
cachedFont = parentNode.styleHelper.getCachedFont(parentNode, parentStyleMap, parentTransitionStates);
} else {
cachedFont = null;
}
}
if (cachedFont == null) cachedFont = new CalculatedValue(Font.getDefault(), null, false);

if (cachedFont == null) {
StyleMap smap = parentHelper.getStyleMap(parent);
cachedFont = parentHelper.lookupFont(parent, "-fx-font", smap, null);
}
cacheContainer.fontSizeCache.put(fontCacheKey,cachedFont);
}
return cachedFont;
}

return cachedFont != SKIP ? cachedFont : null;
private CalculatedValue getFont(final Styleable styleable) {
if (styleable instanceof Node == false) return null;
Node node = (Node)styleable;
if (node.styleHelper == null || node.styleHelper.cacheContainer == null) {
return getFont(styleable.getStyleableParent());
}
Set<PseudoClass>[] transitionStates = node.styleHelper.getTransitionStates(node);
StyleMap styleMap = node.styleHelper.getStyleMap(node);
return getCachedFont((Node)node, styleMap, transitionStates);
}

/*package access for testing*/ FontPosture getFontPosture(Font font) {
Expand Down Expand Up @@ -1694,7 +1685,7 @@ private CalculatedValue getCachedFont(final Styleable styleable) {
}
}

CalculatedValue parentCachedFont = getCachedFont(styleable.getStyleableParent());
CalculatedValue parentCachedFont = getFont(styleable.getStyleableParent());
if (parentCachedFont == null) parentCachedFont = new CalculatedValue(Font.getDefault(), null, false);

//
Expand Down