summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-14 20:29:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-14 20:29:23 +0000
commit07c0a4952a9fe45e51c6ba5a2e19296e52ea6ec7 (patch)
tree818bfc4ae4832250add9f92037994832f22b8e89 /xfa/fxfa/parser
parentc5e0f66f5f2e0645f2beab70b44690fe510a9f2d (diff)
downloadpdfium-07c0a4952a9fe45e51c6ba5a2e19296e52ea6ec7.tar.xz
Fold CXFA_ScriptData into CXFA_Script
This CL removes the CXFA_ScriptData wrapper and uses CXFA_Script directly. Change-Id: I1f1932ef96ee4a24407de7eb1d68b8631a5a67ea Reviewed-on: https://pdfium-review.googlesource.com/21173 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp23
-rw-r--r--xfa/fxfa/parser/cxfa_script.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_script.h11
-rw-r--r--xfa/fxfa/parser/cxfa_scriptdata.cpp29
-rw-r--r--xfa/fxfa/parser/cxfa_scriptdata.h32
-rw-r--r--xfa/fxfa/parser/cxfa_validate.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_validate.h4
11 files changed, 59 insertions, 83 deletions
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp
index 32dc8ef5b7..3d7711d433 100644
--- a/xfa/fxfa/parser/cxfa_calculatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_calculatedata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
#include "xfa/fxfa/parser/cxfa_text.h"
CXFA_CalculateData::CXFA_CalculateData(CXFA_Node* pNode)
@@ -18,8 +19,9 @@ XFA_AttributeEnum CXFA_CalculateData::GetOverride() const {
.value_or(XFA_AttributeEnum::Error);
}
-CXFA_ScriptData CXFA_CalculateData::GetScriptData() const {
- return CXFA_ScriptData(m_pNode->GetChild(0, XFA_Element::Script, false));
+CXFA_Script* CXFA_CalculateData::GetScript() const {
+ return static_cast<CXFA_Script*>(
+ m_pNode->GetChild(0, XFA_Element::Script, false));
}
WideString CXFA_CalculateData::GetMessageText() const {
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.h b/xfa/fxfa/parser/cxfa_calculatedata.h
index 833b1508a4..3e0802e6c4 100644
--- a/xfa/fxfa/parser/cxfa_calculatedata.h
+++ b/xfa/fxfa/parser/cxfa_calculatedata.h
@@ -9,16 +9,16 @@
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_scriptdata.h"
class CXFA_Node;
+class CXFA_Script;
class CXFA_CalculateData : public CXFA_DataData {
public:
explicit CXFA_CalculateData(CXFA_Node* pNode);
XFA_AttributeEnum GetOverride() const;
- CXFA_ScriptData GetScriptData() const;
+ CXFA_Script* GetScript() const;
WideString GetMessageText() const;
};
diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp
index 062d881cda..d5b170b734 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.cpp
+++ b/xfa/fxfa/parser/cxfa_eventdata.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_eventdata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
#include "xfa/fxfa/parser/cxfa_submit.h"
CXFA_EventData::CXFA_EventData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
@@ -31,8 +32,9 @@ WideString CXFA_EventData::GetRef() const {
return m_pNode->JSObject()->GetCData(XFA_Attribute::Ref);
}
-CXFA_ScriptData CXFA_EventData::GetScriptData() const {
- return CXFA_ScriptData(m_pNode->GetChild(0, XFA_Element::Script, false));
+CXFA_Script* CXFA_EventData::GetScript() const {
+ return static_cast<CXFA_Script*>(
+ m_pNode->GetChild(0, XFA_Element::Script, false));
}
CXFA_Submit* CXFA_EventData::GetSubmit() const {
diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h
index 63349690ab..8338767fe0 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.h
+++ b/xfa/fxfa/parser/cxfa_eventdata.h
@@ -11,9 +11,9 @@
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_scriptdata.h"
class CXFA_Node;
+class CXFA_Script;
class CXFA_Submit;
class CXFA_EventData : public CXFA_DataData {
@@ -22,7 +22,7 @@ class CXFA_EventData : public CXFA_DataData {
XFA_AttributeEnum GetActivity();
XFA_Element GetEventType() const;
- CXFA_ScriptData GetScriptData() const;
+ CXFA_Script* GetScript() const;
CXFA_Submit* GetSubmit() const;
WideString GetRef() const;
};
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index f9040d6b4d..4d70d7d50f 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -229,6 +229,15 @@ void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
}
}
+bool RunBreakTestScript(CXFA_Script* pTestScript) {
+ WideString wsExpression = pTestScript->JSObject()->GetContent(false);
+ if (wsExpression.IsEmpty())
+ return true;
+ return pTestScript->GetDocument()->GetNotify()->RunScript(
+ pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent,
+ XFA_ObjectType::ContainerNode));
+}
+
} // namespace
class CXFA_ContainerRecord {
@@ -481,15 +490,6 @@ float CXFA_LayoutPageMgr::GetAvailHeight() {
return FLT_MAX;
}
-bool XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
- WideString wsExpression = pTestScript->JSObject()->GetContent(false);
- if (wsExpression.IsEmpty())
- return true;
- return pTestScript->GetDocument()->GetNotify()->RunScript(
- pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode));
-}
-
CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
CXFA_Node* pPageNode,
bool bCreateNew) {
@@ -816,8 +816,9 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
CXFA_Node* pContainer = pFormNode->GetTemplateNode();
bool bStartNew =
pCurNode->JSObject()->GetInteger(XFA_Attribute::StartNew) != 0;
- CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script);
- if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript))
+ CXFA_Script* pScript = static_cast<CXFA_Script*>(
+ pCurNode->GetFirstChildByClass(XFA_Element::Script));
+ if (pScript && !RunBreakTestScript(pScript))
return false;
WideString wsTarget =
diff --git a/xfa/fxfa/parser/cxfa_script.cpp b/xfa/fxfa/parser/cxfa_script.cpp
index ab317f38e8..1b784b331b 100644
--- a/xfa/fxfa/parser/cxfa_script.cpp
+++ b/xfa/fxfa/parser/cxfa_script.cpp
@@ -46,3 +46,21 @@ CXFA_Script::CXFA_Script(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Script>(this)) {}
CXFA_Script::~CXFA_Script() {}
+
+CXFA_Script::Type CXFA_Script::GetContentType() {
+ pdfium::Optional<WideString> cData =
+ JSObject()->TryCData(XFA_Attribute::ContentType, false);
+ if (!cData || *cData == L"application/x-formcalc")
+ return Type::Formcalc;
+ if (*cData == L"application/x-javascript")
+ return Type::Javascript;
+ return Type::Unknown;
+}
+
+XFA_AttributeEnum CXFA_Script::GetRunAt() {
+ return JSObject()->GetEnum(XFA_Attribute::RunAt);
+}
+
+WideString CXFA_Script::GetExpression() {
+ return JSObject()->GetContent(false);
+}
diff --git a/xfa/fxfa/parser/cxfa_script.h b/xfa/fxfa/parser/cxfa_script.h
index d14f7c113b..8ea7aac60b 100644
--- a/xfa/fxfa/parser/cxfa_script.h
+++ b/xfa/fxfa/parser/cxfa_script.h
@@ -7,12 +7,23 @@
#ifndef XFA_FXFA_PARSER_CXFA_SCRIPT_H_
#define XFA_FXFA_PARSER_CXFA_SCRIPT_H_
+#include "core/fxcrt/widestring.h"
#include "xfa/fxfa/parser/cxfa_node.h"
class CXFA_Script : public CXFA_Node {
public:
+ enum class Type {
+ Formcalc = 0,
+ Javascript,
+ Unknown,
+ };
+
CXFA_Script(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Script() override;
+
+ Type GetContentType();
+ XFA_AttributeEnum GetRunAt();
+ WideString GetExpression();
};
#endif // XFA_FXFA_PARSER_CXFA_SCRIPT_H_
diff --git a/xfa/fxfa/parser/cxfa_scriptdata.cpp b/xfa/fxfa/parser/cxfa_scriptdata.cpp
deleted file mode 100644
index 7e9f49066f..0000000000
--- a/xfa/fxfa/parser/cxfa_scriptdata.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_scriptdata.h"
-
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-CXFA_ScriptData::CXFA_ScriptData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
-CXFA_ScriptData::Type CXFA_ScriptData::GetContentType() const {
- pdfium::Optional<WideString> cData =
- m_pNode->JSObject()->TryCData(XFA_Attribute::ContentType, false);
- if (!cData || *cData == L"application/x-formcalc")
- return Type::Formcalc;
- if (*cData == L"application/x-javascript")
- return Type::Javascript;
- return Type::Unknown;
-}
-
-XFA_AttributeEnum CXFA_ScriptData::GetRunAt() const {
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::RunAt);
-}
-
-WideString CXFA_ScriptData::GetExpression() const {
- return m_pNode->JSObject()->GetContent(false);
-}
diff --git a/xfa/fxfa/parser/cxfa_scriptdata.h b/xfa/fxfa/parser/cxfa_scriptdata.h
deleted file mode 100644
index 983addbd0c..0000000000
--- a/xfa/fxfa/parser/cxfa_scriptdata.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_SCRIPTDATA_H_
-#define XFA_FXFA_PARSER_CXFA_SCRIPTDATA_H_
-
-#include <stdint.h>
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Node;
-
-class CXFA_ScriptData : public CXFA_DataData {
- public:
- enum class Type {
- Formcalc = 0,
- Javascript,
- Unknown,
- };
-
- explicit CXFA_ScriptData(CXFA_Node* pNode);
-
- Type GetContentType() const;
- XFA_AttributeEnum GetRunAt() const;
- WideString GetExpression() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_SCRIPTDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index 9b31a17434..57cf5d4ecf 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -8,6 +8,7 @@
#include "fxjs/xfa/cjx_validate.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
namespace {
@@ -144,6 +145,6 @@ WideString CXFA_Validate::GetPicture() {
return pNode ? pNode->JSObject()->GetContent(false) : L"";
}
-CXFA_ScriptData CXFA_Validate::GetScriptData() {
- return CXFA_ScriptData(GetChild(0, XFA_Element::Script, false));
+CXFA_Script* CXFA_Validate::GetScript() {
+ return static_cast<CXFA_Script*>(GetChild(0, XFA_Element::Script, false));
}
diff --git a/xfa/fxfa/parser/cxfa_validate.h b/xfa/fxfa/parser/cxfa_validate.h
index 9e2be9c959..df08ea6d3d 100644
--- a/xfa/fxfa/parser/cxfa_validate.h
+++ b/xfa/fxfa/parser/cxfa_validate.h
@@ -9,6 +9,8 @@
#include "xfa/fxfa/parser/cxfa_node.h"
+class CXFA_Script;
+
class CXFA_Validate : public CXFA_Node {
public:
CXFA_Validate(CXFA_Document* doc, XFA_PacketType packet);
@@ -29,7 +31,7 @@ class CXFA_Validate : public CXFA_Node {
void SetScriptMessageText(const WideString& wsMessage);
WideString GetPicture();
- CXFA_ScriptData GetScriptData();
+ CXFA_Script* GetScript();
private:
WideString GetMessageText(const WideString& wsMessageType);