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/cxfa_object.cpp | 42 +++++++---------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_object.cpp') diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index c23420446a..d9deaaac9a 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/parser/cxfa_object.h" +#include + #include "core/fxcrt/fx_extension.h" #include "fxjs/cfxjse_value.h" #include "xfa/fxfa/cxfa_ffnotify.h" @@ -16,52 +18,22 @@ CXFA_Object::CXFA_Object(CXFA_Document* pDocument, XFA_ObjectType objectType, XFA_Element elementType, - const WideStringView& elementName) + const WideStringView& elementName, + std::unique_ptr jsObject) : CFXJSE_HostObject(kXFA), m_pDocument(pDocument), m_objectType(objectType), m_elementType(elementType), m_elementNameHash(FX_HashCode_GetW(elementName, false)), - m_elementName(elementName) {} + m_elementName(elementName), + m_pJSObject(std::move(jsObject)) {} CXFA_Object::~CXFA_Object() {} void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetString(FX_UTF8Encode(GetClassName()).AsStringView()); -} - -void CXFA_Object::ThrowInvalidPropertyException() const { - ThrowException(L"Invalid property set operation."); -} - -void CXFA_Object::ThrowIndexOutOfBoundsException() const { - ThrowException(L"Index value is out of bounds."); -} - -void CXFA_Object::ThrowParamCountMismatchException( - const WideString& method) const { - ThrowException(L"Incorrect number of parameters calling method '%.16s'.", - method.c_str()); -} - -void CXFA_Object::ThrowArgumentMismatchException() const { - ThrowException(L"Argument mismatch in property or function argument."); -} - -void CXFA_Object::ThrowException(const wchar_t* str, ...) const { - WideString wsMessage; - va_list arg_ptr; - va_start(arg_ptr, str); - wsMessage.FormatV(str, arg_ptr); - va_end(arg_ptr); - ASSERT(!wsMessage.IsEmpty()); - FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView()); + JSObject()->Script_ObjectClass_ClassName(pValue, bSetting, eAttribute); } CXFA_Node* CXFA_Object::AsNode() { -- cgit v1.2.3