summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-03 17:25:02 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-04 16:02:33 +0000
commita0af75cc4d1e50bb2832dc58636043afe565b02b (patch)
tree7474018a95fbefc318e3316074cc982910e9036f /xfa/fxfa
parent4cf0589c4bc388781cbfc8459c4904bb2bd947bf (diff)
downloadpdfium-a0af75cc4d1e50bb2832dc58636043afe565b02b.tar.xz
Fold CXFA_EventData into CXFA_Event
This CL removes the CXFA_EventData wrapper and puts the code into CXFA_Event. Change-Id: I799a641c434ff926f3ddade1f47845b5666dbbec Reviewed-on: https://pdfium-review.googlesource.com/21991 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp17
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h5
-rw-r--r--xfa/fxfa/parser/cxfa_event.cpp30
-rw-r--r--xfa/fxfa/parser/cxfa_event.h9
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.cpp41
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.h30
-rw-r--r--xfa/fxfa/parser/cxfa_node.h1
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp24
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h6
9 files changed, 64 insertions, 99 deletions
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index a811d37fa4..83d3869bdc 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -23,6 +23,7 @@
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_caption.h"
+#include "xfa/fxfa/parser/cxfa_event.h"
#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_image.h"
#include "xfa/fxfa/parser/cxfa_items.h"
@@ -293,12 +294,12 @@ int32_t CXFA_WidgetAcc::ProcessEvent(XFA_AttributeEnum iActivity,
if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- std::vector<CXFA_Node*> eventArray =
+ std::vector<CXFA_Event*> eventArray =
GetEventByActivity(iActivity, pEventParam->m_bIsFormReady);
bool first = true;
int32_t iRet = XFA_EVENTERROR_NotExist;
- for (CXFA_Node* pNode : eventArray) {
- int32_t result = ProcessEvent(CXFA_EventData(pNode), pEventParam);
+ for (CXFA_Event* event : eventArray) {
+ int32_t result = ProcessEvent(event, pEventParam);
if (first || result == XFA_EVENTERROR_Success)
iRet = result;
first = false;
@@ -306,21 +307,21 @@ int32_t CXFA_WidgetAcc::ProcessEvent(XFA_AttributeEnum iActivity,
return iRet;
}
-int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_EventData& eventData,
+int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event* event,
CXFA_EventParam* pEventParam) {
- if (!eventData.HasValidNode())
+ if (!event)
return XFA_EVENTERROR_NotExist;
- switch (eventData.GetEventType()) {
+ switch (event->GetEventType()) {
case XFA_Element::Execute:
break;
case XFA_Element::Script:
- return ExecuteScript(eventData.GetScript(), pEventParam);
+ return ExecuteScript(event->GetScript(), pEventParam);
case XFA_Element::SignData:
break;
case XFA_Element::Submit:
return GetDoc()->GetDocEnvironment()->Submit(GetDoc(),
- eventData.GetSubmit());
+ event->GetSubmit());
default:
break;
}
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index e09f447a48..3563ff4038 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -14,10 +14,10 @@
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/parser/cxfa_eventdata.h"
#include "xfa/fxfa/parser/cxfa_widgetdata.h"
class CFGAS_GEFont;
+class CXFA_Event;
class CXFA_EventParam;
class CXFA_FFApp;
class CXFA_FFDoc;
@@ -42,8 +42,7 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
bool ProcessValueChanged();
int32_t ProcessEvent(XFA_AttributeEnum iActivity,
CXFA_EventParam* pEventParam);
- int32_t ProcessEvent(const CXFA_EventData& eventData,
- CXFA_EventParam* pEventParam);
+ int32_t ProcessEvent(CXFA_Event* event, CXFA_EventParam* pEventParam);
int32_t ProcessCalculate();
int32_t ProcessValidate(int32_t iFlags);
int32_t ExecuteScript(CXFA_Script* script, CXFA_EventParam* pEventParam);
diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp
index b3ee47b4df..2675761bc6 100644
--- a/xfa/fxfa/parser/cxfa_event.cpp
+++ b/xfa/fxfa/parser/cxfa_event.cpp
@@ -8,6 +8,8 @@
#include "fxjs/xfa/cjx_event.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+#include "xfa/fxfa/parser/cxfa_submit.h"
namespace {
@@ -46,3 +48,31 @@ CXFA_Event::CXFA_Event(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Event>(this)) {}
CXFA_Event::~CXFA_Event() {}
+
+XFA_AttributeEnum CXFA_Event::GetActivity() {
+ return JSObject()->GetEnum(XFA_Attribute::Activity);
+}
+
+XFA_Element CXFA_Event::GetEventType() const {
+ CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild);
+ while (pChild) {
+ XFA_Element eType = pChild->GetElementType();
+ if (eType != XFA_Element::Extras)
+ return eType;
+
+ pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
+ }
+ return XFA_Element::Unknown;
+}
+
+WideString CXFA_Event::GetRef() {
+ return JSObject()->GetCData(XFA_Attribute::Ref);
+}
+
+CXFA_Script* CXFA_Event::GetScript() {
+ return GetChild<CXFA_Script>(0, XFA_Element::Script, false);
+}
+
+CXFA_Submit* CXFA_Event::GetSubmit() {
+ return GetChild<CXFA_Submit>(0, XFA_Element::Submit, false);
+}
diff --git a/xfa/fxfa/parser/cxfa_event.h b/xfa/fxfa/parser/cxfa_event.h
index 655e776b85..a2b2fb804a 100644
--- a/xfa/fxfa/parser/cxfa_event.h
+++ b/xfa/fxfa/parser/cxfa_event.h
@@ -9,10 +9,19 @@
#include "xfa/fxfa/parser/cxfa_node.h"
+class CXFA_Script;
+class CXFA_Submit;
+
class CXFA_Event : public CXFA_Node {
public:
CXFA_Event(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Event() override;
+
+ XFA_AttributeEnum GetActivity();
+ XFA_Element GetEventType() const;
+ CXFA_Script* GetScript();
+ CXFA_Submit* GetSubmit();
+ WideString GetRef();
};
#endif // XFA_FXFA_PARSER_CXFA_EVENT_H_
diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp
deleted file mode 100644
index 89dcb4ed2a..0000000000
--- a/xfa/fxfa/parser/cxfa_eventdata.cpp
+++ /dev/null
@@ -1,41 +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_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) {}
-
-XFA_AttributeEnum CXFA_EventData::GetActivity() {
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::Activity);
-}
-
-XFA_Element CXFA_EventData::GetEventType() const {
- CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pChild) {
- XFA_Element eType = pChild->GetElementType();
- if (eType != XFA_Element::Extras)
- return eType;
-
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- }
- return XFA_Element::Unknown;
-}
-
-WideString CXFA_EventData::GetRef() const {
- return m_pNode->JSObject()->GetCData(XFA_Attribute::Ref);
-}
-
-CXFA_Script* CXFA_EventData::GetScript() const {
- return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false);
-}
-
-CXFA_Submit* CXFA_EventData::GetSubmit() const {
- return m_pNode->GetChild<CXFA_Submit>(0, XFA_Element::Submit, false);
-}
diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h
deleted file mode 100644
index 8338767fe0..0000000000
--- a/xfa/fxfa/parser/cxfa_eventdata.h
+++ /dev/null
@@ -1,30 +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_EVENTDATA_H_
-#define XFA_FXFA_PARSER_CXFA_EVENTDATA_H_
-
-#include <stdint.h>
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Node;
-class CXFA_Script;
-class CXFA_Submit;
-
-class CXFA_EventData : public CXFA_DataData {
- public:
- explicit CXFA_EventData(CXFA_Node* pNode);
-
- XFA_AttributeEnum GetActivity();
- XFA_Element GetEventType() const;
- CXFA_Script* GetScript() const;
- CXFA_Submit* GetSubmit() const;
- WideString GetRef() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_EVENTDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 81d0bfc359..b41a27ef01 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -167,6 +167,7 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* Clone(bool bRecursive);
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const;
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const;
+
std::vector<CXFA_Node*> GetNodeList(uint32_t dwTypeFilter,
XFA_Element eTypeFilter);
CXFA_Node* CreateSamePacketNode(XFA_Element eType);
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 4a8817812f..5833655156 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -17,7 +17,7 @@
#include "xfa/fxfa/parser/cxfa_comb.h"
#include "xfa/fxfa/parser/cxfa_decimal.h"
#include "xfa/fxfa/parser/cxfa_document.h"
-#include "xfa/fxfa/parser/cxfa_eventdata.h"
+#include "xfa/fxfa/parser/cxfa_event.h"
#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_format.h"
#include "xfa/fxfa/parser/cxfa_items.h"
@@ -287,28 +287,24 @@ CXFA_Para* CXFA_WidgetData::GetPara() {
false);
}
-std::vector<CXFA_Node*> CXFA_WidgetData::GetEventList() {
- return m_pNode->GetNodeList(0, XFA_Element::Event);
-}
-
-std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity(
+std::vector<CXFA_Event*> CXFA_WidgetData::GetEventByActivity(
XFA_AttributeEnum iActivity,
bool bIsFormReady) {
- std::vector<CXFA_Node*> events;
- for (CXFA_Node* pNode : GetEventList()) {
- CXFA_EventData eventData(pNode);
- if (eventData.GetActivity() == iActivity) {
+ std::vector<CXFA_Event*> events;
+ for (CXFA_Node* node : m_pNode->GetNodeList(0, XFA_Element::Event)) {
+ auto* event = static_cast<CXFA_Event*>(node);
+ if (event->GetActivity() == iActivity) {
if (iActivity == XFA_AttributeEnum::Ready) {
- WideString wsRef = eventData.GetRef();
+ WideString wsRef = event->GetRef();
if (bIsFormReady) {
if (wsRef == WideStringView(L"$form"))
- events.push_back(pNode);
+ events.push_back(event);
} else {
if (wsRef == WideStringView(L"$layout"))
- events.push_back(pNode);
+ events.push_back(event);
}
} else {
- events.push_back(pNode);
+ events.push_back(event);
}
}
}
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 30d64a09c5..57e6939f37 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -33,6 +33,7 @@ class CXFA_Bind;
class CXFA_Border;
class CXFA_Calculate;
class CXFA_Caption;
+class CXFA_Event;
class CXFA_Font;
class CXFA_Margin;
class CXFA_Node;
@@ -70,8 +71,8 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_Validate* GetValidate(bool bModified);
CXFA_Border* GetUIBorder();
- std::vector<CXFA_Node*> GetEventByActivity(XFA_AttributeEnum iActivity,
- bool bIsFormReady);
+ std::vector<CXFA_Event*> GetEventByActivity(XFA_AttributeEnum iActivity,
+ bool bIsFormReady);
pdfium::Optional<float> TryWidth();
pdfium::Optional<float> TryHeight();
@@ -182,7 +183,6 @@ class CXFA_WidgetData : public CXFA_DataData {
WideString FormatNumStr(const WideString& wsValue, IFX_Locale* pLocale);
CXFA_Node* GetExclGroupNode();
void GetItemLabel(const WideStringView& wsValue, WideString& wsLabel);
- std::vector<CXFA_Node*> GetEventList();
bool m_bIsNull;
bool m_bPreNull;