diff --git a/modules/javafx.controls/src/main/java/javafx/scene/control/TextFormatter.java b/modules/javafx.controls/src/main/java/javafx/scene/control/TextFormatter.java
index af7cd81b978..5439c54e1ba 100644
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/TextFormatter.java
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/TextFormatter.java
@@ -37,17 +37,18 @@
* A Formatter describes a format of a {@code TextInputControl} text by using two distinct mechanisms:
*
* - A filter ({@link #getFilter()}) that can intercept and modify user input. This helps to keep the text
- * in the desired format. A default text supplier can be used to provide the intial text.
+ * in the desired format. A default text supplier can be used to provide the initial text.
* - A value converter ({@link #getValueConverter()}) and value ({@link #valueProperty()})
* can be used to provide special format that represents a value of type {@code V}.
- * If the control is editable and the text is changed by the user, the value is then updated to correspond to the text.
+ * If the control is editable and the text is changed by the user, the value is then updated to correspond to the
+ * text.
*
*
- * It's possible to have a formatter with just filter or value converter. If value converter is not provided however, setting a value will
- * result in an {@code IllegalStateException} and the value is always null.
+ * It's possible to have a formatter with just filter or value converter. If value converter is not provided however,
+ * setting a value will result in an {@code IllegalStateException} and the value is always {#code null}.
*
- * Since {@code Formatter} contains a value which represents the state of the {@code TextInputControl} to which it is currently assigned, a single
- * {@code Formatter} instance can be used only in one {@code TextInputControl} at a time.
+ * Since {@code Formatter} contains a value which represents the state of the {@code TextInputControl} to which it is
+ * currently assigned, a single {@code Formatter} instance can be used only in one {@code TextInputControl} at a time.
*
* @param The type of the value
* @since JavaFX 8u40
diff --git a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableRowSkinBase.java b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableRowSkinBase.java
index 8460e2dc1dd..b06747801c3 100644
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableRowSkinBase.java
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableRowSkinBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022, 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
@@ -243,7 +243,7 @@ protected ObjectProperty graphicProperty() {
}
/** {@inheritDoc} */
- @Override protected void layoutChildren(double x, final double y, final double w, final double h) {
+ @Override protected void layoutChildren(double x, double y, final double w, final double h) {
checkState();
if (cellsMap.isEmpty()) return;
@@ -316,10 +316,6 @@ protected ObjectProperty graphicProperty() {
double width;
double height;
- final double verticalPadding = snappedTopInset() + snappedBottomInset();
- final double horizontalPadding = snappedLeftInset() + snappedRightInset();
- final double controlHeight = control.getHeight();
-
/**
* RT-26743:TreeTableView: Vertical Line looks unfinished.
* We used to not do layout on cells whose row exceeded the number
@@ -347,19 +343,19 @@ protected ObjectProperty graphicProperty() {
// may be variable and / or dynamic.
isVisible = isColumnPartiallyOrFullyVisible(tableColumn);
+ y = 0;
height = fixedCellSize;
} else {
- height = Math.max(controlHeight, tableCell.prefHeight(-1));
- height = snapSizeY(height) - snapSizeY(verticalPadding);
+ height = h;
}
+ width = tableCell.prefWidth(height);
+
if (isVisible) {
if (fixedCellSizeEnabled && tableCell.getParent() == null) {
getChildren().add(tableCell);
}
- width = tableCell.prefWidth(height) - snapSizeX(horizontalPadding);
-
// Added for RT-32700, and then updated for RT-34074.
// We change the alignment from CENTER_LEFT to TOP_LEFT if the
// height of the row is greater than the default size, and if
@@ -367,7 +363,7 @@ protected ObjectProperty graphicProperty() {
// What I would rather do is only change the alignment if the
// alignment has not been manually changed, but for now this will
// do.
- final boolean centreContent = h <= 24.0;
+ final boolean centreContent = height <= 24.0;
// if the style origin is null then the property has not been
// set (or it has been reset to its default), which means that
@@ -392,7 +388,7 @@ protected ObjectProperty graphicProperty() {
disclosureNode.resize(disclosureWidth, ph);
disclosureNode.relocate(x + leftMargin,
- centreContent ? (h / 2.0 - ph / 2.0) :
+ centreContent ? y + (h / 2.0 - ph / 2.0) :
(y + tableCell.getPadding().getTop()));
disclosureNode.toFront();
}
@@ -423,16 +419,13 @@ protected ObjectProperty graphicProperty() {
///////////////////////////////////////////
// further indentation code ends here
///////////////////////////////////////////
-
tableCell.resize(width, height);
- tableCell.relocate(x, snappedTopInset());
+ tableCell.relocate(x, y);
// Request layout is here as (partial) fix for RT-28684.
// This does not appear to impact performance...
tableCell.requestLayout();
} else {
- width = snapSizeX(tableCell.prefWidth(-1)) - snapSizeX(horizontalPadding);
-
if (fixedCellSizeEnabled) {
// we only add/remove to the scenegraph if the fixed cell
// length support is enabled - otherwise we keep all
@@ -562,7 +555,7 @@ VirtualFlow getVirtualFlow() {
/** {@inheritDoc} */
@Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
- double prefWidth = 0.0;
+ double prefWidth = leftInset + rightInset;
for (R cell : cells) {
prefWidth += cell.prefWidth(height);
}
@@ -582,8 +575,9 @@ VirtualFlow getVirtualFlow() {
// cells via CSS, where the desired height is less than the height
// of the TableCells. Essentially, -fx-cell-size is given higher
// precedence now
+ double cellSizeWithInsets = getCellSize() + topInset + bottomInset;
if (getCellSize() < DEFAULT_CELL_SIZE) {
- return getCellSize();
+ return cellSizeWithInsets;
}
// FIXME according to profiling, this method is slow and should
@@ -594,8 +588,10 @@ VirtualFlow getVirtualFlow() {
final R tableCell = cells.get(i);
prefHeight = Math.max(prefHeight, tableCell.prefHeight(-1));
}
- double ph = Math.max(prefHeight, Math.max(getCellSize(), getSkinnable().minHeight(-1)));
+ prefHeight += topInset + bottomInset;
+ double cellSizeOrMinHeight = Math.max(cellSizeWithInsets, getSkinnable().minHeight(-1));
+ double ph = Math.max(prefHeight, cellSizeOrMinHeight);
return ph;
}
@@ -613,7 +609,7 @@ VirtualFlow getVirtualFlow() {
// of the TableCells. Essentially, -fx-cell-size is given higher
// precedence now
if (getCellSize() < DEFAULT_CELL_SIZE) {
- return getCellSize();
+ return getCellSize() + topInset + bottomInset;
}
// FIXME according to profiling, this method is slow and should
@@ -624,6 +620,8 @@ VirtualFlow getVirtualFlow() {
final R tableCell = cells.get(i);
minHeight = Math.max(minHeight, tableCell.minHeight(-1));
}
+
+ minHeight += topInset + bottomInset;
return minHeight;
}
diff --git a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
index 30decd9269a..83cfc3b7f34 100644
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
@@ -2072,7 +2072,7 @@ protected T getFirstVisibleCellWithinViewport() {
*/
void addLeadingCells(int currentIndex, double startOffset) {
// The offset will keep track of the distance from the top of the
- // viewport to the top of the current index. We will increment it
+ // viewport to the top of the current index. We will decrement it
// as we lay out leading cells.
double offset = startOffset;
// The index is the absolute index of the cell being laid out
@@ -2877,6 +2877,10 @@ private double computeViewportOffset(double position) {
double p = com.sun.javafx.util.Utils.clamp(0, position, 1);
double bound = 0d;
double estSize = estimatedSize / getCellCount();
+ double maxOff = estimatedSize - getViewportLength();
+ if ((maxOff > 0) && (absoluteOffset > maxOff)) {
+ return maxOff - absoluteOffset;
+ }
for (int i = 0; i < getCellCount(); i++) {
double h = getCellSize(i);
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
index f5e462c555b..9bce555bbf2 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
@@ -1715,6 +1715,11 @@ public RT22599_DataType(int id, String text) {
if (obj == null) return false;
return id == ((RT22599_DataType)obj).id;
}
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
}
private int rt_39966_count = 0;
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java
index d081aca604d..cde4c7d94fb 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java
@@ -5086,6 +5086,11 @@ public RT22599_DataType(int id, String text) {
if (obj == null) return false;
return id == ((RT22599_DataType)obj).id;
}
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
}
private int rt_39966_count = 0;
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
index 8ff84d72fc6..c7954476e3f 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
@@ -3669,7 +3669,7 @@ protected void assert_rt35857(ObservableList items, MultipleSelectionMode
// However, for now, we'll test on the assumption that across all
// platforms we only get one extra cell created, and we can loosen this
// up if necessary.
- assertEquals(cellCountAtStart + 14, rt36452_instanceCount);
+ assertTrue(rt36452_instanceCount < cellCountAtStart + 15);
sl.dispose();
}
@@ -5754,6 +5754,11 @@ public RT22599_DataType(int id, String text) {
if (obj == null) return false;
return id == ((RT22599_DataType)obj).id;
}
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
}
private int rt_39966_count = 0;
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeViewTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeViewTest.java
index 17c1ee50870..432c56de9ca 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeViewTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeViewTest.java
@@ -3076,6 +3076,11 @@ public RT22599_DataType(int id, String text) {
if (obj == null) return false;
return id == ((RT22599_DataType)obj).id;
}
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
}
private int rt_39966_count = 0;
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TableRowSkinTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TableRowSkinTest.java
index 6d900b3c547..d46ae9ed69f 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TableRowSkinTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TableRowSkinTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 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
@@ -28,7 +28,10 @@
import com.sun.javafx.tk.Toolkit;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import javafx.geometry.Insets;
+import javafx.scene.control.IndexedCell;
import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import org.junit.After;
@@ -72,6 +75,142 @@ public void before() {
stageLoader = new StageLoader(tableView);
}
+ @Test
+ public void tableRowShouldHonorPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+ int verticalPadding = top + bottom;
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ tableView.setRowFactory(tableView -> {
+ TableRow row = new TableRow<>();
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ tableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ assertEquals(minHeight + verticalPadding, cell.minHeight(-1), 0);
+ assertEquals(prefHeight + verticalPadding, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight + verticalPadding, cell.maxHeight(-1), 0);
+ assertEquals(height + verticalPadding, cell.getHeight(), 0);
+ }
+
+ @Test
+ public void tableRowWithCellSizeShouldHonorPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+ int verticalPadding = top + bottom;
+ int verticalPaddingWithCellSize = top + bottom + 10;
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ tableView.setRowFactory(tableView -> {
+ TableRow row = new TableRow<>();
+ row.setStyle("-fx-cell-size: 34px");
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ tableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ // minHeight will take the lowest height - which are the cells (24px)
+ assertEquals(minHeight + verticalPadding, cell.minHeight(-1), 0);
+ assertEquals(prefHeight + verticalPaddingWithCellSize, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight + verticalPaddingWithCellSize, cell.maxHeight(-1), 0);
+ assertEquals(height + verticalPaddingWithCellSize, cell.getHeight(), 0);
+ }
+
+ @Test
+ public void tableRowWithFixedSizeShouldIgnoreVerticalPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+
+ tableView.setFixedCellSize(24);
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ tableView.setRowFactory(tableView -> {
+ TableRow row = new TableRow<>();
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ tableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(tableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ assertEquals(minHeight, cell.minHeight(-1), 0);
+ assertEquals(prefHeight, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight, cell.maxHeight(-1), 0);
+ assertEquals(height, cell.getHeight(), 0);
+ }
+
@Test
public void removedColumnsShouldRemoveCorrespondingCellsInRowFixedCellSize() {
tableView.setFixedCellSize(24);
@@ -113,7 +252,7 @@ private void invisibleColumnsShouldRemoveCorrespondingCellsInRowImpl() {
private void removedColumnsShouldRemoveCorrespondingCellsInRowImpl() {
// Remove the last 2 columns.
- tableView.getColumns().remove(tableView.getColumns().size() - 1, tableView.getColumns().size());
+ tableView.getColumns().remove(tableView.getColumns().size() - 2, tableView.getColumns().size());
Toolkit.getToolkit().firePulse();
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TreeTableRowSkinTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TreeTableRowSkinTest.java
new file mode 100644
index 00000000000..92f2dceb20e
--- /dev/null
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/TreeTableRowSkinTest.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2022, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.javafx.scene.control.skin;
+
+import com.sun.javafx.tk.Toolkit;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.geometry.Insets;
+import javafx.scene.control.IndexedCell;
+import javafx.scene.control.TreeItem;
+import javafx.scene.control.TreeTableColumn;
+import javafx.scene.control.TreeTableRow;
+import javafx.scene.control.TreeTableView;
+import javafx.scene.control.cell.TreeItemPropertyValueFactory;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import test.com.sun.javafx.scene.control.infrastructure.StageLoader;
+import test.com.sun.javafx.scene.control.infrastructure.VirtualFlowTestUtils;
+import test.com.sun.javafx.scene.control.test.Person;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TreeTableRowSkinTest {
+
+ private TreeTableView treeTableView;
+ private StageLoader stageLoader;
+
+ @BeforeEach
+ public void before() {
+ treeTableView = new TreeTableView<>();
+
+ TreeTableColumn firstNameCol = new TreeTableColumn<>("Firstname");
+ firstNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("firstName"));
+ TreeTableColumn lastNameCol = new TreeTableColumn<>("Lastname");
+ lastNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("lastName"));
+ TreeTableColumn emailCol = new TreeTableColumn<>("Email");
+ emailCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("email"));
+ TreeTableColumn ageCol = new TreeTableColumn<>("Age");
+ ageCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("age"));
+
+ treeTableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol, ageCol);
+
+ ObservableList> items = FXCollections.observableArrayList(
+ new TreeItem<>(new Person("firstName1", "lastName1", "email1@javafx.com", 1)),
+ new TreeItem<>(new Person("firstName2", "lastName2", "email2@javafx.com", 2)),
+ new TreeItem<>(new Person("firstName3", "lastName3", "email3@javafx.com", 3)),
+ new TreeItem<>(new Person("firstName4", "lastName4", "email4@javafx.com", 4))
+ );
+
+ TreeItem root = new TreeItem<>();
+ root.getChildren().addAll(items);
+ treeTableView.setRoot(root);
+ treeTableView.setShowRoot(false);
+
+ stageLoader = new StageLoader(treeTableView);
+ }
+
+ @Test
+ public void treeTableRowShouldHonorPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+ int verticalPadding = top + bottom;
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ treeTableView.setRowFactory(treeTableView -> {
+ TreeTableRow row = new TreeTableRow<>();
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ treeTableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ assertEquals(minHeight + verticalPadding, cell.minHeight(-1), 0);
+ assertEquals(prefHeight + verticalPadding, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight + verticalPadding, cell.maxHeight(-1), 0);
+ assertEquals(height + verticalPadding, cell.getHeight(), 0);
+ }
+
+ @Test
+ public void treeTableRowWithCellSizeShouldHonorPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+ int verticalPadding = top + bottom;
+ int verticalPaddingWithCellSize = top + bottom + 10;
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ treeTableView.setRowFactory(treeTableView -> {
+ TreeTableRow row = new TreeTableRow<>();
+ row.setStyle("-fx-cell-size: 34px");
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ treeTableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ // minHeight will take the lowest height - which are the cells (24px)
+ assertEquals(minHeight + verticalPadding, cell.minHeight(-1), 0);
+ assertEquals(prefHeight + verticalPaddingWithCellSize, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight + verticalPaddingWithCellSize, cell.maxHeight(-1), 0);
+ assertEquals(height + verticalPaddingWithCellSize, cell.getHeight(), 0);
+ }
+
+ @Test
+ public void treeTableRowWithFixedCellSizeShouldIgnoreVerticalPadding() {
+ int top = 10;
+ int right = 20;
+ int bottom = 30;
+ int left = 40;
+
+ int horizontalPadding = left + right;
+
+ treeTableView.setFixedCellSize(24);
+
+ IndexedCell cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ double minWidth = cell.minWidth(-1);
+ double prefWidth = cell.prefWidth(-1);
+ double maxWidth = cell.maxWidth(-1);
+ double width = cell.getWidth();
+
+ double minHeight = cell.minHeight(-1);
+ double prefHeight = cell.prefHeight(-1);
+ double maxHeight = cell.maxHeight(-1);
+ double height = cell.getHeight();
+
+ treeTableView.setRowFactory(treeTableView -> {
+ TreeTableRow row = new TreeTableRow<>();
+ row.setPadding(new Insets(top, right, bottom, left));
+ return row;
+ });
+
+ treeTableView.refresh();
+ Toolkit.getToolkit().firePulse();
+
+ cell = VirtualFlowTestUtils.getCell(treeTableView, 0);
+
+ assertEquals(minWidth + horizontalPadding, cell.minWidth(-1), 0);
+ assertEquals(prefWidth + horizontalPadding, cell.prefWidth(-1), 0);
+ assertEquals(maxWidth + horizontalPadding, cell.maxWidth(-1), 0);
+ assertEquals(width + horizontalPadding, cell.getWidth(), 0);
+
+ assertEquals(minHeight, cell.minHeight(-1), 0);
+ assertEquals(prefHeight, cell.prefHeight(-1), 0);
+ assertEquals(maxHeight, cell.maxHeight(-1), 0);
+ assertEquals(height, cell.getHeight(), 0);
+ }
+
+ @Test
+ public void removedColumnsShouldRemoveCorrespondingCellsInRowFixedCellSize() {
+ treeTableView.setFixedCellSize(24);
+ removedColumnsShouldRemoveCorrespondingCellsInRowImpl();
+ }
+
+ @Test
+ public void removedColumnsShouldRemoveCorrespondingCellsInRow() {
+ removedColumnsShouldRemoveCorrespondingCellsInRowImpl();
+ }
+
+ @Test
+ public void invisibleColumnsShouldRemoveCorrespondingCellsInRowFixedCellSize() {
+ treeTableView.setFixedCellSize(24);
+ invisibleColumnsShouldRemoveCorrespondingCellsInRowImpl();
+ }
+
+ @Test
+ public void invisibleColumnsShouldRemoveCorrespondingCellsInRow() {
+ invisibleColumnsShouldRemoveCorrespondingCellsInRowImpl();
+ }
+
+ @AfterEach
+ public void after() {
+ stageLoader.dispose();
+ }
+
+ private void invisibleColumnsShouldRemoveCorrespondingCellsInRowImpl() {
+ // Set the last 2 columns invisible.
+ treeTableView.getColumns().get(treeTableView.getColumns().size() - 1).setVisible(false);
+ treeTableView.getColumns().get(treeTableView.getColumns().size() - 2).setVisible(false);
+
+ Toolkit.getToolkit().firePulse();
+
+ // We set 2 columns to invisible, so the cell count should be decremented by 2 as well.
+ // Note: TreeTableView has an additional children - the disclosure node - therefore we subtract 1 here.
+ assertEquals(treeTableView.getColumns().size() - 2,
+ VirtualFlowTestUtils.getCell(treeTableView, 0).getChildrenUnmodifiable().size() - 1);
+ }
+
+ private void removedColumnsShouldRemoveCorrespondingCellsInRowImpl() {
+ // Remove the last 2 columns.
+ treeTableView.getColumns().remove(treeTableView.getColumns().size() - 2, treeTableView.getColumns().size());
+
+ Toolkit.getToolkit().firePulse();
+
+ // We removed 2 columns, so the cell count should be decremented by 2 as well.
+ // Note: TreeTableView has an additional children - the disclosure node - therefore we subtract 1 here.
+ assertEquals(treeTableView.getColumns().size(),
+ VirtualFlowTestUtils.getCell(treeTableView, 0).getChildrenUnmodifiable().size() - 1);
+ }
+
+}
diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
index 93de0e99162..2069a47c550 100644
--- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
+++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
@@ -1254,6 +1254,40 @@ public void testSheetChildrenRemainsConstant() {
assertEquals("Wrong number of sheet children after removing all items", 12, sheetChildrenSize);
}
+ @Test
+ // See JDK-8291908
+ public void test_noEmptyTrailingCells() {
+ flow = new VirtualFlowShim();
+ flow.setVertical(true);
+ flow.setCellFactory(p -> new CellStub(flow) {
+ @Override
+ protected double computeMaxHeight(double width) {
+ return computePrefHeight(width);
+ }
+
+ @Override
+ protected double computePrefHeight(double width) {
+ return (getIndex() > 100) ? 1 : 20;
+ }
+
+ @Override
+ protected double computeMinHeight(double width) {
+ return computePrefHeight(width);
+ }
+
+ });
+ flow.setCellCount(100);
+ flow.setViewportLength(1000);
+ flow.resize(100, 1000);
+ pulse();
+ flow.sheetChildren.addListener((InvalidationListener) (o) -> {
+ int count = ((List) o).size();
+ assertTrue(Integer.toString(count), count < 101);
+ });
+ flow.scrollTo(99);
+ pulse();
+ }
+
private ArrayLinkedListShim circlelist = new ArrayLinkedListShim();
private VirtualFlowShim createCircleFlow() {
diff --git a/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java b/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java
index b351a666204..dab8edea3ea 100644
--- a/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java
+++ b/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022, 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
@@ -2321,6 +2321,13 @@ public boolean equals(Object obj) {
return false;
}
+ @Override
+ public int hashCode() {
+ int h = FXMLLoader.class.hashCode();
+ h = 31 * h + (location == null ? 0 : location.toExternalForm().hashCode());
+ return h;
+ }
+
private boolean isCyclic(
FXMLLoader currentLoader,
FXMLLoader node) {
diff --git a/modules/javafx.graphics/.classpath b/modules/javafx.graphics/.classpath
index 8cdb392629f..22e5174278f 100644
--- a/modules/javafx.graphics/.classpath
+++ b/modules/javafx.graphics/.classpath
@@ -1,6 +1,10 @@
+
+
+
+
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java
index 6038106c940..5a8dd6452d4 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java
@@ -622,6 +622,7 @@ public final MenuItem createMenuItem(String title, MenuItem.Callback callback,
}
public abstract Pixels createPixels(int width, int height, ByteBuffer data);
+ public abstract Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley);
public abstract Pixels createPixels(int width, int height, IntBuffer data);
public abstract Pixels createPixels(int width, int height, IntBuffer data, float scalex, float scaley);
protected abstract int staticPixels_getNativeFormat();
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Pixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Pixels.java
index 01163387f80..84653f2c53a 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Pixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Pixels.java
@@ -98,6 +98,20 @@ protected Pixels(final int width, final int height, final ByteBuffer pixels) {
this.scaley = 1.0f;
}
+ protected Pixels(final int width, final int height, final ByteBuffer pixels, float scalex, float scaley) {
+ this.width = width;
+ this.height = height;
+ this.bytesPerComponent = 1;
+ this.bytes = pixels.slice();
+ if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height * 4) > this.bytes.capacity())) {
+ throw new IllegalArgumentException("Too small byte buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height*4)+"] > "+this.bytes.capacity());
+ }
+
+ this.ints = null;
+ this.scalex = scalex;
+ this.scaley = scaley;
+ }
+
protected Pixels(final int width, final int height, IntBuffer pixels) {
this.width = width;
this.height = height;
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java
index 141ef7640d9..889f3a70bd1 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java
@@ -437,6 +437,11 @@ public Pixels createPixels(int width, int height, ByteBuffer data) {
return new GtkPixels(width, height, data);
}
+ @Override
+ public Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ return new GtkPixels(width, height, data, scalex, scaley);
+ }
+
@Override
public Pixels createPixels(int width, int height, IntBuffer data) {
return new GtkPixels(width, height, data);
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkPixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkPixels.java
index 0608cd2adca..9d22680e7d7 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkPixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkPixels.java
@@ -35,6 +35,10 @@ public GtkPixels(int width, int height, ByteBuffer data) {
super(width, height, data);
}
+ public GtkPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ super(width, height, data, scalex, scaley);
+ }
+
public GtkPixels(int width, int height, IntBuffer data) {
super(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosApplication.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosApplication.java
index a517e95d5e8..c18231445b4 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosApplication.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosApplication.java
@@ -120,6 +120,11 @@ public Pixels createPixels(int width, int height, ByteBuffer data) {
return new IosPixels(width, height, data);
}
+ @Override
+ public Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ return new IosPixels(width, height, data, scalex, scaley);
+ }
+
/**
* @inheritDoc
*/
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosPixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosPixels.java
index 5c04452bcd8..be4918f9215 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosPixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/ios/IosPixels.java
@@ -38,6 +38,10 @@ protected IosPixels(int width, int height, ByteBuffer data) {
super(width, height, data);
}
+ protected IosPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ super(width, height, data, scalex, scaley);
+ }
+
protected IosPixels(int width, int height, IntBuffer data) {
super(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java
index 7c9e7b378f4..0702d3257e3 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java
@@ -271,6 +271,10 @@ public Menu getAppleMenu() {
return new MacPixels(width, height, data);
}
+ @Override public Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ return new MacPixels(width, height, data, scalex, scaley);
+ }
+
@Override public Pixels createPixels(int width, int height, IntBuffer data) {
return new MacPixels(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacPixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacPixels.java
index 00e2bab7d94..32a14b69a25 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacPixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacPixels.java
@@ -53,6 +53,10 @@ protected MacPixels(int width, int height, ByteBuffer data) {
super(width, height, data);
}
+ protected MacPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ super(width, height, data, scalex, scaley);
+ }
+
protected MacPixels(int width, int height, IntBuffer data) {
super(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/GetEvent.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/GetEvent.java
index 85f83ee13f6..368344fe1e8 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/GetEvent.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/GetEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022, 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
@@ -101,7 +101,7 @@ class GetEvent {
}
devices.add(sysPath);
} else if (action.equals("remove")) {
- devices.remove(devPath);
+ devices.remove(sysPath);
}
} catch (IOException | RuntimeException e) {
e.printStackTrace();
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/IntSet.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/IntSet.java
index f108b67e3f8..16eba710239 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/IntSet.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/IntSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022, 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
@@ -152,6 +152,15 @@ public boolean equals(Object o) {
}
}
+ @Override
+ public int hashCode() {
+ int h = 1;
+ for (int i = 0; i < size; i++) {
+ h = 31 * h + elements[i];
+ }
+ return h;
+ }
+
public String toString() {
StringBuffer sb = new StringBuffer("IntSet[");
for (int i = 0; i < size; i++) {
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java
index b085682c197..3dff9b02436 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonocleApplication.java
@@ -187,15 +187,18 @@ public Pixels createPixels(int width, int height, ByteBuffer data) {
return new MonoclePixels(width, height, data);
}
+ @Override
+ public Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ return new MonoclePixels(width, height, data, scalex, scaley);
+ }
+
@Override
public Pixels createPixels(int width, int height, IntBuffer data) {
return new MonoclePixels(width, height, data);
}
@Override
- public Pixels createPixels(int width, int height, IntBuffer data,
- float scalex, float scaley)
- {
+ public Pixels createPixels(int width, int height, IntBuffer data, float scalex, float scaley) {
return new MonoclePixels(width, height, data, scalex, scaley);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonoclePixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonoclePixels.java
index bbb17ce1d78..5c4fee04b7e 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonoclePixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonoclePixels.java
@@ -37,6 +37,10 @@ final class MonoclePixels extends Pixels {
super(width, height, data);
}
+ MonoclePixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ super(width, height, data, scalex, scaley);
+ }
+
MonoclePixels(int width, int height, IntBuffer data) {
super(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java
index 332d818642d..5304f71ca37 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java
@@ -40,7 +40,11 @@
import javafx.scene.Scene;
import javafx.scene.input.KeyCombination;
import com.sun.glass.ui.Accessible;
+import com.sun.glass.ui.Screen;
import com.sun.glass.ui.View;
+import com.sun.javafx.stage.WindowHelper;
+import com.sun.javafx.tk.TKStage;
+import com.sun.javafx.tk.quantum.WindowStage;
import static javafx.scene.AccessibleAttribute.*;
/*
@@ -877,6 +881,27 @@ private WinVariant GetPropertyValue(int propertyId) {
return variant;
}
+ private Screen getScreen() {
+ Scene scene = (Scene) getAttribute(SCENE);
+ if (scene == null || scene.getWindow() == null) return null;
+ TKStage tkStage = WindowHelper.getPeer(scene.getWindow());
+ if (!(tkStage instanceof WindowStage)) return null;
+ WindowStage windowStage = (WindowStage) tkStage;
+ if (windowStage.getPlatformWindow() == null) return null;
+ return windowStage.getPlatformWindow().getScreen();
+ }
+
+ float[] getPlatformBounds(float x, float y, float w, float h) {
+ float[] platformBounds = new float[] { x, y, w, h };
+ Screen screen = getScreen();
+ if (screen == null) return platformBounds;
+ platformBounds[0] = screen.toPlatformX(x);
+ platformBounds[1] = screen.toPlatformY(y);
+ platformBounds[2] = (float) Math.ceil(w * screen.getPlatformScaleX());
+ platformBounds[3] = (float) Math.ceil(h * screen.getPlatformScaleY());
+ return platformBounds;
+ }
+
/***********************************************/
/* IRawElementProviderFragment */
/***********************************************/
@@ -887,8 +912,10 @@ private float[] get_BoundingRectangle() {
Bounds bounds = (Bounds)getAttribute(BOUNDS);
if (bounds != null) {
- return new float[] {(float)bounds.getMinX(), (float)bounds.getMinY(),
- (float)bounds.getWidth(), (float)bounds.getHeight()};
+ return getPlatformBounds((float) bounds.getMinX(),
+ (float) bounds.getMinY(),
+ (float) bounds.getWidth(),
+ (float) bounds.getHeight());
}
return null;
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java
index 73b9d8c95dd..bdb5dc4ea0d 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinApplication.java
@@ -253,6 +253,11 @@ protected void runLoop(final Runnable launchable) {
return new WinPixels(width, height, data);
}
+ @Override
+ public Pixels createPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ return new WinPixels(width, height, data, scalex, scaley);
+ }
+
@Override public Pixels createPixels(int width, int height, IntBuffer data) {
return new WinPixels(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinPixels.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinPixels.java
index 3c3497632db..fc313d939c8 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinPixels.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinPixels.java
@@ -46,6 +46,10 @@ protected WinPixels(int width, int height, ByteBuffer data) {
super(width, height, data);
}
+ protected WinPixels(int width, int height, ByteBuffer data, float scalex, float scaley) {
+ super(width, height, data, scalex, scaley);
+ }
+
protected WinPixels(int width, int height, IntBuffer data) {
super(width, height, data);
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
index f6632389829..6ed04f0b33b 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
@@ -326,10 +326,16 @@ private double[] GetBoundingRectangles() {
int index = 0;
for (int i = 0; i < bounds.length; i++) {
Bounds b = bounds[i];
- result[index++] = b.getMinX();
- result[index++] = b.getMinY();
- result[index++] = b.getWidth();
- result[index++] = b.getHeight();
+ float[] platformBounds = accessible.getPlatformBounds(
+ (float) b.getMinX(),
+ (float) b.getMinY(),
+ (float) b.getWidth(),
+ (float) b.getHeight());
+
+ result[index++] = platformBounds[0];
+ result[index++] = platformBounds[1];
+ result[index++] = platformBounds[2];
+ result[index++] = platformBounds[3];
}
return result;
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java
index 0125b4897a7..d7636a050d2 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/CalculatedValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2022, 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
@@ -88,6 +88,15 @@ public boolean isRelative() {
return true;
}
+ @Override
+ public int hashCode() {
+ int h = CalculatedValue.class.hashCode();
+ h = 31 * h + Boolean.hashCode(relative);
+ h = 31 * h + (origin == null ? 0 : origin.hashCode());
+ h = 31 * h + (value == null ? 0 : value.hashCode());
+ return h;
+ }
+
private final Object value;
private final StyleOrigin origin;
private final boolean relative;
diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/css/StyleManager.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/StyleManager.java
index b098f692d50..c37bd3dcf90 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/css/StyleManager.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/css/StyleManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022, 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
@@ -1271,8 +1271,8 @@ public void setUserAgentStylesheets(List urls) {
if (fname == null || fname.isEmpty()) break;
StylesheetContainer container = platformUserAgentStylesheetContainers.get(n);
- // assignment in this conditional is intentional!
- if(isSame = fname.equals(container.fname)) {
+ isSame = fname.equals(container.fname);
+ if (isSame) {
// don't use fname in calculateCheckSum since it is just the key to
// find the StylesheetContainer. Rather, use the URL of the
// stylesheet that was already loaded. For example, we could have
diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/PixelUtils.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/PixelUtils.java
index 6d744be23e8..854e101f708 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/PixelUtils.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/PixelUtils.java
@@ -96,7 +96,10 @@ public static Pixels imageToPixels(Image image) {
throw new IllegalArgumentException("non-RGB image format");
}
pixels = app.createPixels(image.getWidth(),
- image.getHeight(), bytes);
+ image.getHeight(),
+ bytes,
+ image.getPixelScale(),
+ image.getPixelScale());
return pixels;
} else if (pixelType == PixelFormat.DataType.INT) {
if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) {
@@ -109,7 +112,10 @@ public static Pixels imageToPixels(Image image) {
*/
IntBuffer ints = (IntBuffer)image.getPixelBuffer();
pixels = app.createPixels(image.getWidth(),
- image.getHeight(), ints);
+ image.getHeight(),
+ ints,
+ image.getPixelScale(),
+ image.getPixelScale());
return pixels;
} else {
throw new IllegalArgumentException("unhandled image type: " + pixelType);
diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
index c8353ae0229..fd45cf15cf4 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
@@ -55,7 +55,7 @@
import java.util.ResourceBundle;
import static com.sun.javafx.FXPermissions.*;
-class WindowStage extends GlassStage {
+public class WindowStage extends GlassStage {
protected Window platformWindow;
@@ -223,7 +223,7 @@ private void computeAndSetBackground(List stops) {
}
}
- final Window getPlatformWindow() {
+ public final Window getPlatformWindow() {
return platformWindow;
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java
index 15c6132e9c6..932432c3874 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022, 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
@@ -870,9 +870,16 @@ public static void forceInit(final Class> classToInit) {
}
}
+ /**
+ * @return true if and only if assertions are enabled at runtime.
+ */
public static boolean assertionEnabled() {
boolean assertsEnabled = false;
- assert assertsEnabled = true; // Intentional side-effect !!!
+
+ // The following assertion check will always pass. The side-effect
+ // of the `assertsEnabled = true` assignment is intentional. It will
+ // be executed if-and-only-if assertions are enabled at runtime.
+ assert (assertsEnabled = true) == true;
return assertsEnabled;
}
diff --git a/modules/javafx.graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrEffectHelper.java b/modules/javafx.graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrEffectHelper.java
index cf189db321b..9aa5c87cabb 100644
--- a/modules/javafx.graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrEffectHelper.java
+++ b/modules/javafx.graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrEffectHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2022, 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
@@ -165,7 +165,9 @@ public static void render(Effect effect,
do {
ImageData res = effect.filter(fctx, transform, rclip, prinfo, defaultInput);
if (res == null) return;
- if (valid = res.validate(fctx)) {
+
+ valid = res.validate(fctx);
+ if (valid) {
Rectangle r = res.getUntransformedBounds();
// the actual image may be much larger than the region
// of interest ("r"), so to improve performance we render
diff --git a/modules/javafx.graphics/src/main/java/javafx/concurrent/ScheduledService.java b/modules/javafx.graphics/src/main/java/javafx/concurrent/ScheduledService.java
index d358902e0bb..a05ece6943b 100644
--- a/modules/javafx.graphics/src/main/java/javafx/concurrent/ScheduledService.java
+++ b/modules/javafx.graphics/src/main/java/javafx/concurrent/ScheduledService.java
@@ -41,7 +41,7 @@
import java.util.TimerTask;
/**
- * The ScheduledService is a {@link Service} which will automatically restart
+ *
The ScheduledService is a {@link Service} that will automatically restart
* itself after a successful execution, and under some conditions will
* restart even in case of failure. A new ScheduledService begins in
* the READY state, just as a normal Service. After calling
@@ -70,7 +70,7 @@
*
*
If a failure occurs and restartOnFailure is false, then
* the ScheduledService will transition to FAILED and will stop. To restart
- * a failed ScheduledService, you must call restart manually.
+ * a failed ScheduledService, you must call restart manually.
*
* If a failure occurs and restartOnFailure is true, then
* the the ScheduledService may restart automatically. First,
@@ -82,7 +82,7 @@
*
*
ScheduledService defines static EXPONENTIAL_BACKOFF_STRATEGY and LOGARITHMIC_BACKOFF_STRATEGY
* implementations, of which LOGARITHMIC_BACKOFF_STRATEGY is the default value for
- * backoffStrategy. After maximumFailureCount is reached, the
+ * backoffStrategy. After maximumFailureCount is reached, the
* ScheduledService will transition to FAILED in exactly the same way as if
* restartOnFailure were false.
*
@@ -127,16 +127,16 @@
* For this purposes of this class, any Duration that answers true to {@link javafx.util.Duration#isUnknown()}
* will treat that duration as if it were Duration.ZERO. Likewise, any Duration which answers true
* to {@link javafx.util.Duration#isIndefinite()} will be treated as if it were a duration of Double.MAX_VALUE
- * milliseconds. Any null Duration is treated as Duration.ZERO. Any custom implementation of an backoff strategy
+ * milliseconds. Any {@code null} Duration is treated as Duration.ZERO. Any custom implementation of a backoff strategy
* callback must be prepared to handle these different potential values.
*
- * The ScheduledService introduces a new property called {@link #lastValueProperty() lastValue}. The lastValue is the value that
- * was last successfully computed. Because a Service clears its {@code value} property on each run, and
- * because the ScheduledService will reschedule a run immediately after completion (unless it enters the
- * cancelled or failed states), the value property is not overly useful on a ScheduledService. In most cases
- * you will want to instead use the value returned by lastValue.
+ * The ScheduledService introduces a new property called {@link #lastValueProperty() lastValue}. The
+ * {@code lastValue} is the value that was last successfully computed. Because a Service clears its {@code value}
+ * property on each run, and because the ScheduledService will reschedule a run immediately after completion (unless it
+ * enters the cancelled or failed states), the value property is not overly useful on a ScheduledService. In most cases
+ * you will want to instead use the value returned by {@code lastValue}.
*
- * Implementer Note: The {@link #ready()}, {@link #scheduled()}, {@link #running()}, {@link #succeeded()},
+ * @implNote The {@link #ready()}, {@link #scheduled()}, {@link #running()}, {@link #succeeded()},
* {@link #cancelled()}, and {@link #failed()} methods are implemented in this class. Subclasses which also
* override these methods must take care to invoke the super implementation.
*
diff --git a/modules/javafx.graphics/src/main/java/javafx/concurrent/Service.java b/modules/javafx.graphics/src/main/java/javafx/concurrent/Service.java
index bff8365855c..b54eb3d4bce 100644
--- a/modules/javafx.graphics/src/main/java/javafx/concurrent/Service.java
+++ b/modules/javafx.graphics/src/main/java/javafx/concurrent/Service.java
@@ -71,7 +71,7 @@
* of managing multithreaded code that interacts with the user interface. As
* such, all of the methods and state on the Service are intended to be
* invoked exclusively from the JavaFX Application thread. The only exception
- * to this, is when initially configuring a Service, which may safely be done
+ * to this is when initially configuring a Service, which may safely be done
* from any thread, and initially starting a Service, which may also safely
* be done from any thread. However, once the Service has been initialized and
* started, it may only thereafter be used from the FX thread.
@@ -99,8 +99,8 @@
*
* Because a Service is intended to simplify declarative use cases, subclasses
* should expose as properties the input parameters to the work to be done.
- * For example, suppose I wanted to write a Service which read the first line
- * from any URL and returned it as a String. Such a Service might be defined,
+ * For example, suppose I wanted to write a Service that reads the first line
+ * from any URL and returned it as a String. Such a Service might be defined
* such that it had a single property, {@code url}. It might be implemented
* as:
*
diff --git a/modules/javafx.graphics/src/main/java/javafx/concurrent/package.html b/modules/javafx.graphics/src/main/java/javafx/concurrent/package.html
index cd8dd118c47..8e714b0ba18 100644
--- a/modules/javafx.graphics/src/main/java/javafx/concurrent/package.html
+++ b/modules/javafx.graphics/src/main/java/javafx/concurrent/package.html
@@ -33,7 +33,7 @@
javafx.task
-Provides the set of classes for javafx.task.
+Provides the set of classes for javafx.concurrent.
This package provides the ability to run application code on threads other
than the JavaFX event dispatch thread. The ability to control the execution
and track the progress of the application code is also provided.
diff --git a/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java b/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java
index 5264c5bc8f9..1ced39430ba 100644
--- a/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java
@@ -1235,6 +1235,7 @@ protected void invalidated() {
if (oldRoot != null) {
oldRoot.setScenes(null, null);
+ oldRoot.getStyleClass().remove("root");
}
oldRoot = _value;
_value.getStyleClass().add(0, "root");
diff --git a/modules/javafx.graphics/src/main/java/javafx/scene/SubScene.java b/modules/javafx.graphics/src/main/java/javafx/scene/SubScene.java
index 7bb95a0bed2..ca7e9afa717 100644
--- a/modules/javafx.graphics/src/main/java/javafx/scene/SubScene.java
+++ b/modules/javafx.graphics/src/main/java/javafx/scene/SubScene.java
@@ -316,6 +316,7 @@ protected void invalidated() {
if (oldRoot != null) {
StyleManager.getInstance().forget(SubScene.this);
oldRoot.setScenes(null, null);
+ oldRoot.getStyleClass().remove("root");
}
oldRoot = _value;
_value.getStyleClass().add(0, "root");
diff --git a/modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m b/modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m
index d26bca3792a..776ca0f113b 100644
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassMenu.m
@@ -45,6 +45,10 @@
static jmethodID jMenuClosedMethod = 0;
static jmethodID jMenuValidateMethod = 0;
static jfieldID jDelegateMenuField = 0;
+static jfieldID jPixelsWidthField = 0;
+static jfieldID jPixelsHeightField = 0;
+static jfieldID jPixelsScaleXField = 0;
+static jfieldID jPixelsScaleYField = 0;
@interface NSMenuItem (SPI)
@@ -262,6 +266,21 @@ - (void)_setPixels:(jobject)pixels
(*env)->CallVoidMethod(env, pixels, jPixelsAttachData, ptr_to_jlong(&image));
if (image != NULL)
{
+ if (jPixelsWidthField
+ && jPixelsHeightField
+ && jPixelsScaleXField
+ && jPixelsScaleYField
+ ) {
+ jint width = (*env)->GetIntField(env, pixels, jPixelsWidthField);
+ jint height = (*env)->GetIntField(env, pixels, jPixelsHeightField);
+ jfloat scalex = (*env)->GetFloatField(env, pixels, jPixelsScaleXField);
+ jfloat scaley = (*env)->GetFloatField(env, pixels, jPixelsScaleYField);
+
+ if ((scalex > 1) && (scaley > 1) && (width > 0) && (height > 0)) {
+ NSSize imgSize = {width / scalex, height / scaley};
+ [image setSize: imgSize];
+ }
+ }
[self->item setImage: image];
[image release];
}
@@ -375,7 +394,6 @@ - (void)_setPixels:(jobject)pixels
if (!jMenuClass) {
return;
}
-
jMenuActionMethod = (*env)->GetMethodID(env, jCallbackClass, "action", "()V");
if ((*env)->ExceptionCheck(env)) return;
jMenuValidateMethod = (*env)->GetMethodID(env, jCallbackClass, "validate", "()V");
@@ -385,6 +403,19 @@ - (void)_setPixels:(jobject)pixels
jMenuClosedMethod = (*env)->GetMethodID(env, jMenuClass, "notifyMenuClosed", "()V");
if ((*env)->ExceptionCheck(env)) return;
jDelegateMenuField = (*env)->GetFieldID(env, jMenuDelegateClass, "menu", "Lcom/sun/glass/ui/Menu;");
+ if ((*env)->ExceptionCheck(env)) return;
+
+ jclass pixelsClass = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacPixels" withEnv: env];
+ if (!pixelsClass) {
+ return;
+ }
+ jPixelsWidthField = (*env)->GetFieldID(env, pixelsClass, "width", "I");
+ if ((*env)->ExceptionCheck(env)) return;
+ jPixelsHeightField = (*env)->GetFieldID(env, pixelsClass, "height", "I");
+ if ((*env)->ExceptionCheck(env)) return;
+ jPixelsScaleXField = (*env)->GetFieldID(env, pixelsClass, "scalex", "F");
+ if ((*env)->ExceptionCheck(env)) return;
+ jPixelsScaleYField = (*env)->GetFieldID(env, pixelsClass, "scaley", "F");
}
/*
diff --git a/modules/javafx.graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java b/modules/javafx.graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java
index 9a57a6b558f..b6694c299a1 100644
--- a/modules/javafx.graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java
+++ b/modules/javafx.graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022, 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
@@ -73,9 +73,15 @@ public Node_cssStyleMap_Test() {
boolean disabled = false;
+ /**
+ * @param property - must be a StyleableProperty
+ * @param map
+ * @param decls
+ */
private void checkFoundStyle(Property> property, Map, List