Hide CJS_EventRecorder behind CJX_EventContext
This initial step will allow a subsequent combination of the two
classes and the removal of the CJS_EventRecorder. There isn't any
reason that these should be separate since one just tightly wraps
the other.
Change-Id: I2b5ff5705209b94cb54d2dc16c8c6477e790e66d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84153
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index d84c11c..d5d78e0 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -445,8 +445,7 @@
if (!m_pFormFillEnv)
return CJS_Result::Failure(JSMessage::kBadObjectError);
- CJS_EventRecorder* pHandler =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pHandler = pRuntime->GetCurrentEventContext();
if (!pHandler->IsUserGesture())
return CJS_Result::Failure(JSMessage::kUserGestureRequiredError);
@@ -574,8 +573,7 @@
if (!m_pFormFillEnv)
return CJS_Result::Failure(JSMessage::kBadObjectError);
- CJS_EventRecorder* pHandler =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pHandler = pRuntime->GetCurrentEventContext();
if (!pHandler->IsUserGesture())
return CJS_Result::Failure(JSMessage::kUserGestureRequiredError);
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index ceb1201..50760d3 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -55,27 +55,22 @@
CJS_Event::~CJS_Event() = default;
CJS_Result CJS_Event::get_change(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Result CJS_Event::set_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
-
if (vp->IsString()) {
- WideString& wChange = pEvent->Change();
- wChange = pRuntime->ToWideString(vp);
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
+ pEvent->Change() = pRuntime->ToWideString(vp);
}
return CJS_Result::Success();
}
CJS_Result CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
@@ -86,8 +81,7 @@
}
CJS_Result CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewNumber(pEvent->CommitKey()));
}
@@ -97,8 +91,7 @@
}
CJS_Result CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Failure(L"unrecognized event");
@@ -111,8 +104,7 @@
}
CJS_Result CJS_Event::get_key_down(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->KeyDown()));
}
@@ -122,8 +114,7 @@
}
CJS_Result CJS_Event::get_modifier(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Modifier()));
}
@@ -133,8 +124,7 @@
}
CJS_Result CJS_Event::get_name(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewString(pEvent->Name()));
}
@@ -143,14 +133,12 @@
}
CJS_Result CJS_Event::get_rc(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Rc()));
}
CJS_Result CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
pEvent->Rc() = pRuntime->ToBoolean(vp);
return CJS_Result::Success();
}
@@ -183,8 +171,7 @@
}
CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Success();
@@ -193,8 +180,7 @@
CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() == "Keystroke")
pEvent->SetSelEnd(pRuntime->ToInt32(vp));
@@ -202,8 +188,7 @@
}
CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Success();
@@ -212,8 +197,7 @@
CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() == "Keystroke")
pEvent->SetSelStart(pRuntime->ToInt32(vp));
@@ -221,8 +205,7 @@
}
CJS_Result CJS_Event::get_shift(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Shift()));
}
@@ -256,8 +239,7 @@
}
CJS_Result CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
@@ -268,8 +250,7 @@
}
CJS_Result CJS_Event::get_type(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewString(pEvent->Type()));
}
@@ -278,8 +259,7 @@
}
CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Type() != "Field")
return CJS_Result::Failure(L"Bad event type.");
@@ -292,8 +272,7 @@
CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Type() != "Field")
return CJS_Result::Failure(L"Bad event type.");
@@ -311,8 +290,7 @@
}
CJS_Result CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->WillCommit()));
}
diff --git a/fxjs/cjs_event_context.h b/fxjs/cjs_event_context.h
index dfcb1b9..f0d260d 100644
--- a/fxjs/cjs_event_context.h
+++ b/fxjs/cjs_event_context.h
@@ -11,9 +11,9 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "fxjs/cjs_eventrecorder.h"
#include "fxjs/ijs_event_context.h"
-class CJS_EventRecorder;
class CJS_Field;
class CJS_Runtime;
class CPDFSDK_FormFillEnvironment;
@@ -119,11 +119,39 @@
void OnExternal_Exec() override;
CJS_Runtime* GetJSRuntime() const { return m_pRuntime.Get(); }
- CJS_EventRecorder* GetEventRecorder() const { return m_pEventRecorder.get(); }
CPDFSDK_FormFillEnvironment* GetFormFillEnv();
CJS_Field* SourceField();
CJS_Field* TargetField();
+ WideString& Change() { return m_pEventRecorder->Change(); }
+ WideString ChangeEx() const { return m_pEventRecorder->ChangeEx(); }
+ bool IsUserGesture() const { return m_pEventRecorder->IsUserGesture(); }
+ int CommitKey() const { return m_pEventRecorder->CommitKey(); }
+ ByteStringView Name() const { return m_pEventRecorder->Name(); }
+ ByteStringView Type() const { return m_pEventRecorder->Type(); }
+ bool FieldFull() const { return m_pEventRecorder->FieldFull(); }
+ bool KeyDown() const { return m_pEventRecorder->KeyDown(); }
+ bool Modifier() const { return m_pEventRecorder->Modifier(); }
+ bool& Rc() { return m_pEventRecorder->Rc(); }
+ int SelEnd() const { return m_pEventRecorder->SelEnd(); }
+ int SelStart() const { return m_pEventRecorder->SelStart(); }
+ void SetSelEnd(int value) { m_pEventRecorder->SetSelEnd(value); }
+ void SetSelStart(int value) { m_pEventRecorder->SetSelStart(value); }
+ bool Shift() const { return m_pEventRecorder->Shift(); }
+ bool HasValue() const { return m_pEventRecorder->HasValue(); }
+ WideString& Value() { return m_pEventRecorder->Value(); }
+ WideString TargetName() const { return m_pEventRecorder->TargetName(); }
+ bool WillCommit() const { return m_pEventRecorder->WillCommit(); }
+
+ void SetValueForTest(WideString* pStr) {
+ m_pEventRecorder->SetValueForTest(pStr);
+ }
+ void SetRCForTest(bool* pRC) { m_pEventRecorder->SetRCForTest(pRC); }
+ void SetStrChangeForTest(WideString* pStrChange) {
+ m_pEventRecorder->SetStrChangeForTest(pStrChange);
+ }
+ void ResetWillCommitForTest() { m_pEventRecorder->ResetWillCommitForTest(); }
+
private:
UnownedPtr<CJS_Runtime> const m_pRuntime;
std::unique_ptr<CJS_EventRecorder> const m_pEventRecorder;
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 5c7a91b..611c11f 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -126,7 +126,7 @@
}
#endif
-WideString CalcMergedString(const CJS_EventRecorder* event,
+WideString CalcMergedString(const CJS_EventContext* event,
const WideString& value,
const WideString& change) {
WideString prefix = value.First(event->SelStart());
@@ -592,11 +592,10 @@
return CJS_Result::Failure(JSMessage::kParamError);
CJS_EventContext* pEventContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pEventContext->GetEventRecorder();
- if (!pEvent->HasValue())
+ if (!pEventContext->HasValue())
return CJS_Result::Failure(WideString::FromASCII("No event handler"));
- WideString& Value = pEvent->Value();
+ WideString& Value = pEventContext->Value();
ByteString strValue = StrTrim(Value.ToDefANSI());
if (strValue.IsEmpty())
return CJS_Result::Success();
@@ -699,22 +698,21 @@
return CJS_Result::Failure(JSMessage::kParamError);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pContext->GetEventRecorder();
- if (!pEvent->HasValue())
+ if (!pContext->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
- WideString& val = pEvent->Value();
- WideString& wstrChange = pEvent->Change();
+ WideString& val = pContext->Value();
+ WideString& wstrChange = pContext->Change();
WideString wstrValue = val;
- if (pEvent->WillCommit()) {
+ if (pContext->WillCommit()) {
WideString swTemp = StrTrim(wstrValue);
if (swTemp.IsEmpty())
return CJS_Result::Success();
NormalizeDecimalMarkW(&swTemp);
if (!IsNumber(swTemp)) {
- pEvent->Rc() = false;
+ pContext->Rc() = false;
WideString sError = JSGetStringFromID(JSMessage::kInvalidInputError);
AlertIfPossible(pContext, L"AFNumber_Keystroke", sError);
return CJS_Result::Failure(sError);
@@ -724,16 +722,16 @@
}
WideString wstrSelected;
- if (pEvent->SelStart() != -1) {
- wstrSelected = wstrValue.Substr(pEvent->SelStart(),
- pEvent->SelEnd() - pEvent->SelStart());
+ if (pContext->SelStart() != -1) {
+ wstrSelected = wstrValue.Substr(pContext->SelStart(),
+ pContext->SelEnd() - pContext->SelStart());
}
bool bHasSign = wstrValue.Contains(L'-') && !wstrSelected.Contains(L'-');
if (bHasSign) {
// can't insert "change" in front of sign position.
- if (!wstrSelected.IsEmpty() && pEvent->SelStart() == 0) {
- pEvent->Rc() = false;
+ if (!wstrSelected.IsEmpty() && pContext->SelStart() == 0) {
+ pContext->Rc() = false;
return CJS_Result::Success();
}
}
@@ -745,7 +743,7 @@
for (size_t i = 0; i < wstrChange.GetLength(); ++i) {
if (wstrChange[i] == cSep) {
if (bHasSep) {
- pEvent->Rc() = false;
+ pContext->Rc() = false;
return CJS_Result::Success();
}
bHasSep = true;
@@ -753,16 +751,16 @@
}
if (wstrChange[i] == L'-') {
if (bHasSign) {
- pEvent->Rc() = false;
+ pContext->Rc() = false;
return CJS_Result::Success();
}
// sign's position is not correct
if (i != 0) {
- pEvent->Rc() = false;
+ pContext->Rc() = false;
return CJS_Result::Success();
}
- if (pEvent->SelStart() != 0) {
- pEvent->Rc() = false;
+ if (pContext->SelStart() != 0) {
+ pContext->Rc() = false;
return CJS_Result::Success();
}
bHasSign = true;
@@ -770,12 +768,12 @@
}
if (!FXSYS_IsDecimalDigit(wstrChange[i])) {
- pEvent->Rc() = false;
+ pContext->Rc() = false;
return CJS_Result::Success();
}
}
- val = CalcMergedString(pEvent, wstrValue, wstrChange);
+ val = CalcMergedString(pContext, wstrValue, wstrChange);
return CJS_Result::Success();
}
@@ -787,8 +785,7 @@
if (params.size() < 2)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -882,8 +879,7 @@
if (params.size() != 1)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pContext->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -904,7 +900,7 @@
if (isnan(dDate)) {
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
- AlertIfPossible(pContext, L"AFDate_FormatEx", swMsg);
+ AlertIfPossible(pEvent, L"AFDate_FormatEx", swMsg);
return CJS_Result::Failure(JSMessage::kParseDateError);
}
@@ -957,8 +953,7 @@
"AFDate_KeystrokeEx's parameter size not correct"));
}
- CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pContext->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->WillCommit())
return CJS_Result::Success();
@@ -975,7 +970,7 @@
if (bWrongFormat || isnan(dRet)) {
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
- AlertIfPossible(pContext, L"AFDate_KeystrokeEx", swMsg);
+ AlertIfPossible(pEvent, L"AFDate_KeystrokeEx", swMsg);
pEvent->Rc() = false;
}
return CJS_Result::Success();
@@ -1054,8 +1049,7 @@
if (params.size() != 1)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -1090,8 +1084,7 @@
if (params.size() < 1)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pContext->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -1105,7 +1098,7 @@
return CJS_Result::Success();
if (valEvent.GetLength() > wstrMask.GetLength()) {
- AlertIfPossible(pContext, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1117,7 +1110,7 @@
break;
}
if (iIndex != wstrMask.GetLength()) {
- AlertIfPossible(pContext, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
JSGetStringFromID(JSMessage::kInvalidInputError));
pEvent->Rc() = false;
}
@@ -1133,14 +1126,14 @@
size_t combined_len = valEvent.GetLength() + wChange.GetLength() +
pEvent->SelStart() - pEvent->SelEnd();
if (combined_len > wstrMask.GetLength()) {
- AlertIfPossible(pContext, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
- AlertIfPossible(pContext, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1148,7 +1141,7 @@
for (size_t i = 0; i < wChange.GetLength(); ++i) {
if (iIndexMask >= wstrMask.GetLength()) {
- AlertIfPossible(pContext, L"AFSpecial_KeystrokeEx",
+ AlertIfPossible(pEvent, L"AFSpecial_KeystrokeEx",
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
return CJS_Result::Success();
@@ -1174,8 +1167,7 @@
if (params.size() != 1)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -1209,19 +1201,17 @@
if (params.size() != 1)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventRecorder* pEventRecorder =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
WideString swValue;
- if (pEventRecorder->HasValue())
- swValue = pEventRecorder->Value();
+ if (pEvent->HasValue())
+ swValue = pEvent->Value();
- if (pEventRecorder->WillCommit())
+ if (pEvent->WillCommit())
return CJS_Result::Success(pRuntime->NewString(swValue.AsStringView()));
return CJS_Result::Success(pRuntime->NewString(
- CalcMergedString(pEventRecorder, swValue, pEventRecorder->Change())
- .AsStringView()));
+ CalcMergedString(pEvent, swValue, pEvent->Change()).AsStringView()));
}
CJS_Result CJS_PublicMethods::AFParseDateEx(
@@ -1370,10 +1360,8 @@
dValue = floor(dValue * powf(10, 6) + 0.49) / powf(10, 6);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- if (pContext->GetEventRecorder()->HasValue()) {
- pContext->GetEventRecorder()->Value() =
- pRuntime->ToWideString(pRuntime->NewNumber(dValue));
- }
+ if (pContext->HasValue())
+ pContext->Value() = pRuntime->ToWideString(pRuntime->NewNumber(dValue));
return CJS_Result::Success();
}
@@ -1386,8 +1374,7 @@
if (params.size() != 4)
return CJS_Result::Failure(JSMessage::kParamError);
- CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
- CJS_EventRecorder* pEvent = pContext->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (!pEvent->HasValue())
return CJS_Result::Failure(JSMessage::kBadObjectError);
@@ -1420,7 +1407,7 @@
}
if (!swMsg.IsEmpty()) {
- AlertIfPossible(pContext, L"AFRange_Validate", swMsg);
+ AlertIfPossible(pEvent, L"AFRange_Validate", swMsg);
pEvent->Rc() = false;
}
return CJS_Result::Success();
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp
index fd86392..a21a938 100644
--- a/fxjs/cjs_publicmethods_embeddertest.cpp
+++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -192,8 +192,7 @@
runtime.NewEventContext();
WideString result;
- runtime.GetCurrentEventContext()->GetEventRecorder()->SetValueForTest(
- &result);
+ runtime.GetCurrentEventContext()->SetValueForTest(&result);
auto ary = runtime.NewArray();
runtime.PutArrayElement(ary, 0, runtime.NewString("Calc1_A"));
@@ -206,8 +205,7 @@
CJS_Result ret = CJS_PublicMethods::AFSimple_Calculate(&runtime, params);
UnloadPage(page);
- runtime.GetCurrentEventContext()->GetEventRecorder()->SetValueForTest(
- nullptr);
+ runtime.GetCurrentEventContext()->SetValueForTest(nullptr);
ASSERT_TRUE(!ret.HasError());
ASSERT_TRUE(!ret.HasReturn());
@@ -227,7 +225,7 @@
CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle()));
runtime.NewEventContext();
- auto* handler = runtime.GetCurrentEventContext()->GetEventRecorder();
+ auto* handler = runtime.GetCurrentEventContext();
bool valid = true;
WideString result = L"-10";