Chromium Code Reviews| Index: xfa/fxfa/parser/xfa_object_imp.cpp |
| diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp |
| index 87941af070350665662581b4c64fd04738573720..be6689131a6fe3b591636cd61905a5699435c9c6 100644 |
| --- a/xfa/fxfa/parser/xfa_object_imp.cpp |
| +++ b/xfa/fxfa/parser/xfa_object_imp.cpp |
| @@ -1298,9 +1298,9 @@ void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue, |
| ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET); |
| } |
| } |
| + |
| void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| - void* eAttribute, |
| - void* eValue, |
| + XFA_ATTRIBUTE eAttribute, |
| FX_BOOL bScriptModify) { |
| CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
| if (!pLayoutPro) { |
| @@ -1317,20 +1317,19 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| switch (eType) { |
| case XFA_ELEMENT_Caption: |
| bNeedFindContainer = TRUE; |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, this, GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, this, |
| + GetNodeItem(XFA_NODEITEM_Parent)); |
| break; |
| case XFA_ELEMENT_Font: |
| case XFA_ELEMENT_Para: { |
| bNeedFindContainer = TRUE; |
| CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
| if (pParentNode->GetClassID() == XFA_ELEMENT_Caption) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pParentNode, |
| - pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged( |
| + this, eAttribute, pParentNode, |
| + pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } else { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, this, pParentNode); |
| + pNotify->OnValueChanged(this, eAttribute, this, pParentNode); |
| } |
| } break; |
| case XFA_ELEMENT_Margin: { |
| @@ -1338,18 +1337,16 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent); |
| XFA_ELEMENT eParentType = pParentNode->GetClassID(); |
| if (pParentNode->IsContainerNode()) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, this, pParentNode); |
| + pNotify->OnValueChanged(this, eAttribute, this, pParentNode); |
| } else if (eParentType == XFA_ELEMENT_Caption) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pParentNode, |
| - pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged( |
| + this, eAttribute, pParentNode, |
| + pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } else { |
| CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); |
| if (pNode && pNode->GetClassID() == XFA_ELEMENT_Ui) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pNode, |
| - pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, pNode, |
| + pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } |
| } |
| } break; |
| @@ -1361,9 +1358,8 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| eUIType == XFA_ELEMENT_TextEdit)) { |
| CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent); |
| if (pUINode) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pUINode, |
| - pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, pUINode, |
| + pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } |
| } |
| } break; |
| @@ -1376,18 +1372,16 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| case XFA_ELEMENT_TextEdit: { |
| CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); |
| if (pUINode) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pUINode, |
| - pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, pUINode, |
| + pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } |
| } break; |
| case XFA_ELEMENT_CheckButton: { |
| bNeedFindContainer = TRUE; |
| CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent); |
| if (pUINode) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pUINode, |
| - pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, pUINode, |
| + pUINode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } |
| } break; |
| case XFA_ELEMENT_Keep: |
| @@ -1405,8 +1399,7 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| case XFA_ELEMENT_Subform: |
| case XFA_ELEMENT_SubformSet: |
| pLayoutPro->AddChangedContainer(this); |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, this, this); |
| + pNotify->OnValueChanged(this, eAttribute, this, this); |
| break; |
| case XFA_ELEMENT_Sharptext: |
| case XFA_ELEMENT_Sharpxml: |
| @@ -1427,19 +1420,16 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| if (bScriptModify) { |
| pValueNode = pNode; |
| } |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pValueNode, pNode); |
| + pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); |
| } else { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pNode, |
| - pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| + pNotify->OnValueChanged(this, eAttribute, pNode, |
| + pNode->GetNodeItem(XFA_NODEITEM_Parent)); |
| } |
| } else { |
| if (eType == XFA_ELEMENT_Items) { |
| CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent); |
| if (pNode && pNode->IsContainerNode()) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, |
| - eValue, pValueNode, pNode); |
| + pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode); |
| } |
| } |
| } |
| @@ -1460,10 +1450,10 @@ void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
| } |
| } |
| } else { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, eValue, |
| - this, this); |
| + pNotify->OnValueChanged(this, eAttribute, this, this); |
| } |
| } |
| + |
| void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue, |
| FX_BOOL bSetting, |
| XFA_ATTRIBUTE eAttribute) { |
| @@ -3912,9 +3902,9 @@ FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr, |
| CXFA_Measurement mValue, |
| FX_BOOL bNotify) { |
| void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| - OnChanging(eAttr, &mValue, bNotify); |
| + OnChanging(eAttr, bNotify); |
| SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); |
| - OnChanged(eAttr, &mValue, bNotify); |
| + OnChanged(eAttr, bNotify); |
| return TRUE; |
| } |
| FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr, |
| @@ -3946,7 +3936,7 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, |
| FX_BOOL bNotify, |
| FX_BOOL bScriptModify) { |
| void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| - OnChanging(eAttr, (void*)wsValue.c_str(), bNotify); |
| + OnChanging(eAttr, bNotify); |
| if (eAttr == XFA_ATTRIBUTE_Value) { |
| CFX_WideString* pClone = new CFX_WideString(wsValue); |
| SetUserData(pKey, pClone, &deleteWideStringCallBack); |
| @@ -3955,7 +3945,7 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, |
| if (eAttr == XFA_ATTRIBUTE_Name) |
| UpdateNameHash(); |
| } |
| - OnChanged(eAttr, (void*)wsValue.c_str(), bNotify, bScriptModify); |
| + OnChanged(eAttr, bNotify, bScriptModify); |
| if (IsNeedSavingXMLNode() && eAttr != XFA_ATTRIBUTE_QualifiedName && |
| eAttr != XFA_ATTRIBUTE_BindingNode) { |
| if (eAttr == XFA_ATTRIBUTE_Name && |
| @@ -4015,11 +4005,10 @@ FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, |
| FX_BOOL bNotify, |
| FX_BOOL bScriptModify) { |
| void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value); |
| - OnChanging(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify); |
| + OnChanging(XFA_ATTRIBUTE_Value, bNotify); |
| CFX_WideString* pClone = new CFX_WideString(wsValue); |
| SetUserData(pKey, pClone, &deleteWideStringCallBack); |
| - OnChanged(XFA_ATTRIBUTE_Value, (void*)wsValue.c_str(), bNotify, |
| - bScriptModify); |
| + OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); |
| if (IsNeedSavingXMLNode()) { |
| FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType(); |
| switch (eXMLType) { |
| @@ -4128,9 +4117,9 @@ FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr, |
| void* pValue, |
| FX_BOOL bNotify) { |
| void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr); |
| - OnChanging(eAttr, pValue, bNotify); |
| + OnChanging(eAttr, bNotify); |
| SetMapModuleValue(pKey, pValue); |
| - OnChanged(eAttr, pValue, bNotify); |
| + OnChanged(eAttr, bNotify); |
| if (IsNeedSavingXMLNode()) { |
| FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element); |
| const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); |
| @@ -4620,9 +4609,9 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { |
| ASSERT(m_pLastChild->m_pNext == NULL); |
| pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
| CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| - if (pNotify) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); |
| - } |
| + if (pNotify) |
| + pNotify->OnChildAdded(this); |
| + |
| if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
| m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); |
| @@ -4666,9 +4655,9 @@ FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { |
| ASSERT(m_pLastChild->m_pNext == NULL); |
| pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE); |
| CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| - if (pNotify) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode); |
| - } |
| + if (pNotify) |
| + pNotify->OnChildAdded(this); |
| + |
| if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { |
| FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL); |
| m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); |
| @@ -4858,7 +4847,7 @@ void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { |
| if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) { |
| CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| if (pNotify) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready); |
| + pNotify->OnNodeReady(this); |
| } |
| } |
| break; |
| @@ -4873,34 +4862,32 @@ void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) { |
| FX_BOOL CXFA_Node::IsAttributeInXML() { |
| return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; |
| } |
| + |
| void CXFA_Node::OnRemoved(CXFA_Node* pParent, |
| CXFA_Node* pRemoved, |
| FX_BOOL bNotify) { |
| if (bNotify && pParent) { |
|
Tom Sepez
2016/04/14 22:45:44
nit: prefer early returns.
Lei Zhang
2016/04/15 01:16:40
Done.
|
| CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| if (pNotify) { |
| - pNotify->OnNodeEvent(pParent, XFA_NODEEVENT_ChildRemoved, pRemoved); |
| + pNotify->OnChildRemoved(); |
| } |
| } |
| } |
| -void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, |
| - void* pNewValue, |
| - FX_BOOL bNotify) { |
| + |
| +void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, FX_BOOL bNotify) { |
| if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { |
| CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| if (pNotify) { |
| - pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanging, |
| - (void*)(uintptr_t)eAttr, pNewValue); |
| + pNotify->OnValueChanging(this, eAttr); |
| } |
| } |
| } |
| + |
| void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr, |
| - void* pNewValue, |
| FX_BOOL bNotify, |
| FX_BOOL bScriptModify) { |
| if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) { |
| - Script_Attribute_SendAttributeChangeMessage((void*)(uintptr_t)eAttr, |
| - pNewValue, bScriptModify); |
| + Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify); |
| } |
| } |
| int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName, |