summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_object.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_object.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_object.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_object.cpp42
1 files changed, 7 insertions, 35 deletions
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 <utility>
+
#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<CJX_Object> 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() {