diff --git a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarThemeImpl.java b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarThemeImpl.java index 841e6a69d3..18b6ec8210 100644 --- a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarThemeImpl.java +++ b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarThemeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -48,9 +48,6 @@ private final static PlatformLogger log = PlatformLogger.getLogger(ScrollBarThemeImpl.class.getName()); - private WeakReference testSBRef = // used for scrollbar thickness calculation - new WeakReference(null); - private final Accessor accessor; private final Pool pool; @@ -81,19 +78,14 @@ public ScrollBarThemeImpl(final Accessor accessor) { accessor.addViewListener(new ViewListener(pool, accessor) { @Override public void invalidated(Observable ov) { super.invalidated(ov); - ScrollBar testSB = new ScrollBarWidget(ScrollBarThemeImpl.this); + ScrollBar testSB = new ScrollBarWidget(); // testSB should be added to the new WebView (if any) accessor.addChild(testSB); - testSBRef = new WeakReference(testSB); } }); } - ScrollBar getTestSBRef() { - return testSBRef.get(); - } - private static Orientation convertOrientation(int orientation) { return orientation == VERTICAL_SCROLLBAR ? Orientation.VERTICAL : Orientation.HORIZONTAL; } @@ -156,7 +148,7 @@ private void adjustScrollBar(ScrollBar sb, int w, int h, int orientation, { ScrollBarWidget sb = pool.get(id); if (sb == null) { - sb = new ScrollBarWidget(this); + sb = new ScrollBarWidget(); pool.put(id, sb, accessor.getPage().getUpdateContentCycleID()); accessor.addChild(sb); } diff --git a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarWidget.java b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarWidget.java index b90cc0fb95..dd701b68b8 100644 --- a/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarWidget.java +++ b/modules/javafx.web/src/main/java/com/sun/javafx/webkit/theme/ScrollBarWidget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -40,15 +40,12 @@ public void doUpdatePeer(Node node) { }); } - private ScrollBarThemeImpl sbtImpl; - { // To initialize the class helper at the begining each constructor of this class ScrollBarWidgetHelper.initHelper(this); } - public ScrollBarWidget(ScrollBarThemeImpl sbtImpl) { - this.sbtImpl = sbtImpl; + public ScrollBarWidget() { setOrientation(Orientation.VERTICAL); setMin(0); setManaged(false); @@ -72,14 +69,10 @@ protected void layoutChildren() { initializeThickness(); } - private boolean thicknessInitialized = false; + private static boolean thicknessInitialized = false; private void initializeThickness() { if (!thicknessInitialized) { - ScrollBar testSB = sbtImpl.getTestSBRef(); - if (testSB == null) { - return; - } - int thickness = (int) testSB.prefWidth(-1); + int thickness = (int) prefWidth(-1); if (thickness != 0 && ScrollBarTheme.getThickness() != thickness) { ScrollBarTheme.setThickness(thickness); }