Field* CJS_EventHandler::Target_Field() {
  CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
  v8::Local<v8::Object> pDocObj =
      pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
  if (pDocObj.IsEmpty())
    return nullptr;

  v8::Local<v8::Object> pFieldObj =
      pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
  if (pFieldObj.IsEmpty())
    return nullptr;

  CJS_Document* pJSDocument =
      static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
  CJS_Field* pJSField =
      static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));

  Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
  pDocument->SetFormFillEnv(m_pTargetFormFillEnv
                                ? m_pTargetFormFillEnv.Get()
                                : m_pJSEventContext->GetFormFillEnv());

  Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
  pField->AttachField(pDocument, m_strTargetName);
  return pField;
}
Field* CJS_EventHandler::Target_Field() {
  CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
  v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
      pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID);
  ASSERT(!pDocObj.IsEmpty());

  v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
      pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID);
  ASSERT(!pFieldObj.IsEmpty());

  CJS_Document* pJSDocument =
      (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
  Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
  pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
                                    : m_pJSContext->GetReaderDocument());

  CJS_Field* pJSField =
      (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj);
  Field* pField = (Field*)pJSField->GetEmbedObject();
  pField->AttachField(pDocument, m_strTargetName);
  return pField;
}
Exemple #3
0
void CJS_Runtime::SetFormFillEnvToDocument() {
  v8::Isolate::Scope isolate_scope(GetIsolate());
  v8::HandleScope handle_scope(GetIsolate());
  v8::Local<v8::Context> context = NewLocalContext();
  v8::Context::Scope context_scope(context);

  v8::Local<v8::Object> pThis = GetThisObj();
  if (pThis.IsEmpty())
    return;

  if (CFXJS_Engine::GetObjDefnID(pThis) != CJS_Document::g_nObjDefnID)
    return;

  CJS_Document* pJSDocument =
      static_cast<CJS_Document*>(GetObjectPrivate(pThis));
  if (!pJSDocument)
    return;

  Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
  if (!pDocument)
    return;

  pDocument->SetFormFillEnv(m_pFormFillEnv.Get());
}