summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-18 06:36:51 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-18 06:36:51 -0700
commitc1df5d4375027aa9d0b88f456f95177c016e8cad (patch)
treea06026f0df134604b4cc8082b15a1875ddcc00a0 /xfa/fxfa
parente8a80664a888526ca4f0d08b4e6b290eb0aa0d76 (diff)
downloadpdfium-c1df5d4375027aa9d0b88f456f95177c016e8cad.tar.xz
Pass element hash and name into CXFA_Object constructor.
Providing the element hash and name in the constructor allows us to remove the calls to XFA_GetElementByID in the get methods. Review-Url: https://codereview.chromium.org/2101403002
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/xfa_document_imp.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_object.h9
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp24
-rw-r--r--xfa/fxfa/parser/xfa_script_datawindow.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp3
-rw-r--r--xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp5
-rw-r--r--xfa/fxfa/parser/xfa_script_logpseudomodel.cpp9
-rw-r--r--xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp8
9 files changed, 55 insertions, 18 deletions
diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp
index 4c8b4dba1d..382fd7db3b 100644
--- a/xfa/fxfa/parser/xfa_document_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_imp.cpp
@@ -160,8 +160,9 @@ CXFA_Node* CXFA_Document::CreateNode(const XFA_PACKETINFO* pPacket,
const XFA_ELEMENTINFO* pElement = XFA_GetElementByID(eElement);
if (pElement && (pElement->dwPackets & pPacket->eName)) {
- CXFA_Node* pNode = new CXFA_Node(this, pPacket->eName,
- pElement->eObjectType, pElement->eName);
+ CXFA_Node* pNode =
+ new CXFA_Node(this, pPacket->eName, pElement->eObjectType,
+ pElement->eName, pElement->pName);
AddPurgeNode(pNode);
return pNode;
}
diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h
index 268d5c4c79..08eedeeab5 100644
--- a/xfa/fxfa/parser/xfa_object.h
+++ b/xfa/fxfa/parser/xfa_object.h
@@ -48,7 +48,8 @@ class CXFA_Object : public CFXJSE_HostObject {
public:
CXFA_Object(CXFA_Document* pDocument,
XFA_ObjectType objectType,
- XFA_Element eType);
+ XFA_Element eType,
+ const CFX_WideStringC& elementName);
~CXFA_Object() override;
CXFA_Document* GetDocument() const { return m_pDocument; }
@@ -95,6 +96,9 @@ class CXFA_Object : public CFXJSE_HostObject {
CXFA_Document* const m_pDocument;
const XFA_ObjectType m_objectType;
const XFA_Element m_elementType;
+
+ const uint32_t m_elementNameHash;
+ const CFX_WideStringC m_elementName;
};
using CXFA_ObjArray = CFX_ArrayTemplate<CXFA_Object*>;
@@ -619,7 +623,8 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node(CXFA_Document* pDoc,
uint16_t ePacket,
XFA_ObjectType oType,
- XFA_Element eType);
+ XFA_Element eType,
+ const CFX_WideStringC& elementName);
~CXFA_Node() override;
bool HasFlag(XFA_NodeFlag dwFlag) const;
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index e3d9f6bcdf..a9a5b29458 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -53,19 +53,22 @@ XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = {
CXFA_Object::CXFA_Object(CXFA_Document* pDocument,
XFA_ObjectType objectType,
- XFA_Element elementType)
+ XFA_Element elementType,
+ const CFX_WideStringC& elementName)
: m_pDocument(pDocument),
m_objectType(objectType),
- m_elementType(elementType) {}
+ m_elementType(elementType),
+ m_elementNameHash(FX_HashCode_GetW(elementName, false)),
+ m_elementName(elementName) {}
CXFA_Object::~CXFA_Object() {}
CFX_WideStringC CXFA_Object::GetClassName() const {
- return XFA_GetElementByID(GetElementType())->pName;
+ return m_elementName;
}
uint32_t CXFA_Object::GetClassHashCode() const {
- return XFA_GetElementByID(GetElementType())->uHash;
+ return m_elementNameHash;
}
XFA_Element CXFA_Object::GetElementType() const {
@@ -105,8 +108,9 @@ XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {}
CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
uint16_t ePacket,
XFA_ObjectType oType,
- XFA_Element eType)
- : CXFA_Object(pDoc, oType, eType),
+ XFA_Element eType,
+ const CFX_WideStringC& elementName)
+ : CXFA_Object(pDoc, oType, eType, elementName),
m_pNext(nullptr),
m_pChild(nullptr),
m_pLastChild(nullptr),
@@ -5066,7 +5070,8 @@ void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule,
CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode)
: CXFA_Object(pThisNode->GetDocument(),
XFA_ObjectType::VariablesThis,
- XFA_Element::Unknown),
+ XFA_Element::Unknown,
+ CFX_WideStringC()),
m_pThisNode(nullptr),
m_pScriptNode(nullptr) {
m_pThisNode = pThisNode;
@@ -5084,7 +5089,10 @@ CXFA_Node* CXFA_ThisProxy::GetScriptNode() const {
}
CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument)
- : CXFA_Object(pDocument, XFA_ObjectType::NodeList, XFA_Element::NodeList) {
+ : CXFA_Object(pDocument,
+ XFA_ObjectType::NodeList,
+ XFA_Element::NodeList,
+ CFX_WideStringC(L"nodeList")) {
m_pDocument->GetScriptContext()->AddToCacheList(
std::unique_ptr<CXFA_NodeList>(this));
}
diff --git a/xfa/fxfa/parser/xfa_script_datawindow.cpp b/xfa/fxfa/parser/xfa_script_datawindow.cpp
index e953206c4d..aa399b79de 100644
--- a/xfa/fxfa/parser/xfa_script_datawindow.cpp
+++ b/xfa/fxfa/parser/xfa_script_datawindow.cpp
@@ -15,7 +15,10 @@
#include "xfa/fxfa/parser/xfa_utils.h"
CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument)
- : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::DataWindow) {}
+ : CXFA_Object(pDocument,
+ XFA_ObjectType::Object,
+ XFA_Element::DataWindow,
+ CFX_WideStringC(L"dataWindow")) {}
CScript_DataWindow::~CScript_DataWindow() {}
diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
index 507aef3c6a..de4b7ae8da 100644
--- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
@@ -51,7 +51,8 @@ void BooleanProperty(CFXJSE_Value* pValue, FX_BOOL& bValue, FX_BOOL bSetting) {
CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
- XFA_Element::EventPseudoModel) {}
+ XFA_Element::EventPseudoModel,
+ CFX_WideStringC(L"eventPseudoModel")) {}
CScript_EventPseudoModel::~CScript_EventPseudoModel() {}
diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
index 2ede85e204..9153761abf 100644
--- a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
@@ -28,8 +28,11 @@ CXFA_Node* ToNode(CFXJSE_Value* pValue, CFXJSE_Class* pClass) {
CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
- XFA_Element::HostPseudoModel) {}
+ XFA_Element::HostPseudoModel,
+ CFX_WideStringC(L"hostPseudoModel")) {}
+
CScript_HostPseudoModel::~CScript_HostPseudoModel() {}
+
void CScript_HostPseudoModel::LoadString(CFXJSE_Value* pValue,
CXFA_FFNotify* pNotify,
uint32_t dwFlag) {
diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
index 977b83ff03..4a64af9869 100644
--- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
@@ -24,8 +24,11 @@
CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
- XFA_Element::LayoutPseudoModel) {}
+ XFA_Element::LayoutPseudoModel,
+ CFX_WideStringC(L"layoutPseudoModel")) {}
+
CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {}
+
void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
diff --git a/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
index 57909cdd79..4abed33a77 100644
--- a/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
@@ -17,10 +17,17 @@
CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
- XFA_Element::LogPseudoModel) {}
+ XFA_Element::LogPseudoModel,
+ CFX_WideStringC(L"logPseudoModel")) {}
+
CScript_LogPseudoModel::~CScript_LogPseudoModel() {}
+
void CScript_LogPseudoModel::Message(CFXJSE_Arguments* pArguments) {}
+
void CScript_LogPseudoModel::TraceEnabled(CFXJSE_Arguments* pArguments) {}
+
void CScript_LogPseudoModel::TraceActivate(CFXJSE_Arguments* pArguments) {}
+
void CScript_LogPseudoModel::TraceDeactivate(CFXJSE_Arguments* pArguments) {}
+
void CScript_LogPseudoModel::Trace(CFXJSE_Arguments* pArguments) {}
diff --git a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
index 0341fc12de..95b9a3605b 100644
--- a/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
@@ -20,8 +20,11 @@ CScript_SignaturePseudoModel::CScript_SignaturePseudoModel(
CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
- XFA_Element::SignaturePseudoModel) {}
+ XFA_Element::SignaturePseudoModel,
+ CFX_WideStringC(L"signaturePseudoModel")) {}
+
CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {}
+
void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 4) {
@@ -42,6 +45,7 @@ void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
if (pValue)
pValue->SetInteger(bVerify);
}
+
void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 3 || iLength > 7) {
@@ -73,6 +77,7 @@ void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
if (pValue)
pValue->SetBoolean(bSign);
}
+
void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 0) {
@@ -90,6 +95,7 @@ void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
pArguments->GetReturnValue()->Assign(
m_pDocument->GetScriptContext()->GetJSValueFromMap(pList));
}
+
void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 2) {