Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" | 7 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 if (!calc) { | 369 if (!calc) { |
| 370 return XFA_EVENTERROR_NotExist; | 370 return XFA_EVENTERROR_NotExist; |
| 371 } | 371 } |
| 372 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { | 372 if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) { |
| 373 return XFA_EVENTERROR_Disabled; | 373 return XFA_EVENTERROR_Disabled; |
| 374 } | 374 } |
| 375 CXFA_EventParam EventParam; | 375 CXFA_EventParam EventParam; |
| 376 EventParam.m_eType = XFA_EVENT_Calculate; | 376 EventParam.m_eType = XFA_EVENT_Calculate; |
| 377 CXFA_Script script = calc.GetScript(); | 377 CXFA_Script script = calc.GetScript(); |
| 378 int32_t iRet = ExecuteScript(script, &EventParam); | 378 int32_t iRet = ExecuteScript(script, &EventParam); |
| 379 if (iRet == XFA_EVENTERROR_Success) { | 379 if (iRet == XFA_EVENTERROR_Success) { |
|
Tom Sepez
2016/04/14 22:08:55
nit: might prefer early return.
Lei Zhang
2016/04/15 01:16:40
Done.
| |
| 380 if (GetRawValue() != EventParam.m_wsResult) { | 380 if (GetRawValue() != EventParam.m_wsResult) { |
| 381 const bool bNotify = GetDoc()->GetDocType() == XFA_DOCTYPE_Static; | |
| 382 SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); | 381 SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); |
| 383 UpdateUIDisplay(); | 382 UpdateUIDisplay(); |
| 384 if (bNotify) { | |
| 385 NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, NULL, NULL); | |
| 386 } | |
| 387 iRet = XFA_EVENTERROR_Success; | |
| 388 } | 383 } |
| 389 } | 384 } |
| 390 return iRet; | 385 return iRet; |
| 391 } | 386 } |
| 392 void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, | 387 void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, |
| 393 int32_t iRet, | 388 int32_t iRet, |
| 394 FXJSE_HVALUE pRetValue, | 389 FXJSE_HVALUE pRetValue, |
| 395 FX_BOOL bVersionFlag) { | 390 FX_BOOL bVersionFlag) { |
| 396 if (iRet == XFA_EVENTERROR_Success && pRetValue) { | 391 if (iRet == XFA_EVENTERROR_Success && pRetValue) { |
| 397 if (FXJSE_Value_IsBoolean(pRetValue) && !FXJSE_Value_ToBoolean(pRetValue)) { | 392 if (FXJSE_Value_IsBoolean(pRetValue) && !FXJSE_Value_ToBoolean(pRetValue)) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 CXFA_FFWidget* pWidget = NULL; | 739 CXFA_FFWidget* pWidget = NULL; |
| 745 while ((pWidget = GetNextWidget(pWidget))) { | 740 while ((pWidget = GetNextWidget(pWidget))) { |
| 746 if (pWidget == pExcept || !pWidget->IsLoaded() || | 741 if (pWidget == pExcept || !pWidget->IsLoaded() || |
| 747 (GetUIType() != XFA_ELEMENT_CheckButton && pWidget->IsFocused())) { | 742 (GetUIType() != XFA_ELEMENT_CheckButton && pWidget->IsFocused())) { |
| 748 continue; | 743 continue; |
| 749 } | 744 } |
| 750 pWidget->UpdateFWLData(); | 745 pWidget->UpdateFWLData(); |
| 751 pWidget->AddInvalidateRect(); | 746 pWidget->AddInvalidateRect(); |
| 752 } | 747 } |
| 753 } | 748 } |
| 754 void CXFA_WidgetAcc::NotifyEvent(uint32_t dwEvent, | 749 |
| 755 CXFA_FFWidget* pWidget, | |
| 756 void* pParam, | |
| 757 void* pAdditional) { | |
| 758 IXFA_DocProvider* pDocProvider = GetDoc()->GetDocProvider(); | |
| 759 if (pWidget) { | |
| 760 pDocProvider->WidgetEvent(pWidget, this, dwEvent, pParam, pAdditional); | |
| 761 } else { | |
| 762 pWidget = GetNextWidget(pWidget); | |
| 763 if (pWidget == NULL) { | |
| 764 pDocProvider->WidgetEvent(NULL, this, dwEvent, pParam, pAdditional); | |
| 765 return; | |
| 766 } | |
| 767 while (pWidget) { | |
| 768 pDocProvider->WidgetEvent(pWidget, this, dwEvent, pParam, pAdditional); | |
| 769 pWidget = GetNextWidget(pWidget); | |
| 770 } | |
| 771 } | |
| 772 } | |
| 773 void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { | 750 void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { |
| 774 CXFA_Caption caption = GetCaption(); | 751 CXFA_Caption caption = GetCaption(); |
| 775 if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { | 752 if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { |
| 776 return; | 753 return; |
| 777 } | 754 } |
| 778 LoadCaption(); | 755 LoadCaption(); |
| 779 XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); | 756 XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); |
| 780 int32_t iCapPlacement = caption.GetPlacementType(); | 757 int32_t iCapPlacement = caption.GetPlacementType(); |
| 781 FX_FLOAT fCapReserve = caption.GetReserve(); | 758 FX_FLOAT fCapReserve = caption.GetReserve(); |
| 782 const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || | 759 const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1716 if (pIDNode) { | 1693 if (pIDNode) { |
| 1717 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); | 1694 pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); |
| 1718 } | 1695 } |
| 1719 if (pEmbAcc) { | 1696 if (pEmbAcc) { |
| 1720 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 1697 pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
| 1721 return TRUE; | 1698 return TRUE; |
| 1722 } | 1699 } |
| 1723 } | 1700 } |
| 1724 return FALSE; | 1701 return FALSE; |
| 1725 } | 1702 } |
| OLD | NEW |