summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-04 14:43:27 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-04 20:19:41 +0000
commitc560a8c11a6f8ee239e570db8c022ae0fd2a4db5 (patch)
tree0c16389f7e5c5e29c57a9c7f77dd062fa07d8640 /fxjs
parentdf0a749452d933e4f434e2a33112667f1880db34 (diff)
downloadpdfium-c560a8c11a6f8ee239e570db8c022ae0fd2a4db5.tar.xz
Convert usages of pdfium::Optional to Optional
Change-Id: I29769f78eaad10c6a8b79e27524336c4f330377e Reviewed-on: https://pdfium-review.googlesource.com/22258 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_engine.cpp2
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp2
-rw-r--r--fxjs/xfa/cjx_field.cpp6
-rw-r--r--fxjs/xfa/cjx_object.cpp56
-rw-r--r--fxjs/xfa/cjx_object.h26
5 files changed, 41 insertions, 51 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 3def7f250f..224cb25fd7 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -464,7 +464,7 @@ bool CFXJSE_Engine::RunVariablesScript(CXFA_Node* pScriptNode) {
if (!pTextNode)
return false;
- pdfium::Optional<WideString> wsScript =
+ Optional<WideString> wsScript =
pTextNode->JSObject()->TryCData(XFA_Attribute::Value, true);
if (!wsScript)
return false;
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 47d6ce6e4f..1c7d998807 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -5947,7 +5947,7 @@ bool CFXJSE_FormCalcContext::ResolveObjects(CFXJSE_Value* pThis,
if (bHasNoResolveName) {
WideString wsName;
if (CXFA_Node* pXFANode = pNode->AsNode()) {
- pdfium::Optional<WideString> ret =
+ Optional<WideString> ret =
pXFANode->JSObject()->TryAttribute(XFA_Attribute::Name, false);
if (ret)
wsName = *ret;
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index cb0722eeee..b652aeedab 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -104,8 +104,7 @@ CJS_Return CJX_Field::getSaveItem(
if (!pWidgetAcc)
return CJS_Return(runtime->NewNull());
- pdfium::Optional<WideString> value =
- pWidgetAcc->GetChoiceListItem(iIndex, true);
+ Optional<WideString> value = pWidgetAcc->GetChoiceListItem(iIndex, true);
if (!value)
return CJS_Return(runtime->NewNull());
@@ -169,8 +168,7 @@ CJS_Return CJX_Field::getDisplayItem(
if (!pWidgetAcc)
return CJS_Return(runtime->NewNull());
- pdfium::Optional<WideString> value =
- pWidgetAcc->GetChoiceListItem(iIndex, false);
+ Optional<WideString> value = pWidgetAcc->GetChoiceListItem(iIndex, false);
if (!value)
return CJS_Return(runtime->NewNull());
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index e574454673..1512a32545 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -222,7 +222,7 @@ bool CJX_Object::SetAttribute(XFA_Attribute eAttr,
bool bNotify) {
switch (ToNode(GetXFAObject())->GetAttributeType(eAttr)) {
case XFA_AttributeType::Enum: {
- pdfium::Optional<XFA_AttributeEnum> item =
+ Optional<XFA_AttributeEnum> item =
CXFA_Node::NameToAttributeEnum(wsValue);
return SetEnum(
eAttr,
@@ -271,11 +271,11 @@ WideString CJX_Object::GetAttribute(XFA_Attribute attr) {
return TryAttribute(attr, true).value_or(WideString());
}
-pdfium::Optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
- bool bUseDefault) {
+Optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
+ bool bUseDefault) {
switch (ToNode(GetXFAObject())->GetAttributeType(eAttr)) {
case XFA_AttributeType::Enum: {
- pdfium::Optional<XFA_AttributeEnum> value = TryEnum(eAttr, bUseDefault);
+ Optional<XFA_AttributeEnum> value = TryEnum(eAttr, bUseDefault);
if (!value)
return {};
@@ -285,19 +285,19 @@ pdfium::Optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
return TryCData(eAttr, bUseDefault);
case XFA_AttributeType::Boolean: {
- pdfium::Optional<bool> value = TryBoolean(eAttr, bUseDefault);
+ Optional<bool> value = TryBoolean(eAttr, bUseDefault);
if (!value)
return {};
return {*value ? L"1" : L"0"};
}
case XFA_AttributeType::Integer: {
- pdfium::Optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
+ Optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
if (!iValue)
return {};
return {WideString::Format(L"%d", *iValue)};
}
case XFA_AttributeType::Measure: {
- pdfium::Optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
+ Optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
if (!value)
return {};
@@ -309,9 +309,8 @@ pdfium::Optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
return {};
}
-pdfium::Optional<WideString> CJX_Object::TryAttribute(
- const WideStringView& wsAttr,
- bool bUseDefault) {
+Optional<WideString> CJX_Object::TryAttribute(const WideStringView& wsAttr,
+ bool bUseDefault) {
XFA_Attribute attr = CXFA_Node::NameToAttribute(wsAttr);
if (attr != XFA_Attribute::Unknown)
return TryAttribute(attr, bUseDefault);
@@ -330,8 +329,7 @@ void CJX_Object::RemoveAttribute(const WideStringView& wsAttr) {
RemoveMapModuleKey(pKey);
}
-pdfium::Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr,
- bool bUseDefault) {
+Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr, bool bUseDefault) {
void* pValue = nullptr;
void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
if (GetMapModuleValue(pKey, pValue))
@@ -368,8 +366,8 @@ int32_t CJX_Object::GetInteger(XFA_Attribute eAttr) {
return TryInteger(eAttr, true).value_or(0);
}
-pdfium::Optional<int32_t> CJX_Object::TryInteger(XFA_Attribute eAttr,
- bool bUseDefault) {
+Optional<int32_t> CJX_Object::TryInteger(XFA_Attribute eAttr,
+ bool bUseDefault) {
void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
void* pValue = nullptr;
if (GetMapModuleValue(pKey, pValue))
@@ -380,8 +378,8 @@ pdfium::Optional<int32_t> CJX_Object::TryInteger(XFA_Attribute eAttr,
return ToNode(GetXFAObject())->GetDefaultInteger(eAttr);
}
-pdfium::Optional<XFA_AttributeEnum> CJX_Object::TryEnum(XFA_Attribute eAttr,
- bool bUseDefault) {
+Optional<XFA_AttributeEnum> CJX_Object::TryEnum(XFA_Attribute eAttr,
+ bool bUseDefault) {
void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
void* pValue = nullptr;
if (GetMapModuleValue(pKey, pValue)) {
@@ -420,9 +418,8 @@ bool CJX_Object::SetMeasure(XFA_Attribute eAttr,
return true;
}
-pdfium::Optional<CXFA_Measurement> CJX_Object::TryMeasure(
- XFA_Attribute eAttr,
- bool bUseDefault) const {
+Optional<CXFA_Measurement> CJX_Object::TryMeasure(XFA_Attribute eAttr,
+ bool bUseDefault) const {
void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
void* pValue;
int32_t iBytes;
@@ -436,9 +433,8 @@ pdfium::Optional<CXFA_Measurement> CJX_Object::TryMeasure(
return ToNode(GetXFAObject())->GetDefaultMeasurement(eAttr);
}
-pdfium::Optional<float> CJX_Object::TryMeasureAsFloat(
- XFA_Attribute attr) const {
- pdfium::Optional<CXFA_Measurement> measure = TryMeasure(attr, false);
+Optional<float> CJX_Object::TryMeasureAsFloat(XFA_Attribute attr) const {
+ Optional<CXFA_Measurement> measure = TryMeasure(attr, false);
if (measure)
return {measure->ToUnit(XFA_Unit::Pt)};
return {};
@@ -579,8 +575,8 @@ void CJX_Object::SetAttributeValue(const WideString& wsValue,
}
}
-pdfium::Optional<WideString> CJX_Object::TryCData(XFA_Attribute eAttr,
- bool bUseDefault) {
+Optional<WideString> CJX_Object::TryCData(XFA_Attribute eAttr,
+ bool bUseDefault) {
void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
if (eAttr == XFA_Attribute::Value) {
void* pData;
@@ -744,7 +740,7 @@ bool CJX_Object::SetContent(const WideString& wsContent,
case XFA_ObjectType::ContentNode: {
WideString wsContentType;
if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::ExData) {
- pdfium::Optional<WideString> ret =
+ Optional<WideString> ret =
TryAttribute(XFA_Attribute::ContentType, false);
if (ret)
wsContentType = *ret;
@@ -817,8 +813,7 @@ WideString CJX_Object::GetContent(bool bScriptModify) {
return TryContent(bScriptModify, true).value_or(WideString());
}
-pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify,
- bool bProto) {
+Optional<WideString> CJX_Object::TryContent(bool bScriptModify, bool bProto) {
CXFA_Node* pNode = nullptr;
switch (ToNode(GetXFAObject())->GetObjectType()) {
case XFA_ObjectType::ContainerNode:
@@ -847,7 +842,7 @@ pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify,
if (!pContentRawDataNode) {
XFA_Element element = XFA_Element::Sharptext;
if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::ExData) {
- pdfium::Optional<WideString> contentType =
+ Optional<WideString> contentType =
TryAttribute(XFA_Attribute::ContentType, false);
if (contentType) {
if (*contentType == L"text/html")
@@ -883,7 +878,7 @@ pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify,
return {};
}
-pdfium::Optional<WideString> CJX_Object::TryNamespace() {
+Optional<WideString> CJX_Object::TryNamespace() {
if (ToNode(GetXFAObject())->IsModelNode() ||
ToNode(GetXFAObject())->GetElementType() == XFA_Element::Packet) {
CFX_XMLNode* pXMLNode = ToNode(GetXFAObject())->GetXMLMappingNode();
@@ -1706,8 +1701,7 @@ void CJX_Object::Script_Form_Checksum(CFXJSE_Value* pValue,
return;
}
- pdfium::Optional<WideString> checksum =
- TryAttribute(XFA_Attribute::Checksum, false);
+ Optional<WideString> checksum = TryAttribute(XFA_Attribute::Checksum, false);
pValue->SetString(checksum ? checksum->UTF8Encode().AsStringView() : "");
}
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index d7979a381f..2718f1738c 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -89,12 +89,11 @@ class CJX_Object {
void RemoveAttribute(const WideStringView& wsAttr);
WideString GetAttribute(const WideStringView& attr);
WideString GetAttribute(XFA_Attribute attr);
- pdfium::Optional<WideString> TryAttribute(const WideStringView& wsAttr,
- bool bUseDefault);
- pdfium::Optional<WideString> TryAttribute(XFA_Attribute eAttr,
- bool bUseDefault);
+ Optional<WideString> TryAttribute(const WideStringView& wsAttr,
+ bool bUseDefault);
+ Optional<WideString> TryAttribute(XFA_Attribute eAttr, bool bUseDefault);
- pdfium::Optional<WideString> TryContent(bool bScriptModify, bool bProto);
+ Optional<WideString> TryContent(bool bScriptModify, bool bProto);
bool SetContent(const WideString& wsContent,
const WideString& wsXMLValue,
bool bNotify,
@@ -174,31 +173,30 @@ class CJX_Object {
bool bSetting,
XFA_Attribute eAttribute);
- pdfium::Optional<WideString> TryNamespace();
+ Optional<WideString> TryNamespace();
- pdfium::Optional<int32_t> TryInteger(XFA_Attribute eAttr, bool bUseDefault);
+ Optional<int32_t> TryInteger(XFA_Attribute eAttr, bool bUseDefault);
bool SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify);
int32_t GetInteger(XFA_Attribute eAttr);
- pdfium::Optional<WideString> TryCData(XFA_Attribute eAttr, bool bUseDefault);
+ Optional<WideString> TryCData(XFA_Attribute eAttr, bool bUseDefault);
bool SetCData(XFA_Attribute eAttr,
const WideString& wsValue,
bool bNotify,
bool bScriptModify);
WideString GetCData(XFA_Attribute eAttr);
- pdfium::Optional<XFA_AttributeEnum> TryEnum(XFA_Attribute eAttr,
- bool bUseDefault);
+ Optional<XFA_AttributeEnum> TryEnum(XFA_Attribute eAttr, bool bUseDefault);
bool SetEnum(XFA_Attribute eAttr, XFA_AttributeEnum eValue, bool bNotify);
XFA_AttributeEnum GetEnum(XFA_Attribute eAttr);
- pdfium::Optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault);
+ Optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault);
bool SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify);
bool GetBoolean(XFA_Attribute eAttr);
- pdfium::Optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr,
- bool bUseDefault) const;
- pdfium::Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
+ Optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr,
+ bool bUseDefault) const;
+ Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
bool SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify);
CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const;