diff options
Diffstat (limited to 'xfa/fxfa/parser/cxfa_validate.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_validate.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp index d65b17083..2ca381161 100644 --- a/xfa/fxfa/parser/cxfa_validate.cpp +++ b/xfa/fxfa/parser/cxfa_validate.cpp @@ -1,4 +1,4 @@ -// Copyright 2017 PDFium Authors. All rights reserved. +// Copyright 2017 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,7 @@ #include "fxjs/xfa/cjx_node.h" #include "fxjs/xfa/cjx_object.h" -#include "third_party/base/ptr_util.h" +#include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_message.h" #include "xfa/fxfa/parser/cxfa_picture.h" #include "xfa/fxfa/parser/cxfa_script.h" @@ -17,10 +17,10 @@ namespace { const CXFA_Node::PropertyData kValidatePropertyData[] = { - {XFA_Element::Message, 1, 0}, - {XFA_Element::Picture, 1, 0}, - {XFA_Element::Script, 1, 0}, - {XFA_Element::Extras, 1, 0}, + {XFA_Element::Message, 1, {}}, + {XFA_Element::Picture, 1, {}}, + {XFA_Element::Script, 1, {}}, + {XFA_Element::Extras, 1, {}}, }; const CXFA_Node::AttributeData kValidateAttributeData[] = { {XFA_Attribute::Id, XFA_AttributeType::CData, nullptr}, @@ -43,15 +43,17 @@ constexpr wchar_t kScriptTest[] = L"scriptTest"; } // namespace CXFA_Validate::CXFA_Validate(CXFA_Document* doc, XFA_PacketType packet) - : CXFA_Node( - doc, - packet, - (XFA_XDPPACKET_Config | XFA_XDPPACKET_Template | XFA_XDPPACKET_Form), - XFA_ObjectType::ContentNode, - XFA_Element::Validate, - kValidatePropertyData, - kValidateAttributeData, - pdfium::MakeUnique<CJX_Node>(this)) {} + : CXFA_Node(doc, + packet, + {XFA_XDPPACKET::kConfig, XFA_XDPPACKET::kTemplate, + XFA_XDPPACKET::kForm}, + XFA_ObjectType::ContentNode, + XFA_Element::Validate, + kValidatePropertyData, + kValidateAttributeData, + cppgc::MakeGarbageCollected<CJX_Node>( + doc->GetHeap()->GetAllocationHandle(), + this)) {} CXFA_Validate::~CXFA_Validate() = default; @@ -60,10 +62,11 @@ XFA_AttributeValue CXFA_Validate::GetFormatTest() { } void CXFA_Validate::SetNullTest(const WideString& wsValue) { - Optional<XFA_AttributeValue> item = + absl::optional<XFA_AttributeValue> item = XFA_GetAttributeValueByName(wsValue.AsStringView()); - JSObject()->SetEnum(XFA_Attribute::NullTest, - item ? *item : XFA_AttributeValue::Disabled, false); + JSObject()->SetEnum( + XFA_Attribute::NullTest, + item.has_value() ? item.value() : XFA_AttributeValue::Disabled, false); } XFA_AttributeValue CXFA_Validate::GetNullTest() { @@ -138,13 +141,12 @@ void CXFA_Validate::SetMessageText(const WideString& wsMessageType, CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_Element::Text); pNode->InsertChildAndNotify(pTextNode, nullptr); - pTextNode->JSObject()->SetCData(XFA_Attribute::Name, wsMessageType, false, - false); + pTextNode->JSObject()->SetCData(XFA_Attribute::Name, wsMessageType); pTextNode->JSObject()->SetContent(wsMessage, wsMessage, false, false, true); } -WideString CXFA_Validate::GetPicture() { - CXFA_Picture* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false); +WideString CXFA_Validate::GetPicture() const { + const auto* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false); return pNode ? pNode->JSObject()->GetContent(false) : WideString(); } |