Skip to content

Commit

Permalink
8310054: ScrollPane insets are incorrect
Browse files Browse the repository at this point in the history
Reviewed-by: honkar, prr
  • Loading branch information
aivanov-jdk committed Jun 16, 2023
1 parent 4eb4f20 commit d6c2ee3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, 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 @@ -24,7 +24,13 @@
*/
package sun.awt.windows;

import java.awt.*;
import java.awt.Adjustable;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
import java.awt.ScrollPane;
import java.awt.ScrollPaneAdjustable;
import java.awt.event.AdjustmentEvent;
import java.awt.peer.ScrollPanePeer;

Expand Down Expand Up @@ -105,7 +111,6 @@ public void childResized(int width, int height) {
ScrollPane sp = (ScrollPane)target;
Dimension vs = sp.getSize();
setSpans(vs.width, vs.height, width, height);
setInsets();
}

synchronized native void setSpans(int viewWidth, int viewHeight,
Expand Down
Expand Up @@ -525,6 +525,7 @@ void AwtScrollPane::_SetSpans(void *param)
parentWidth, parentHeight, childWidth, childHeight);
s->RecalcSizes(parentWidth, parentHeight, childWidth, childHeight);
s->VerifyState();
s->SetInsets(env);
}
ret:
env->DeleteGlobalRef(self);
Expand Down Expand Up @@ -718,7 +719,7 @@ Java_sun_awt_windows_WScrollPanePeer_setInsets(JNIEnv *env, jobject self)
{
TRY

AwtToolkit::GetInstance().SyncCall(AwtScrollPane::_SetInsets,
AwtToolkit::GetInstance().InvokeFunction(AwtScrollPane::_SetInsets,
env->NewGlobalRef(self));
// global ref is deleted in _SetInsets()

Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/awt/ScrollPane/ScrollPaneExtraScrollBar.java
Expand Up @@ -23,7 +23,7 @@

/*
@test
@bug 4152524
@bug 4152524 8310054
@requires os.family=="windows"
@summary Test that scroll pane doesn't have scroll bars visible when it is
shown for the first time with SCROLLBARS_AS_NEEDED style
Expand Down Expand Up @@ -57,7 +57,7 @@ public void init() throws Exception {
sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sp.add(new Button("TEST"));
f.add("Center", sp);
f.pack();
// Frame must not be packed, otherwise the bug isn't reproduced
f.setLocationRelativeTo(null);
f.setVisible(true);
});
Expand Down

3 comments on commit d6c2ee3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@aivanov-jdk
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21

@openjdk
Copy link

@openjdk openjdk bot commented on d6c2ee3 Jun 19, 2023

Choose a reason for hiding this comment

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

@aivanov-jdk the backport was successfully created on the branch aivanov-jdk-backport-d6c2ee34 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d6c2ee34 from the openjdk/jdk repository.

The commit being backported was authored by Alexey Ivanov on 16 Jun 2023 and was reviewed by Harshitha Onkar and Phil Race.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:

$ git fetch https://github.com/openjdk-bots/jdk21.git aivanov-jdk-backport-d6c2ee34:aivanov-jdk-backport-d6c2ee34
$ git checkout aivanov-jdk-backport-d6c2ee34
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21.git aivanov-jdk-backport-d6c2ee34

Please sign in to comment.