Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: fpdfsdk/src/javascript/Field.cpp

Issue 1382263002: Store object definition ID in each js_class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebased Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 3302 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
3303 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 3303 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
3304 return FALSE; 3304 return FALSE;
3305 3305
3306 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 3306 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
3307 if (!pFormControl) 3307 if (!pFormControl)
3308 return FALSE; 3308 return FALSE;
3309 3309
3310 CJS_Context* pContext = (CJS_Context*)cc; 3310 CJS_Context* pContext = (CJS_Context*)cc;
3311 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 3311 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
3312 v8::Local<v8::Object> pObj = 3312 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
3313 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, 3313 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID);
3314 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
3315 ASSERT(pObj.IsEmpty() == FALSE); 3314 ASSERT(pObj.IsEmpty() == FALSE);
3316 3315
3317 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 3316 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
3318 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); 3317 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
3319 3318
3320 CPDF_Stream* pIconStream = NULL; 3319 CPDF_Stream* pIconStream = NULL;
3321 if (nface == 0) 3320 if (nface == 0)
3322 pIconStream = pFormControl->GetNormalIcon(); 3321 pIconStream = pFormControl->GetNormalIcon();
3323 else if (nface == 1) 3322 else if (nface == 1)
3324 pIconStream = pFormControl->GetDownIcon(); 3323 pIconStream = pFormControl->GetDownIcon();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 3512
3514 CJS_Context* pContext = (CJS_Context*)cc; 3513 CJS_Context* pContext = (CJS_Context*)cc;
3515 ASSERT(pContext != NULL); 3514 ASSERT(pContext != NULL);
3516 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 3515 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
3517 ASSERT(pRuntime != NULL); 3516 ASSERT(pRuntime != NULL);
3518 3517
3519 CJS_Array FormFieldArray(m_isolate); 3518 CJS_Array FormFieldArray(m_isolate);
3520 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { 3519 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) {
3521 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); 3520 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j));
3522 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( 3521 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
3523 pRuntime->GetIsolate(), pContext, 3522 pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID);
3524 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); 3523 ASSERT(!pObj.IsEmpty());
3525 ASSERT(pObj.IsEmpty() == FALSE);
3526 3524
3527 CJS_Field* pJSField = 3525 CJS_Field* pJSField =
3528 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 3526 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
3529 Field* pField = (Field*)pJSField->GetEmbedObject(); 3527 Field* pField = (Field*)pJSField->GetEmbedObject();
3530 pField->AttachField(m_pJSDoc, *pStr); 3528 pField->AttachField(m_pJSDoc, *pStr);
3531 3529
3532 CJS_Value FormFieldValue(m_isolate); 3530 CJS_Value FormFieldValue(m_isolate);
3533 FormFieldValue = pJSField; 3531 FormFieldValue = pJSField;
3534 FormFieldArray.SetElement(j, FormFieldValue); 3532 FormFieldArray.SetElement(j, FormFieldValue);
3535 } 3533 }
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 #define JS_FIELD_MINWIDTH 1 4038 #define JS_FIELD_MINWIDTH 1
4041 #define JS_FIELD_MINHEIGHT 1 4039 #define JS_FIELD_MINHEIGHT 1
4042 4040
4043 void Field::AddField(CPDFSDK_Document* pDocument, 4041 void Field::AddField(CPDFSDK_Document* pDocument,
4044 int nPageIndex, 4042 int nPageIndex,
4045 int nFieldType, 4043 int nFieldType,
4046 const CFX_WideString& sName, 4044 const CFX_WideString& sName,
4047 const CPDF_Rect& rcCoords) { 4045 const CPDF_Rect& rcCoords) {
4048 // Not supported. 4046 // Not supported.
4049 } 4047 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698