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

Side by Side Diff: fpdfsdk/src/javascript/JS_Runtime.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_EventHandler.h" 9 #include "../../include/javascript/JS_EventHandler.h"
10 #include "../../include/javascript/JS_Runtime.h" 10 #include "../../include/javascript/JS_Runtime.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 void CJS_Runtime::DefineJSObjects() { 74 void CJS_Runtime::DefineJSObjects() {
75 v8::Isolate::Scope isolate_scope(GetIsolate()); 75 v8::Isolate::Scope isolate_scope(GetIsolate());
76 v8::HandleScope handle_scope(GetIsolate()); 76 v8::HandleScope handle_scope(GetIsolate());
77 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); 77 v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
78 v8::Context::Scope context_scope(context); 78 v8::Context::Scope context_scope(context);
79 79
80 // The call order determines the "ObjDefID" assigned to each class. 80 // The call order determines the "ObjDefID" assigned to each class.
81 // ObjDefIDs 0 - 2 81 // ObjDefIDs 0 - 2
82 CJS_Border::DefineJSObjects(GetIsolate(), FXJS_STATIC); 82 CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
83 CJS_Display::DefineJSObjects(GetIsolate(), FXJS_STATIC); 83 CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
84 CJS_Font::DefineJSObjects(GetIsolate(), FXJS_STATIC); 84 CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
85 85
86 // ObjDefIDs 3 - 5 86 // ObjDefIDs 3 - 5
87 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJS_STATIC); 87 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
88 CJS_Position::DefineJSObjects(GetIsolate(), FXJS_STATIC); 88 CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
89 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJS_STATIC); 89 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
90 90
91 // ObjDefIDs 6 - 8 91 // ObjDefIDs 6 - 8
92 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJS_STATIC); 92 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
93 CJS_Style::DefineJSObjects(GetIsolate(), FXJS_STATIC); 93 CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
94 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJS_STATIC); 94 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
95 95
96 // ObjDefIDs 9 - 11 96 // ObjDefIDs 9 - 11
97 CJS_App::DefineJSObjects(GetIsolate(), FXJS_STATIC); 97 CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
98 CJS_Color::DefineJSObjects(GetIsolate(), FXJS_STATIC); 98 CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
99 CJS_Console::DefineJSObjects(GetIsolate(), FXJS_STATIC); 99 CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
100 100
101 // ObjDefIDs 12 - 14 101 // ObjDefIDs 12 - 14
102 CJS_Document::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); 102 CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL);
103 CJS_Event::DefineJSObjects(GetIsolate(), FXJS_STATIC); 103 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
104 CJS_Field::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); 104 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
105 105
106 // ObjDefIDs 15 - 17 106 // ObjDefIDs 15 - 17
107 CJS_Global::DefineJSObjects(GetIsolate(), FXJS_STATIC); 107 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
108 CJS_Icon::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); 108 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
109 CJS_Util::DefineJSObjects(GetIsolate(), FXJS_STATIC); 109 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
110 110
111 // ObjDefIDs 18 - 20 (these can't fail, return void). 111 // ObjDefIDs 18 - 20 (these can't fail, return void).
112 CJS_PublicMethods::DefineJSObjects(GetIsolate()); 112 CJS_PublicMethods::DefineJSObjects(GetIsolate());
113 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); 113 CJS_GlobalConsts::DefineJSObjects(GetIsolate());
114 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); 114 CJS_GlobalArrays::DefineJSObjects(GetIsolate());
115 115
116 // ObjDefIDs 21 - 22. 116 // ObjDefIDs 21 - 22.
117 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); 117 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
118 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); 118 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
119 } 119 }
120 120
121 IFXJS_Context* CJS_Runtime::NewContext() { 121 IFXJS_Context* CJS_Runtime::NewContext() {
122 CJS_Context* p = new CJS_Context(this); 122 CJS_Context* p = new CJS_Context(this);
123 m_ContextArray.Add(p); 123 m_ContextArray.Add(p);
124 return p; 124 return p;
125 } 125 }
126 126
127 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { 127 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) {
128 CJS_Context* pJSContext = (CJS_Context*)pContext; 128 CJS_Context* pJSContext = (CJS_Context*)pContext;
(...skipping 18 matching lines...) Expand all
147 v8::Isolate::Scope isolate_scope(m_isolate); 147 v8::Isolate::Scope isolate_scope(m_isolate);
148 v8::HandleScope handle_scope(m_isolate); 148 v8::HandleScope handle_scope(m_isolate);
149 v8::Local<v8::Context> context = 149 v8::Local<v8::Context> context =
150 v8::Local<v8::Context>::New(m_isolate, m_context); 150 v8::Local<v8::Context>::New(m_isolate, m_context);
151 v8::Context::Scope context_scope(context); 151 v8::Context::Scope context_scope(context);
152 152
153 m_pDocument = pReaderDoc; 153 m_pDocument = pReaderDoc;
154 if (pReaderDoc) { 154 if (pReaderDoc) {
155 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate()); 155 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate());
156 if (!pThis.IsEmpty()) { 156 if (!pThis.IsEmpty()) {
157 if (FXJS_GetObjDefnID(pThis) == 157 if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) {
158 FXJS_GetObjDefnID(GetIsolate(), L"Document")) {
159 if (CJS_Document* pJSDocument = 158 if (CJS_Document* pJSDocument =
160 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) { 159 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) {
161 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) 160 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
162 pDocument->AttachDoc(pReaderDoc); 161 pDocument->AttachDoc(pReaderDoc);
163 } 162 }
164 } 163 }
165 } 164 }
166 } 165 }
167 } 166 }
168 } 167 }
(...skipping 18 matching lines...) Expand all
187 void CJS_Runtime::RemoveObserver(Observer* observer) { 186 void CJS_Runtime::RemoveObserver(Observer* observer) {
188 ASSERT(m_observers.find(observer) != m_observers.end()); 187 ASSERT(m_observers.find(observer) != m_observers.end());
189 m_observers.erase(observer); 188 m_observers.erase(observer);
190 } 189 }
191 190
192 CFX_WideString ChangeObjName(const CFX_WideString& str) { 191 CFX_WideString ChangeObjName(const CFX_WideString& str) {
193 CFX_WideString sRet = str; 192 CFX_WideString sRet = str;
194 sRet.Replace(L"_", L"."); 193 sRet.Replace(L"_", L".");
195 return sRet; 194 return sRet;
196 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698