Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c7b8baac
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c7b8baac
编写于
10月 04, 2018
作者:
R
rpatil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8208638: Instead of circle rendered in appl window, but ellipse is produced JEditor Pane
Reviewed-by: serb, psadhukhan
上级
7c590ec4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
34 deletion
+90
-34
src/share/classes/javax/swing/text/html/ImageView.java
src/share/classes/javax/swing/text/html/ImageView.java
+28
-14
test/javax/swing/JEditorPane/8195095/ImageViewTest.java
test/javax/swing/JEditorPane/8195095/ImageViewTest.java
+62
-20
未找到文件。
src/share/classes/javax/swing/text/html/ImageView.java
浏览文件 @
c7b8baac
...
@@ -734,20 +734,6 @@ public class ImageView extends View {
...
@@ -734,20 +734,6 @@ public class ImageView extends View {
newState
|=
HEIGHT_FLAG
;
newState
|=
HEIGHT_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:
if
((
newState
&
(
WIDTH_FLAG
|
HEIGHT_FLAG
))
!=
0
)
{
if
((
newState
&
(
WIDTH_FLAG
|
HEIGHT_FLAG
))
!=
0
)
{
Toolkit
.
getDefaultToolkit
().
prepareImage
(
newImage
,
newWidth
,
Toolkit
.
getDefaultToolkit
().
prepareImage
(
newImage
,
newWidth
,
...
@@ -909,6 +895,34 @@ public class ImageView extends View {
...
@@ -909,6 +895,34 @@ public class ImageView extends View {
changed
|=
2
;
changed
|=
2
;
}
}
/**
* If the image properties (height and width) have been loaded,
* tehn 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
;
...
...
test/javax/swing/JEditorPane/8195095/ImageViewTest.java
浏览文件 @
c7b8baac
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/**
/**
* @test
* @test
* @bug 8195095
* @bug 8195095
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
*/
*/
...
@@ -39,25 +39,23 @@ import javax.swing.WindowConstants;
...
@@ -39,25 +39,23 @@ import javax.swing.WindowConstants;
public
class
ImageViewTest
{
public
class
ImageViewTest
{
private
static
final
int
WIDTH
=
200
;
private
static
final
int
HEIGHT
=
200
;
private
static
JFrame
f
;
private
static
JFrame
f
;
private
static
JEditorPane
editorPane1
;
private
static
void
test
(
Robot
r
,
JEditorPane
editorPane
,
private
static
JEditorPane
editorPane2
;
final
int
WIDTH
,
final
int
HEIGHT
)
throws
Exception
{
private
static
JEditorPane
editorPane3
;
private
static
JEditorPane
editorPane4
;
private
static
void
test
(
Robot
r
,
JEditorPane
editorPane
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
SwingUtilities
.
invokeAndWait
(()
->
{
f
=
new
JFrame
();
f
=
new
JFrame
();
editorPane
.
setEditable
(
false
);
editorPane
.
setEditable
(
false
);
f
.
add
(
editorPane
);
f
.
add
(
editorPane
);
f
.
setSize
(
220
,
2
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
);
});
});
...
@@ -108,34 +106,78 @@ public class ImageViewTest {
...
@@ -108,34 +106,78 @@ public class ImageViewTest {
Robot
r
=
new
Robot
();
Robot
r
=
new
Robot
();
final
JEditorPane
[]
editorPanes
=
new
JEditorPane
[
11
];
SwingUtilities
.
invokeAndWait
(()
->
{
SwingUtilities
.
invokeAndWait
(()
->
{
editorPane
1
=
new
JEditorPane
(
"text/html"
,
editorPane
s
[
0
]
=
new
JEditorPane
(
"text/html"
,
"<img height=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
"<img height=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPane
2
=
new
JEditorPane
(
"text/html"
,
editorPane
s
[
1
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
"<img width=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPane
3
=
new
JEditorPane
(
"text/html"
,
editorPane
s
[
2
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"200\" height=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
"<img width=\"200\" height=\"200\" src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPane
4
=
new
JEditorPane
(
"text/html"
,
editorPane
s
[
3
]
=
new
JEditorPane
(
"text/html"
,
"<img src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
"<img src=\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
4
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"100\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
5
]
=
new
JEditorPane
(
"text/html"
,
"<img height=\"100\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
6
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"100\" height=\"100\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
7
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"50\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
8
]
=
new
JEditorPane
(
"text/html"
,
"<img height=\"50\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
9
]
=
new
JEditorPane
(
"text/html"
,
"<img width=\"300\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
editorPanes
[
10
]
=
new
JEditorPane
(
"text/html"
,
"<img height=\"300\" src =\"file:///"
+
ABSOLUTE_FILE_PATH
+
"\""
);
});
});
r
.
waitForIdle
();
r
.
waitForIdle
();
System
.
out
.
println
(
"Test with only height set to 200"
);
System
.
out
.
println
(
"Test with only height set to 200"
);
test
(
r
,
editorPane
1
);
test
(
r
,
editorPane
s
[
0
],
200
,
200
);
System
.
out
.
println
(
"Test with only width set to 200"
);
System
.
out
.
println
(
"Test with only width set to 200"
);
test
(
r
,
editorPane2
);
test
(
r
,
editorPanes
[
1
],
200
,
200
);
System
.
out
.
println
(
"Test with both of them set"
);
test
(
r
,
editorPanes
[
2
],
200
,
200
);
System
.
out
.
println
(
"Test with none of them set to 200"
);
test
(
r
,
editorPanes
[
3
],
200
,
200
);
System
.
out
.
println
(
"Test with only width set to 100"
);
test
(
r
,
editorPanes
[
4
],
100
,
100
);
System
.
out
.
println
(
"Test with only height set to 100"
);
test
(
r
,
editorPanes
[
5
],
100
,
100
);
System
.
out
.
println
(
"Test with both width and height set to 100"
);
test
(
r
,
editorPanes
[
6
],
100
,
100
);
System
.
out
.
println
(
"Test with only width set to 50"
);
test
(
r
,
editorPanes
[
7
],
50
,
50
);
System
.
out
.
println
(
"Test with only height set to 50"
);
test
(
r
,
editorPanes
[
8
],
50
,
50
);
System
.
out
.
println
(
"Test with
none of them set
"
);
System
.
out
.
println
(
"Test with
only width set to 300
"
);
test
(
r
,
editorPane
3
);
test
(
r
,
editorPane
s
[
9
],
300
,
300
);
System
.
out
.
println
(
"Test with
both of them set to 2
00"
);
System
.
out
.
println
(
"Test with
only height set to 3
00"
);
test
(
r
,
editorPane
4
);
test
(
r
,
editorPane
s
[
10
],
300
,
300
);
System
.
out
.
println
(
"Test Passed."
);
System
.
out
.
println
(
"Test Passed."
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录