diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-08 15:12:10 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-08 20:34:05 +0000 |
commit | 94fc2af0c9a800f39e4dbcac859f1ad490f7d725 (patch) | |
tree | 3543b5cd38104b00027adde5a8bfe1f5152360c1 /fxjs/xfa | |
parent | 625de446907e8720f0114422683b78a898dd6878 (diff) | |
download | pdfium-94fc2af0c9a800f39e4dbcac859f1ad490f7d725.tar.xz |
Move CXFA_WidgetAcc from CJX_Object to CXFA_Object
This CL change the CJX code to not store the pointer to the
CXFA_WidgetAcc. If needed the CJX object gets the Acc from the Node
itself.
Change-Id: I5a5a500b8fbc1749d362346d72678acd5250d112
Reviewed-on: https://pdfium-review.googlesource.com/22411
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-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 |
8 files changed, 30 insertions, 50 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())); } |