From c30d5bf3efaef5c7254ae326466e6a35cff63365 Mon Sep 17 00:00:00 2001 From: Jun Fang Date: Tue, 2 Feb 2016 18:12:23 -0800 Subject: XFA: Fix a crashier in SetFocus() BUG=pdfium:374 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1640233004 . --- fpdfsdk/include/fsdk_mgr.h | 4 ++++ fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp | 8 +++++-- public/fpdf_formfill.h | 28 +++++++++++------------ xfa/src/fxfa/src/app/xfa_ffnotify.cpp | 8 +++---- xfa/src/fxfa/src/parser/xfa_layout_appadapter.cpp | 8 +++++-- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 72497e2d5f..2df44c7ca1 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -404,6 +404,10 @@ class CPDFDoc_Environment final { } return L""; } + void FFI_PageEvent(int iPageIndex, int iEventType) const { + // Todo: call a call-back function when it's implemented + // in applicaiton's side. + } #endif // PDF_ENABLE_XFA int JS_appAlert(const FX_WCHAR* Msg, diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp index e1f14aa9d4..b8549fce74 100644 --- a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp @@ -477,17 +477,21 @@ void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, return; } CPDFXFA_Page* pPage = nullptr; + CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { - pPage = GetPage(pPageView->GetPageViewIndex()); + int nPageIndex = pPageView->GetPageViewIndex(); + pPage = GetPage(nPageIndex); if (pPage) pPage->SetXFAPageView(pPageView); + pEnv->FFI_PageEvent(nPageIndex, dwFlags); return; } pPage = GetPage(pPageView); if (!pPage) return; - pPage->SetXFAPageView(nullptr); + pEnv->FFI_PageEvent(pPage->GetPageIndex(), dwFlags); m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots(); + pPage->Release(); } void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h index b3bbb9280c..45c7e52c0c 100644 --- a/public/fpdf_formfill.h +++ b/public/fpdf_formfill.h @@ -709,7 +709,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_DisplayCaret * This method will show the caret at specified position. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -739,7 +739,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_GetCurrentPageIndex * This method will get the current page index. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -756,7 +756,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_SetCurrentPage * This method will set the current page. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -775,7 +775,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_GotoURL * This method will link to the specified URL. * Interface Version: - * 1 + * 2 * Implementation Required: * no * Parameters: @@ -794,7 +794,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_GetPageViewRect * This method will get the current page view rectangle. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -822,7 +822,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_PopupMenu * This method will track the right context menu for XFA fields. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -845,7 +845,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_OpenFile * This method will open the specified file with the specified mode. * Interface Version - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -868,7 +868,7 @@ typedef struct _FPDF_FORMFILLINFO { * This method will email the specified file stream to the specified *contacter. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -899,7 +899,7 @@ typedef struct _FPDF_FORMFILLINFO { * This method will get upload the specified file stream to the *specified URL. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -920,7 +920,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_GetPlatform * This method will get the current platform. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -940,7 +940,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_GetLanguage * This method will get the current language. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -960,7 +960,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_DownloadFromURL * This method will download the specified file from the URL. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -975,7 +975,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_PostRequestURL * This method will post the request to the server URL. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: @@ -998,7 +998,7 @@ typedef struct _FPDF_FORMFILLINFO { * Method: FFI_PutRequestURL * This method will put the request to the server URL. * Interface Version: - * 1 + * 2 * Implementation Required: * yes * Parameters: diff --git a/xfa/src/fxfa/src/app/xfa_ffnotify.cpp b/xfa/src/fxfa/src/app/xfa_ffnotify.cpp index a65819de22..9dd93f387a 100644 --- a/xfa/src/fxfa/src/app/xfa_ffnotify.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffnotify.cpp @@ -615,12 +615,12 @@ void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, void* pParam2) { CXFA_FFWidget* pWidget = static_cast(pSender); pDocView->DeleteLayoutItem(pWidget); - if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) { + if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) return; - } m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), - XFA_WIDGETEVENT_PreRemoved, NULL, NULL); - pWidget->AddInvalidateRect(NULL); + XFA_WIDGETEVENT_PreRemoved, nullptr, + pWidget->GetPageView()); + pWidget->AddInvalidateRect(nullptr); } void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, IXFA_DocLayout* pLayout, diff --git a/xfa/src/fxfa/src/parser/xfa_layout_appadapter.cpp b/xfa/src/fxfa/src/parser/xfa_layout_appadapter.cpp index 00908944b2..8e0a9444c5 100644 --- a/xfa/src/fxfa/src/parser/xfa_layout_appadapter.cpp +++ b/xfa/src/fxfa/src/parser/xfa_layout_appadapter.cpp @@ -40,14 +40,18 @@ FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) { } void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; + IXFA_Notify* pNotify = + pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); + IXFA_DocLayout* pDocLayout = + pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); while (pNode) { CXFA_LayoutItem* pNext = pNode->m_pNextSibling; pNode->m_pParent = nullptr; + pNotify->OnLayoutEvent(pDocLayout, static_cast(pNode), + XFA_LAYOUTEVENT_ItemRemoving); XFA_ReleaseLayoutItem(pNode); pNode = pNext; } - IXFA_Notify* pNotify = - pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) { pNotify->OnPageEvent(static_cast(pLayoutItem), XFA_PAGEEVENT_PageRemoved); -- cgit v1.2.3