Skip to content
Permalink
Browse files
8089913: CSS pseudo classes missing by default for some controls
Reviewed-by: kcr, aghaisas
  • Loading branch information
mstr2 authored and kevinrushforth committed Mar 8, 2021
1 parent e394b0a commit 3374f4798342aea926cd51c065bd2c7e996dd2c4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 0 deletions.
@@ -356,6 +356,8 @@ public ListView(ObservableList<T> items) {
selectFirstRowByDefault = _selectFirstRowByDefault;
}
});

pseudoClassStateChanged(PSEUDO_CLASS_VERTICAL, true);
}


@@ -121,6 +121,7 @@ private void initialize() {
//Initialize the style class to be 'slider'.
getStyleClass().setAll(DEFAULT_STYLE_CLASS);
setAccessibleRole(AccessibleRole.SLIDER);
pseudoClassStateChanged(HORIZONTAL_PSEUDOCLASS_STATE, true);
}
/**
* The maximum value represented by this Slider. This must be a
@@ -559,6 +559,8 @@ public void onChanged(Change<? extends Object, ? extends Object> c) {
}
});

pseudoClassStateChanged(PseudoClass.getPseudoClass(getColumnResizePolicy().toString()), true);

isInited = true;
}

@@ -413,6 +413,8 @@ public TreeTableView(TreeItem<S> root) {
}
});

pseudoClassStateChanged(PseudoClass.getPseudoClass(getColumnResizePolicy().toString()), true);

isInited = true;
}

@@ -157,6 +157,18 @@ public class ListViewTest {
assertEquals(-1, b2.getSelectionModel().getSelectedIndex());
}

@Test public void noArgConstructorSetsVerticalPseudoclass() {
ListView<?> listView = new ListView<String>();
assertTrue(listView.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("vertical")));
assertFalse(listView.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("horizontal")));
}

@Test public void singleArgConstructorSetsVerticalPseudoclass() {
ListView<?> listView = new ListView<>(FXCollections.observableArrayList());
assertTrue(listView.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("vertical")));
assertFalse(listView.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("horizontal")));
}

/*********************************************************************
* Tests for selection model *
********************************************************************/
@@ -39,6 +39,8 @@
import javafx.stage.Stage;
import javafx.util.StringConverter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -99,6 +101,12 @@ public void testSnapToTicks() {
slider.setSnapToTicks(true);
assertEquals(6.25, slider.getValue(), 0);
}
@Test
public void testSliderHasHorizontalPseudoclassByDefault() {
Slider slider = new Slider();
assertTrue(slider.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("horizontal")));
assertFalse(slider.getPseudoClassStates().stream().anyMatch(c -> c.getPseudoClassName().equals("vertical")));
}
// Slider slider;
//
// /**
@@ -203,6 +203,18 @@ public class TableViewTest {
assertEquals(-1, b2.getSelectionModel().getSelectedIndex());
}

@Test public void noArgConstructorSetsDefaultColumnResizePolicyPseudoclass() {
TableView<?> view = new TableView<>();
assertTrue(view.getPseudoClassStates().stream().anyMatch(
c -> c.getPseudoClassName().equals(TableView.UNCONSTRAINED_RESIZE_POLICY.toString())));
}

@Test public void singleArgConstructorSetsDefaultColumnResizePolicyPseudoclass() {
TableView<?> view = new TableView<>(FXCollections.observableArrayList());
assertTrue(view.getPseudoClassStates().stream().anyMatch(
c -> c.getPseudoClassName().equals(TableView.UNCONSTRAINED_RESIZE_POLICY.toString())));
}

/*********************************************************************
* Tests for selection model *
********************************************************************/
@@ -260,6 +260,18 @@ private String debug() {
assertNull(treeTableView.getOnSort());
}

@Test public void noArgConstructorSetsDefaultColumnResizePolicyPseudoclass() {
TreeTableView<?> view = new TreeTableView<>();
assertTrue(view.getPseudoClassStates().stream().anyMatch(
c -> c.getPseudoClassName().equals(TreeTableView.UNCONSTRAINED_RESIZE_POLICY.toString())));
}

@Test public void singleArgConstructorSetsDefaultColumnResizePolicyPseudoclass() {
TreeTableView<?> view = new TreeTableView<>(null);
assertTrue(view.getPseudoClassStates().stream().anyMatch(
c -> c.getPseudoClassName().equals(TreeTableView.UNCONSTRAINED_RESIZE_POLICY.toString())));
}

// @Test public void singleArgConstructorSetsNonNullSelectionModel() {
// final TreeTableView<String> b2 = new TreeTableView<String>(FXCollections.observableArrayList("Hi"));
// assertNotNull(b2.getSelectionModel());

1 comment on commit 3374f47

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 3374f47 Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.