Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrushforth committed Jun 12, 2020
2 parents 1663624 + b2b46eb commit f6ec5f1
Show file tree
Hide file tree
Showing 67 changed files with 6,137 additions and 4,264 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3430,6 +3430,9 @@ project(":web") {
exec {
workingDir("$webkitOutputDir")
def cmakeArgs = "-DENABLE_TOOLS=1"
if (IS_STATIC_BUILD) {
cmakeArgs = " $cmakeArgs -DSTATIC_BUILD=1 -DUSE_THIN_ARCHIVES=OFF";
}
cmakeArgs = " $cmakeArgs -DCMAKE_C_COMPILER='${webkitProperties.compiler}'"
if (t.name == "win") {
// To enable ninja build on Windows
Expand All @@ -3446,6 +3449,9 @@ project(":web") {
// TODO: Use cflags and ldflags from all platforms
def cFlags = webkitProperties.ccFlags?.join(' ') ?: ''
def lFlags = webkitProperties.linkFlags?.join(' ') ?: ''
if (IS_STATIC_BUILD) {
cFlags = " $cFlags -DSTATIC_BUILD=1";
}
// -shared flag should be omitted while creating executable.
def exeFlags = webkitProperties.linkFlags?.join(' ')?.replace('-shared', '') ?: ''
cmakeArgs = "$cmakeArgs -DCMAKE_C_FLAGS='${cFlags}' -DCMAKE_CXX_FLAGS='${cFlags}'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import com.sun.javafx.PlatformUtil;
import com.sun.javafx.scene.control.inputmap.KeyBinding;

import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.scene.control.ButtonBase;
import com.sun.javafx.scene.control.inputmap.InputMap;
Expand Down Expand Up @@ -56,6 +58,7 @@ public class ButtonBehavior<C extends ButtonBase> extends BehaviorBase<C> {
*/
private boolean keyDown;

private InvalidationListener focusListener = this::focusChanged;


/***************************************************************************
Expand Down Expand Up @@ -89,7 +92,7 @@ public ButtonBehavior(C control) {
);

// Button also cares about focus
control.focusedProperty().addListener(this::focusChanged);
control.focusedProperty().addListener(focusListener);
}


Expand All @@ -105,10 +108,9 @@ public ButtonBehavior(C control) {
}

@Override public void dispose() {
// TODO specify contract of dispose and post-condition for getNode()
getNode().focusedProperty().removeListener(focusListener);
super.dispose();

// TODO
getNode().focusedProperty().removeListener(this::focusChanged);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
package com.sun.javafx.scene.control.behavior;

import com.sun.javafx.scene.control.inputmap.InputMap;

import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
Expand All @@ -47,6 +49,7 @@
public class ComboBoxBaseBehavior<T> extends BehaviorBase<ComboBoxBase<T>> {

private final InputMap<ComboBoxBase<T>> inputMap;
private InvalidationListener focusListener = this::focusChanged;

/***************************************************************************
* *
Expand Down Expand Up @@ -102,7 +105,7 @@ public ComboBoxBaseBehavior(final ComboBoxBase<T> comboBox) {
enterReleased.setAutoConsume(false);

// ComboBoxBase also cares about focus
comboBox.focusedProperty().addListener(this::focusChanged);
comboBox.focusedProperty().addListener(focusListener);

// Only add this if we're on an embedded platform that supports 5-button navigation
if (Utils.isTwoLevelFocus()) {
Expand All @@ -112,7 +115,7 @@ public ComboBoxBaseBehavior(final ComboBoxBase<T> comboBox) {

@Override public void dispose() {
if (tlFocus != null) tlFocus.dispose();
getNode().focusedProperty().removeListener(this::focusChanged);
getNode().focusedProperty().removeListener(focusListener);
super.dispose();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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 @@ -213,16 +213,20 @@ public ListViewBehavior(ListView<T> control) {
ListView<T> control = getNode();

ListCellBehavior.removeAnchor(control);
control.selectionModelProperty().removeListener(weakSelectionModelListener);
if (control.getSelectionModel() != null) {
control.getSelectionModel().getSelectedIndices().removeListener(weakSelectedIndicesListener);
}
control.itemsProperty().removeListener(weakItemsListener);
if (control.getItems() != null) {
control.getItems().removeListener(weakItemsListListener);
}

if (tlFocus != null) tlFocus.dispose();
control.removeEventFilter(KeyEvent.ANY, keyEventListener);
super.dispose();

control.removeEventHandler(KeyEvent.ANY, keyEventListener);
}





/**************************************************************************
* State and Functions *
*************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
*/
public abstract class SpinnerValueFactory<T> {

/**
* Creates a default SpinnerValueFactory.
*/
public SpinnerValueFactory() {}

/***************************************************************************
* *
* Private fields *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ public ChoiceBoxSkin(ChoiceBox<T> control) {

/** {@inheritDoc} */
@Override public void dispose() {
// removing the content listener fixes NPE from listener
if (choiceBoxItems != null) {
choiceBoxItems.removeListener(weakChoiceBoxItemsListener);
choiceBoxItems = null;
}
// removing the path listener fixes the memory leak on replacing skin
if (selectionModel != null) {
selectionModel.selectedIndexProperty().removeListener(selectionChangeListener);
selectionModel = null;
}

super.dispose();

if (behavior != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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 @@ -37,6 +37,7 @@
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.collections.WeakListChangeListener;
import javafx.collections.WeakMapChangeListener;
import javafx.event.EventHandler;
import javafx.geometry.Orientation;
import javafx.scene.AccessibleAction;
Expand Down Expand Up @@ -104,7 +105,6 @@ public class ListViewSkin<T> extends VirtualContainerBase<ListView<T>, ListCell<
private Node placeholderNode;

private ObservableList<T> listViewItems;
private final InvalidationListener itemsChangeListener = observable -> updateListViewItems();

private boolean needCellsRebuilt = true;
private boolean needCellsReconfigured = false;
Expand All @@ -129,6 +129,9 @@ public class ListViewSkin<T> extends VirtualContainerBase<ListView<T>, ListCell<
}
};

private WeakMapChangeListener<Object, Object> weakPropertiesMapListener =
new WeakMapChangeListener<>(propertiesMapListener);

private final ListChangeListener<T> listViewItemsListener = new ListChangeListener<T>() {
@Override public void onChanged(Change<? extends T> c) {
while (c.next()) {
Expand Down Expand Up @@ -166,6 +169,12 @@ public class ListViewSkin<T> extends VirtualContainerBase<ListView<T>, ListCell<
new WeakListChangeListener<T>(listViewItemsListener);


private final InvalidationListener itemsChangeListener = observable -> updateListViewItems();

private WeakInvalidationListener
weakItemsChangeListener = new WeakInvalidationListener(itemsChangeListener);

private EventHandler<MouseEvent> ml;

/***************************************************************************
* *
Expand Down Expand Up @@ -208,7 +217,7 @@ public ListViewSkin(final ListView<T> control) {
flow.setFixedCellSize(control.getFixedCellSize());
getChildren().add(flow);

EventHandler<MouseEvent> ml = event -> {
ml = event -> {
// RT-15127: cancel editing on scroll. This is a bit extreme
// (we are cancelling editing on touching the scrollbars).
// This can be improved at a later date.
Expand All @@ -230,11 +239,11 @@ public ListViewSkin(final ListView<T> control) {

updateItemCount();

control.itemsProperty().addListener(new WeakInvalidationListener(itemsChangeListener));
control.itemsProperty().addListener(weakItemsChangeListener);

final ObservableMap<Object, Object> properties = control.getProperties();
properties.remove(Properties.RECREATE);
properties.addListener(propertiesMapListener);
properties.addListener(weakPropertiesMapListener);

// Register listeners
registerChangeListener(control.itemsProperty(), o -> updateListViewItems());
Expand Down Expand Up @@ -263,6 +272,20 @@ public ListViewSkin(final ListView<T> control) {

/** {@inheritDoc} */
@Override public void dispose() {
if (getSkinnable() == null) return;
// listener cleanup fixes side-effects (NPE on refresh, setItems, modifyItems)
getSkinnable().getProperties().removeListener(weakPropertiesMapListener);
getSkinnable().itemsProperty().removeListener(weakItemsChangeListener);
if (listViewItems != null) {
listViewItems.removeListener(weakListViewItemsListener);
listViewItems = null;
}
// flow related cleanup
// leaking without nulling factory
flow.setCellFactory(null);
// for completeness - but no effect with/out?
flow.getVbar().removeEventFilter(MouseEvent.MOUSE_PRESSED, ml);
flow.getHbar().removeEventFilter(MouseEvent.MOUSE_PRESSED, ml);
super.dispose();

if (behavior != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2289,4 +2289,9 @@ private void stopAnim(Animation anim) {
ContextMenu test_getTabsMenu() {
return tabHeaderArea.controlButtons.popup;
}

void test_disableAnimations() {
closeTabAnimation.set(TabAnimation.NONE);
openTabAnimation.set(TabAnimation.NONE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class ToolBarSkin extends SkinBase<ToolBar> {
private final ParentTraversalEngine engine;
private final BehaviorBase<ToolBar> behavior;


private ListChangeListener<Node> itemsListener;

/***************************************************************************
* *
Expand Down Expand Up @@ -228,8 +228,8 @@ public Node selectLast(TraversalContext context) {
});
ParentHelper.setTraversalEngine(getSkinnable(), engine);

control.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
registerChangeListener(control.focusedProperty(), ov -> {
if (getSkinnable().isFocused()) {
// TODO need to detect the focus direction
// to selected the first control in the toolbar when TAB is pressed
// or select the last control in the toolbar when SHIFT TAB is pressed.
Expand All @@ -241,7 +241,7 @@ public Node selectLast(TraversalContext context) {
}
});

control.getItems().addListener((ListChangeListener<Node>) c -> {
itemsListener = (ListChangeListener<Node>) c -> {
while (c.next()) {
for (Node n: c.getRemoved()) {
box.getChildren().remove(n);
Expand All @@ -250,7 +250,8 @@ public Node selectLast(TraversalContext context) {
}
needsUpdate = true;
getSkinnable().requestLayout();
});
};
control.getItems().addListener(itemsListener);
}


Expand Down Expand Up @@ -365,6 +366,8 @@ public CssMetaData<ToolBar,Pos> getCssMetaData() {

/** {@inheritDoc} */
@Override public void dispose() {
if (getSkinnable() == null) return;
getSkinnable().getItems().removeListener(itemsListener);
super.dispose();

if (behavior != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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 All @@ -25,6 +25,7 @@

package javafx.scene.control.skin;

import javafx.event.EventHandler;
import javafx.scene.control.Control;
import javafx.scene.control.IndexedCell;
import javafx.scene.control.ScrollToEvent;
Expand Down Expand Up @@ -53,6 +54,7 @@ public abstract class VirtualContainerBase<C extends Control, I extends IndexedC
*/
private final VirtualFlow<I> flow;

private EventHandler<? super ScrollToEvent<Integer>> scrollToEventHandler;


/***************************************************************************
Expand All @@ -69,7 +71,7 @@ public VirtualContainerBase(final C control) {
super(control);
flow = createVirtualFlow();

control.addEventHandler(ScrollToEvent.scrollToTopIndex(), event -> {
scrollToEventHandler = event -> {
// Fix for RT-24630: The row count in VirtualFlow was incorrect
// (normally zero), so the scrollTo call was misbehaving.
if (itemCountDirty) {
Expand All @@ -78,7 +80,8 @@ public VirtualContainerBase(final C control) {
itemCountDirty = false;
}
flow.scrollToTop(event.getScrollTarget());
});
};
control.addEventHandler(ScrollToEvent.scrollToTopIndex(), scrollToEventHandler);
}


Expand Down Expand Up @@ -123,6 +126,17 @@ protected VirtualFlow<I> createVirtualFlow() {
return new VirtualFlow<>();
}

/**
* {@inheritDoc} <p>
* Overridden to remove EventHandler.
*/
@Override
public void dispose() {
if (getSkinnable() == null) return;
getSkinnable().removeEventHandler(ScrollToEvent.scrollToTopIndex(), scrollToEventHandler);
super.dispose();
}

/**
* Get the virtualized container.
* Subclasses can invoke this method to get the VirtualFlow instance.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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 All @@ -25,12 +25,25 @@

package javafx.scene.control.skin;

import java.util.List;

import javafx.scene.control.ContextMenu;
import javafx.scene.control.TabPane;
import javafx.scene.layout.StackPane;
import javafx.scene.Node;

public class TabPaneSkinShim {

public static ContextMenu getTabsMenu(TabPaneSkin tpSkin) {
return tpSkin.test_getTabsMenu();
}

public static void disableAnimations(TabPaneSkin tpSkin) {
tpSkin.test_disableAnimations();
}

public static List<Node> getTabHeaders(TabPane tabPane) {
StackPane headersRegion = (StackPane) tabPane.lookup(".headers-region");
return headersRegion.getChildren();
}
}
Loading

0 comments on commit f6ec5f1

Please sign in to comment.