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>
diff --git a/fxjs/cfx_globaldata.cpp b/fxjs/cfx_globaldata.cpp
index 6d6efd5..b07974e 100644
--- a/fxjs/cfx_globaldata.cpp
+++ b/fxjs/cfx_globaldata.cpp
@@ -254,7 +254,7 @@
bool ret;
{
// Span can't outlive call to BufferDone().
- absl::optional<pdfium::span<uint8_t>> buffer = m_pDelegate->LoadBuffer();
+ std::optional<pdfium::span<uint8_t>> buffer = m_pDelegate->LoadBuffer();
if (!buffer.has_value() || buffer.value().empty())
return false;
diff --git a/fxjs/cfx_globaldata.h b/fxjs/cfx_globaldata.h
index ac94058..7ca4fd6 100644
--- a/fxjs/cfx_globaldata.h
+++ b/fxjs/cfx_globaldata.h
@@ -8,12 +8,12 @@
#define FXJS_CFX_GLOBALDATA_H_
#include <memory>
+#include <optional>
#include <vector>
#include "core/fxcrt/binary_buffer.h"
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfx_keyvalue.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/containers/span.h"
class CFX_GlobalData {
@@ -23,7 +23,7 @@
virtual ~Delegate() = default;
virtual bool StoreBuffer(pdfium::span<const uint8_t> pBuffer) = 0;
- virtual absl::optional<pdfium::span<uint8_t>> LoadBuffer() = 0;
+ virtual std::optional<pdfium::span<uint8_t>> LoadBuffer() = 0;
virtual void BufferDone() = 0;
};
diff --git a/fxjs/cfx_globaldata_unittest.cpp b/fxjs/cfx_globaldata_unittest.cpp
index 8121701..569d159 100644
--- a/fxjs/cfx_globaldata_unittest.cpp
+++ b/fxjs/cfx_globaldata_unittest.cpp
@@ -23,7 +23,7 @@
last_buffer_ = DataVector<uint8_t>(buffer.begin(), buffer.end());
return true;
}
- absl::optional<pdfium::span<uint8_t>> LoadBuffer() override {
+ std::optional<pdfium::span<uint8_t>> LoadBuffer() override {
return pdfium::span<uint8_t>(last_buffer_);
}
void BufferDone() override {
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 35653c9..b3dd904 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -574,7 +574,7 @@
GetIsolate()->SetData(g_embedderDataSlot, nullptr);
}
-absl::optional<IJS_Runtime::JS_Error> CFXJS_Engine::Execute(
+std::optional<IJS_Runtime::JS_Error> CFXJS_Engine::Execute(
const WideString& script) {
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::TryCatch try_catch(GetIsolate());
@@ -599,7 +599,7 @@
std::tie(line, column) = GetLineAndColumnFromError(msg, context);
return IJS_Runtime::JS_Error(line, column, WideString::FromUTF8(*error));
}
- return absl::nullopt;
+ return std::nullopt;
}
v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(uint32_t nObjDefnID,
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index b0011fc..91ac103 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -130,7 +130,7 @@
void ReleaseEngine();
// Called after FXJS_InitializeEngine call made.
- absl::optional<IJS_Runtime::JS_Error> Execute(const WideString& script);
+ std::optional<IJS_Runtime::JS_Error> Execute(const WideString& script);
v8::Local<v8::Object> GetThisObj();
v8::Local<v8::Object> NewFXJSBoundObject(uint32_t nObjDefnID,
diff --git a/fxjs/cfxjs_engine_embeddertest.cpp b/fxjs/cfxjs_engine_embeddertest.cpp
index 70e84ab..f8952af 100644
--- a/fxjs/cfxjs_engine_embeddertest.cpp
+++ b/fxjs/cfxjs_engine_embeddertest.cpp
@@ -40,7 +40,7 @@
v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope(GetV8Context());
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine()->Execute(WideString(kScript1));
EXPECT_FALSE(err);
CheckAssignmentInEngineContext(engine(), kExpected1);
@@ -58,7 +58,7 @@
v8::Context::Scope context_scope(GetV8Context());
{
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine()->Execute(WideString(kScript0));
EXPECT_FALSE(err);
CheckAssignmentInEngineContext(engine(), kExpected0);
@@ -66,7 +66,7 @@
{
// engine1 executing in engine1's context doesn't affect main.
v8::Context::Scope context_scope1(engine1.GetV8Context());
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine1.Execute(WideString(kScript1));
EXPECT_FALSE(err);
CheckAssignmentInEngineContext(engine(), kExpected0);
@@ -75,7 +75,7 @@
{
// engine1 executing in engine2's context doesn't affect engine1.
v8::Context::Scope context_scope2(engine2.GetV8Context());
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine1.Execute(WideString(kScript2));
EXPECT_FALSE(err);
CheckAssignmentInEngineContext(engine(), kExpected0);
@@ -91,7 +91,7 @@
v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope(GetV8Context());
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine()->Execute(L"functoon(x) { return x+1; }");
EXPECT_TRUE(err);
EXPECT_STREQ(L"SyntaxError: Unexpected token '{'", err->exception.c_str());
@@ -104,7 +104,7 @@
v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope(GetV8Context());
- absl::optional<IJS_Runtime::JS_Error> err =
+ std::optional<IJS_Runtime::JS_Error> err =
engine()->Execute(L"let a = 3;\nundefined.colour");
EXPECT_TRUE(err);
EXPECT_EQ(
diff --git a/fxjs/cfxjs_engine_unittest.cpp b/fxjs/cfxjs_engine_unittest.cpp
index 8d6c36b..c138255 100644
--- a/fxjs/cfxjs_engine_unittest.cpp
+++ b/fxjs/cfxjs_engine_unittest.cpp
@@ -92,7 +92,7 @@
EXPECT_FALSE(temp_destroyed);
}
- absl::optional<IJS_Runtime::JS_Error> err = engine()->Execute(L"gc();");
+ std::optional<IJS_Runtime::JS_Error> err = engine()->Execute(L"gc();");
EXPECT_FALSE(err);
EXPECT_TRUE(perm_created);
diff --git a/fxjs/cjs_event_context.cpp b/fxjs/cjs_event_context.cpp
index 65eee9d..5fa7cd0 100644
--- a/fxjs/cjs_event_context.cpp
+++ b/fxjs/cjs_event_context.cpp
@@ -22,7 +22,7 @@
CJS_EventContext::~CJS_EventContext() = default;
-absl::optional<IJS_Runtime::JS_Error> CJS_EventContext::RunScript(
+std::optional<IJS_Runtime::JS_Error> CJS_EventContext::RunScript(
const WideString& script) {
v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
@@ -44,7 +44,7 @@
1, 1, JSGetStringFromID(JSMessage::kDuplicateEventError));
}
- absl::optional<IJS_Runtime::JS_Error> err;
+ std::optional<IJS_Runtime::JS_Error> err;
if (script.GetLength() > 0)
err = m_pRuntime->ExecuteScript(script);
diff --git a/fxjs/cjs_event_context.h b/fxjs/cjs_event_context.h
index a0b266b..793c247 100644
--- a/fxjs/cjs_event_context.h
+++ b/fxjs/cjs_event_context.h
@@ -47,7 +47,7 @@
~CJS_EventContext() override;
// IJS_EventContext
- absl::optional<IJS_Runtime::JS_Error> RunScript(
+ std::optional<IJS_Runtime::JS_Error> RunScript(
const WideString& script) override;
void OnDoc_Open(const WideString& strTargetName) override;
void OnDoc_WillPrint() override;
diff --git a/fxjs/cjs_event_context_stub.cpp b/fxjs/cjs_event_context_stub.cpp
index b8d0518..43ca89b 100644
--- a/fxjs/cjs_event_context_stub.cpp
+++ b/fxjs/cjs_event_context_stub.cpp
@@ -10,7 +10,7 @@
CJS_EventContextStub::~CJS_EventContextStub() = default;
-absl::optional<IJS_Runtime::JS_Error> CJS_EventContextStub::RunScript(
+std::optional<IJS_Runtime::JS_Error> CJS_EventContextStub::RunScript(
const WideString& script) {
return IJS_Runtime::JS_Error(1, 1, L"JavaScript support not present");
}
diff --git a/fxjs/cjs_event_context_stub.h b/fxjs/cjs_event_context_stub.h
index 5c9b50a..f6494b2 100644
--- a/fxjs/cjs_event_context_stub.h
+++ b/fxjs/cjs_event_context_stub.h
@@ -15,7 +15,7 @@
~CJS_EventContextStub() override;
// IJS_EventContext:
- absl::optional<IJS_Runtime::JS_Error> RunScript(
+ std::optional<IJS_Runtime::JS_Error> RunScript(
const WideString& script) override;
void OnDoc_Open(const WideString& strTargetName) override {}
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 1724f81..08d9b9d 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <memory>
+#include <optional>
#include <utility>
#include "constants/access_permissions.h"
@@ -27,7 +28,6 @@
#include "fxjs/cjs_icon.h"
#include "fxjs/fxv8.h"
#include "fxjs/js_resources.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/check.h"
#include "third_party/base/containers/span.h"
#include "third_party/base/notreached.h"
@@ -68,7 +68,7 @@
if (IsComboBoxOrTextField(pFormField)) {
for (auto& pWidget : widgets) {
if (pWidget) {
- absl::optional<WideString> sValue = pWidget->OnFormat();
+ std::optional<WideString> sValue = pWidget->OnFormat();
if (pWidget) { // Not redundant, may be clobbered by OnFormat.
pWidget->ResetAppearance(sValue, CPDFSDK_Widget::kValueUnchanged);
}
@@ -77,7 +77,7 @@
} else {
for (auto& pWidget : widgets) {
if (pWidget) {
- pWidget->ResetAppearance(absl::nullopt,
+ pWidget->ResetAppearance(std::nullopt,
CPDFSDK_Widget::kValueUnchanged);
}
}
@@ -108,13 +108,12 @@
FormFieldType fieldType = pWidget->GetFieldType();
if (fieldType == FormFieldType::kComboBox ||
fieldType == FormFieldType::kTextField) {
- absl::optional<WideString> sValue = pWidget->OnFormat();
+ std::optional<WideString> sValue = pWidget->OnFormat();
if (!observed_widget)
return;
pWidget->ResetAppearance(sValue, CPDFSDK_Widget::kValueUnchanged);
} else {
- pWidget->ResetAppearance(absl::nullopt,
- CPDFSDK_Widget::kValueUnchanged);
+ pWidget->ResetAppearance(std::nullopt, CPDFSDK_Widget::kValueUnchanged);
}
if (!observed_widget)
return;
@@ -132,7 +131,7 @@
int control_index;
};
-absl::optional<FieldNameData> ParseFieldName(const WideString& field_name) {
+std::optional<FieldNameData> ParseFieldName(const WideString& field_name) {
auto reverse_it = field_name.rbegin();
while (reverse_it != field_name.rend()) {
if (*reverse_it == L'.')
@@ -140,14 +139,14 @@
++reverse_it;
}
if (reverse_it == field_name.rend()) {
- return absl::nullopt;
+ return std::nullopt;
}
WideString suffixal = field_name.Last(reverse_it - field_name.rbegin());
int control_index = FXSYS_wtoi(suffixal.c_str());
if (control_index == 0) {
suffixal.TrimRight(L' ');
if (suffixal != L"0") {
- return absl::nullopt;
+ return std::nullopt;
}
}
return FieldNameData(field_name.First(field_name.rend() - reverse_it - 1),
@@ -649,7 +648,7 @@
swFieldNameTemp.Replace(L"..", L".");
if (pForm->CountFields(swFieldNameTemp) <= 0) {
- absl::optional<FieldNameData> parsed_data = ParseFieldName(swFieldNameTemp);
+ std::optional<FieldNameData> parsed_data = ParseFieldName(swFieldNameTemp);
if (!parsed_data.has_value())
return false;
@@ -1905,7 +1904,7 @@
return CJS_Result::Failure(JSMessage::kBadObjectError);
CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
- absl::optional<CFX_Color::TypeAndARGB> maybe_type_argb_pair =
+ std::optional<CFX_Color::TypeAndARGB> maybe_type_argb_pair =
FieldAppearance.GetColorARGB();
CFX_Color crRet;
@@ -1956,7 +1955,7 @@
return CJS_Result::Failure(JSMessage::kObjectTypeError);
}
- absl::optional<WideString> wsFontName =
+ std::optional<WideString> wsFontName =
pFormControl->GetDefaultControlFontName();
if (!wsFontName.has_value())
return CJS_Result::Failure(JSMessage::kBadObjectError);
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 0377d93..2cd257d 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -12,6 +12,7 @@
#include <iomanip>
#include <iterator>
#include <limits>
+#include <optional>
#include <sstream>
#include <string>
#include <utility>
@@ -35,7 +36,6 @@
#include "fxjs/fx_date_helpers.h"
#include "fxjs/js_define.h"
#include "fxjs/js_resources.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/check.h"
#include "third_party/base/containers/span.h"
#include "third_party/base/numerics/safe_conversions.h"
@@ -213,9 +213,9 @@
str->Replace(L",", L".");
}
-absl::optional<double> ApplyNamedOperation(const WideString& wsFunction,
- double dValue1,
- double dValue2) {
+std::optional<double> ApplyNamedOperation(const WideString& wsFunction,
+ double dValue1,
+ double dValue2) {
if (wsFunction.EqualsASCIINoCase("AVG") ||
wsFunction.EqualsASCIINoCase("SUM")) {
return dValue1 + dValue2;
@@ -226,7 +226,7 @@
return std::min(dValue1, dValue2);
if (wsFunction.EqualsASCIINoCase("MAX"))
return std::max(dValue1, dValue2);
- return absl::nullopt;
+ return std::nullopt;
}
} // namespace
@@ -846,7 +846,7 @@
strValue.ReleaseBuffer(szNewSize);
// for processing separator style
- absl::optional<size_t> mark_pos = strValue.Find('.');
+ std::optional<size_t> mark_pos = strValue.Find('.');
if (mark_pos.has_value()) {
char mark = DecimalMarkForStyle(iSepStyle);
if (mark != '.')
@@ -1255,7 +1255,7 @@
if (isnan(arg1) || isnan(arg2))
return CJS_Result::Failure(JSMessage::kValueError);
- absl::optional<double> result = ApplyNamedOperation(sFunction, arg1, arg2);
+ std::optional<double> result = ApplyNamedOperation(sFunction, arg1, arg2);
if (!result.has_value())
return CJS_Result::Failure(JSMessage::kValueError);
@@ -1354,7 +1354,7 @@
wcscmp(sFunction.c_str(), L"MAX") == 0)) {
dValue = dTemp;
}
- absl::optional<double> dResult =
+ std::optional<double> dResult =
ApplyNamedOperation(sFunction, dValue, dTemp);
if (!dResult.has_value())
return CJS_Result::Failure(JSMessage::kValueError);
diff --git a/fxjs/cjs_result.h b/fxjs/cjs_result.h
index 993a4dc..2e94797 100644
--- a/fxjs/cjs_result.h
+++ b/fxjs/cjs_result.h
@@ -7,8 +7,9 @@
#ifndef FXJS_CJS_RESULT_H_
#define FXJS_CJS_RESULT_H_
+#include <optional>
+
#include "fxjs/js_resources.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "v8/include/v8-forward.h"
class CJS_Result {
@@ -50,7 +51,7 @@
explicit CJS_Result(const WideString&); // Error with custom message.
explicit CJS_Result(JSMessage id); // Error with stock message.
- absl::optional<WideString> error_;
+ std::optional<WideString> error_;
v8::Local<v8::Value> return_;
};
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index f7d76da..aba2346 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -166,7 +166,7 @@
return m_pFormFillEnv.Get();
}
-absl::optional<IJS_Runtime::JS_Error> CJS_Runtime::ExecuteScript(
+std::optional<IJS_Runtime::JS_Error> CJS_Runtime::ExecuteScript(
const WideString& script) {
return Execute(script);
}
diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h
index a3569f6..97e4ebf 100644
--- a/fxjs/cjs_runtime.h
+++ b/fxjs/cjs_runtime.h
@@ -34,7 +34,7 @@
IJS_EventContext* NewEventContext() override;
void ReleaseEventContext(IJS_EventContext* pContext) override;
CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override;
- absl::optional<IJS_Runtime::JS_Error> ExecuteScript(
+ std::optional<IJS_Runtime::JS_Error> ExecuteScript(
const WideString& script) override;
CJS_EventContext* GetCurrentEventContext() const;
diff --git a/fxjs/cjs_runtimestub.cpp b/fxjs/cjs_runtimestub.cpp
index 0a68a17..c020664 100644
--- a/fxjs/cjs_runtimestub.cpp
+++ b/fxjs/cjs_runtimestub.cpp
@@ -29,7 +29,7 @@
return nullptr;
}
-absl::optional<IJS_Runtime::JS_Error> CJS_RuntimeStub::ExecuteScript(
+std::optional<IJS_Runtime::JS_Error> CJS_RuntimeStub::ExecuteScript(
const WideString& script) {
- return absl::nullopt;
+ return std::nullopt;
}
diff --git a/fxjs/cjs_runtimestub.h b/fxjs/cjs_runtimestub.h
index c58e2c4..e1b96a4 100644
--- a/fxjs/cjs_runtimestub.h
+++ b/fxjs/cjs_runtimestub.h
@@ -27,7 +27,7 @@
void ReleaseEventContext(IJS_EventContext* pContext) override;
CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override;
- absl::optional<IJS_Runtime::JS_Error> ExecuteScript(
+ std::optional<IJS_Runtime::JS_Error> ExecuteScript(
const WideString& script) override;
private:
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 7efb840..e868fcc 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -112,7 +112,7 @@
{
size_t offset = 0;
while (true) {
- absl::optional<size_t> offset_end =
+ std::optional<size_t> offset_end =
unsafe_fmt_string.Find(L"%", offset + 1);
if (!offset_end.has_value()) {
unsafe_conversion_specifiers.push_back(
diff --git a/fxjs/ijs_event_context.h b/fxjs/ijs_event_context.h
index 8e9d23c..607144f 100644
--- a/fxjs/ijs_event_context.h
+++ b/fxjs/ijs_event_context.h
@@ -7,9 +7,10 @@
#ifndef FXJS_IJS_EVENT_CONTEXT_H_
#define FXJS_IJS_EVENT_CONTEXT_H_
+#include <optional>
+
#include "core/fxcrt/widestring.h"
#include "fxjs/ijs_runtime.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class CPDF_FormField;
@@ -20,7 +21,7 @@
public:
virtual ~IJS_EventContext() = default;
- virtual absl::optional<IJS_Runtime::JS_Error> RunScript(
+ virtual std::optional<IJS_Runtime::JS_Error> RunScript(
const WideString& script) = 0;
virtual void OnDoc_Open(const WideString& strTargetName) = 0;
diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h
index d2ce19f..827d8ca 100644
--- a/fxjs/ijs_runtime.h
+++ b/fxjs/ijs_runtime.h
@@ -8,11 +8,11 @@
#define FXJS_IJS_RUNTIME_H_
#include <memory>
+#include <optional>
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxcrt/widestring.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class CJS_Runtime;
class CPDFSDK_FormFillEnvironment;
@@ -57,7 +57,7 @@
virtual IJS_EventContext* NewEventContext() = 0;
virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
- virtual absl::optional<JS_Error> ExecuteScript(const WideString& script) = 0;
+ virtual std::optional<JS_Error> ExecuteScript(const WideString& script) = 0;
protected:
IJS_Runtime() = default;
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index c0f66a6..94fa0f9 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -180,7 +180,7 @@
m_FormCalcContext = std::make_unique<CFXJSE_FormCalcContext>(
GetIsolate(), m_JsContext.get(), m_pDocument.Get());
}
- absl::optional<WideTextBuffer> wsJavaScript =
+ std::optional<WideTextBuffer> wsJavaScript =
CFXJSE_FormCalcContext::Translate(m_pDocument->GetHeap(), wsScript);
if (!wsJavaScript.has_value()) {
auto undefined_value = std::make_unique<CFXJSE_Value>();
@@ -209,7 +209,7 @@
if (!refNode)
return false;
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
ResolveObjects(refNode, propname, dwFlag);
if (!maybeResult.has_value())
return false;
@@ -236,7 +236,7 @@
if (!refNode)
return false;
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
ResolveObjects(refNode, propname, dwFlag);
if (!maybeResult.has_value())
return false;
@@ -426,7 +426,7 @@
&pReturnValue)) {
return pReturnValue;
}
- absl::optional<XFA_SCRIPTATTRIBUTEINFO> info = XFA_GetScriptAttributeByName(
+ std::optional<XFA_SCRIPTATTRIBUTEINFO> info = XFA_GetScriptAttributeByName(
pObject->GetElementType(), wsPropName.AsStringView());
if (info.has_value()) {
(*info.value().callback)(pIsolate, pObject->JSObject(), &pReturnValue,
@@ -467,7 +467,7 @@
CXFA_Object* pObject = pScriptContext->GetVariablesThis(pOriginalObject);
WideString wsPropName = WideString::FromUTF8(szPropName);
WideStringView wsPropNameView = wsPropName.AsStringView();
- absl::optional<XFA_SCRIPTATTRIBUTEINFO> info =
+ std::optional<XFA_SCRIPTATTRIBUTEINFO> info =
XFA_GetScriptAttributeByName(pObject->GetElementType(), wsPropNameView);
if (info.has_value()) {
CJX_Object* jsObject = pObject->JSObject();
@@ -526,7 +526,7 @@
return FXJSE_ClassPropType::kMethod;
if (bQueryIn) {
- absl::optional<XFA_SCRIPTATTRIBUTEINFO> maybe_info =
+ std::optional<XFA_SCRIPTATTRIBUTEINFO> maybe_info =
XFA_GetScriptAttributeByName(eType, wsPropName.AsStringView());
if (!maybe_info.has_value())
return FXJSE_ClassPropType::kNone;
@@ -611,7 +611,7 @@
if (!pTextNode)
return;
- absl::optional<WideString> wsScript =
+ std::optional<WideString> wsScript =
pTextNode->JSObject()->TryCData(XFA_Attribute::Value, true);
if (!wsScript.has_value())
return;
@@ -685,20 +685,20 @@
fxv8::ReentrantDeleteObjectPropertyHelper(GetIsolate(), pObject, "Date");
}
-absl::optional<CFXJSE_Engine::ResolveResult> CFXJSE_Engine::ResolveObjects(
+std::optional<CFXJSE_Engine::ResolveResult> CFXJSE_Engine::ResolveObjects(
CXFA_Object* refObject,
WideStringView wsExpression,
Mask<XFA_ResolveFlag> dwStyles) {
return ResolveObjectsWithBindNode(refObject, wsExpression, dwStyles, nullptr);
}
-absl::optional<CFXJSE_Engine::ResolveResult>
+std::optional<CFXJSE_Engine::ResolveResult>
CFXJSE_Engine::ResolveObjectsWithBindNode(CXFA_Object* refObject,
WideStringView wsExpression,
Mask<XFA_ResolveFlag> dwStyles,
CXFA_Node* bindNode) {
if (wsExpression.IsEmpty())
- return absl::nullopt;
+ return std::nullopt;
AutoRestorer<bool> resolving_restorer(&m_bResolvingNodes);
m_bResolvingNodes = true;
@@ -862,12 +862,12 @@
result.type = ResolveResult::Type::kExistNodes;
if (result.objects.empty())
- return absl::nullopt;
+ return std::nullopt;
return result;
}
if (nNodes == 0)
- return absl::nullopt;
+ return std::nullopt;
return result;
}
diff --git a/fxjs/xfa/cfxjse_engine.h b/fxjs/xfa/cfxjse_engine.h
index bcac43c..487bf23 100644
--- a/fxjs/xfa/cfxjse_engine.h
+++ b/fxjs/xfa/cfxjse_engine.h
@@ -133,11 +133,11 @@
WideStringView wsScript,
CXFA_Object* pThisObject);
- absl::optional<ResolveResult> ResolveObjects(CXFA_Object* refObject,
- WideStringView wsExpression,
- Mask<XFA_ResolveFlag> dwStyles);
+ std::optional<ResolveResult> ResolveObjects(CXFA_Object* refObject,
+ WideStringView wsExpression,
+ Mask<XFA_ResolveFlag> dwStyles);
- absl::optional<ResolveResult> ResolveObjectsWithBindNode(
+ std::optional<ResolveResult> ResolveObjectsWithBindNode(
CXFA_Object* refObject,
WideStringView wsExpression,
Mask<XFA_ResolveFlag> dwStyles,
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index cae2f73..b591122 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -14,6 +14,7 @@
#include <algorithm>
#include <limits>
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -30,7 +31,6 @@
#include "fxjs/xfa/cfxjse_engine.h"
#include "fxjs/xfa/cfxjse_value.h"
#include "fxjs/xfa/cjx_object.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/check_op.h"
#include "third_party/base/numerics/safe_conversions.h"
#include "v8/include/v8-container.h"
@@ -1123,8 +1123,8 @@
return fxv8::ReentrantToDoubleHelper(pIsolate, extracted);
}
-absl::optional<double> ExtractDouble(v8::Isolate* pIsolate,
- v8::Local<v8::Value> src) {
+std::optional<double> ExtractDouble(v8::Isolate* pIsolate,
+ v8::Local<v8::Value> src) {
if (src.IsEmpty())
return 0.0;
@@ -1134,7 +1134,7 @@
v8::Local<v8::Array> arr = src.As<v8::Array>();
uint32_t iLength = fxv8::GetArrayLengthHelper(arr);
if (iLength < 3)
- return absl::nullopt;
+ return std::nullopt;
v8::Local<v8::Value> propertyValue =
fxv8::ReentrantGetArrayElementHelper(pIsolate, arr, 1);
@@ -1235,7 +1235,7 @@
return v8::Local<v8::Value>();
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(
pScriptContext->GetThisObject(),
WideString::FromUTF8(bsAccessorName).AsStringView(),
@@ -1251,7 +1251,7 @@
maybeResult.value().objects.front().Get());
}
-absl::optional<CFXJSE_Engine::ResolveResult> ResolveObjects(
+std::optional<CFXJSE_Engine::ResolveResult> ResolveObjects(
CFXJSE_HostObject* pHostObject,
v8::Local<v8::Value> pRefValue,
ByteStringView bsSomExp,
@@ -1259,7 +1259,7 @@
bool bHasNoResolveName) {
CXFA_Document* pDoc = ToFormCalcContext(pHostObject)->GetDocument();
if (!pDoc)
- return absl::nullopt;
+ return std::nullopt;
v8::Isolate* pIsolate = ToFormCalcContext(pHostObject)->GetIsolate();
WideString wsSomExpression = WideString::FromUTF8(bsSomExp);
@@ -1273,12 +1273,12 @@
} else {
pNode = CFXJSE_Engine::ToObject(pIsolate, pRefValue);
if (!pNode)
- return absl::nullopt;
+ return std::nullopt;
if (bHasNoResolveName) {
WideString wsName;
if (CXFA_Node* pXFANode = pNode->AsNode()) {
- absl::optional<WideString> ret =
+ std::optional<WideString> ret =
pXFANode->JSObject()->TryAttribute(XFA_Attribute::Name, false);
if (ret.has_value())
wsName = ret.value();
@@ -1516,9 +1516,9 @@
return;
}
- absl::optional<double> maybe_dividend =
+ std::optional<double> maybe_dividend =
ExtractDouble(info.GetIsolate(), info[0]);
- absl::optional<double> maybe_divisor =
+ std::optional<double> maybe_divisor =
ExtractDouble(info.GetIsolate(), info[1]);
if (!maybe_dividend.has_value() || !maybe_divisor.has_value()) {
pContext->ThrowArgumentMismatchException();
@@ -1552,8 +1552,7 @@
return;
}
- absl::optional<double> maybe_value =
- ExtractDouble(info.GetIsolate(), info[0]);
+ std::optional<double> maybe_value = ExtractDouble(info.GetIsolate(), info[0]);
if (!maybe_value.has_value()) {
pContext->ThrowArgumentMismatchException();
return;
@@ -1566,7 +1565,7 @@
info.GetReturnValue().SetNull();
return;
}
- absl::optional<double> maybe_precision =
+ std::optional<double> maybe_precision =
ExtractDouble(info.GetIsolate(), info[1]);
if (!maybe_precision.has_value()) {
pContext->ThrowArgumentMismatchException();
@@ -2982,7 +2981,7 @@
}
WideString wsCalcScript = WideString::FromUTF8(bsUtf8Script.AsStringView());
- absl::optional<WideTextBuffer> wsJavaScriptBuf =
+ std::optional<WideTextBuffer> wsJavaScriptBuf =
CFXJSE_FormCalcContext::Translate(pContext->GetDocument()->GetHeap(),
wsCalcScript.AsStringView());
if (!wsJavaScriptBuf.has_value()) {
@@ -4783,7 +4782,7 @@
}
WideString wsCalcScript = WideString::FromUTF8(bsArg.AsStringView());
- absl::optional<WideTextBuffer> wsJavaScriptBuf =
+ std::optional<WideTextBuffer> wsJavaScriptBuf =
CFXJSE_FormCalcContext::Translate(pContext->GetDocument()->GetHeap(),
wsCalcScript.AsStringView());
if (!wsJavaScriptBuf.has_value()) {
@@ -4972,7 +4971,7 @@
return bsSomExp;
}
-absl::optional<WideTextBuffer> CFXJSE_FormCalcContext::Translate(
+std::optional<WideTextBuffer> CFXJSE_FormCalcContext::Translate(
cppgc::Heap* pHeap,
WideStringView wsFormcalc) {
if (wsFormcalc.IsEmpty())
@@ -4982,15 +4981,15 @@
CXFA_FMParser parser(pHeap, &lexer);
CXFA_FMAST* ast = parser.Parse();
if (!ast || parser.HasError())
- return absl::nullopt;
+ return std::nullopt;
CXFA_FMToJavaScriptDepth::Reset();
- absl::optional<WideTextBuffer> wsJavaScript = ast->ToJavaScript();
+ std::optional<WideTextBuffer> wsJavaScript = ast->ToJavaScript();
if (!wsJavaScript.has_value())
- return absl::nullopt;
+ return std::nullopt;
if (CXFA_IsTooBig(wsJavaScript.value()))
- return absl::nullopt;
+ return std::nullopt;
return wsJavaScript;
}
@@ -5062,7 +5061,7 @@
for (uint32_t i = 2; i < iLength; i++) {
v8::Local<v8::Value> hJSObjValue =
fxv8::ReentrantGetArrayElementHelper(info.GetIsolate(), arr, i);
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
ResolveObjects(pThis, hJSObjValue, bsSomExp.AsStringView(),
bDotAccessor, bHasNoResolveName);
if (maybeResult.has_value()) {
@@ -5091,7 +5090,7 @@
return;
}
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult;
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult;
ByteString bsAccessorName =
fxv8::ReentrantToByteStringHelper(info.GetIsolate(), info[1]);
if (fxv8::IsObject(argAccessor) ||
diff --git a/fxjs/xfa/cfxjse_formcalc_context.h b/fxjs/xfa/cfxjse_formcalc_context.h
index a0bf84f..79fd891 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.h
+++ b/fxjs/xfa/cfxjse_formcalc_context.h
@@ -10,11 +10,11 @@
#include <stdint.h>
#include <functional>
+#include <optional>
#include "core/fxcrt/bytestring.h"
#include "core/fxcrt/widetext_buffer.h"
#include "fxjs/xfa/fxjse.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "v8/include/cppgc/persistent.h"
#include "v8/include/v8-forward.h"
#include "v8/include/v8-persistent-handle.h"
@@ -267,8 +267,8 @@
static void concat_fm_object(CFXJSE_HostObject* pThis,
const v8::FunctionCallbackInfo<v8::Value>& info);
- static absl::optional<WideTextBuffer> Translate(cppgc::Heap* pHeap,
- WideStringView wsFormcalc);
+ static std::optional<WideTextBuffer> Translate(cppgc::Heap* pHeap,
+ WideStringView wsFormcalc);
v8::Local<v8::Value> GlobalPropertyGetter();
v8::Isolate* GetIsolate() const { return m_pIsolate; }
diff --git a/fxjs/xfa/cfxjse_mapmodule.cpp b/fxjs/xfa/cfxjse_mapmodule.cpp
index 7e656b8..1e43a3a 100644
--- a/fxjs/xfa/cfxjse_mapmodule.cpp
+++ b/fxjs/xfa/cfxjse_mapmodule.cpp
@@ -32,25 +32,25 @@
m_MeasurementMap[key] = measurement;
}
-absl::optional<int32_t> CFXJSE_MapModule::GetValue(uint32_t key) const {
+std::optional<int32_t> CFXJSE_MapModule::GetValue(uint32_t key) const {
auto it = m_ValueMap.find(key);
if (it == m_ValueMap.end())
- return absl::nullopt;
+ return std::nullopt;
return it->second;
}
-absl::optional<WideString> CFXJSE_MapModule::GetString(uint32_t key) const {
+std::optional<WideString> CFXJSE_MapModule::GetString(uint32_t key) const {
auto it = m_StringMap.find(key);
if (it == m_StringMap.end())
- return absl::nullopt;
+ return std::nullopt;
return it->second;
}
-absl::optional<CXFA_Measurement> CFXJSE_MapModule::GetMeasurement(
+std::optional<CXFA_Measurement> CFXJSE_MapModule::GetMeasurement(
uint32_t key) const {
auto it = m_MeasurementMap.find(key);
if (it == m_MeasurementMap.end())
- return absl::nullopt;
+ return std::nullopt;
return it->second;
}
diff --git a/fxjs/xfa/cfxjse_mapmodule.h b/fxjs/xfa/cfxjse_mapmodule.h
index 9c75750..81b8f9c 100644
--- a/fxjs/xfa/cfxjse_mapmodule.h
+++ b/fxjs/xfa/cfxjse_mapmodule.h
@@ -10,9 +10,9 @@
#include <stdint.h>
#include <map>
+#include <optional>
#include "core/fxcrt/widestring.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class CXFA_Measurement;
@@ -27,9 +27,9 @@
void SetValue(uint32_t key, int32_t value);
void SetString(uint32_t key, const WideString& wsString);
void SetMeasurement(uint32_t key, const CXFA_Measurement& measurement);
- absl::optional<int32_t> GetValue(uint32_t key) const;
- absl::optional<WideString> GetString(uint32_t key) const;
- absl::optional<CXFA_Measurement> GetMeasurement(uint32_t key) const;
+ std::optional<int32_t> GetValue(uint32_t key) const;
+ std::optional<WideString> GetString(uint32_t key) const;
+ std::optional<CXFA_Measurement> GetMeasurement(uint32_t key) const;
bool HasKey(uint32_t key) const;
void RemoveKey(uint32_t key);
void MergeDataFrom(const CFXJSE_MapModule* pSrc);
diff --git a/fxjs/xfa/cfxjse_mapmodule_unittest.cpp b/fxjs/xfa/cfxjse_mapmodule_unittest.cpp
index 3119b58..1a65bed 100644
--- a/fxjs/xfa/cfxjse_mapmodule_unittest.cpp
+++ b/fxjs/xfa/cfxjse_mapmodule_unittest.cpp
@@ -6,9 +6,10 @@
#include "fxjs/xfa/cfxjse_mapmodule.h"
+#include <optional>
+
#include "core/fxcrt/fx_string.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
TEST(CFXJSEMapModule, EmptyModule) {
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index 2829672..fad97d3 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -213,7 +213,7 @@
CXFA_Object* curNode,
CFXJSE_Engine::ResolveResult* rnd,
WideStringView strAttr) {
- absl::optional<XFA_SCRIPTATTRIBUTEINFO> info =
+ std::optional<XFA_SCRIPTATTRIBUTEINFO> info =
XFA_GetScriptAttributeByName(curNode->GetElementType(), strAttr);
if (!info.has_value())
return false;
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index 7c21b95..c9e2b51 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -109,7 +109,7 @@
if (!node->IsWidgetReady())
return CJS_Result::Success(runtime->NewNull());
- absl::optional<WideString> value = node->GetChoiceListItem(iIndex, true);
+ std::optional<WideString> value = node->GetChoiceListItem(iIndex, true);
if (!value.has_value())
return CJS_Result::Success(runtime->NewNull());
@@ -172,7 +172,7 @@
if (!node->IsWidgetReady())
return CJS_Result::Success(runtime->NewNull());
- absl::optional<WideString> value = node->GetChoiceListItem(iIndex, false);
+ std::optional<WideString> value = node->GetChoiceListItem(iIndex, false);
if (!value.has_value())
return CJS_Result::Success(runtime->NewNull());
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index 462b47a..9513786 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -136,7 +136,7 @@
return;
}
- absl::optional<WideString> checksum =
+ std::optional<WideString> checksum =
TryAttribute(XFA_Attribute::Checksum, false);
*pValue = fxv8::NewStringHelper(
pIsolate,
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 00a6eb1..8bdd809 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -300,7 +300,7 @@
constexpr Mask<XFA_ResolveFlag> kFlags = {XFA_ResolveFlag::kChildren,
XFA_ResolveFlag::kParent,
XFA_ResolveFlag::kSiblings};
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
runtime->ResolveObjects(
pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags);
if (!maybeResult.has_value() ||
@@ -385,7 +385,7 @@
constexpr Mask<XFA_ResolveFlag> kFlags = {XFA_ResolveFlag::kChildren,
XFA_ResolveFlag::kParent,
XFA_ResolveFlag::kSiblings};
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
runtime->ResolveObjects(pObject, wsName.AsStringView(), kFlags);
if (!maybeResult.has_value() ||
!maybeResult.value().objects.front()->IsNode())
@@ -448,7 +448,7 @@
constexpr Mask<XFA_ResolveFlag> kFlags = {XFA_ResolveFlag::kChildren,
XFA_ResolveFlag::kParent,
XFA_ResolveFlag::kSiblings};
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
runtime->ResolveObjects(
pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags);
if (!maybeResult.has_value() ||
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index d7e2c06..bdae56e 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -175,7 +175,7 @@
return CJS_Result::Failure(JSMessage::kParamError);
WideString expression = runtime->ToWideString(params[0]);
- absl::optional<XFA_ATTRIBUTEINFO> attr =
+ std::optional<XFA_ATTRIBUTEINFO> attr =
XFA_GetAttributeByName(expression.AsStringView());
if (attr.has_value() && HasAttribute(attr.value().attribute))
return CJS_Result::Success(runtime->NewBoolean(true));
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 2479b4a..f68cdc2 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -218,7 +218,7 @@
bool bNotify) {
switch (GetXFANode()->GetAttributeType(eAttr)) {
case XFA_AttributeType::Enum: {
- absl::optional<XFA_AttributeValue> item =
+ std::optional<XFA_AttributeValue> item =
XFA_GetAttributeValueByName(wsValue.AsStringView());
SetEnum(eAttr,
item.has_value() ? item.value()
@@ -246,7 +246,7 @@
void CJX_Object::SetAttributeByString(WideStringView wsAttr,
const WideString& wsValue) {
- absl::optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(wsAttr);
+ std::optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(wsAttr);
if (attr.has_value()) {
SetAttributeByEnum(attr.value().attribute, wsValue, true);
return;
@@ -256,8 +256,8 @@
}
WideString CJX_Object::GetAttributeByString(WideStringView attr) const {
- absl::optional<WideString> result;
- absl::optional<XFA_ATTRIBUTEINFO> enum_attr = XFA_GetAttributeByName(attr);
+ std::optional<WideString> result;
+ std::optional<XFA_ATTRIBUTEINFO> enum_attr = XFA_GetAttributeByName(attr);
if (enum_attr.has_value())
result = TryAttribute(enum_attr.value().attribute, true);
else
@@ -269,52 +269,52 @@
return TryAttribute(attr, true).value_or(WideString());
}
-absl::optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
+ bool bUseDefault) const {
switch (GetXFANode()->GetAttributeType(eAttr)) {
case XFA_AttributeType::Enum: {
- absl::optional<XFA_AttributeValue> value = TryEnum(eAttr, bUseDefault);
+ std::optional<XFA_AttributeValue> value = TryEnum(eAttr, bUseDefault);
if (!value.has_value())
- return absl::nullopt;
+ return std::nullopt;
return WideString::FromASCII(XFA_AttributeValueToName(value.value()));
}
case XFA_AttributeType::CData:
return TryCData(eAttr, bUseDefault);
case XFA_AttributeType::Boolean: {
- absl::optional<bool> value = TryBoolean(eAttr, bUseDefault);
+ std::optional<bool> value = TryBoolean(eAttr, bUseDefault);
if (!value.has_value())
- return absl::nullopt;
+ return std::nullopt;
return WideString(value.value() ? L"1" : L"0");
}
case XFA_AttributeType::Integer: {
- absl::optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
+ std::optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
if (!iValue.has_value())
- return absl::nullopt;
+ return std::nullopt;
return WideString::FormatInteger(iValue.value());
}
case XFA_AttributeType::Measure: {
- absl::optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
+ std::optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
if (!value.has_value())
- return absl::nullopt;
+ return std::nullopt;
return value->ToString();
}
}
- return absl::nullopt;
+ return std::nullopt;
}
void CJX_Object::RemoveAttribute(WideStringView wsAttr) {
RemoveMapModuleKey(GetMapKey_Custom(wsAttr));
}
-absl::optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr,
+ bool bUseDefault) const {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
+ std::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
if (value.has_value())
return !!value.value();
if (!bUseDefault)
- return absl::nullopt;
+ return std::nullopt;
return GetXFANode()->GetDefaultBoolean(eAttr);
}
@@ -342,25 +342,25 @@
return TryInteger(eAttr, true).value_or(0);
}
-absl::optional<int32_t> CJX_Object::TryInteger(XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<int32_t> CJX_Object::TryInteger(XFA_Attribute eAttr,
+ bool bUseDefault) const {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
+ std::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
if (value.has_value())
return value.value();
if (!bUseDefault)
- return absl::nullopt;
+ return std::nullopt;
return GetXFANode()->GetDefaultInteger(eAttr);
}
-absl::optional<XFA_AttributeValue> CJX_Object::TryEnum(XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<XFA_AttributeValue> CJX_Object::TryEnum(XFA_Attribute eAttr,
+ bool bUseDefault) const {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
+ std::optional<int32_t> value = GetMapModuleValueFollowingChain(key);
if (value.has_value())
return static_cast<XFA_AttributeValue>(value.value());
if (!bUseDefault)
- return absl::nullopt;
+ return std::nullopt;
return GetXFANode()->GetDefaultEnum(eAttr);
}
@@ -391,23 +391,22 @@
OnChanged(eAttr, false);
}
-absl::optional<CXFA_Measurement> CJX_Object::TryMeasure(
- XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<CXFA_Measurement> CJX_Object::TryMeasure(XFA_Attribute eAttr,
+ bool bUseDefault) const {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<CXFA_Measurement> result =
+ std::optional<CXFA_Measurement> result =
GetMapModuleMeasurementFollowingChain(key);
if (result.has_value())
return result.value();
if (!bUseDefault)
- return absl::nullopt;
+ return std::nullopt;
return GetXFANode()->GetDefaultMeasurement(eAttr);
}
-absl::optional<float> CJX_Object::TryMeasureAsFloat(XFA_Attribute attr) const {
- absl::optional<CXFA_Measurement> measure = TryMeasure(attr, false);
+std::optional<float> CJX_Object::TryMeasureAsFloat(XFA_Attribute attr) const {
+ std::optional<CXFA_Measurement> measure = TryMeasure(attr, false);
if (!measure.has_value())
- return absl::nullopt;
+ return std::nullopt;
return measure->ToUnit(XFA_Unit::Pt);
}
@@ -433,7 +432,7 @@
bool bScriptModify) {
CXFA_Node* xfaObj = GetXFANode();
uint32_t key = GetMapKey_Element(xfaObj->GetElementType(), eAttr);
- absl::optional<WideString> old_value = GetMapModuleString(key);
+ std::optional<WideString> old_value = GetMapModuleString(key);
if (!old_value.has_value() || old_value.value() != wsValue) {
if (bNotify)
OnChanging(eAttr);
@@ -483,7 +482,7 @@
auto* xfaObj = GetXFANode();
uint32_t key =
GetMapKey_Element(xfaObj->GetElementType(), XFA_Attribute::Value);
- absl::optional<WideString> old_value = GetMapModuleString(key);
+ std::optional<WideString> old_value = GetMapModuleString(key);
if (!old_value.has_value() || old_value.value() != wsValue) {
if (bNotify)
OnChanging(XFA_Attribute::Value);
@@ -495,15 +494,15 @@
}
}
-absl::optional<WideString> CJX_Object::TryCData(XFA_Attribute eAttr,
- bool bUseDefault) const {
+std::optional<WideString> CJX_Object::TryCData(XFA_Attribute eAttr,
+ bool bUseDefault) const {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<WideString> value = GetMapModuleStringFollowingChain(key);
+ std::optional<WideString> value = GetMapModuleStringFollowingChain(key);
if (value.has_value())
return value;
if (!bUseDefault)
- return absl::nullopt;
+ return std::nullopt;
return GetXFANode()->GetDefaultCData(eAttr);
}
@@ -512,7 +511,7 @@
int32_t value,
bool bNotify) {
uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
- absl::optional<int32_t> old_value = GetMapModuleValue(key);
+ std::optional<int32_t> old_value = GetMapModuleValue(key);
if (!old_value.has_value() || old_value.value() != value) {
if (bNotify)
OnChanging(eAttr);
@@ -623,7 +622,7 @@
case XFA_ObjectType::ContentNode: {
WideString wsContentType;
if (GetXFANode()->GetElementType() == XFA_Element::ExData) {
- absl::optional<WideString> ret =
+ std::optional<WideString> ret =
TryAttribute(XFA_Attribute::ContentType, false);
if (ret.has_value())
wsContentType = ret.value();
@@ -690,8 +689,8 @@
return TryContent(bScriptModify, true).value_or(WideString());
}
-absl::optional<WideString> CJX_Object::TryContent(bool bScriptModify,
- bool bProto) const {
+std::optional<WideString> CJX_Object::TryContent(bool bScriptModify,
+ bool bProto) const {
CXFA_Node* pNode = nullptr;
switch (GetXFANode()->GetObjectType()) {
case XFA_ObjectType::ContainerNode:
@@ -701,7 +700,7 @@
CXFA_Value* pValue =
GetXFANode()->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValue)
- return absl::nullopt;
+ return std::nullopt;
CXFA_Node* pChildValue = pValue->GetFirstChild();
if (pChildValue && XFA_FieldIsMultiListBox(GetXFANode())) {
@@ -709,7 +708,7 @@
XFA_Attribute::ContentType, L"text/xml", false);
}
if (!pChildValue)
- return absl::nullopt;
+ return std::nullopt;
return pChildValue->JSObject()->TryContent(bScriptModify, bProto);
}
break;
@@ -718,7 +717,7 @@
if (!pContentRawDataNode) {
XFA_Element element = XFA_Element::Sharptext;
if (GetXFANode()->GetElementType() == XFA_Element::ExData) {
- absl::optional<WideString> contentType =
+ std::optional<WideString> contentType =
TryAttribute(XFA_Attribute::ContentType, false);
if (contentType.has_value()) {
if (contentType.value().EqualsASCII("text/html"))
@@ -749,16 +748,16 @@
}
return TryCData(XFA_Attribute::Value, false);
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<WideString> CJX_Object::TryNamespace() const {
+std::optional<WideString> CJX_Object::TryNamespace() const {
if (GetXFANode()->IsModelNode() ||
GetXFANode()->GetElementType() == XFA_Element::Packet) {
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
CFX_XMLElement* element = ToXMLElement(pXMLNode);
if (!element)
- return absl::nullopt;
+ return std::nullopt;
return element->GetNamespaceURI();
}
@@ -769,14 +768,14 @@
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
CFX_XMLElement* element = ToXMLElement(pXMLNode);
if (!element)
- return absl::nullopt;
+ return std::nullopt;
if (GetXFANode()->GetElementType() == XFA_Element::DataValue &&
GetEnum(XFA_Attribute::Contains) == XFA_AttributeValue::MetaData) {
WideString wsNamespace;
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
element, GetCData(XFA_Attribute::QualifiedName), &wsNamespace)) {
- return absl::nullopt;
+ return std::nullopt;
}
return wsNamespace;
}
@@ -816,29 +815,29 @@
CreateMapModule()->SetMeasurement(key, value);
}
-absl::optional<int32_t> CJX_Object::GetMapModuleValue(uint32_t key) const {
+std::optional<int32_t> CJX_Object::GetMapModuleValue(uint32_t key) const {
CFXJSE_MapModule* pModule = GetMapModule();
if (!pModule)
- return absl::nullopt;
+ return std::nullopt;
return pModule->GetValue(key);
}
-absl::optional<WideString> CJX_Object::GetMapModuleString(uint32_t key) const {
+std::optional<WideString> CJX_Object::GetMapModuleString(uint32_t key) const {
CFXJSE_MapModule* pModule = GetMapModule();
if (!pModule)
- return absl::nullopt;
+ return std::nullopt;
return pModule->GetString(key);
}
-absl::optional<CXFA_Measurement> CJX_Object::GetMapModuleMeasurement(
+std::optional<CXFA_Measurement> CJX_Object::GetMapModuleMeasurement(
uint32_t key) const {
CFXJSE_MapModule* pModule = GetMapModule();
if (!pModule)
- return absl::nullopt;
+ return std::nullopt;
return pModule->GetMeasurement(key);
}
-absl::optional<int32_t> CJX_Object::GetMapModuleValueFollowingChain(
+std::optional<int32_t> CJX_Object::GetMapModuleValueFollowingChain(
uint32_t key) const {
std::set<const CXFA_Node*> visited;
for (const CXFA_Node* pNode = GetXFANode(); pNode;
@@ -846,17 +845,17 @@
if (!visited.insert(pNode).second)
break;
- absl::optional<int32_t> result = pNode->JSObject()->GetMapModuleValue(key);
+ std::optional<int32_t> result = pNode->JSObject()->GetMapModuleValue(key);
if (result.has_value())
return result;
if (pNode->GetPacketType() == XFA_PacketType::Datasets)
break;
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<WideString> CJX_Object::GetMapModuleStringFollowingChain(
+std::optional<WideString> CJX_Object::GetMapModuleStringFollowingChain(
uint32_t key) const {
std::set<const CXFA_Node*> visited;
for (const CXFA_Node* pNode = GetXFANode(); pNode;
@@ -864,7 +863,7 @@
if (!visited.insert(pNode).second)
break;
- absl::optional<WideString> result =
+ std::optional<WideString> result =
pNode->JSObject()->GetMapModuleString(key);
if (result.has_value())
return result;
@@ -872,10 +871,10 @@
if (pNode->GetPacketType() == XFA_PacketType::Datasets)
break;
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<CXFA_Measurement>
+std::optional<CXFA_Measurement>
CJX_Object::GetMapModuleMeasurementFollowingChain(uint32_t key) const {
std::set<const CXFA_Node*> visited;
for (const CXFA_Node* pNode = GetXFANode(); pNode;
@@ -883,7 +882,7 @@
if (!visited.insert(pNode).second)
break;
- absl::optional<CXFA_Measurement> result =
+ std::optional<CXFA_Measurement> result =
pNode->JSObject()->GetMapModuleMeasurement(key);
if (result.has_value())
return result;
@@ -891,7 +890,7 @@
if (pNode->GetPacketType() == XFA_PacketType::Datasets)
break;
}
- return absl::nullopt;
+ return std::nullopt;
}
bool CJX_Object::HasMapModuleKey(uint32_t key) const {
@@ -1015,7 +1014,7 @@
CXFA_Node* pProtoNode = nullptr;
if (!wsSOM.IsEmpty()) {
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
GetDocument()->GetScriptContext()->ResolveObjects(
pProtoRoot, wsSOM.AsStringView(),
Mask<XFA_ResolveFlag>{
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index fb98185..1736d2a 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -9,13 +9,13 @@
#include <map>
#include <memory>
+#include <optional>
#include <vector>
#include "core/fxcrt/widestring.h"
#include "fxjs/gc/heap.h"
#include "fxjs/xfa/fxjse.h"
#include "fxjs/xfa/jse_define.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/containers/span.h"
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/member.h"
@@ -126,8 +126,8 @@
bool HasAttribute(XFA_Attribute eAttr) const;
WideString GetAttributeByString(WideStringView attr) const;
WideString GetAttributeByEnum(XFA_Attribute attr) const;
- absl::optional<WideString> TryAttribute(XFA_Attribute eAttr,
- bool bUseDefault) const;
+ std::optional<WideString> TryAttribute(XFA_Attribute eAttr,
+ bool bUseDefault) const;
void SetAttributeByEnum(XFA_Attribute eAttr,
const WideString& wsValue,
bool bNotify);
@@ -135,7 +135,7 @@
void RemoveAttribute(WideStringView wsAttr);
WideString GetContent(bool bScriptModify) const;
- absl::optional<WideString> TryContent(bool bScriptModify, bool bProto) const;
+ std::optional<WideString> TryContent(bool bScriptModify, bool bProto) const;
void SetContent(const WideString& wsContent,
const WideString& wsXMLValue,
bool bNotify,
@@ -172,32 +172,32 @@
JSE_PROP(ScriptSomInstanceIndex);
JSE_PROP(ScriptSubmitFormatMode);
- absl::optional<WideString> TryNamespace() const;
+ std::optional<WideString> TryNamespace() const;
int32_t GetInteger(XFA_Attribute eAttr) const;
- absl::optional<int32_t> TryInteger(XFA_Attribute eAttr,
- bool bUseDefault) const;
+ std::optional<int32_t> TryInteger(XFA_Attribute eAttr,
+ bool bUseDefault) const;
void SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify);
WideString GetCData(XFA_Attribute eAttr) const;
- absl::optional<WideString> TryCData(XFA_Attribute eAttr,
- bool bUseDefault) const;
+ std::optional<WideString> TryCData(XFA_Attribute eAttr,
+ bool bUseDefault) const;
void SetCData(XFA_Attribute eAttr, const WideString& wsValue);
XFA_AttributeValue GetEnum(XFA_Attribute eAttr) const;
- absl::optional<XFA_AttributeValue> TryEnum(XFA_Attribute eAttr,
- bool bUseDefault) const;
+ std::optional<XFA_AttributeValue> TryEnum(XFA_Attribute eAttr,
+ bool bUseDefault) const;
void SetEnum(XFA_Attribute eAttr, XFA_AttributeValue eValue, bool bNotify);
bool GetBoolean(XFA_Attribute eAttr) const;
- absl::optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault) const;
+ std::optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault) const;
void SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify);
CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const;
float GetMeasureInUnit(XFA_Attribute eAttr, XFA_Unit unit) const;
- absl::optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr,
- bool bUseDefault) const;
- absl::optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
+ std::optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr,
+ bool bUseDefault) const;
+ std::optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
void SetMeasure(XFA_Attribute eAttr,
const CXFA_Measurement& mValue,
bool bNotify);
@@ -261,13 +261,13 @@
void SetMapModuleValue(uint32_t key, int32_t value);
void SetMapModuleString(uint32_t key, const WideString& wsValue);
void SetMapModuleMeasurement(uint32_t key, const CXFA_Measurement& value);
- absl::optional<int32_t> GetMapModuleValue(uint32_t key) const;
- absl::optional<WideString> GetMapModuleString(uint32_t key) const;
- absl::optional<CXFA_Measurement> GetMapModuleMeasurement(uint32_t key) const;
- absl::optional<int32_t> GetMapModuleValueFollowingChain(uint32_t key) const;
- absl::optional<WideString> GetMapModuleStringFollowingChain(
+ std::optional<int32_t> GetMapModuleValue(uint32_t key) const;
+ std::optional<WideString> GetMapModuleString(uint32_t key) const;
+ std::optional<CXFA_Measurement> GetMapModuleMeasurement(uint32_t key) const;
+ std::optional<int32_t> GetMapModuleValueFollowingChain(uint32_t key) const;
+ std::optional<WideString> GetMapModuleStringFollowingChain(
uint32_t key) const;
- absl::optional<CXFA_Measurement> GetMapModuleMeasurementFollowingChain(
+ std::optional<CXFA_Measurement> GetMapModuleMeasurementFollowingChain(
uint32_t key) const;
bool HasMapModuleKey(uint32_t key) const;
void RemoveMapModuleKey(uint32_t key);
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 8fe54e4..76b3a3c 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -47,7 +47,7 @@
if (pRefNode->GetElementType() == XFA_Element::Xfa)
pRefNode = runtime->GetThisObject();
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
runtime->ResolveObjects(
ToNode(pRefNode), wsExpression.AsStringView(),
Mask<XFA_ResolveFlag>{
@@ -216,7 +216,7 @@
pDoc->GetNodeOwner()->PersistList(pNodeList);
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
- absl::optional<CFXJSE_Engine::ResolveResult> maybeResult =
+ std::optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(),
dwFlag);