summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cscript_layoutpseudomodel.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/cscript_layoutpseudomodel.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/cscript_layoutpseudomodel.cpp')
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index 574b62644a..4c7d7f2006 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -10,6 +10,8 @@
#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cjx_object.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -28,7 +30,8 @@ CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument)
: CXFA_Object(pDocument,
XFA_ObjectType::Object,
XFA_Element::LayoutPseudoModel,
- WideStringView(L"layoutPseudoModel")) {}
+ WideStringView(L"layoutPseudoModel"),
+ pdfium::MakeUnique<CJX_Object>(this)) {}
CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {}
@@ -40,7 +43,7 @@ void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
return;
}
if (bSetting) {
- ThrowSetReadyException();
+ JSObject()->ThrowException(L"Unable to set ready value.");
return;
}
int32_t iStatus = pNotify->GetLayoutStatus();
@@ -66,7 +69,7 @@ void CScript_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments,
methodName = L"y";
break;
}
- ThrowParamCountMismatchException(methodName);
+ JSObject()->ThrowParamCountMismatchException(methodName);
return;
}
CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
@@ -170,7 +173,7 @@ void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowParamCountMismatchException(L"pageSpan");
+ JSObject()->ThrowParamCountMismatchException(L"pageSpan");
return;
}
CXFA_Node* pNode = nullptr;
@@ -334,7 +337,7 @@ std::vector<CXFA_Node*> CScript_LayoutPseudoModel::GetObjArray(
void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"pageContent");
+ JSObject()->ThrowParamCountMismatchException(L"pageContent");
return;
}
int32_t iIndex = 0;
@@ -398,7 +401,7 @@ void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"absPageInBatch");
+ JSObject()->ThrowParamCountMismatchException(L"absPageInBatch");
return;
}
@@ -407,7 +410,7 @@ void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) {
if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"sheetInBatch");
+ JSObject()->ThrowParamCountMismatchException(L"sheetInBatch");
return;
}
@@ -433,7 +436,8 @@ void CScript_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments,
bool bAbsPage) {
int32_t iLength = pArguments->GetLength();
if (iLength != 1) {
- ThrowParamCountMismatchException(bAbsPage ? L"absPage" : L"page");
+ JSObject()->ThrowParamCountMismatchException(bAbsPage ? L"absPage"
+ : L"page");
return;
}
@@ -454,7 +458,3 @@ void CScript_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments,
int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
}
-
-void CScript_LayoutPseudoModel::ThrowSetReadyException() const {
- ThrowException(L"Unable to set ready value.");
-}