mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8208638: Instead of circle rendered in appl window, but ellipse is produced JEditor Pane
Reviewed-by: serb, psadhukhan
This commit is contained in:
parent
ad74d2a16e
commit
c105cd5164
2 changed files with 34 additions and 24 deletions
|
@ -776,32 +776,10 @@ public class ImageView extends View {
|
||||||
|
|
||||||
if (newWidth > 0) {
|
if (newWidth > 0) {
|
||||||
newState |= WIDTH_FLAG;
|
newState |= WIDTH_FLAG;
|
||||||
if (newHeight <= 0) {
|
|
||||||
newHeight = newWidth;
|
|
||||||
newState |= HEIGHT_FLAG;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newHeight > 0) {
|
if (newHeight > 0) {
|
||||||
newState |= HEIGHT_FLAG;
|
newState |= HEIGHT_FLAG;
|
||||||
if (newWidth <= 0) {
|
|
||||||
newWidth = newHeight;
|
|
||||||
newState |= WIDTH_FLAG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newWidth <= 0) {
|
|
||||||
newWidth = newImage.getWidth(imageObserver);
|
|
||||||
if (newWidth <= 0) {
|
|
||||||
newWidth = DEFAULT_WIDTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newHeight <= 0) {
|
|
||||||
newHeight = newImage.getHeight(imageObserver);
|
|
||||||
if (newHeight <= 0) {
|
|
||||||
newHeight = DEFAULT_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the image starts loading:
|
// Make sure the image starts loading:
|
||||||
|
@ -965,6 +943,35 @@ public class ImageView extends View {
|
||||||
changed |= 2;
|
changed |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the image properties (height and width) have been loaded,
|
||||||
|
* then figure out if scaling is necessary based on the
|
||||||
|
* specified HTML attributes.
|
||||||
|
*/
|
||||||
|
if (((flags & ImageObserver.HEIGHT) != 0) &&
|
||||||
|
((flags & ImageObserver.WIDTH) != 0)) {
|
||||||
|
double proportion = 0.0;
|
||||||
|
final int specifiedWidth = getIntAttr(HTML.Attribute.WIDTH, -1);
|
||||||
|
final int specifiedHeight = getIntAttr(HTML.Attribute.HEIGHT, -1);
|
||||||
|
/**
|
||||||
|
* If either of the attributes are not specified, then calculate the
|
||||||
|
* proportion for the specified dimension wrt actual value, and then
|
||||||
|
* apply the same proportion to the unspecified dimension as well,
|
||||||
|
* so that the aspect ratio of the image is maintained.
|
||||||
|
*/
|
||||||
|
if (specifiedWidth != -1 ^ specifiedHeight != -1) {
|
||||||
|
if (specifiedWidth <= 0) {
|
||||||
|
proportion = specifiedHeight / ((double)newHeight);
|
||||||
|
newWidth = (int)(proportion * newWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (specifiedHeight <= 0) {
|
||||||
|
proportion = specifiedWidth / ((double)newWidth);
|
||||||
|
newHeight = (int)(proportion * newHeight);
|
||||||
|
}
|
||||||
|
changed |= 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
synchronized(ImageView.this) {
|
synchronized(ImageView.this) {
|
||||||
if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) {
|
if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) {
|
||||||
height = newHeight;
|
height = newHeight;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @key headful
|
* @key headful
|
||||||
* @bug 8195095 8206238
|
* @bug 8195095 8206238 8208638
|
||||||
* @summary Tests if Images are scaled correctly in JEditorPane.
|
* @summary Tests if Images are scaled correctly in JEditorPane.
|
||||||
* @run main ImageViewTest
|
* @run main ImageViewTest
|
||||||
*/
|
*/
|
||||||
|
@ -51,8 +51,11 @@ public class ImageViewTest {
|
||||||
f.add(editorPane);
|
f.add(editorPane);
|
||||||
f.setSize(WIDTH + 20, HEIGHT + 40);
|
f.setSize(WIDTH + 20, HEIGHT + 40);
|
||||||
f.setLocationRelativeTo(null);
|
f.setLocationRelativeTo(null);
|
||||||
|
|
||||||
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
//This line will trigger the imageupdate, and consequently, the view
|
||||||
|
//will be populated with the appropriate color when the pixel color
|
||||||
|
//is queried by robot.
|
||||||
|
editorPane.getUI().getPreferredSize(editorPane);
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue