summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_nodelist.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-01 16:06:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-01 16:06:07 +0000
commita85e5ca5f2dfadcf9f3812a8ef039d1f206833a4 (patch)
tree5d44e797d038158cdc19b14ac6951435eb85c912 /xfa/fxfa/parser/cxfa_nodelist.cpp
parente5434b5531f2c081c1d69f67125b6665070ea969 (diff)
downloadpdfium-a85e5ca5f2dfadcf9f3812a8ef039d1f206833a4.tar.xz
Split JS methods out of CXFA_Object
This CL moves the javascript code from CXFA_Object to CJX_Object. The Script_* methods are proxied to CJX_Object. The ownership of the CJX_ object was removed from CXFA_Node and moved up to CXFA_Object. Change-Id: I58d286e6bb0151aa88d4f673bc7729987417bde6 Reviewed-on: https://pdfium-review.googlesource.com/17310 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_nodelist.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_nodelist.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodelist.cpp b/xfa/fxfa/parser/cxfa_nodelist.cpp
index cbee420870..4c5e5435c2 100644
--- a/xfa/fxfa/parser/cxfa_nodelist.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelist.cpp
@@ -17,7 +17,8 @@ CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::NodeList,
XFA_Element::NodeList,
- WideStringView(L"nodeList")) {
+ WideStringView(L"nodeList"),
+ pdfium::MakeUnique<CJX_Object>(this)) {
m_pDocument->GetScriptContext()->AddToCacheList(
std::unique_ptr<CXFA_NodeList>(this));
}
@@ -38,13 +39,13 @@ CXFA_Node* CXFA_NodeList::NamedItem(const WideStringView& wsName) {
void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc != 1) {
- ThrowParamCountMismatchException(L"append");
+ JSObject()->ThrowParamCountMismatchException(L"append");
return;
}
CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
if (!pNode) {
- ThrowArgumentMismatchException();
+ JSObject()->ThrowArgumentMismatchException();
return;
}
Append(pNode);
@@ -53,14 +54,14 @@ void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) {
void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc != 2) {
- ThrowParamCountMismatchException(L"insert");
+ JSObject()->ThrowParamCountMismatchException(L"insert");
return;
}
CXFA_Node* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
CXFA_Node* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
if (!pNewNode) {
- ThrowArgumentMismatchException();
+ JSObject()->ThrowArgumentMismatchException();
return;
}
Insert(pNewNode, pBeforeNode);
@@ -69,13 +70,13 @@ void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) {
void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc != 1) {
- ThrowParamCountMismatchException(L"remove");
+ JSObject()->ThrowParamCountMismatchException(L"remove");
return;
}
CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
if (!pNode) {
- ThrowArgumentMismatchException();
+ JSObject()->ThrowArgumentMismatchException();
return;
}
Remove(pNode);
@@ -84,13 +85,13 @@ void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) {
void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc != 1) {
- ThrowParamCountMismatchException(L"item");
+ JSObject()->ThrowParamCountMismatchException(L"item");
return;
}
int32_t iIndex = pArguments->GetInt32(0);
if (iIndex < 0 || iIndex >= GetLength()) {
- ThrowIndexOutOfBoundsException();
+ JSObject()->ThrowIndexOutOfBoundsException();
return;
}
pArguments->GetReturnValue()->Assign(
@@ -101,7 +102,7 @@ void CXFA_NodeList::Script_TreelistClass_NamedItem(
CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc != 1) {
- ThrowParamCountMismatchException(L"namedItem");
+ JSObject()->ThrowParamCountMismatchException(L"namedItem");
return;
}
@@ -119,7 +120,7 @@ void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowInvalidPropertyException();
+ JSObject()->ThrowInvalidPropertyException();
return;
}
pValue->SetInteger(GetLength());