7016396: (spec) JCK test mentioned in 6735293 is still failing
Reviewed-by: alexsch
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java Mon Oct 14 13:22:36 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java Mon Oct 14 13:59:38 2013 +0400
@@ -1560,6 +1560,10 @@
* location that one might place a caret. Some views may not be visible,
* they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model.
+ * This method enables specifying a position to convert
+ * within the range of >=0. If the value is -1, a position
+ * will be calculated automatically. If the value < -1,
+ * the {@code BadLocationException} will be thrown.
*
* @param pos the position to convert >= 0
* @param a the allocated region to render into
@@ -1569,13 +1573,17 @@
* SwingConstants.NORTH, or SwingConstants.SOUTH.
* @return the location within the model that best represents the next
* location visual position.
- * @exception BadLocationException
+ * @exception BadLocationException the given position is not a valid
+ * position within the document
* @exception IllegalArgumentException for an invalid direction
*/
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException {
+ if (pos < -1) {
+ throw new BadLocationException("invalid position", pos);
+ }
if( view != null ) {
int nextPos = view.getNextVisualPositionFrom(pos, b, a,
direction, biasRet);
--- a/jdk/src/share/classes/javax/swing/text/AsyncBoxView.java Mon Oct 14 13:22:36 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/text/AsyncBoxView.java Mon Oct 14 13:59:38 2013 +0400
@@ -827,8 +827,12 @@
* location that one might place a caret. Some views may not be visible,
* they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model.
+ * This method enables specifying a position to convert
+ * within the range of >=0. If the value is -1, a position
+ * will be calculated automatically. If the value < -1,
+ * the {@code BadLocationException} will be thrown.
*
- * @param pos the position to convert >= 0
+ * @param pos the position to convert
* @param a the allocated region to render into
* @param direction the direction from the current position that can
* be thought of as the arrow keys typically found on a keyboard;
@@ -842,13 +846,17 @@
* @param biasRet an array contain the bias that was checked
* @return the location within the model that best represents the next
* location visual position
- * @exception BadLocationException
+ * @exception BadLocationException the given position is not a valid
+ * position within the document
* @exception IllegalArgumentException if <code>direction</code> is invalid
*/
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException {
+ if (pos < -1) {
+ throw new BadLocationException("invalid position", pos);
+ }
return Utilities.getNextVisualPositionFrom(
this, pos, b, a, direction, biasRet);
}
--- a/jdk/src/share/classes/javax/swing/text/CompositeView.java Mon Oct 14 13:22:36 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/text/CompositeView.java Mon Oct 14 13:59:38 2013 +0400
@@ -435,8 +435,12 @@
* might not allow access to some of the locations in the model.
* This is a convenience method for {@link #getNextNorthSouthVisualPositionFrom}
* and {@link #getNextEastWestVisualPositionFrom}.
+ * This method enables specifying a position to convert
+ * within the range of >=0. If the value is -1, a position
+ * will be calculated automatically. If the value < -1,
+ * the {@code BadLocationException} will be thrown.
*
- * @param pos the position to convert >= 0
+ * @param pos the position to convert
* @param b a bias value of either <code>Position.Bias.Forward</code>
* or <code>Position.Bias.Backward</code>
* @param a the allocated region to render into
@@ -452,12 +456,16 @@
* @param biasRet an array containing the bias that was checked
* @return the location within the model that best represents the next
* location visual position
- * @exception BadLocationException
+ * @exception BadLocationException the given position is not a valid
+ * position within the document
* @exception IllegalArgumentException if <code>direction</code> is invalid
*/
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
int direction, Position.Bias[] biasRet)
throws BadLocationException {
+ if (pos < -1) {
+ throw new BadLocationException("invalid position", pos);
+ }
Rectangle alloc = getInsideAllocation(a);
switch (direction) {
--- a/jdk/src/share/classes/javax/swing/text/GlyphView.java Mon Oct 14 13:22:36 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/text/GlyphView.java Mon Oct 14 13:59:38 2013 +0400
@@ -879,8 +879,12 @@
* visible, they might not be in the same order found in the model, or
* they just might not allow access to some of the locations in the
* model.
+ * This method enables specifying a position to convert
+ * within the range of >=0. If the value is -1, a position
+ * will be calculated automatically. If the value < -1,
+ * the {@code BadLocationException} will be thrown.
*
- * @param pos the position to convert >= 0
+ * @param pos the position to convert
* @param a the allocated region to render into
* @param direction the direction from the current position that can
* be thought of as the arrow keys typically found on a keyboard.
@@ -888,7 +892,8 @@
* SwingConstants.NORTH, or SwingConstants.SOUTH.
* @return the location within the model that best represents the next
* location visual position.
- * @exception BadLocationException
+ * @exception BadLocationException the given position is not a valid
+ * position within the document
* @exception IllegalArgumentException for an invalid direction
*/
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
@@ -896,6 +901,9 @@
Position.Bias[] biasRet)
throws BadLocationException {
+ if (pos < -1) {
+ throw new BadLocationException("invalid position", pos);
+ }
return painter.getNextVisualPositionFrom(this, pos, b, a, direction, biasRet);
}
--- a/jdk/src/share/classes/javax/swing/text/View.java Mon Oct 14 13:22:36 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/text/View.java Mon Oct 14 13:59:38 2013 +0400
@@ -476,8 +476,12 @@
* Some views may not be visible,
* they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model.
+ * This method enables specifying a position to convert
+ * within the range of >=0. If the value is -1, a position
+ * will be calculated automatically. If the value < -1,
+ * the {@code BadLocationException} will be thrown.
*
- * @param pos the position to convert >= 0
+ * @param pos the position to convert
* @param a the allocated region in which to render
* @param direction the direction from the current position that can
* be thought of as the arrow keys typically found on a keyboard.
@@ -490,7 +494,8 @@
* </ul>
* @return the location within the model that best represents the next
* location visual position
- * @exception BadLocationException
+ * @exception BadLocationException the given position is not a valid
+ * position within the document
* @exception IllegalArgumentException if <code>direction</code>
* doesn't have one of the legal values above
*/