Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f4d3bb08
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f4d3bb08
编写于
6月 02, 2010
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6636983: Japanese text does not display correctly in a JEditorPane
Reviewed-by: peterz
上级
1ab59122
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
173 addition
and
14 deletion
+173
-14
src/share/classes/javax/swing/text/DefaultStyledDocument.java
...share/classes/javax/swing/text/DefaultStyledDocument.java
+13
-8
src/share/classes/javax/swing/text/GlyphView.java
src/share/classes/javax/swing/text/GlyphView.java
+1
-1
src/share/classes/javax/swing/text/html/HTMLDocument.java
src/share/classes/javax/swing/text/html/HTMLDocument.java
+1
-5
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+6
-0
test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java
.../swing/text/DefaultStyledDocument/6636983/bug6636983.java
+152
-0
未找到文件。
src/share/classes/javax/swing/text/DefaultStyledDocument.java
浏览文件 @
f4d3bb08
...
...
@@ -25,15 +25,12 @@
package
javax.swing.text
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.font.TextAttribute
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.WeakReference
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Stack
;
...
...
@@ -41,15 +38,14 @@ import java.util.Vector;
import
java.util.ArrayList
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.Serializable
;
import
javax.swing.Icon
;
import
javax.swing.event.*
;
import
javax.swing.undo.AbstractUndoableEdit
;
import
javax.swing.undo.CannotRedoException
;
import
javax.swing.undo.CannotUndoException
;
import
javax.swing.undo.UndoableEdit
;
import
javax.swing.SwingUtilities
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A document that can be marked up with character and paragraph
...
...
@@ -782,9 +778,18 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
// Check for the composed text element. If it is, merge the character attributes
// into this element as well.
if
(
Utilities
.
isComposedTextAttributeDefined
(
attr
))
{
((
MutableAttributeSet
)
attr
).
addAttributes
(
cattr
);
((
MutableAttributeSet
)
attr
).
addAttribute
(
AbstractDocument
.
ElementNameAttribute
,
AbstractDocument
.
ContentElementName
);
MutableAttributeSet
mattr
=
(
MutableAttributeSet
)
attr
;
mattr
.
addAttributes
(
cattr
);
mattr
.
addAttribute
(
AbstractDocument
.
ElementNameAttribute
,
AbstractDocument
.
ContentElementName
);
// Assure that the composed text element is named properly
// and doesn't have the CR attribute defined.
mattr
.
addAttribute
(
StyleConstants
.
NameAttribute
,
AbstractDocument
.
ContentElementName
);
if
(
mattr
.
isDefined
(
IMPLIED_CR
))
{
mattr
.
removeAttribute
(
IMPLIED_CR
);
}
}
ElementSpec
[]
spec
=
new
ElementSpec
[
parseBuffer
.
size
()];
...
...
src/share/classes/javax/swing/text/GlyphView.java
浏览文件 @
f4d3bb08
...
...
@@ -32,6 +32,7 @@ import java.util.Locale;
import
javax.swing.UIManager
;
import
sun.swing.SwingUtilities2
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A GlyphView is a styled chunk of text that represents a view
...
...
@@ -1061,7 +1062,6 @@ public class GlyphView extends View implements TabableView, Cloneable {
int
length
;
// if it is an implied newline character
boolean
impliedCR
;
private
static
final
String
IMPLIED_CR
=
"CR"
;
boolean
skipWidth
;
/**
...
...
src/share/classes/javax/swing/text/html/HTMLDocument.java
浏览文件 @
f4d3bb08
...
...
@@ -24,20 +24,17 @@
*/
package
javax.swing.text.html
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.font.TextAttribute
;
import
java.util.*
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.MalformedURLException
;
import
java.io.*
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.text.*
;
import
javax.swing.undo.*
;
import
java.text.Bidi
;
import
sun.swing.SwingUtilities2
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A document that models HTML. The purpose of this model is to
...
...
@@ -1819,7 +1816,6 @@ public class HTMLDocument extends DefaultStyledDocument {
static
String
MAP_PROPERTY
=
"__MAP__"
;
private
static
char
[]
NEWLINE
;
private
static
final
String
IMPLIED_CR
=
"CR"
;
/**
* I18N property key.
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
f4d3bb08
...
...
@@ -108,6 +108,12 @@ public class SwingUtilities2 {
public
static
final
Object
AA_TEXT_PROPERTY_KEY
=
new
StringBuffer
(
"AATextInfoPropertyKey"
);
/**
* Attribute key for the content elements. If it is set on an element, the
* element is considered to be a line break.
*/
public
static
final
String
IMPLIED_CR
=
"CR"
;
/**
* Used to tell a text component, being used as an editor for table
* or tree, how many clicks it took to start editing.
...
...
test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java
0 → 100644
浏览文件 @
f4d3bb08
/*
* Copyright (c) 2010, 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 6636983
* @summary test that composed text at the line starts is handled correctly
* @author Sergey Groznyh
* @run main bug6636983
*/
import
sun.swing.SwingUtilities2
;
import
javax.swing.*
;
import
javax.swing.text.*
;
import
javax.swing.text.html.HTMLDocument
;
import
java.awt.*
;
import
java.awt.event.InputMethodEvent
;
import
java.awt.event.KeyEvent
;
import
java.text.AttributedString
;
public
class
bug6636983
{
private
Robot
robot
;
private
final
AttributedString
Hiragana_A
=
new
AttributedString
(
"\u3042"
);
void
sendInputMethodEvent
()
{
InputMethodEvent
ime
=
new
InputMethodEvent
(
ep
,
InputMethodEvent
.
INPUT_METHOD_TEXT_CHANGED
,
Hiragana_A
.
getIterator
(),
0
,
null
,
null
);
ep
.
dispatchEvent
(
ime
);
}
void
checkComposedTextRun
()
{
HTMLDocument
d
=
(
HTMLDocument
)
ep
.
getDocument
();
ElementIterator
it
=
new
ElementIterator
(
d
.
getDefaultRootElement
());
while
(
true
)
{
Element
e
=
it
.
next
();
if
(
e
==
null
)
{
throw
new
RuntimeException
(
"no composed text found"
);
}
AttributeSet
a
=
e
.
getAttributes
();
if
(
a
.
isDefined
(
StyleConstants
.
ComposedTextAttribute
))
{
if
(!
AbstractDocument
.
ContentElementName
.
equals
(
a
.
getAttribute
(
StyleConstants
.
NameAttribute
)))
{
throw
new
RuntimeException
(
"AbstractDocument.ContentElementName.equals(a.getAttribute(StyleConstants.NameAttribute)) is false"
);
}
if
(
a
.
isDefined
(
SwingUtilities2
.
IMPLIED_CR
))
{
throw
new
RuntimeException
(
"a.isDefined(SwingUtilities2.IMPLIED_CR) is true"
);
}
return
;
}
}
}
JEditorPane
ep
;
void
initAtParagraphStart
()
{
ep
.
setText
(
"A<p>B"
);
hitKey
(
KeyEvent
.
VK_LEFT
);
}
void
sendAtParagraphStart
()
{
sendInputMethodEvent
();
}
void
checkAtParagraphStart
()
{
checkComposedTextRun
();
}
void
initAfterBRElement
()
{
ep
.
setText
(
"A<br>B"
);
hitKey
(
KeyEvent
.
VK_LEFT
);
}
void
sendAtBRElement
()
{
sendInputMethodEvent
();
}
void
checkAtBrElement
()
{
checkComposedTextRun
();
}
private
void
hitKey
(
int
keycode
)
{
robot
.
keyPress
(
keycode
);
robot
.
keyRelease
(
keycode
);
robot
.
delay
(
550
);
// The magic number equals JRobot.DEFAULT_DELAY
}
private
void
run
()
throws
Exception
{
robot
=
new
Robot
();
ep
=
new
JEditorPane
();
ep
.
setContentType
(
"text/html"
);
ep
.
setPreferredSize
(
new
Dimension
(
100
,
100
));
JFrame
frame
=
new
JFrame
(
"Test: "
+
getClass
().
getName
());
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
add
(
ep
);
frame
.
setVisible
(
true
);
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
try
{
bug6636983
bug6636983
=
new
bug6636983
();
bug6636983
.
run
();
bug6636983
.
initAtParagraphStart
();
bug6636983
.
sendAtParagraphStart
();
bug6636983
.
checkAtParagraphStart
();
bug6636983
.
initAfterBRElement
();
bug6636983
.
sendAtBRElement
();
bug6636983
.
checkAtBrElement
();
System
.
out
.
println
(
"OK"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"The test failed"
,
e
);
}
}
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录