void RenderHandler::OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) { JNIEnv* env = GetJNIEnv(); if (!env) return; jobject rect_obj = NewJNIRect(env, rect); if (!rect_obj) return; JNI_CALL_VOID_METHOD(env, jhandler_, "onPopupSize", "(Lorg/cef/browser/CefBrowser;Ljava/awt/Rectangle;)V", GetJNIBrowser(browser), rect_obj); env->DeleteLocalRef(rect_obj); }
jobjectArray NewJNIRectArray(JNIEnv* env, const std::vector<CefRect>& vals) { if(vals.empty()) return NULL; jclass cls = env->FindClass("java/awt/Rectangle"); if (!cls) return NULL; jobjectArray arr = env->NewObjectArray( static_cast<jsize>(vals.size()), cls, NULL); for(jsize i = 0; i < static_cast<jsize>(vals.size()); i++) env->SetObjectArrayElement(arr, i, NewJNIRect(env, vals[i])); return arr; }