Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3dc07b8c
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看板
提交
3dc07b8c
编写于
8月 29, 2011
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7030332: Default borders in tables looks incorrect JEditorPane
Reviewed-by: peterz
上级
31d11eaa
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
145 addition
and
23 deletion
+145
-23
src/share/classes/javax/swing/text/html/CSS.java
src/share/classes/javax/swing/text/html/CSS.java
+32
-20
src/share/classes/javax/swing/text/html/TableView.java
src/share/classes/javax/swing/text/html/TableView.java
+3
-3
test/javax/swing/text/html/TableView/7030332/bug7030332.html
test/javax/swing/text/html/TableView/7030332/bug7030332.html
+12
-0
test/javax/swing/text/html/TableView/7030332/bug7030332.java
test/javax/swing/text/html/TableView/7030332/bug7030332.java
+98
-0
test/javax/swing/text/html/TableView/7030332/sample0.png
test/javax/swing/text/html/TableView/7030332/sample0.png
+0
-0
test/javax/swing/text/html/TableView/7030332/sample1.png
test/javax/swing/text/html/TableView/7030332/sample1.png
+0
-0
test/javax/swing/text/html/TableView/7030332/sample2.png
test/javax/swing/text/html/TableView/7030332/sample2.png
+0
-0
test/javax/swing/text/html/TableView/7030332/sample3.png
test/javax/swing/text/html/TableView/7030332/sample3.png
+0
-0
test/javax/swing/text/html/TableView/7030332/sample4.png
test/javax/swing/text/html/TableView/7030332/sample4.png
+0
-0
未找到文件。
src/share/classes/javax/swing/text/html/CSS.java
浏览文件 @
3dc07b8c
...
...
@@ -806,15 +806,11 @@ public class CSS implements Serializable {
// translate border width into the cells, if it has non-zero value.
AttributeSet
tableAttr
=
elem
.
getParentElement
().
getParentElement
().
getAttributes
();
int
borderWidth
;
try
{
borderWidth
=
Integer
.
parseInt
(
(
String
)
tableAttr
.
getAttribute
(
HTML
.
Attribute
.
BORDER
));
}
catch
(
NumberFormatException
e
)
{
borderWidth
=
0
;
}
int
borderWidth
=
getTableBorder
(
tableAttr
);
if
(
borderWidth
>
0
)
{
translateAttribute
(
HTML
.
Attribute
.
BORDER
,
tableAttr
,
cssAttrSet
);
// If table contains the BORDER attribute cells should have border width equals 1
translateAttribute
(
HTML
.
Attribute
.
BORDER
,
"1"
,
cssAttrSet
);
}
String
pad
=
(
String
)
tableAttr
.
getAttribute
(
HTML
.
Attribute
.
CELLPADDING
);
if
(
pad
!=
null
)
{
...
...
@@ -850,6 +846,21 @@ public class CSS implements Serializable {
return
cssAttrSet
;
}
private
static
int
getTableBorder
(
AttributeSet
tableAttr
)
{
String
borderValue
=
(
String
)
tableAttr
.
getAttribute
(
HTML
.
Attribute
.
BORDER
);
if
(
borderValue
==
HTML
.
NULL_ATTRIBUTE_VALUE
||
""
.
equals
(
borderValue
))
{
// Some browsers accept <TABLE BORDER> and <TABLE BORDER=""> with the same semantics as BORDER=1
return
1
;
}
try
{
return
Integer
.
parseInt
(
borderValue
);
}
catch
(
NumberFormatException
e
)
{
return
0
;
}
}
private
static
final
Hashtable
<
String
,
Attribute
>
attributeMap
=
new
Hashtable
<
String
,
Attribute
>();
private
static
final
Hashtable
<
String
,
Value
>
valueMap
=
new
Hashtable
<
String
,
Value
>();
...
...
@@ -1400,17 +1411,20 @@ public class CSS implements Serializable {
}
}
}
else
{
/*
* The html size attribute has a mapping in the CSS world only
* if it is par of a font or base font tag.
*/
if
(
key
==
HTML
.
Attribute
.
SIZE
&&
!
isHTMLFontTag
(
tag
))
{
continue
;
/*
* The html size attribute has a mapping in the CSS world only
* if it is par of a font or base font tag.
*/
}
else
if
(
tag
==
HTML
.
Tag
.
TABLE
&&
key
==
HTML
.
Attribute
.
BORDER
)
{
int
borderWidth
=
getTableBorder
(
htmlAttrSet
);
if
(
borderWidth
>
0
)
{
translateAttribute
(
HTML
.
Attribute
.
BORDER
,
Integer
.
toString
(
borderWidth
),
cssAttrSet
);
}
}
else
{
translateAttribute
(
key
,
(
String
)
htmlAttrSet
.
getAttribute
(
key
),
cssAttrSet
);
}
translateAttribute
(
key
,
htmlAttrSet
,
cssAttrSet
);
}
}
else
if
(
name
instanceof
CSS
.
Attribute
)
{
cssAttrSet
.
addAttribute
(
name
,
htmlAttrSet
.
getAttribute
(
name
));
...
...
@@ -1419,7 +1433,7 @@ public class CSS implements Serializable {
}
private
void
translateAttribute
(
HTML
.
Attribute
key
,
AttributeSet
htmlAttrSet
,
String
htmlAttrValue
,
MutableAttributeSet
cssAttrSet
)
{
/*
* In the case of all remaining HTML.Attribute's they
...
...
@@ -1427,8 +1441,6 @@ public class CSS implements Serializable {
*/
CSS
.
Attribute
[]
cssAttrList
=
getCssAttribute
(
key
);
String
htmlAttrValue
=
(
String
)
htmlAttrSet
.
getAttribute
(
key
);
if
(
cssAttrList
==
null
||
htmlAttrValue
==
null
)
{
return
;
}
...
...
src/share/classes/javax/swing/text/html/TableView.java
浏览文件 @
3dc07b8c
...
...
@@ -242,7 +242,8 @@ import javax.swing.text.*;
if
(
lv
!=
null
)
{
cellSpacing
=
(
int
)
lv
.
getValue
();
}
else
{
cellSpacing
=
0
;
// Default cell spacing equals 2
cellSpacing
=
2
;
}
lv
=
(
CSS
.
LengthValue
)
attr
.
getAttribute
(
CSS
.
Attribute
.
BORDER_TOP_WIDTH
);
...
...
@@ -251,8 +252,7 @@ import javax.swing.text.*;
}
else
{
borderWidth
=
0
;
}
}
}
}
/**
...
...
test/javax/swing/text/html/TableView/7030332/bug7030332.html
0 → 100644
浏览文件 @
3dc07b8c
<html>
<body>
<applet
code=
"bug7030332.class"
width=
600
height=
400
></applet>
Compare Golden Images with rendered JEditorPane.
They should looks simalar in each line. Pay attention to:
1. Border width around tables
2. Border width around cells
</body>
</html>
test/javax/swing/text/html/TableView/7030332/bug7030332.java
0 → 100644
浏览文件 @
3dc07b8c
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7030332
@summary Default borders in tables looks incorrect JEditorPane
@author Pavel Porvatov
* @run applet/manual=yesno bug7030332.html
*/
import
javax.swing.*
;
import
java.awt.*
;
import
java.net.URL
;
public
class
bug7030332
extends
JApplet
{
public
static
final
String
[]
HTML_SAMPLES
=
new
String
[]{
"<table border><tr><th>Column1</th><th>Column2</th></tr></table>"
,
"<table border=\"\"><tr><th>Column1</th><th>Column2</th></tr></table>"
,
"<table border=\"1\"><tr><th>Column1</th><th>Column2</th></tr></table>"
,
"<table border=\"2\"><tr><th>Column1</th><th>Column2</th></tr></table>"
,
};
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
JFrame
frame
=
new
JFrame
();
frame
.
setContentPane
(
createContentPane
());
frame
.
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
frame
.
setSize
(
600
,
400
);
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
}
});
}
public
void
init
()
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
setContentPane
(
createContentPane
());
}
});
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
static
Container
createContentPane
()
{
JPanel
result
=
new
JPanel
(
new
GridLayout
(
HTML_SAMPLES
.
length
+
1
,
3
,
10
,
10
));
result
.
add
(
new
JLabel
(
"Html code"
));
result
.
add
(
new
JLabel
(
"Golden image"
));
result
.
add
(
new
JLabel
(
"JEditorPane"
));
for
(
int
i
=
0
;
i
<
HTML_SAMPLES
.
length
;
i
++)
{
String
htmlSample
=
HTML_SAMPLES
[
i
];
JTextArea
textArea
=
new
JTextArea
(
htmlSample
);
textArea
.
setLineWrap
(
true
);
result
.
add
(
textArea
);
String
imageName
=
"sample"
+
i
+
".png"
;
URL
resource
=
bug7030332
.
class
.
getResource
(
imageName
);
result
.
add
(
resource
==
null
?
new
JLabel
(
imageName
+
" not found"
)
:
new
JLabel
(
new
ImageIcon
(
resource
),
SwingConstants
.
LEFT
));
result
.
add
(
new
JEditorPane
(
"text/html"
,
htmlSample
));
}
return
result
;
}
}
test/javax/swing/text/html/TableView/7030332/sample0.png
0 → 100644
浏览文件 @
3dc07b8c
696 字节
test/javax/swing/text/html/TableView/7030332/sample1.png
0 → 100644
浏览文件 @
3dc07b8c
696 字节
test/javax/swing/text/html/TableView/7030332/sample2.png
0 → 100644
浏览文件 @
3dc07b8c
696 字节
test/javax/swing/text/html/TableView/7030332/sample3.png
0 → 100644
浏览文件 @
3dc07b8c
660 字节
test/javax/swing/text/html/TableView/7030332/sample4.png
0 → 100644
浏览文件 @
3dc07b8c
660 字节
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录