Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: xfa/fxfa/app/xfa_ffwidgetacc.cpp

Issue 1890563003: Simplify XFA event handling. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: remove CXFA_FFNotify::OnWidgetDataEvent Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698