7#include "fxjs/xfa/cjx_packet.h"
12#include "core/fxcrt/xml/cfx_xmldocument.h"
13#include "core/fxcrt/xml/cfx_xmlelement.h"
14#include "core/fxcrt/xml/cfx_xmltext.h"
15#include "fxjs/cfx_v8.h"
17#include "fxjs/js_resources.h"
18#include "third_party/base/containers/span.h"
19#include "v8/include/v8-primitive.h"
20#include "xfa/fxfa/cxfa_ffdoc.h"
21#include "xfa/fxfa/cxfa_ffnotify.h"
22#include "xfa/fxfa/parser/cxfa_packet.h"
25 {
"getAttribute", getAttribute_static},
26 {
"removeAttribute", removeAttribute_static},
27 {
"setAttribute", setAttribute_static}};
29CJX_Packet::CJX_Packet(CXFA_Packet* packet) :
CJX_Node(packet) {
40 pdfium::span<v8::Local<v8::Value>> params) {
41 if (params.size() != 1)
44 WideString attributeValue;
45 CFX_XMLElement* element = ToXMLElement(
GetXFANode()->GetXMLMappingNode());
47 attributeValue = element->GetAttribute(runtime->ToWideString(params[0]));
50 runtime->NewString(attributeValue
.ToUTF8().AsStringView())
);
54 pdfium::span<v8::Local<v8::Value>> params) {
55 if (params.size() != 2)
58 CFX_XMLElement* element = ToXMLElement(
GetXFANode()->GetXMLMappingNode());
60 element->SetAttribute(runtime->ToWideString(params[1]),
61 runtime->ToWideString(params[0]));
68 pdfium::span<v8::Local<v8::Value>> params) {
69 if (params.size() != 1)
72 CFX_XMLElement* pElement = ToXMLElement(
GetXFANode()->GetXMLMappingNode());
74 pElement->RemoveAttribute(runtime->ToWideString(params[0]));
79void CJX_Packet::content(
v8::Isolate* pIsolate,
80 v8::Local<v8::Value>* pValue,
83 CFX_XMLElement* element = ToXMLElement(
GetXFANode()->GetXMLMappingNode());
86 element->AppendLastChild(
93 fxv8::ReentrantToWideStringHelper(pIsolate, *pValue)));
98 WideString wsTextData;
102 *pValue = fxv8::NewStringHelper(pIsolate, wsTextData
.ToUTF8().AsStringView());
friend class EventParamScope
WideString GetTextData() const
static CJS_Result Success()
static CJS_Result Failure(JSMessage id)
bool DynamicTypeIs(TypeTag eType) const override
void DefineMethods(pdfium::span< const CJX_MethodSpec > methods)
CXFA_Node * GetXFANode() const
bool DynamicTypeIs(TypeTag eType) const override
ByteString ToUTF8() const
WideString & operator=(WideString &&that) noexcept