Unverified Commit 3923076d authored by Oleksandr Karpovich's avatar Oleksandr Karpovich Committed by GitHub

change Long to Int in Line Metrics (#216)

Co-authored-by: 's avatarOleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
parent e7f21e59
...@@ -7,19 +7,19 @@ class LineMetrics( ...@@ -7,19 +7,19 @@ class LineMetrics(
/** /**
* The index in the text buffer the line begins. * The index in the text buffer the line begins.
*/ */
val startIndex: Long, val startIndex: Int,
/** /**
* The index in the text buffer the line ends. * The index in the text buffer the line ends.
*/ */
val endIndex: Long, val endIndex: Int,
/** /**
* The index in the text buffer the line ends. * The index in the text buffer the line ends.
*/ */
val endExcludingWhitespaces: Long, val endExcludingWhitespaces: Int,
/** /**
* The index in the text buffer the line begins. * The index in the text buffer the line begins.
*/ */
val endIncludingNewline: Long, val endIncludingNewline: Int,
val isHardBreak: Boolean, val isHardBreak: Boolean,
/** /**
* The final computed ascent for the line. This can be impacted by the strut, height, * The final computed ascent for the line. This can be impacted by the strut, height,
...@@ -61,7 +61,7 @@ class LineMetrics( ...@@ -61,7 +61,7 @@ class LineMetrics(
/** /**
* Zero indexed line number * Zero indexed line number
*/ */
val lineNumber: Long val lineNumber: Int
) { ) {
/** /**
* The final computed ascent for the line. This can be impacted by the strut, height, * The final computed ascent for the line. This can be impacted by the strut, height,
...@@ -156,17 +156,17 @@ class LineMetrics( ...@@ -156,17 +156,17 @@ class LineMetrics(
override fun getArraySize(array: InteropPointer) = LineMetrics_nGetArraySize(array) override fun getArraySize(array: InteropPointer) = LineMetrics_nGetArraySize(array)
override fun disposeArray(array: InteropPointer) = LineMetrics_nDisposeArray(array) override fun disposeArray(array: InteropPointer) = LineMetrics_nDisposeArray(array)
override fun getArrayElement(array: InteropPointer, index: Int): LineMetrics { override fun getArrayElement(array: InteropPointer, index: Int): LineMetrics {
val longArray = LongArray(6) val intArray = IntArray(6)
val doubleArray = DoubleArray(7) val doubleArray = DoubleArray(7)
val result = interopScope { val result = interopScope {
LineMetrics_nGetArrayElement(array, index, toInterop(longArray), toInterop(doubleArray)) LineMetrics_nGetArrayElement(array, index, toInterop(intArray), toInterop(doubleArray))
} }
return LineMetrics( return LineMetrics(
longArray[0], intArray[0],
longArray[1], intArray[1],
longArray[2], intArray[2],
longArray[3], intArray[3],
longArray[4] != 0L, intArray[4] != 0,
doubleArray[0], doubleArray[0],
doubleArray[1], doubleArray[1],
doubleArray[2], doubleArray[2],
...@@ -174,7 +174,7 @@ class LineMetrics( ...@@ -174,7 +174,7 @@ class LineMetrics(
doubleArray[4], doubleArray[4],
doubleArray[5], doubleArray[5],
doubleArray[6], doubleArray[6],
longArray[5] intArray[5]
) )
} }
} }
......
...@@ -10,7 +10,7 @@ namespace skija { ...@@ -10,7 +10,7 @@ namespace skija {
void onLoad(JNIEnv* env) { void onLoad(JNIEnv* env) {
jclass local = env->FindClass("org/jetbrains/skia/paragraph/LineMetrics"); jclass local = env->FindClass("org/jetbrains/skia/paragraph/LineMetrics");
cls = static_cast<jclass>(env->NewGlobalRef(local)); cls = static_cast<jclass>(env->NewGlobalRef(local));
ctor = env->GetMethodID(cls, "<init>", "(JJJJZDDDDDDDJ)V"); ctor = env->GetMethodID(cls, "<init>", "(IIIIZDDDDDDDI)V");
} }
void onUnload(JNIEnv* env) { void onUnload(JNIEnv* env) {
...@@ -75,6 +75,6 @@ namespace skija { ...@@ -75,6 +75,6 @@ namespace skija {
DecorationStyle::onUnload(env); DecorationStyle::onUnload(env);
TextBox::onUnload(env); TextBox::onUnload(env);
LineMetrics::onUnload(env); LineMetrics::onUnload(env);
} }
} }
} }
\ No newline at end of file
...@@ -302,6 +302,16 @@ class SkiaWindowTest { ...@@ -302,6 +302,16 @@ class SkiaWindowTest {
window.isVisible = true window.isVisible = true
delay(1000) delay(1000)
// check the line metrics
val lineMetrics = paragraph.lineMetrics
assertTrue(lineMetrics.isNotEmpty())
assertEquals(0, lineMetrics.first().startIndex)
assertEquals(5, lineMetrics.first().endIndex)
assertEquals(5, lineMetrics.first().endExcludingWhitespaces)
assertEquals(5, lineMetrics.first().endIncludingNewline)
assertEquals(true, lineMetrics.first().isHardBreak)
assertEquals(0, lineMetrics.first().lineNumber)
screenshots.assert(window.bounds) screenshots.assert(window.bounds)
} finally { } finally {
window.close() window.close()
...@@ -353,4 +363,4 @@ class SkiaWindowTest { ...@@ -353,4 +363,4 @@ class SkiaWindowTest {
} }
} }
private fun JFrame.close() = dispatchEvent(WindowEvent(this, WindowEvent.WINDOW_CLOSING)) private fun JFrame.close() = dispatchEvent(WindowEvent(this, WindowEvent.WINDOW_CLOSING))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment