changeset 7743:e4d86f6cd678

RT-37092: (cont.) Revert workaround for test failure and fix StubTextLayout instead. Reviewed-by: fheidric
author leifs
date Wed, 20 Aug 2014 14:49:16 -0700
parents ad87c1b0b658
children a3d4992f65ea
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java modules/graphics/src/test/java/com/sun/javafx/pgstub/StubTextLayout.java
diffstat 2 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Wed Aug 20 07:00:02 2014 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Wed Aug 20 14:49:16 2014 -0700
@@ -59,7 +59,6 @@
 import com.sun.javafx.scene.control.behavior.TextBinding;
 import com.sun.javafx.scene.text.HitInfo;
 import com.sun.javafx.scene.text.TextLayout;
-import com.sun.javafx.scene.text.TextLine;
 import com.sun.javafx.tk.Toolkit;
 import javafx.util.Callback;
 
@@ -111,13 +110,8 @@
             layout.setBoundsType(0);
         }
 
-        TextLine[] textLines = layout.getLines();
-        if (textLines != null && textLines.length > 0) {
-            // RT-37092: Use the line bounds specifically, to include font leading.
-            return textLines[0].getBounds().getHeight();
-        } else {
-            return layout.getBounds().getHeight();
-        }
+        // RT-37092: Use the line bounds specifically, to include font leading.
+        return layout.getLines()[0].getBounds().getHeight();
     }
 
     static double computeTextWidth(Font font, String text, double wrappingWidth) {
--- a/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubTextLayout.java	Wed Aug 20 07:00:02 2014 -0700
+++ b/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubTextLayout.java	Wed Aug 20 14:49:16 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -93,9 +93,30 @@
                 (float)width, (float)(height-fontSize), 0);
     }
 
+    class StubTextLine implements TextLine {
+        @Override public GlyphList[] getRuns() {
+            return new GlyphList[0];
+        }
+        @Override public RectBounds getBounds() {
+            return new RectBounds();
+        }
+        @Override public float getLeftSideBearing() {
+            return 0;
+        }
+        @Override public float getRightSideBearing() {
+            return 0;
+        }
+        @Override public int getStart() {
+            return 0;
+        }
+        @Override public int getLength() {
+            return 0;
+        }
+    }
+
     @Override
     public TextLine[] getLines() {
-        return null;
+        return new TextLine[] {new StubTextLine()};
     }
 
     @Override