summaryrefslogtreecommitdiff
path: root/fxjs/cjs_event.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-06-05 18:24:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-05 18:24:12 +0000
commite9f7db9dbb2c5b9d1953c6643e1c38f82130f98b (patch)
tree8918f344abae83984dcd976dbe2a19bf0b0bcc1c /fxjs/cjs_event.cpp
parent22de733a693f27c90f58ee13cfd398c55d9a064f (diff)
downloadpdfium-e9f7db9dbb2c5b9d1953c6643e1c38f82130f98b.tar.xz
[xfa] Make the event context available when calling back in XFA
When calling into the XFA JS engine with a request for a non-XFA JS call which accesses the EventContext we would get a crash in XFA as we never set the context. This CL changes the XFA code to accept the CJS_Runtime instead of the CFXJS_Engine and then calls NewEventContext before executing JS scripts. This will correctly setup the event context as needed for any JS callbacks. Bug: pdfium:1003 Change-Id: Icf202252b2e6e56afdf0d1766a32a893935a2fd3 Reviewed-on: https://pdfium-review.googlesource.com/33930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjs_event.cpp')
-rw-r--r--fxjs/cjs_event.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index ca0671d3a9..de22ab8488 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -50,6 +50,8 @@ CJS_Event::CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Event::~CJS_Event() = default;
CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
@@ -57,6 +59,8 @@ CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -68,6 +72,8 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -80,6 +86,8 @@ CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -92,6 +100,8 @@ CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -245,6 +255,8 @@ CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pEvent->Target_Field()->ToV8Object());
@@ -256,6 +268,8 @@ CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
@@ -267,6 +281,8 @@ CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->Type()));
@@ -277,6 +293,8 @@ CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
}
CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -291,6 +309,8 @@ CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -305,6 +325,8 @@ CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
}
CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
+ ASSERT(pRuntime->GetCurrentEventContext());
+
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));