pdfium/fxjs/ijs_event_context.h
Lei Zhang 24c6be6924 Switch from absl::optional to std::optional
Since absl::optional is using std::optional underneath, just switch to
using std::optional directly.

Change-Id: Ide39da5ac9c7551a710e653a60e15f022046df7b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116290
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-02-08 20:06:48 +00:00

89 lines
3.5 KiB
C++

// Copyright 2016 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef FXJS_IJS_EVENT_CONTEXT_H_
#define FXJS_IJS_EVENT_CONTEXT_H_
#include <optional>
#include "core/fxcrt/widestring.h"
#include "fxjs/ijs_runtime.h"
class CPDF_FormField;
// Records the details of an event and triggers JS execution for it. There
// can be more than one of these at any given time, as JS callbacks to C++
// may trigger new events on top of one another.
class IJS_EventContext {
public:
virtual ~IJS_EventContext() = default;
virtual std::optional<IJS_Runtime::JS_Error> RunScript(
const WideString& script) = 0;
virtual void OnDoc_Open(const WideString& strTargetName) = 0;
virtual void OnDoc_WillPrint() = 0;
virtual void OnDoc_DidPrint() = 0;
virtual void OnDoc_WillSave() = 0;
virtual void OnDoc_DidSave() = 0;
virtual void OnDoc_WillClose() = 0;
virtual void OnPage_Open() = 0;
virtual void OnPage_Close() = 0;
virtual void OnPage_InView() = 0;
virtual void OnPage_OutView() = 0;
virtual void OnField_MouseDown(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) = 0;
virtual void OnField_MouseEnter(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) = 0;
virtual void OnField_MouseExit(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) = 0;
virtual void OnField_MouseUp(bool bModifier,
bool bShift,
CPDF_FormField* pTarget) = 0;
virtual void OnField_Focus(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
WideString* Value) = 0;
virtual void OnField_Blur(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
WideString* Value) = 0;
virtual void OnField_Calculate(CPDF_FormField* pSource,
CPDF_FormField* pTarget,
WideString* Value,
bool* bRc) = 0;
virtual void OnField_Format(CPDF_FormField* pTarget, WideString* Value) = 0;
virtual void OnField_Keystroke(WideString* strChange,
const WideString& strChangeEx,
bool KeyDown,
bool bModifier,
int* nSelEnd,
int* nSelStart,
bool bShift,
CPDF_FormField* pTarget,
WideString* Value,
bool bWillCommit,
bool bFieldFull,
bool* bRc) = 0;
virtual void OnField_Validate(WideString* strChange,
const WideString& strChangeEx,
bool bKeyDown,
bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
WideString* Value,
bool* bRc) = 0;
virtual void OnExternal_Exec() = 0;
};
#endif // FXJS_IJS_EVENT_CONTEXT_H_