diff options
32 files changed, 850 insertions, 108 deletions
@@ -72,3 +72,4 @@ cf44386c8fe3fbdb9da14346be25d19fd1092f71 jdk7-b94 db951e984ccf50756160fee3078c791300b0917e jdk7-b95 51b9e5dbc2da0631414484b934ac3fb62e48a2c6 jdk7-b96 b1903d7528d33b521df42bc9291bdcdd2f444a29 jdk7-b97 +82593186fa54ab12f17af31f86a7bf364efaf4df jdk7-b98 diff --git a/make/common/shared/Defs-windows.gmk b/make/common/shared/Defs-windows.gmk index 067e4a44c..79cc031c6 100644 --- a/make/common/shared/Defs-windows.gmk +++ b/make/common/shared/Defs-windows.gmk @@ -331,23 +331,50 @@ ifeq ($(_ms_sdk),) endif endif -# Compilers for 64bit may be from SDK. For VS 2010 we use those. -# The Express compilers don't contain 64 bit compilers, so in -# that case, you additionally need the SDK. At this time, -# there's no 64 bit SDK available that has VS 2010. -# Presumably SDK v7.1 will provide that and we may want to update -# the logic here to work with that. -# However official builds will use the Professional version. +# Compilers for 64bit may be from the free SDK, or Visual Studio Professional +# The free Express compilers don't contain 64 bit compilers, which is why +# you instead need the SDK. +# So for VS2010 based builds, either VS2010 Pro with the 7.0a SDK, or +# the Windows 7.1 standalone SDK with compilers may be used. +# Release enginering will use VS2010 Pro, so the frequency of testing of +# SDK based builds will depend entirely on individual usage. ifeq ($(ARCH_DATA_MODEL), 64) ifdef VS100COMNTOOLS # /Common7/Tools directory, use ../../Vc + # VS2010 default location is used when building 64 bit using the 7.1 SDK + # This is safe to hardwire as the SDK installer won't let you change it + # and the VS2010 variable is only used if the compilers are from the SDK + xVS2010 :="$(_program_files32)/Microsoft Visual Studio 10.0/" + VS2010 :=$(call FullPath,$(xVS2010)) xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))" _vs100tools :=$(call FullPath,$(xVS100COMNTOOLS)) endif ifneq ($(_vs100tools),) _compiler_bin :=$(_vs100tools)/../../Vc/bin/amd64 - _redist_sdk :=$(_vs100tools)/../../Vc/redist/x64/Microsoft.VC100.CRT - xMSSDK70 :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/" - MSSDK70 :=$(call FullPath,$(xMSSDK70)) + x_redist_sdk :=$(_vs100tools)/../../Vc/redist/x64/Microsoft.VC100.CRT + _redist_sdk :=$(call FullPath,$(x_redist_sdk)) + # The SDK doesn't have the redist directory, but the DLL is installed + # into the windows directory. + ifeq ($(_redist_sdk),) + _redist_sdk :=c:/windows/system32 + endif + # Not currently using MSSDK7n, but maybe we can make use of it for + # doing default location lookup to find some SDK tools that presently + # require the developer to explicitly set the path. + # The 7.0a path is from VS2010 Pro, the 7.1 path is the standalone SDK. + # Either will work for us. + # If a developer chooses to install the standalone SDK in some other + # location, then this will fail to find it, which won't matter so long as + # we aren't using this variable. If we do they'd still need to set the + # ALT_MSDEVTOOLS_PATH as now. + # %WindowsSdkDir% could be referenced instead but the SDK installer + # doesn't set it and in the case of the VS2010 compilers, + # you can't change this location in the installer anyway. + xMSSDK7n :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/" + MSSDK7n :=$(call FullPath,$(xMSSDK7n)) + ifeq ($(MSSDK7n),) + xMSSDK7n :="$(_program_files32)/Microsoft SDKs/Windows/v7.1/" + MSSDK7n :=$(call FullPath,$(xMSSDK7n)) + endif else xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/" VS2008 :=$(call FullPath,$(xVS2008)) @@ -355,7 +382,7 @@ ifeq ($(ARCH_DATA_MODEL), 64) _compiler_bin :=$(VS2008)/VC/Bin/$(ARCH) xMSSDK61 :="$(_program_files)/Microsoft SDKs/Windows/v6.1/" MSSDK61 :=$(call FullPath,$(xMSSDK61)) - _redist_sdk :=$(VS2008)/VC/redist/x86/Microsoft.VC90.CRT + _redist_sdk :=$(VS2008)/VC/redist/x64/Microsoft.VC90.CRT else ifneq ($(_ms_sdk),) ifeq ($(ARCH), ia64) diff --git a/make/sun/pisces/Makefile b/make/sun/pisces/Makefile index cb0f0761d..7823361e8 100644 --- a/make/sun/pisces/Makefile +++ b/make/sun/pisces/Makefile @@ -52,5 +52,11 @@ build: copy-files copy-files: $(FILES_copy) -$(SERVICEDIR)/%: $(SHARE_SRC)/classes/sun/java2d/pisces/META-INF/services/% +ifneq ($(PLATFORM), windows) + SERVICE_SRC = $(PLATFORM_SRC) +else + SERVICE_SRC = $(SHARE_SRC) +endif + +$(SERVICEDIR)/%: $(SERVICE_SRC)/classes/sun/java2d/pisces/META-INF/services/% $(install-file) diff --git a/make/tools/freetypecheck/freetypecheck.c b/make/tools/freetypecheck/freetypecheck.c index 08d7ce8ec..ddbc2e0e7 100644 --- a/make/tools/freetypecheck/freetypecheck.c +++ b/make/tools/freetypecheck/freetypecheck.c @@ -33,7 +33,7 @@ #include FT_FREETYPE_H #ifdef _MSC_VER -#if _MSC_VER > 1400 +#if _MSC_VER > 1400 && _MSC_VER < 1600 /* * When building for Microsoft Windows, your program has a dependency @@ -68,7 +68,7 @@ "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"") #endif /* _M_AMD64 */ -#endif /* _MSC_VER > 1400 */ +#endif /* _MSC_VER > 1400 && _MSC_VER < 1600 */ #endif /* _MSC_VER */ #define QUOTEMACRO(x) QUOTEME(x) diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java index 097e6a689..ae33ddd36 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java @@ -424,7 +424,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { State rv; rv = super.getState(); if (rv != State.DISABLED - && ! comboBox.isEditable() + && comboBox != null && ! comboBox.isEditable() && XPStyle.getXP().isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) { /* diff --git a/src/share/classes/javax/swing/BorderFactory.java b/src/share/classes/javax/swing/BorderFactory.java index d71ed98ab..0f53bed45 100644 --- a/src/share/classes/javax/swing/BorderFactory.java +++ b/src/share/classes/javax/swing/BorderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -26,7 +26,6 @@ package javax.swing; import java.awt.Color; import java.awt.Font; -import javax.swing.JComponent; import javax.swing.border.*; /** @@ -74,10 +73,20 @@ public class BorderFactory return new LineBorder(color, thickness); } -// public static Border createLineBorder(Color color, int thickness, -// boolean drawRounded) { -// return new JLineBorder(color, thickness, drawRounded); -// } + /** + * Creates a line border with the specified color, thickness, and corner shape. + * + * @param color the color of the border + * @param thickness the thickness of the border + * @param rounded whether or not border corners should be round + * @return the {@code Border} object + * + * @see LineBorder#LineBorder(Color, int, boolean) + * @since 1.7 + */ + public static Border createLineBorder(Color color, int thickness, boolean rounded) { + return new LineBorder(color, thickness, rounded); + } //// BevelBorder ///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -180,7 +189,115 @@ public class BorderFactory } return null; } + +//// SoftBevelBorder /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + private static Border sharedSoftRaisedBevel; + private static Border sharedSoftLoweredBevel; + + /** + * Creates a beveled border with a raised edge and softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * In a raised border, highlights are on top and shadows are underneath. + * + * @return the {@code Border} object + * + * @since 1.7 + */ + public static Border createRaisedSoftBevelBorder() { + if (sharedSoftRaisedBevel == null) { + sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED); + } + return sharedSoftRaisedBevel; + } + + /** + * Creates a beveled border with a lowered edge and softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * In a lowered border, shadows are on top and highlights are underneath. + * + * @return the {@code Border} object + * + * @since 1.7 + */ + public static Border createLoweredSoftBevelBorder() { + if (sharedSoftLoweredBevel == null) { + sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED); + } + return sharedSoftLoweredBevel; + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * + * @param type a type of a bevel + * @return the {@code Border} object or {@code null} + * if the specified type is not valid + * + * @see BevelBorder#BevelBorder(int) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type) { + if (type == BevelBorder.RAISED) { + return createRaisedSoftBevelBorder(); + } + if (type == BevelBorder.LOWERED) { + return createLoweredSoftBevelBorder(); + } + return null; + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using the specified highlighting and shadowing. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * The outer edge of the highlight area uses + * a brighter shade of the {@code highlight} color. + * The inner edge of the shadow area uses + * a brighter shade of the {@code shadow} color. + * + * @param type a type of a bevel + * @param highlight a basic color of the highlight area + * @param shadow a basic color of the shadow area + * @return the {@code Border} object + * + * @see BevelBorder#BevelBorder(int, Color, Color) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) { + return new BevelBorder(type, highlight, shadow); + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using the specified colors for the inner and outer edges + * of the highlight and the shadow areas. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * Note: The shadow inner and outer colors are switched + * for a lowered bevel border. + * + * @param type a type of a bevel + * @param highlightOuter a color of the outer edge of the highlight area + * @param highlightInner a color of the inner edge of the highlight area + * @param shadowOuter a color of the outer edge of the shadow area + * @param shadowInner a color of the inner edge of the shadow area + * @return the {@code Border} object + * + * @see BevelBorder#BevelBorder(int, Color, Color, Color, Color) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) { + return new BevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner); + } + //// EtchedBorder /////////////////////////////////////////////////////////// + static final Border sharedEtchedBorder = new EtchedBorder(); private static Border sharedRaisedEtchedBorder; diff --git a/src/share/classes/javax/swing/plaf/synth/SynthParser.java b/src/share/classes/javax/swing/plaf/synth/SynthParser.java index cfde2fcd6..37a1893e7 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthParser.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthParser.java @@ -658,8 +658,7 @@ class SynthParser extends DefaultHandler { } try { _colorTypes.add((ColorType)checkCast(typeClass. - getField(typeName.substring(classIndex, - typeName.length() - classIndex)). + getField(typeName.substring(classIndex)). get(typeClass), ColorType.class)); } catch (NoSuchFieldException nsfe) { throw new SAXException("Unable to find color type: " + diff --git a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java index 60888f674..0b55a61f0 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java @@ -363,18 +363,24 @@ public class SynthToolBarUI extends BasicToolBarUI SynthIcon.getIconWidth(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getMinimumSize(); - dim.width += compDim.width; - dim.height = Math.max(dim.height, compDim.height); + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getMinimumSize(); + dim.width += compDim.width; + dim.height = Math.max(dim.height, compDim.height); + } } } else { dim.height = tb.isFloatable() ? SynthIcon.getIconHeight(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getMinimumSize(); - dim.width = Math.max(dim.width, compDim.width); - dim.height += compDim.height; + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getMinimumSize(); + dim.width = Math.max(dim.width, compDim.width); + dim.height += compDim.height; + } } } dim.width += insets.left + insets.right; @@ -395,18 +401,24 @@ public class SynthToolBarUI extends BasicToolBarUI SynthIcon.getIconWidth(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getPreferredSize(); - dim.width += compDim.width; - dim.height = Math.max(dim.height, compDim.height); + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getPreferredSize(); + dim.width += compDim.width; + dim.height = Math.max(dim.height, compDim.height); + } } } else { dim.height = tb.isFloatable() ? SynthIcon.getIconHeight(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getPreferredSize(); - dim.width = Math.max(dim.width, compDim.width); - dim.height += compDim.height; + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getPreferredSize(); + dim.width = Math.max(dim.width, compDim.width); + dim.height += compDim.height; + } } } dim.width += insets.left + insets.right; @@ -469,22 +481,24 @@ public class SynthToolBarUI extends BasicToolBarUI for (int i = 0; i < tb.getComponentCount(); i++) { c = tb.getComponent(i); - d = c.getPreferredSize(); - int y, h; - if (d.height >= baseH || c instanceof JSeparator) { - // Fill available height - y = baseY; - h = baseH; - } else { - // Center component vertically in the available space - y = baseY + (baseH / 2) - (d.height / 2); - h = d.height; + if (c.isVisible()) { + d = c.getPreferredSize(); + int y, h; + if (d.height >= baseH || c instanceof JSeparator) { + // Fill available height + y = baseY; + h = baseH; + } else { + // Center component vertically in the available space + y = baseY + (baseH / 2) - (d.height / 2); + h = d.height; + } + //if the component is a "glue" component then add to its + //width the extraSpacePerGlue it is due + if (isGlue(c)) d.width += extraSpacePerGlue; + c.setBounds(ltr ? x : x - d.width, y, d.width, h); + x = ltr ? x + d.width : x - d.width; } - //if the component is a "glue" component then add to its - //width the extraSpacePerGlue it is due - if (isGlue(c)) d.width += extraSpacePerGlue; - c.setBounds(ltr ? x : x - d.width, y, d.width, h); - x = ltr ? x + d.width : x - d.width; } } else { int handleHeight = tb.isFloatable() ? @@ -512,29 +526,31 @@ public class SynthToolBarUI extends BasicToolBarUI for (int i = 0; i < tb.getComponentCount(); i++) { c = tb.getComponent(i); - d = c.getPreferredSize(); - int x, w; - if (d.width >= baseW || c instanceof JSeparator) { - // Fill available width - x = baseX; - w = baseW; - } else { - // Center component horizontally in the available space - x = baseX + (baseW / 2) - (d.width / 2); - w = d.width; + if (c.isVisible()) { + d = c.getPreferredSize(); + int x, w; + if (d.width >= baseW || c instanceof JSeparator) { + // Fill available width + x = baseX; + w = baseW; + } else { + // Center component horizontally in the available space + x = baseX + (baseW / 2) - (d.width / 2); + w = d.width; + } + //if the component is a "glue" component then add to its + //height the extraSpacePerGlue it is due + if (isGlue(c)) d.height += extraSpacePerGlue; + c.setBounds(x, y, w, d.height); + y += d.height; } - //if the component is a "glue" component then add to its - //height the extraSpacePerGlue it is due - if (isGlue(c)) d.height += extraSpacePerGlue; - c.setBounds(x, y, w, d.height); - y += d.height; } } context.dispose(); } private boolean isGlue(Component c) { - if (c instanceof Box.Filler) { + if (c.isVisible() && c instanceof Box.Filler) { Box.Filler f = (Box.Filler)c; Dimension min = f.getMinimumSize(); Dimension pref = f.getPreferredSize(); diff --git a/src/share/classes/javax/swing/text/DefaultStyledDocument.java b/src/share/classes/javax/swing/text/DefaultStyledDocument.java index 79da25362..938fd84f2 100644 --- a/src/share/classes/javax/swing/text/DefaultStyledDocument.java +++ b/src/share/classes/javax/swing/text/DefaultStyledDocument.java @@ -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()]; diff --git a/src/share/classes/javax/swing/text/GlyphView.java b/src/share/classes/javax/swing/text/GlyphView.java index abb46de25..72487eafc 100644 --- a/src/share/classes/javax/swing/text/GlyphView.java +++ b/src/share/classes/javax/swing/text/GlyphView.java @@ -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; /** diff --git a/src/share/classes/javax/swing/text/Utilities.java b/src/share/classes/javax/swing/text/Utilities.java index bb0f8f3be..394bba3ed 100644 --- a/src/share/classes/javax/swing/text/Utilities.java +++ b/src/share/classes/javax/swing/text/Utilities.java @@ -404,6 +404,24 @@ public class Utilities { } /** + * Adjust text offset so that the length of a resulting string as a whole + * fits into the specified width. + */ + static int adjustOffsetForFractionalMetrics( + Segment s, FontMetrics fm, int offset, int width) { + // Sometimes the offset returned by getTabbedTextOffset is beyond the + // available area, when fractional metrics are enabled. We should + // guard against this. + if (offset < s.count) { + while (offset > 0 && + fm.charsWidth(s.array, s.offset, offset + 1) > width) { + offset--; + } + } + return offset; + } + + /** * Determine where to break the given text to fit * within the given span. This tries to find a word boundary. * @param s the source of the text @@ -425,7 +443,7 @@ public class Utilities { int txtCount = s.count; int index = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset, false); - + index = adjustOffsetForFractionalMetrics(s, metrics, index, x - x0); if (index >= txtCount - 1) { return txtCount; diff --git a/src/share/classes/javax/swing/text/WrappedPlainView.java b/src/share/classes/javax/swing/text/WrappedPlainView.java index 7d01cd904..abdaf8d5f 100644 --- a/src/share/classes/javax/swing/text/WrappedPlainView.java +++ b/src/share/classes/javax/swing/text/WrappedPlainView.java @@ -108,7 +108,7 @@ public class WrappedPlainView extends BoxView implements TabExpander { try { if (line.isLeaf()) { - drawText(line, p0, p1, g, x, y); + drawText(line, p0, p1, g, x, y); } else { // this line contains the composed text. int idx = line.getElementIndex(p0); @@ -239,9 +239,11 @@ public class WrappedPlainView extends BoxView implements TabExpander { tabBase, tabBase + currentWidth, this, p0); } else { - p = p0 + Utilities.getTabbedTextOffset(segment, metrics, - tabBase, tabBase + currentWidth, - this, p0, false); + int offset = Utilities.getTabbedTextOffset(segment, metrics, + tabBase, tabBase + currentWidth, this, p0, false); + offset = Utilities.adjustOffsetForFractionalMetrics( + segment, metrics, offset, currentWidth); + p = p0 + offset; } SegmentCache.releaseSharedSegment(segment); return p; diff --git a/src/share/classes/javax/swing/text/html/HTMLDocument.java b/src/share/classes/javax/swing/text/html/HTMLDocument.java index 5443ede76..d489b487d 100644 --- a/src/share/classes/javax/swing/text/html/HTMLDocument.java +++ b/src/share/classes/javax/swing/text/html/HTMLDocument.java @@ -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. diff --git a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine index 66b2ae9c6..607ff5905 100644 --- a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine +++ b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine @@ -1,5 +1,2 @@ -# Jules Rendering Engine module -sun.java2d.jules.JulesRenderingEngine - # Pisces Rendering Engine module -sun.java2d.pisces.PiscesRenderingEngine
\ No newline at end of file +sun.java2d.pisces.PiscesRenderingEngine diff --git a/src/share/classes/sun/swing/SwingUtilities2.java b/src/share/classes/sun/swing/SwingUtilities2.java index 6358d9870..d1385316d 100644 --- a/src/share/classes/sun/swing/SwingUtilities2.java +++ b/src/share/classes/sun/swing/SwingUtilities2.java @@ -109,6 +109,12 @@ public class SwingUtilities2 { 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. */ diff --git a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java index 8187fea6f..78207ce1c 100644 --- a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java +++ b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java @@ -127,7 +127,7 @@ public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer public static SortOrder getColumnSortOrder(JTable table, int column) { SortOrder rv = null; - if (table.getRowSorter() == null) { + if (table == null || table.getRowSorter() == null) { return rv; } java.util.List<? extends RowSorter.SortKey> sortKeys = diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_png.c b/src/share/native/sun/awt/splashscreen/splashscreen_png.c index 6c4b3a896..7a814d215 100644 --- a/src/share/native/sun/awt/splashscreen/splashscreen_png.c +++ b/src/share/native/sun/awt/splashscreen/splashscreen_png.c @@ -182,7 +182,7 @@ SplashDecodePngStream(Splash * splash, SplashStream * stream) int success = 0; stream->read(stream, sig, SIG_BYTES); - if (!png_check_sig(sig, SIG_BYTES)) { + if (png_sig_cmp(sig, 0, SIG_BYTES)) { goto done; } success = SplashDecodePng(splash, my_png_read_stream, stream); diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c index 39768c467..c132a4a5a 100644 --- a/src/share/native/sun/font/freetypeScaler.c +++ b/src/share/native/sun/font/freetypeScaler.c @@ -490,22 +490,23 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( /* ascent */ ax = 0; - ay = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.ascender + - bmodifier/2); + ay = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->ascender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* descent */ dx = 0; - dy = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.descender + - bmodifier/2); + dy = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->descender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* baseline */ bx = by = 0; /* leading */ lx = 0; - ly = (jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.height + - bmodifier) + ay - dy; + ly = (jfloat) FT26Dot6ToFloat(FT_MulFix( + (jlong) scalerInfo->face->height + bmodifier, + (jlong) scalerInfo->face->size->metrics.y_scale)) + + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance + diff --git a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java index e16c55675..582527720 100644 --- a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java +++ b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java @@ -275,7 +275,7 @@ public class XEmbeddedFramePeer extends XFramePeer { Point absoluteLoc = XlibUtil.translateCoordinates(getWindow(), XToolkit.getDefaultRootWindow(), new Point(0, 0)); - return absoluteLoc.x; + return absoluteLoc != null ? absoluteLoc.x : 0; } public int getAbsoluteY() @@ -283,7 +283,7 @@ public class XEmbeddedFramePeer extends XFramePeer { Point absoluteLoc = XlibUtil.translateCoordinates(getWindow(), XToolkit.getDefaultRootWindow(), new Point(0, 0)); - return absoluteLoc.y; + return absoluteLoc != null ? absoluteLoc.y : 0; } public int getWidth() { diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java index 0be90d02d..3b98cb032 100644 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -849,7 +849,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { // if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect // if the struts area intersects with screenBounds, however some window // managers don't set this hint correctly, so we just get intersection with windowBounds - if (windowBounds.intersects(screenBounds)) + if (windowBounds != null && windowBounds.intersects(screenBounds)) { insets.left = Math.max((int)Native.getLong(native_ptr, 0), insets.left); insets.right = Math.max((int)Native.getLong(native_ptr, 1), insets.right); @@ -1961,7 +1961,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } static long reset_time_utc; - static final long WRAP_TIME_MILLIS = Integer.MAX_VALUE; + static final long WRAP_TIME_MILLIS = 0x00000000FFFFFFFFL; /* * This function converts between the X server time (number of milliseconds diff --git a/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine b/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine new file mode 100644 index 000000000..c79fdbde9 --- /dev/null +++ b/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine @@ -0,0 +1,5 @@ +# Jules Rendering Engine module +sun.java2d.jules.JulesRenderingEngine + +# Pisces Rendering Engine module +sun.java2d.pisces.PiscesRenderingEngine diff --git a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index 717a38382..f04436422 100644 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -52,11 +52,15 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit { if (dialog != NULL) { + fp_gdk_threads_enter(); + fp_gtk_widget_hide (dialog); fp_gtk_widget_destroy (dialog); fp_gtk_main_quit (); dialog = NULL; + + fp_gdk_threads_leave(); } } @@ -162,7 +166,6 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, (*env)->GetJavaVM(env, &jvm); } - fp_gdk_threads_init(); fp_gdk_threads_enter(); const char *title = (*env)->GetStringUTFChars(env, jtitle, 0); diff --git a/src/windows/native/sun/font/fontpath.c b/src/windows/native/sun/font/fontpath.c index 67a5aec77..9c82f3dce 100644 --- a/src/windows/native/sun/font/fontpath.c +++ b/src/windows/native/sun/font/fontpath.c @@ -154,7 +154,7 @@ static int CALLBACK EnumFontFacesInFamilyProcA( fullname = JNU_NewStringPlatform(env, lpelfe->elfFullName); fullnameLC = (*env)->CallObjectMethod(env, fullname, fmi->toLowerCaseMID, fmi->locale); - (*env)->CallObjectMethod(env, fmi->list, fmi->addMID, fullname); + (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname); (*env)->CallObjectMethod(env, fmi->fontToFamilyMap, fmi->putMID, fullnameLC, fmi->family); return 1; @@ -238,7 +238,7 @@ static int CALLBACK EnumFontFacesInFamilyProcW( wcslen((LPWSTR)lpelfe->elfFullName)); fullnameLC = (*env)->CallObjectMethod(env, fullname, fmi->toLowerCaseMID, fmi->locale); - (*env)->CallObjectMethod(env, fmi->list, fmi->addMID, fullname); + (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname); (*env)->CallObjectMethod(env, fmi->fontToFamilyMap, fmi->putMID, fullnameLC, fmi->family); return 1; diff --git a/test/java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java b/test/java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java index 323ede041..f93c2cd74 100644 --- a/test/java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java +++ b/test/java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java @@ -83,6 +83,12 @@ public class FilenameFilterTest extends Applet if (fd == null) { throw new RuntimeException("fd is null (very unexpected thing :("); } + //Wait a little; some native dialog implementations may take a while + //to initialize and call the filter. See 6959787 for an example. + try { + Thread.sleep(5000); + } catch (Exception ex) { + } fd.dispose(); if (!filter_was_called) { throw new RuntimeException("Filter was not called"); diff --git a/test/javax/swing/JTable/6788484/bug6788484.java b/test/javax/swing/JTable/6788484/bug6788484.java new file mode 100644 index 000000000..cbc23310e --- /dev/null +++ b/test/javax/swing/JTable/6788484/bug6788484.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* @test + @bug 6788484 + @summary NPE in DefaultTableCellHeaderRenderer.getColumnSortOrder() with null table + @author Alexander Potochkin + @run main bug6788484 +*/ +import sun.swing.table.DefaultTableCellHeaderRenderer; + +import javax.swing.*; + +public class bug6788484 { + + public static void main(String[] args) throws Exception { + DefaultTableCellHeaderRenderer.getColumnSortOrder(null, 0); + } +} diff --git a/test/javax/swing/plaf/synth/6771547/SynthTest.java b/test/javax/swing/plaf/synth/6771547/SynthTest.java new file mode 100644 index 000000000..93921c981 --- /dev/null +++ b/test/javax/swing/plaf/synth/6771547/SynthTest.java @@ -0,0 +1,50 @@ +/* + * 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 6771547 + * @author Alexander Potochkin + * @summary SynthParser throws StringIndexOutOfBoundsException parsing custom ColorTypes + */ + +import javax.swing.plaf.synth.SynthLookAndFeel; +import javax.swing.*; +import java.io.InputStream; +import java.awt.*; + +public class SynthTest { + + public static void main(String[] args) throws Exception { + SynthLookAndFeel laf = new SynthLookAndFeel(); + InputStream in = SynthTest.class.getResourceAsStream( + "synthconfig.xml"); + laf.load(in, SynthTest.class); + + UIManager.setLookAndFeel(laf); + + if (!Color.RED.equals(new JButton().getForeground())) { + throw new RuntimeException("The wrong foreground color!"); + } + } +} diff --git a/test/javax/swing/plaf/synth/6771547/synthconfig.xml b/test/javax/swing/plaf/synth/6771547/synthconfig.xml new file mode 100644 index 000000000..48aa2e73d --- /dev/null +++ b/test/javax/swing/plaf/synth/6771547/synthconfig.xml @@ -0,0 +1,10 @@ +<synth> + <style id="button"> + <font name="Verdana" size="16"/> + <state> + <color value="RED" + type="javax.swing.plaf.synth.ColorType.FOREGROUND"/> + </state> + </style> + <bind style="button" type="region" key="button"/> +</synth> diff --git a/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java b/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java new file mode 100644 index 000000000..27e486723 --- /dev/null +++ b/test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6739756 + * @author Alexander Potochkin + * @summary JToolBar leaves space for non-visible items under Nimbus L&F + * @run main bug6739756 + */ + +import javax.swing.*; +import java.awt.*; + +public class bug6739756 { + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel( + "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + } + catch (Exception e) { + e.printStackTrace(); + return; + } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + JToolBar tb = new JToolBar(); + Dimension preferredSize = tb.getPreferredSize(); + JButton button = new JButton("Test"); + button.setVisible(false); + tb.add(button); + if (!preferredSize.equals(tb.getPreferredSize())) { + throw new RuntimeException("Toolbar's preferredSize is wrong"); + } + } + }); + } +} diff --git a/test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java b/test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java new file mode 100644 index 000000000..15619c990 --- /dev/null +++ b/test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java @@ -0,0 +1,152 @@ +/* + * 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); + } + } + }); + } +} diff --git a/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java b/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java new file mode 100644 index 000000000..a96f18e44 --- /dev/null +++ b/test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java @@ -0,0 +1,87 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import javax.swing.text.*; + +class StubBranchElement implements Element { + Document document = new DefaultStyledDocument(); + String context; + Element[] children = new StubLeafElement[3]; + + public StubBranchElement(String context) { + this.context = context; + int len = context.length() / 3; + for (int i = 0; i < 3; i++) { + children[i] = new StubLeafElement( + context.substring(len * i, len * (i + 1)), this, len * i); + } + try { + document.insertString(0, context, new SimpleAttributeSet()); + } catch (BadLocationException e) { + } + } + + public Document getDocument() { + return document; + } + + public Element getParentElement() { + return null; + } + + public String getName() { + return "StubBranchElement"; + } + + public AttributeSet getAttributes() { + return new SimpleAttributeSet(); + } + + public int getStartOffset() { + return 0; + } + + public int getEndOffset() { + return document.getLength(); + } + + public int getElementIndex(int offset) { + return offset / 3; + } + + public int getElementCount() { + return 3; + } + + public Element getElement(int index) { + return children[index]; + } + + public boolean isLeaf() { + return false; + } + + public Element[] getChildren() { + return children; + } +} diff --git a/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java b/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java new file mode 100644 index 000000000..cdaa1d132 --- /dev/null +++ b/test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java @@ -0,0 +1,81 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import javax.swing.text.*; + +class StubLeafElement implements Element { + Document document = new DefaultStyledDocument(); + String context; + Element parent; + int position; + + public StubLeafElement(String context, Element parent, int position) { + this.context = context; + this.parent = parent; + this.position = position; + try { + document.insertString(0, context, new SimpleAttributeSet()); + } catch (BadLocationException e) { + } + } + + public Document getDocument() { + return document; + } + + public Element getParentElement() { + return parent; + } + + public String getName() { + return "StubLeafElement"; + } + + public AttributeSet getAttributes() { + return new SimpleAttributeSet(); + } + + public int getStartOffset() { + return position; + } + + public int getEndOffset() { + return position + document.getLength(); + } + + public int getElementIndex(int offset) { + return 0; + } + + public int getElementCount() { + return 0; + } + + public Element getElement(int index) { + return this; + } + + public boolean isLeaf() { + return true; + } +} diff --git a/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java b/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java new file mode 100644 index 000000000..b8ad6af68 --- /dev/null +++ b/test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6857057 + * @summary test that the JCK GlyphView2021 test doesn't fail + * @author Sergey Groznyh + * @run main bug6857057 + */ + +import javax.swing.*; +import javax.swing.text.Element; +import javax.swing.text.GlyphView; +import javax.swing.text.View; + +public class bug6857057 { + + bug6857057() { + Element elem = new StubBranchElement(" G L Y P H V"); + GlyphView view = new GlyphView(elem); + float pos = elem.getStartOffset(); + float len = elem.getEndOffset() - pos; + int res = view.getBreakWeight(View.X_AXIS, pos, len); + if (res != View.ExcellentBreakWeight) { + throw new RuntimeException("breakWeight != ExcellentBreakWeight"); + } + } + + public static void main(String[] args) throws Throwable { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new bug6857057(); + } + }); + + System.out.println("OK"); + } +} |