Replace UnownedPtr with RetainPtr to parser objects in fpdfdoc
Bug: chromium:983867
Change-Id: Ib07bfb48ef85ee7a013f5e1a3d2127648dc950ba
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/57854
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h
index 699d913..8b44153 100644
--- a/core/fpdfdoc/cpdf_aaction.h
+++ b/core/fpdfdoc/cpdf_aaction.h
@@ -8,6 +8,7 @@
#define CORE_FPDFDOC_CPDF_AACTION_H_
#include "core/fpdfdoc/cpdf_action.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
@@ -50,7 +51,7 @@
static bool IsUserClick(AActionType eType);
private:
- UnownedPtr<CPDF_Dictionary> const m_pDict;
+ RetainPtr<CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_AACTION_H_
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index 6ea1c63..f55c42a 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -9,6 +9,7 @@
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
class CPDF_Document;
@@ -56,7 +57,7 @@
CPDF_Action GetSubAction(size_t iIndex) const;
private:
- UnownedPtr<CPDF_Dictionary> const m_pDict;
+ RetainPtr<CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_ACTION_H_
diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h
index 1081867..c2de6ff 100644
--- a/core/fpdfdoc/cpdf_bookmark.h
+++ b/core/fpdfdoc/cpdf_bookmark.h
@@ -10,7 +10,7 @@
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fxcrt/fx_string.h"
-#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
class CPDF_Document;
@@ -31,7 +31,7 @@
CPDF_Action GetAction() const;
private:
- UnownedPtr<CPDF_Dictionary> m_pDict;
+ RetainPtr<CPDF_Dictionary> m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_BOOKMARK_H_
diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h
index 4d9bfb8..c1b1df3 100644
--- a/core/fpdfdoc/cpdf_dest.h
+++ b/core/fpdfdoc/cpdf_dest.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
-#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Document;
class CPDF_Array;
@@ -41,7 +41,7 @@
float* pZoom) const;
private:
- UnownedPtr<CPDF_Array> const m_pArray;
+ RetainPtr<CPDF_Array> const m_pArray;
};
#endif // CORE_FPDFDOC_CPDF_DEST_H_
diff --git a/testing/resources/javascript/bug_983867.in b/testing/resources/javascript/bug_983867.in
new file mode 100644
index 0000000..910be61
--- /dev/null
+++ b/testing/resources/javascript/bug_983867.in
@@ -0,0 +1,73 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /AcroForm 4 0 R
+ /Pages 2 0 R
+ /OpenAction 7 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+{{object 3 0}} <<
+ /MediaBox [ 0 0 612 792 ]
+ /Parent 2 0 R
+ /Type /Page
+ /CropBox [ 0 0 612 792 ]
+ /Annots [ 5 0 R 6 0 R ]
+>>
+endobj
+{{object 4 0}} <<
+ /Fields [ 5 0 R 6 0 R ]
+>>
+endobj
+{{object 5 0}} <<
+ /AA 6 0 R
+ /DV (default value)
+ /T (textfld1)
+ /Rect [ 116 615 393 677 ]
+ /F 4
+ /V (default value)
+ /Subtype /Widget
+ /Type /Annot
+ /FT /Tx
+>>
+endobj
+{{object 6 0}} <<
+ /Ff 0
+ /RV (blah)
+ /Rect [ 226 735 373 771 ]
+ /T (textfld2)
+ /V <<
+ /S /JavaScript
+ /JS (
+ this.a += 1;
+ if (this.a == 3) this.resetForm();
+ )
+ /Type /Action
+ >>
+ /F 4
+ /Subtype /Widget
+ /Type /Annot
+ /FT /Tx
+>>
+endobj
+{{object 7 0}} <<
+ /Type /Action
+ /S /JavaScript
+ /JS (
+ this.a = 1;
+ this.getField("textfld1").setFocus();
+ this.getField("textfld1").value = "1";
+ this.getField("textfld2").setFocus();
+ app.alert("Finished !!!");
+ )
+>>
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/bug_983867_expected.txt b/testing/resources/javascript/bug_983867_expected.txt
new file mode 100644
index 0000000..cc87d2b
--- /dev/null
+++ b/testing/resources/javascript/bug_983867_expected.txt
@@ -0,0 +1 @@
+Alert: Finished !!!