Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8342703: CSS transition is not started when initial value was not specified #1607

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Oct 21, 2024

When the initial value of a styleable property is not specified in a stylesheet, no transition is started:

.button {
    transition: -fx-opacity 1s;
}

.button:hover {
    -fx-opacity: 0.5;
}

The expected behavior is that a transition is started in this case, since the default value of -fx-opacity is 1.

The reason for this bug is that StyleableProperty implementations do not start a CSS transition when the value is applied for the first time. The intention behind this is that a node that is added to the scene graph should not start transitions. CSS transitions should only be started after the node has been shown for the first time.

The logic to detect this situation is currently as follows:

    // If this.origin == null, we're setting the value for the first time.
    // No transition should be started in this case.
    TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
        NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

However, this does not work. When no initial style is specified in the stylesheet, this.origin will not be set, and thus no transition will be started even after the node has been shown. The new logic works like this:

A Node.initialCssState flag is added. Initially, this is true. Manually calling applyCss or similar methods will not clear this flag, as we consider all manual CSS processing to be part of the "initial CSS state". Only at the end of Scene.doCSSPass will this flag be cleared on all nodes that have expressed their interest. This mechanism ensures that a node will be eligible for CSS transitions only after the following conditions have been satisfied:

  1. The node was added to a scene graph
  2. CSS processing was completed for a scene pulse

/reviewers 2


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8342703: CSS transition is not started when initial value was not specified (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1607/head:pull/1607
$ git checkout pull/1607

Update a local copy of the PR:
$ git checkout pull/1607
$ git pull https://git.openjdk.org/jfx.git pull/1607/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1607

View PR using the GUI difftool:
$ git pr show -t 1607

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1607.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 21, 2024

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 21, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Ready for review label Oct 21, 2024
@openjdk
Copy link

openjdk bot commented Oct 21, 2024

@mstr2
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@mlbridge
Copy link

mlbridge bot commented Oct 21, 2024

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Ready for review
Development

Successfully merging this pull request may close these issues.

2 participants