Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Release notes on GitHub are taken from the matching section here.

### Fixed

- Text typed into Roblox's search bar and other TextBoxes is no longer invisible when Roblox enables
`UseUIPaddingInNativeInputs4` (the 19-argument `NativeTextBoxInfo` constructor with UI padding).
- Blocking and unblocking players works when Nightcap has no saved `RBXEventTrackerV2` cookie. Roblox refused
those requests with "BrowserTrackerID is missing or invalid"; Nightcap now sends its browser tracker.
- Games that size their UI by screen size, such as Racket Rivals, no longer show a tiny phone layout. Nightcap
Expand Down
4 changes: 4 additions & 0 deletions include/jnivm/jnivm.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ struct RobloxTextBoxInfo {
int return_key_type = 0;
bool manual_focus_release = false;
bool text_wrapped = false;
float padding_left = 0.0f;
float padding_top = 0.0f;
float padding_right = 0.0f;
float padding_bottom = 0.0f;
};

struct RobloxTextInputShowRequest {
Expand Down
4 changes: 4 additions & 0 deletions include/runtime/roblox_native_text_box_info_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ struct RobloxNativeTextBoxInfoSnapshot {
int return_key_type = 0;
bool manual_focus_release = false;
bool text_wrapped = false;
float padding_left = 0.0F;
float padding_top = 0.0F;
float padding_right = 0.0F;
float padding_bottom = 0.0F;
};

struct RobloxNativeTextBoxInfoQueryResult {
Expand Down
4 changes: 4 additions & 0 deletions include/runtime/roblox_text_display_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ struct RobloxTextOverlayPresentation {
int32_t font = 0;
int32_t text_input_type = 0;
bool text_wrapped = false;
int32_t padding_left = 0;
int32_t padding_top = 0;
int32_t padding_right = 0;
int32_t padding_bottom = 0;
std::string display_utf8;
std::size_t caret_utf8_byte = 0;
std::size_t selection_begin_utf8_byte = 0;
Expand Down
12 changes: 12 additions & 0 deletions include/runtime/roblox_text_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct RobloxTextFocusSession {
int32_t text_input_type = 0;
int32_t return_key_type = 0;
bool text_wrapped = false;
int32_t padding_left = 0;
int32_t padding_top = 0;
int32_t padding_right = 0;
int32_t padding_bottom = 0;
};

// Non-text properties returned by NativeGLInterface.nativeGetTextBoxInfo.
Expand All @@ -53,6 +57,10 @@ struct RobloxTextFocusProperties {
int32_t text_input_type = 0;
int32_t return_key_type = 0;
bool text_wrapped = false;
int32_t padding_left = 0;
int32_t padding_top = 0;
int32_t padding_right = 0;
int32_t padding_bottom = 0;
};

enum class RobloxTextDisplayEvent { kShow, kUpdate, kHide };
Expand All @@ -74,6 +82,10 @@ struct RobloxTextDisplayUpdate {
int32_t font = 0;
int32_t text_input_type = 0;
bool text_wrapped = false;
int32_t padding_left = 0;
int32_t padding_top = 0;
int32_t padding_right = 0;
int32_t padding_bottom = 0;
const char* utf8 = nullptr;
std::size_t utf8_size = 0;
int32_t cursor_utf16 = 0;
Expand Down
61 changes: 51 additions & 10 deletions src/jnivm/jnivm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,10 @@ jobject MakeNativeTextBoxInfoObject() {
SetBooleanFieldRaw(object, "secureTextEntry", JNI_FALSE);
SetBooleanFieldRaw(object, "showKeyboard", JNI_FALSE);
SetBooleanFieldRaw(object, "editable", JNI_FALSE);
SetFloatFieldRaw(object, "paddingLeft", 0.0f);
SetFloatFieldRaw(object, "paddingTop", 0.0f);
SetFloatFieldRaw(object, "paddingRight", 0.0f);
SetFloatFieldRaw(object, "paddingBottom", 0.0f);
return object;
}

Expand Down Expand Up @@ -2452,21 +2456,36 @@ constexpr char kRobloxNativeHelperClass[] =
"com/roblox/client/startup/NativeHelper";
constexpr char kRobloxShowKeyboardSignature[] =
"(JZ[BLcom/roblox/engine/jni/model/NativeTextBoxInfo;)V";
constexpr char kRobloxLegacyTextBoxInfoConstructor[] = "(FFFFFZIIIIIIZZ)V";
constexpr char kRobloxTextBoxInfoConstructor[] = "(FFFFFZIIIIIIZZZ)V";
constexpr char kRobloxTextBoxInfoBasePrefix[] = "(FFFFFZIIIIIIZZ";
constexpr std::size_t kRobloxTextBoxInfoBasePrefixLength =
sizeof(kRobloxTextBoxInfoBasePrefix) - 1;

bool IsRobloxTextBoxInfoConstructor(jmethodID method_id) {
if (MethodOf(method_id) != JniMethod::kConstructor) {
return false;
}
const char* signature = MethodSignature(method_id);
return std::strcmp(signature, kRobloxLegacyTextBoxInfoConstructor) == 0 ||
std::strcmp(signature, kRobloxTextBoxInfoConstructor) == 0;
const std::size_t length = std::strlen(signature);
// Matches legacy (FFFFFZIIIIIIZZ)V, editable (FFFFFZIIIIIIZZZ)V,
// UIPadding (FFFFFZIIIIIIZZZFFFF)V, and any future overload that only
// appends trailing fields after the 14 base arguments.
return length >= kRobloxTextBoxInfoBasePrefixLength + 2 &&
std::strncmp(signature, kRobloxTextBoxInfoBasePrefix,
kRobloxTextBoxInfoBasePrefixLength) == 0 &&
signature[length - 2] == ')' && signature[length - 1] == 'V';
}

bool HasRobloxTextBoxEditableArgument(jmethodID method_id) {
return std::strcmp(MethodSignature(method_id),
kRobloxTextBoxInfoConstructor) == 0;
const char* signature = MethodSignature(method_id);
return IsRobloxTextBoxInfoConstructor(method_id) &&
signature[kRobloxTextBoxInfoBasePrefixLength] == 'Z';
}

bool HasRobloxTextBoxPaddingArguments(jmethodID method_id) {
const char* signature = MethodSignature(method_id);
return IsRobloxTextBoxInfoConstructor(method_id) &&
std::strncmp(signature + kRobloxTextBoxInfoBasePrefixLength, "ZFFFF",
5) == 0;
}

void ClearSensitiveString(std::string* value) {
Expand Down Expand Up @@ -2565,6 +2584,10 @@ bool SnapshotRobloxTextInputShow(jlong text_box, jboolean show_native_input,
snapshot.info.manual_focus_release =
BooleanFieldValue(info_object, "manualFocusRelease");
snapshot.info.text_wrapped = BooleanFieldValue(info_object, "textWrapped");
snapshot.info.padding_left = FloatFieldValue(info_object, "paddingLeft");
snapshot.info.padding_top = FloatFieldValue(info_object, "paddingTop");
snapshot.info.padding_right = FloatFieldValue(info_object, "paddingRight");
snapshot.info.padding_bottom = FloatFieldValue(info_object, "paddingBottom");
*request = std::move(snapshot);
return true;
}
Expand Down Expand Up @@ -4174,15 +4197,26 @@ jobject ConstructObjectV(jclass clazz, jmethodID methodID, va_list args) {
SetBooleanFieldRaw(object, "editable",
static_cast<jboolean>(va_arg(args, jint)));
}
if (HasRobloxTextBoxPaddingArguments(methodID)) {
SetFloatFieldRaw(object, "paddingLeft",
static_cast<jfloat>(va_arg(args, double)));
SetFloatFieldRaw(object, "paddingTop",
static_cast<jfloat>(va_arg(args, double)));
SetFloatFieldRaw(object, "paddingRight",
static_cast<jfloat>(va_arg(args, double)));
SetFloatFieldRaw(object, "paddingBottom",
static_cast<jfloat>(va_arg(args, double)));
}
} else if (object_class->GetName() ==
"com/roblox/engine/jni/model/NativeTextBoxInfo" &&
MethodOf(methodID) == JniMethod::kConstructor &&
std::strcmp(
MethodSignature(methodID),
"(Lcom/roblox/engine/jni/model/NativeTextBoxInfo;)V") == 0) {
const jobject source = va_arg(args, jobject);
constexpr const char *kFloatFields[] = {"x", "y", "width", "height",
"fontSize"};
constexpr const char *kFloatFields[] = {
"x", "y", "width", "height", "fontSize",
"paddingLeft", "paddingTop", "paddingRight", "paddingBottom"};
for (const char *field : kFloatFields) {
SetFloatFieldRaw(object, field, FloatFieldValue(source, field));
}
Expand Down Expand Up @@ -4256,15 +4290,22 @@ jobject ConstructObjectA(jclass clazz, jmethodID methodID, const jvalue *args) {
if (HasRobloxTextBoxEditableArgument(methodID)) {
SetBooleanFieldRaw(object, "editable", args[14].z);
}
if (HasRobloxTextBoxPaddingArguments(methodID)) {
SetFloatFieldRaw(object, "paddingLeft", args[15].f);
SetFloatFieldRaw(object, "paddingTop", args[16].f);
SetFloatFieldRaw(object, "paddingRight", args[17].f);
SetFloatFieldRaw(object, "paddingBottom", args[18].f);
}
} else if (object_class->GetName() ==
"com/roblox/engine/jni/model/NativeTextBoxInfo" &&
MethodOf(methodID) == JniMethod::kConstructor &&
std::strcmp(
MethodSignature(methodID),
"(Lcom/roblox/engine/jni/model/NativeTextBoxInfo;)V") == 0) {
const jobject source = args[0].l;
constexpr const char *kFloatFields[] = {"x", "y", "width", "height",
"fontSize"};
constexpr const char *kFloatFields[] = {
"x", "y", "width", "height", "fontSize",
"paddingLeft", "paddingTop", "paddingRight", "paddingBottom"};
for (const char *field : kFloatFields) {
SetFloatFieldRaw(object, field, FloatFieldValue(source, field));
}
Expand Down
31 changes: 31 additions & 0 deletions src/runtime/roblox_native_text_box_info_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ Status ReadFloat(JNIEnv* env, jclass info_class, jobject info, const char* name,
return CheckJni(env, name);
}

Status ReadOptionalFloat(JNIEnv* env, jclass info_class, jobject info,
const char* name, float* value) {
jfieldID field = env->GetFieldID(info_class, name, "F");
Status status = CheckJni(env, name);
if (!status.ok()) {
return status;
}
if (field == nullptr) {
*value = 0.0F;
return Status::Ok();
}
*value = env->GetFloatField(info, field);
return CheckJni(env, name);
}

Status ReadInt(JNIEnv* env, jclass info_class, jobject info, const char* name,
int* value) {
jfieldID field = nullptr;
Expand Down Expand Up @@ -134,6 +149,22 @@ Status Snapshot(JNIEnv* env, jobject info,
status = ReadBoolean(env, info_class, info, "textWrapped",
&candidate.text_wrapped);
}
if (status.ok()) {
status = ReadOptionalFloat(env, info_class, info, "paddingLeft",
&candidate.padding_left);
}
if (status.ok()) {
status = ReadOptionalFloat(env, info_class, info, "paddingTop",
&candidate.padding_top);
}
if (status.ok()) {
status = ReadOptionalFloat(env, info_class, info, "paddingRight",
&candidate.padding_right);
}
if (status.ok()) {
status = ReadOptionalFloat(env, info_class, info, "paddingBottom",
&candidate.padding_bottom);
}

env->DeleteLocalRef(info_class);
const Status delete_status = CheckJni(env, "DeleteLocalRef(class)");
Expand Down
16 changes: 16 additions & 0 deletions src/runtime/roblox_text_display_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ RobloxTextOverlayPresentation::RobloxTextOverlayPresentation(
font(other.font),
text_input_type(other.text_input_type),
text_wrapped(other.text_wrapped),
padding_left(other.padding_left),
padding_top(other.padding_top),
padding_right(other.padding_right),
padding_bottom(other.padding_bottom),
display_utf8(other.display_utf8),
caret_utf8_byte(other.caret_utf8_byte),
selection_begin_utf8_byte(other.selection_begin_utf8_byte),
Expand All @@ -149,6 +153,10 @@ RobloxTextOverlayPresentation& RobloxTextOverlayPresentation::operator=(
font = other.font;
text_input_type = other.text_input_type;
text_wrapped = other.text_wrapped;
padding_left = other.padding_left;
padding_top = other.padding_top;
padding_right = other.padding_right;
padding_bottom = other.padding_bottom;
display_utf8 = other.display_utf8;
caret_utf8_byte = other.caret_utf8_byte;
selection_begin_utf8_byte = other.selection_begin_utf8_byte;
Expand All @@ -170,6 +178,10 @@ void RobloxTextOverlayPresentation::ClearSensitive() {
font = 0;
text_input_type = 0;
text_wrapped = false;
padding_left = 0;
padding_top = 0;
padding_right = 0;
padding_bottom = 0;
caret_utf8_byte = 0;
selection_begin_utf8_byte = 0;
selection_end_utf8_byte = 0;
Expand Down Expand Up @@ -236,6 +248,10 @@ Status BuildRobloxTextOverlayPresentation(
candidate.font = update.font;
candidate.text_input_type = update.text_input_type;
candidate.text_wrapped = update.text_wrapped;
candidate.padding_left = std::max(0, update.padding_left);
candidate.padding_top = std::max(0, update.padding_top);
candidate.padding_right = std::max(0, update.padding_right);
candidate.padding_bottom = std::max(0, update.padding_bottom);

std::size_t codepoints_before_cursor = 0;
const std::size_t caret_source_byte = Utf8ByteForUtf16Cursor(
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/roblox_text_editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ Status RobloxTextEditor::UpdateFocusProperties(
session_.text_input_type = properties.text_input_type;
session_.return_key_type = properties.return_key_type;
session_.text_wrapped = properties.text_wrapped;
session_.padding_left = properties.padding_left;
session_.padding_top = properties.padding_top;
session_.padding_right = properties.padding_right;
session_.padding_bottom = properties.padding_bottom;
PublishDisplayLocked(RobloxTextDisplayEvent::kUpdate);
return Status::Ok();
}
Expand Down Expand Up @@ -755,6 +759,10 @@ void RobloxTextEditor::PublishDisplayLocked(RobloxTextDisplayEvent event) {
update.font = session_.font;
update.text_input_type = session_.text_input_type;
update.text_wrapped = session_.text_wrapped;
update.padding_left = session_.padding_left;
update.padding_top = session_.padding_top;
update.padding_right = session_.padding_right;
update.padding_bottom = session_.padding_bottom;
if (event != RobloxTextDisplayEvent::kHide) {
update.utf8 = text_.data();
update.utf8_size = text_.size();
Expand Down
22 changes: 21 additions & 1 deletion src/runtime/roblox_text_input_jni_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ bool SameTextBoxInfo(const jnivm::RobloxTextBoxInfo& left,
left.text_input_type == right.text_input_type &&
left.return_key_type == right.return_key_type &&
left.manual_focus_release == right.manual_focus_release &&
left.text_wrapped == right.text_wrapped;
left.text_wrapped == right.text_wrapped &&
left.padding_left == right.padding_left &&
left.padding_top == right.padding_top &&
left.padding_right == right.padding_right &&
left.padding_bottom == right.padding_bottom;
}

void PreserveGeometry(const jnivm::RobloxTextBoxInfo& source,
Expand All @@ -73,6 +77,10 @@ void PreserveGeometry(const jnivm::RobloxTextBoxInfo& source,
destination->y = source.y;
destination->width = source.width;
destination->height = source.height;
destination->padding_left = source.padding_left;
destination->padding_top = source.padding_top;
destination->padding_right = source.padding_right;
destination->padding_bottom = source.padding_bottom;
}

jnivm::RobloxTextBoxInfo ToTextBoxInfo(
Expand All @@ -92,6 +100,10 @@ jnivm::RobloxTextBoxInfo ToTextBoxInfo(
info.return_key_type = snapshot.return_key_type;
info.manual_focus_release = snapshot.manual_focus_release;
info.text_wrapped = snapshot.text_wrapped;
info.padding_left = snapshot.padding_left;
info.padding_top = snapshot.padding_top;
info.padding_right = snapshot.padding_right;
info.padding_bottom = snapshot.padding_bottom;
return info;
}

Expand All @@ -112,6 +124,10 @@ RobloxTextFocusProperties ToFocusProperties(
properties.text_input_type = info.text_input_type;
properties.return_key_type = info.return_key_type;
properties.text_wrapped = info.text_wrapped;
properties.padding_left = RoundedCoordinate(info.padding_left);
properties.padding_top = RoundedCoordinate(info.padding_top);
properties.padding_right = RoundedCoordinate(info.padding_right);
properties.padding_bottom = RoundedCoordinate(info.padding_bottom);
return properties;
}

Expand Down Expand Up @@ -657,6 +673,10 @@ struct RobloxTextInputJniBridge::State {
session.text_input_type = command.info.text_input_type;
session.return_key_type = command.info.return_key_type;
session.text_wrapped = command.info.text_wrapped;
session.padding_left = RoundedCoordinate(command.info.padding_left);
session.padding_top = RoundedCoordinate(command.info.padding_top);
session.padding_right = RoundedCoordinate(command.info.padding_right);
session.padding_bottom = RoundedCoordinate(command.info.padding_bottom);
status = backend->BeginTextFocusSession(std::move(session));
const window::TextInputOptions options{command.info.text_input_type,
command.info.multiline};
Expand Down
20 changes: 13 additions & 7 deletions src/runtime/roblox_text_surface_overlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,17 @@ Status RobloxTextSurfaceOverlay::RasterizeLocked() {
static_cast<std::size_t>(width * height * 4), 0);
const int frame_width = static_cast<int>(width);
const int frame_height = static_cast<int>(height);
// Use Roblox's text bounds directly. Extra padding shifts the native text
// origin, scrolls long lines too early and clips compact chat fields.
const int clip_left = 0;
const int clip_right = frame_width;
const int clip_top = 0;
const int clip_bottom = frame_height;
// Apply only the UIPadding Roblox reports in NativeTextBoxInfo; when unset
// (0), use Roblox's text bounds directly. Clamp so padding can never invert
// or collapse the drawable clip box.
const int clip_left =
std::clamp(presentation.padding_left, 0, std::max(0, frame_width - 1));
const int clip_right = std::clamp(frame_width - presentation.padding_right,
clip_left + 1, frame_width);
const int clip_top =
std::clamp(presentation.padding_top, 0, std::max(0, frame_height - 1));
const int clip_bottom = std::clamp(frame_height - presentation.padding_bottom,
clip_top + 1, frame_height);
const int available_width = std::max(1, clip_right - clip_left);
const bool wrapped_layout =
presentation.multiline || presentation.text_wrapped;
Expand Down Expand Up @@ -612,7 +617,8 @@ Status RobloxTextSurfaceOverlay::RasterizeLocked() {
}
int text_y = clip_top;
if (presentation.y_alignment == 1) {
text_y = std::max(clip_top, (frame_height - text_height) / 2);
text_y = std::max(
clip_top, clip_top + ((clip_bottom - clip_top) - text_height) / 2);
} else if (presentation.y_alignment == 2) {
text_y = std::max(clip_top, clip_bottom - text_height);
}
Expand Down
Loading