summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-04 16:39:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-04 16:39:06 +0000
commitddf945fc297356062eb8ba07b2d58e65a09b152b (patch)
tree36ba73d65c709547f64eca8310c8c01a181c3dbd
parentd1fe53b26814f711b37e77fedaf371393423b779 (diff)
downloadpdfium-ddf945fc297356062eb8ba07b2d58e65a09b152b.tar.xz
Cleanup CFXJSE_Engine visibility
This CL makes CFXJSE_Engine methods private where possible and shuffles static methods to the top of the declarations. Change-Id: Ife84ce30d00e126bcbc5cb86d1a189eec2c7cb1c Reviewed-on: https://pdfium-review.googlesource.com/20310 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cfxjse_engine.cpp94
-rw-r--r--fxjs/cfxjse_engine.h71
2 files changed, 79 insertions, 86 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 3ba6a3699f..cc4f85554b 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -122,7 +122,6 @@ CFXJSE_Engine::CFXJSE_Engine(CXFA_Document* pDocument, v8::Isolate* pIsolate)
m_pScriptNodeArray(nullptr),
m_ResolveProcessor(pdfium::MakeUnique<CFXJSE_ResolveProcessor>()),
m_pThisObject(nullptr),
- m_dwBuiltInInFlags(0),
m_eRunAtType(XFA_AttributeEnum::Client) {
RemoveBuiltInObjs(m_JsContext.get());
m_JsContext->EnableCompatibleMode();
@@ -165,6 +164,32 @@ bool CFXJSE_Engine::RunScript(CXFA_ScriptData::Type eScriptType,
return m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
}
+bool CFXJSE_Engine::QueryNodeByFlag(CXFA_Node* refNode,
+ const WideStringView& propname,
+ CFXJSE_Value* pValue,
+ uint32_t dwFlag,
+ bool bSetting) {
+ if (!refNode)
+ return false;
+
+ XFA_RESOLVENODE_RS resolveRs;
+ if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0)
+ return false;
+ if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) {
+ pValue->Assign(GetJSValueFromMap(resolveRs.objects.front()));
+ return true;
+ }
+ if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Attribute) {
+ const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute;
+ if (lpAttributeInfo) {
+ CJX_Object* jsObject = resolveRs.objects.front()->JSObject();
+ (jsObject->*(lpAttributeInfo->callback))(pValue, bSetting,
+ lpAttributeInfo->attribute);
+ }
+ }
+ return true;
+}
+
void CFXJSE_Engine::GlobalPropertySetter(CFXJSE_Value* pObject,
const ByteStringView& szPropName,
CFXJSE_Value* pValue) {
@@ -197,32 +222,6 @@ void CFXJSE_Engine::GlobalPropertySetter(CFXJSE_Value* pObject,
szPropName, pValue);
}
-bool CFXJSE_Engine::QueryNodeByFlag(CXFA_Node* refNode,
- const WideStringView& propname,
- CFXJSE_Value* pValue,
- uint32_t dwFlag,
- bool bSetting) {
- if (!refNode)
- return false;
-
- XFA_RESOLVENODE_RS resolveRs;
- if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0)
- return false;
- if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) {
- pValue->Assign(GetJSValueFromMap(resolveRs.objects.front()));
- return true;
- }
- if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Attribute) {
- const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute;
- if (lpAttributeInfo) {
- CJX_Object* jsObject = resolveRs.objects.front()->JSObject();
- (jsObject->*(lpAttributeInfo->callback))(pValue, bSetting,
- lpAttributeInfo->attribute);
- }
- }
- return true;
-}
-
void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject,
const ByteStringView& szPropName,
CFXJSE_Value* pValue) {
@@ -279,6 +278,24 @@ void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject,
pNotify->GetDocEnvironment()->GetGlobalProperty(pNotify->GetHDOC(),
szPropName, pValue);
}
+
+int32_t CFXJSE_Engine::GlobalPropTypeGetter(CFXJSE_Value* pOriginalValue,
+ const ByteStringView& szPropName,
+ bool bQueryIn) {
+ CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
+ if (!pObject)
+ return FXJSE_ClassPropType_None;
+
+ CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext();
+ pObject = lpScriptContext->GetVariablesThis(pObject);
+ XFA_Element eType = pObject->GetElementType();
+ WideString wsPropName = WideString::FromUTF8(szPropName);
+ if (GetMethodByName(eType, wsPropName.AsStringView()))
+ return FXJSE_ClassPropType_Method;
+
+ return FXJSE_ClassPropType_Property;
+}
+
void CFXJSE_Engine::NormalPropertyGetter(CFXJSE_Value* pOriginalValue,
const ByteStringView& szPropName,
CFXJSE_Value* pReturnValue) {
@@ -401,23 +418,6 @@ int32_t CFXJSE_Engine::NormalPropTypeGetter(CFXJSE_Value* pOriginalValue,
return FXJSE_ClassPropType_Property;
}
-int32_t CFXJSE_Engine::GlobalPropTypeGetter(CFXJSE_Value* pOriginalValue,
- const ByteStringView& szPropName,
- bool bQueryIn) {
- CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
- if (!pObject)
- return FXJSE_ClassPropType_None;
-
- CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext();
- pObject = lpScriptContext->GetVariablesThis(pObject);
- XFA_Element eType = pObject->GetElementType();
- WideString wsPropName = WideString::FromUTF8(szPropName);
- if (GetMethodByName(eType, wsPropName.AsStringView()))
- return FXJSE_ClassPropType_Method;
-
- return FXJSE_ClassPropType_Property;
-}
-
void CFXJSE_Engine::NormalMethodCall(CFXJSE_Value* pThis,
const ByteStringView& szFuncName,
CFXJSE_Arguments& args) {
@@ -736,6 +736,7 @@ CFXJSE_Value* CFXJSE_Engine::GetJSValueFromMap(CXFA_Object* pObject) {
auto jsValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
jsValue->SetObject(pObject, m_pJsClass);
+
CFXJSE_Value* pValue = jsValue.get();
m_mapObjectToValue.insert(std::make_pair(pObject, std::move(jsValue)));
return pValue;
@@ -764,11 +765,6 @@ void CFXJSE_Engine::SetNodesOfRunScript(std::vector<CXFA_Node*>* pArray) {
m_pScriptNodeArray = pArray;
}
-void CFXJSE_Engine::AddNodesOfRunScript(const std::vector<CXFA_Node*>& nodes) {
- if (m_pScriptNodeArray && !nodes.empty())
- *m_pScriptNodeArray = nodes;
-}
-
void CFXJSE_Engine::AddNodesOfRunScript(CXFA_Node* pNode) {
if (m_pScriptNodeArray && !pdfium::ContainsValue(*m_pScriptNodeArray, pNode))
m_pScriptNodeArray->push_back(pNode);
diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h
index 1409f71001..66fe7a53e8 100644
--- a/fxjs/cfxjse_engine.h
+++ b/fxjs/cfxjse_engine.h
@@ -23,6 +23,29 @@ class CFXJSE_ResolveProcessor;
class CFXJSE_Engine {
public:
+ static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass);
+ static void GlobalPropertyGetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue);
+ static void GlobalPropertySetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue);
+ static void NormalPropertyGetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue);
+ static void NormalPropertySetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ CFXJSE_Value* pValue);
+ static void NormalMethodCall(CFXJSE_Value* hThis,
+ const ByteStringView& szFuncName,
+ CFXJSE_Arguments& args);
+ static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ bool bQueryIn);
+ static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject,
+ const ByteStringView& szPropName,
+ bool bQueryIn);
+
explicit CFXJSE_Engine(CXFA_Document* pDocument, v8::Isolate* pIsolate);
~CFXJSE_Engine();
@@ -48,57 +71,32 @@ class CFXJSE_Engine {
void GetSomExpression(CXFA_Node* refNode, WideString& wsExpression);
void SetNodesOfRunScript(std::vector<CXFA_Node*>* pArray);
- void AddNodesOfRunScript(const std::vector<CXFA_Node*>& nodes);
void AddNodesOfRunScript(CXFA_Node* pNode);
CFXJSE_Class* GetJseNormalClass();
void SetRunAtType(XFA_AttributeEnum eRunAt) { m_eRunAtType = eRunAt; }
bool IsRunAtClient() { return m_eRunAtType != XFA_AttributeEnum::Server; }
+
+ CXFA_ScriptData::Type GetType();
+ std::vector<CXFA_Node*>* GetUpObjectArray() { return &m_upObjectArray; }
+ CXFA_Document* GetDocument() const { return m_pDocument.Get(); }
+
+ private:
+ CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode,
+ CXFA_Node* pSubform);
+ void RemoveBuiltInObjs(CFXJSE_Context* pContext) const;
bool QueryNodeByFlag(CXFA_Node* refNode,
const WideStringView& propname,
CFXJSE_Value* pValue,
uint32_t dwFlag,
bool bSetting);
+ bool IsStrictScopeInJavaScript();
+ CXFA_Object* GetVariablesThis(CXFA_Object* pObject, bool bScriptNode = false);
bool QueryVariableValue(CXFA_Node* pScriptNode,
const ByteStringView& szPropName,
CFXJSE_Value* pValue,
bool bGetter);
- bool QueryBuiltinValue(const ByteStringView& szPropName,
- CFXJSE_Value* pValue);
- static void GlobalPropertyGetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue);
- static void GlobalPropertySetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue);
- static void NormalPropertyGetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue);
- static void NormalPropertySetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- CFXJSE_Value* pValue);
- static void NormalMethodCall(CFXJSE_Value* hThis,
- const ByteStringView& szFuncName,
- CFXJSE_Arguments& args);
- static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- bool bQueryIn);
- static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject,
- const ByteStringView& szPropName,
- bool bQueryIn);
bool RunVariablesScript(CXFA_Node* pScriptNode);
- CXFA_Object* GetVariablesThis(CXFA_Object* pObject, bool bScriptNode = false);
- bool IsStrictScopeInJavaScript();
- CXFA_ScriptData::Type GetType();
- std::vector<CXFA_Node*>* GetUpObjectArray() { return &m_upObjectArray; }
- CXFA_Document* GetDocument() const { return m_pDocument.Get(); }
-
- static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass);
-
- private:
- CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode,
- CXFA_Node* pSubform);
- void RemoveBuiltInObjs(CFXJSE_Context* pContext) const;
UnownedPtr<CXFA_Document> const m_pDocument;
std::unique_ptr<CFXJSE_Context> m_JsContext;
@@ -116,7 +114,6 @@ class CFXJSE_Engine {
std::unique_ptr<CFXJSE_ResolveProcessor> m_ResolveProcessor;
std::unique_ptr<CFXJSE_FormCalcContext> m_FM2JSContext;
CXFA_Object* m_pThisObject;
- uint32_t m_dwBuiltInInFlags;
XFA_AttributeEnum m_eRunAtType;
};