diff options
-rw-r--r-- | fxjs/xfa/cjx_boolean.cpp | 1 | ||||
-rw-r--r-- | fxjs/xfa/cjx_draw.cpp | 4 | ||||
-rw-r--r-- | fxjs/xfa/cjx_exclgroup.cpp | 2 | ||||
-rw-r--r-- | fxjs/xfa/cjx_field.cpp | 16 | ||||
-rw-r--r-- | fxjs/xfa/cjx_manifest.cpp | 4 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 37 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.h | 7 | ||||
-rw-r--r-- | fxjs/xfa/cjx_template.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_object.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_object.h | 5 |
13 files changed, 52 insertions, 56 deletions
diff --git a/fxjs/xfa/cjx_boolean.cpp b/fxjs/xfa/cjx_boolean.cpp index 1e66a14e77..761d0a2be9 100644 --- a/fxjs/xfa/cjx_boolean.cpp +++ b/fxjs/xfa/cjx_boolean.cpp @@ -7,6 +7,7 @@ #include "fxjs/xfa/cjx_boolean.h" #include "fxjs/cfxjse_value.h" +#include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/parser/cxfa_boolean.h" CJX_Boolean::CJX_Boolean(CXFA_Boolean* node) : CJX_Content(node) {} diff --git a/fxjs/xfa/cjx_draw.cpp b/fxjs/xfa/cjx_draw.cpp index 036cfc76bc..a1baabfd2c 100644 --- a/fxjs/xfa/cjx_draw.cpp +++ b/fxjs/xfa/cjx_draw.cpp @@ -7,6 +7,7 @@ #include "fxjs/xfa/cjx_draw.h" #include "fxjs/cfxjse_value.h" +#include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/parser/cxfa_draw.h" CJX_Draw::CJX_Draw(CXFA_Draw* node) : CJX_Container(node) {} @@ -119,8 +120,7 @@ void CJX_Draw::defaultValue(CFXJSE_Value* pValue, if (!pValue || !pValue->IsString()) return; - CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc(); - XFA_Element uiType = pWidgetAcc->GetUIType(); + XFA_Element uiType = GetXFANode()->GetWidgetAcc()->GetUIType(); if (uiType != XFA_Element::Text) return; diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp index b7223ec200..8d814dc125 100644 --- a/fxjs/xfa/cjx_exclgroup.cpp +++ b/fxjs/xfa/cjx_exclgroup.cpp @@ -85,7 +85,7 @@ CJS_Return CJX_ExclGroup::selectedMember( if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(runtime->NewNull()); diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index e62fa3a33a..b04d8de26a 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp @@ -41,7 +41,7 @@ CJX_Field::~CJX_Field() {} CJS_Return CJX_Field::clearItems( CJS_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (pWidgetAcc) pWidgetAcc->DeleteItem(-1, true, false); return CJS_Return(true); @@ -82,7 +82,7 @@ CJS_Return CJX_Field::deleteItem( if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(true); @@ -100,7 +100,7 @@ CJS_Return CJX_Field::getSaveItem( if (iIndex < 0) return CJS_Return(runtime->NewNull()); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(runtime->NewNull()); @@ -117,7 +117,7 @@ CJS_Return CJX_Field::boundItem( if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(true); @@ -132,7 +132,7 @@ CJS_Return CJX_Field::getItemState( if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(true); @@ -164,7 +164,7 @@ CJS_Return CJX_Field::getDisplayItem( if (iIndex < 0) return CJS_Return(runtime->NewNull()); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(runtime->NewNull()); @@ -181,7 +181,7 @@ CJS_Return CJX_Field::setItemState( if (params.size() != 2) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(true); @@ -201,7 +201,7 @@ CJS_Return CJX_Field::addItem(CJS_V8* runtime, if (params.size() != 1 && params.size() != 2) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); + CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc(); if (!pWidgetAcc) return CJS_Return(true); diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp index 69c3e944df..0882238aba 100644 --- a/fxjs/xfa/cjx_manifest.cpp +++ b/fxjs/xfa/cjx_manifest.cpp @@ -27,8 +27,8 @@ CJS_Return CJX_Manifest::evaluate( if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - CXFA_WidgetAcc* pWidgetAcc = GetWidgetAcc(); - return CJS_Return(runtime->NewBoolean(!!pWidgetAcc)); + return CJS_Return( + runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc())); } void CJX_Manifest::defaultValue(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index de747f4419..0528bd5edd 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -1304,10 +1304,7 @@ void CJX_Object::Script_Attribute_Integer(CFXJSE_Value* pValue, void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - if (!widget_data_) - return; - - CXFA_Font* font = widget_data_->GetNode()->GetFont(true); + CXFA_Font* font = ToNode(object_.Get())->GetFont(true); if (!font) return; @@ -1332,10 +1329,7 @@ void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue, void CJX_Object::Script_Som_FillColor(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - if (!widget_data_) - return; - - CXFA_Border* border = widget_data_->GetNode()->GetBorder(true); + CXFA_Border* border = ToNode(object_.Get())->GetBorder(true); CXFA_Fill* borderfill = border->GetFill(true); if (!borderfill) return; @@ -1363,10 +1357,7 @@ void CJX_Object::Script_Som_FillColor(CFXJSE_Value* pValue, void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - if (!widget_data_) - return; - - CXFA_Border* border = widget_data_->GetNode()->GetBorder(true); + CXFA_Border* border = ToNode(object_.Get())->GetBorder(true); int32_t iSize = border->CountEdges(); if (bSetting) { int32_t r = 0; @@ -1393,10 +1384,7 @@ void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue, void CJX_Object::Script_Som_BorderWidth(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - if (!widget_data_) - return; - - CXFA_Border* border = widget_data_->GetNode()->GetBorder(true); + CXFA_Border* border = ToNode(object_.Get())->GetBorder(true); if (bSetting) { CXFA_Measurement thickness = border->GetEdge(0)->GetMSThickness(); pValue->SetString(thickness.ToString().UTF8Encode().AsStringView()); @@ -1413,13 +1401,10 @@ void CJX_Object::Script_Som_BorderWidth(CFXJSE_Value* pValue, void CJX_Object::Script_Som_Message(CFXJSE_Value* pValue, bool bSetting, XFA_SOM_MESSAGETYPE iMessageType) { - if (!widget_data_) - return; - bool bNew = false; - CXFA_Validate* validate = widget_data_->GetNode()->GetValidate(false); + CXFA_Validate* validate = ToNode(object_.Get())->GetValidate(false); if (!validate) { - validate = widget_data_->GetNode()->GetValidate(true); + validate = ToNode(object_.Get())->GetValidate(true); bNew = true; } @@ -1483,11 +1468,12 @@ void CJX_Object::Script_Field_Length(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - if (!widget_data_) { + if (!ToNode(object_.Get())->GetWidgetAcc()) { pValue->SetInteger(0); return; } - pValue->SetInteger(widget_data_->CountChoiceListItems(true)); + pValue->SetInteger( + ToNode(object_.Get())->GetWidgetAcc()->CountChoiceListItems(true)); } void CJX_Object::Script_Som_DefaultValue(CFXJSE_Value* pValue, @@ -1600,10 +1586,7 @@ void CJX_Object::Script_Som_DataNode(CFXJSE_Value* pValue, void CJX_Object::Script_Som_Mandatory(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - if (!widget_data_) - return; - - CXFA_Validate* validate = widget_data_->GetNode()->GetValidate(true); + CXFA_Validate* validate = ToNode(object_.Get())->GetValidate(true); if (!validate) return; diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 2718f1738c..87a164ff8b 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -17,7 +17,6 @@ #include "core/fxcrt/xml/cfx_xmlelement.h" #include "fxjs/CJX_Define.h" #include "third_party/base/optional.h" -#include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/fxfa_basic.h" class CFXJSE_Value; @@ -64,11 +63,6 @@ class CJX_Object { CXFA_Document* GetDocument() const; - void SetWidgetAcc(std::unique_ptr<CXFA_WidgetAcc> data) { - widget_data_ = std::move(data); - } - CXFA_WidgetAcc* GetWidgetAcc() const { return widget_data_.get(); } - void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } size_t GetCalcRecursionCount() const { return calc_recursion_count_; } @@ -271,7 +265,6 @@ class CJX_Object { UnownedPtr<CXFA_Object> object_; UnownedPtr<CXFA_LayoutItem> layout_item_; - std::unique_ptr<CXFA_WidgetAcc> widget_data_; std::unique_ptr<XFA_MAPMODULEDATA> map_module_data_; std::unique_ptr<CXFA_CalcData> calc_data_; std::map<ByteString, CJX_MethodCall> method_specs_; diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp index 9e72257cf3..816c9d487b 100644 --- a/fxjs/xfa/cjx_template.cpp +++ b/fxjs/xfa/cjx_template.cpp @@ -50,7 +50,8 @@ CJS_Return CJX_Template::execInitialize( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(runtime->NewBoolean(!!GetWidgetAcc())); + return CJS_Return( + runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc())); } CJS_Return CJX_Template::recalculate( @@ -66,7 +67,8 @@ CJS_Return CJX_Template::execCalculate( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(runtime->NewBoolean(!!GetWidgetAcc())); + return CJS_Return( + runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc())); } CJS_Return CJX_Template::execValidate( @@ -74,5 +76,6 @@ CJS_Return CJX_Template::execValidate( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(runtime->NewBoolean(!!GetWidgetAcc())); + return CJS_Return( + runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc())); } diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index a85fef96b0..21273f246d 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -340,7 +340,7 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { XFA_Element eType = pNode->GetElementType(); if (XFA_IsCreateWidget(eType)) { - pNode->JSObject()->SetWidgetAcc(pdfium::MakeUnique<CXFA_WidgetAcc>(pNode)); + pNode->CreateWidgetAcc(); return; } diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 86d2300cb4..6021ec377d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -565,10 +565,6 @@ bool CXFA_Node::HasBindItem() { return GetPacketType() == XFA_PacketType::Datasets && GetBindingNode(); } -CXFA_WidgetAcc* CXFA_Node::GetWidgetAcc() { - return JSObject()->GetWidgetAcc(); -} - CXFA_WidgetAcc* CXFA_Node::GetContainerWidgetAcc() { if (GetPacketType() != XFA_PacketType::Form) return nullptr; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 4def12caaf..c2edc70ed9 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -13,12 +13,23 @@ #include <vector> #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/ifx_locale.h" +#include "core/fxge/fx_dib.h" #include "fxjs/xfa/cjx_node.h" #include "third_party/base/optional.h" #include "xfa/fxfa/parser/cxfa_object.h" class CFX_XMLNode; +class CXFA_Bind; +class CXFA_Border; +class CXFA_Calculate; +class CXFA_Caption; +class CXFA_Font; +class CXFA_Margin; class CXFA_Occur; +class CXFA_Para; +class CXFA_Validate; +class CXFA_Value; class CXFA_WidgetAcc; class IXFA_Locale; @@ -182,7 +193,6 @@ class CXFA_Node : public CXFA_Object { int32_t AddBindItem(CXFA_Node* pFormNode); int32_t RemoveBindItem(CXFA_Node* pFormNode); bool HasBindItem(); - CXFA_WidgetAcc* GetWidgetAcc(); CXFA_WidgetAcc* GetContainerWidgetAcc(); IFX_Locale* GetLocale(); Optional<WideString> GetLocaleName(); diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index 666186c4ba..7c73db0ff5 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -11,6 +11,7 @@ #include "core/fxcrt/fx_extension.h" #include "fxjs/cfxjse_engine.h" #include "fxjs/cfxjse_value.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -55,6 +56,10 @@ const CXFA_TreeList* CXFA_Object::AsTreeList() const { return IsTreeList() ? static_cast<const CXFA_TreeList*>(this) : nullptr; } +void CXFA_Object::CreateWidgetAcc() { + acc_ = pdfium::MakeUnique<CXFA_WidgetAcc>(AsNode()); +} + CXFA_Node* ToNode(CXFA_Object* pObj) { return pObj ? pObj->AsNode() : nullptr; } diff --git a/xfa/fxfa/parser/cxfa_object.h b/xfa/fxfa/parser/cxfa_object.h index 0b17273316..a58a922ea2 100644 --- a/xfa/fxfa/parser/cxfa_object.h +++ b/xfa/fxfa/parser/cxfa_object.h @@ -31,6 +31,7 @@ class CJX_Object; class CXFA_Document; class CXFA_Node; class CXFA_TreeList; +class CXFA_WidgetAcc; class CXFA_Object : public CFXJSE_HostObject { public: @@ -71,6 +72,9 @@ class CXFA_Object : public CFXJSE_HostObject { CJX_Object* JSObject() { return m_pJSObject.get(); } const CJX_Object* JSObject() const { return m_pJSObject.get(); } + void CreateWidgetAcc(); + CXFA_WidgetAcc* GetWidgetAcc() { return acc_.get(); } + XFA_Element GetElementType() const { return m_elementType; } WideStringView GetClassName() const { return m_elementName; } uint32_t GetClassHashCode() const { return m_elementNameHash; } @@ -92,6 +96,7 @@ class CXFA_Object : public CFXJSE_HostObject { const WideStringView m_elementName; std::unique_ptr<CJX_Object> m_pJSObject; + std::unique_ptr<CXFA_WidgetAcc> acc_; }; CXFA_Node* ToNode(CXFA_Object* pObj); |