From a85e5ca5f2dfadcf9f3812a8ef039d1f206833a4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 1 Nov 2017 16:06:07 +0000 Subject: 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 Commit-Queue: dsinclair --- xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'xfa/fxfa/parser/cscript_layoutpseudomodel.cpp') 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(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(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 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."); -} -- cgit v1.2.3