Use EqualsASCII{,NoCase}() and narrow literals in many places.
Fix some IWYU noise noticed as well.
Change-Id: I87fd8e636181a006a80c32a5ed909c12194f2893
Reviewed-on: https://pdfium-review.googlesource.com/c/46170
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
index 99fd965..19f5791 100644
--- a/core/fpdfdoc/cpdf_metadata.cpp
+++ b/core/fpdfdoc/cpdf_metadata.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfdoc/cpdf_metadata.h"
+#include <memory>
+
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/cfx_readonlymemorystream.h"
@@ -18,15 +20,16 @@
void CheckForSharedFormInternal(CFX_XMLElement* element,
std::vector<UnsupportedFeature>* unsupported) {
- WideString attr = element->GetAttribute(L"xmlns:adhocwf");
- if (attr == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") {
+ WideString attr =
+ element->GetAttribute(WideString::FromASCII("xmlns:adhocwf"));
+ if (attr.EqualsASCII("http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/")) {
for (const auto* child = element->GetFirstChild(); child;
child = child->GetNextSibling()) {
if (child->GetType() != FX_XMLNODE_Element)
continue;
const auto* child_elem = static_cast<const CFX_XMLElement*>(child);
- if (child_elem->GetName() != L"adhocwf:workflowType")
+ if (!child_elem->GetName().EqualsASCII("adhocwf:workflowType"))
continue;
switch (child_elem->GetTextData().GetInteger()) {
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp
index 73fe548..2f8cfef 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp
@@ -32,16 +32,16 @@
}
bool CFX_XMLInstruction::IsOriginalXFAVersion() const {
- return name_ == L"originalXFAVersion";
+ return name_.EqualsASCII("originalXFAVersion");
}
bool CFX_XMLInstruction::IsAcrobat() const {
- return name_ == L"acrobat";
+ return name_.EqualsASCII("acrobat");
}
void CFX_XMLInstruction::Save(
const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) {
- if (name_.CompareNoCase(L"xml") == 0) {
+ if (name_.EqualsASCIINoCase("xml")) {
pXMLStream->WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
return;
}
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index 047c546..e636f10 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -165,8 +165,8 @@
current_parser_state = FDE_XmlSyntaxState::TargetData;
WideString target_name = GetTextData();
- if (target_name == L"originalXFAVersion" ||
- target_name == L"acrobat") {
+ if (target_name.EqualsASCII("originalXFAVersion") ||
+ target_name.EqualsASCII("acrobat")) {
auto* node = doc->CreateNode<CFX_XMLInstruction>(target_name);
current_node_->AppendChild(node);
current_node_ = node;
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index d46c4bb..bfea7a4 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -300,7 +300,7 @@
pOriginalObject->GetDocument()->GetScriptContext();
CXFA_Object* pObject =
lpScriptContext->GetVariablesThis(pOriginalObject, false);
- if (wsPropName == L"xfa") {
+ if (wsPropName.EqualsASCII("xfa")) {
CFXJSE_Value* pValue = lpScriptContext->GetJSValueFromMap(
lpScriptContext->GetDocument()->GetRoot());
pReturnValue->Assign(pValue);
diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp
index 6dd4d0c..b13f394 100644
--- a/fxjs/cfxjse_resolveprocessor.cpp
+++ b/fxjs/cfxjse_resolveprocessor.cpp
@@ -627,9 +627,9 @@
ASSERT(iFoundCount == pdfium::CollectionSize<int32_t>(rnd.m_Objects));
WideString wsExpression;
CXFA_Script::Type eLangType = CXFA_Script::Type::Unknown;
- if (wsCondition.Left(2) == L".[" && wsCondition.Last() == L']')
+ if (wsCondition.Left(2).EqualsASCII(".[") && wsCondition.Last() == L']')
eLangType = CXFA_Script::Type::Formcalc;
- else if (wsCondition.Left(2) == L".(" && wsCondition.Last() == L')')
+ else if (wsCondition.Left(2).EqualsASCII(".(") && wsCondition.Last() == L')')
eLangType = CXFA_Script::Type::Javascript;
else
return;
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index e51cf54..fa1d805 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -91,7 +91,7 @@
WideString sSpace =
pRuntime->ToWideString(pRuntime->GetArrayElement(array, 0));
- if (sSpace == L"T")
+ if (sSpace.EqualsASCII("T"))
return CFX_Color(CFX_Color::kTransparent);
float d1 = 0;
@@ -99,8 +99,7 @@
d1 = static_cast<float>(
pRuntime->ToDouble(pRuntime->GetArrayElement(array, 1)));
}
-
- if (sSpace == L"G")
+ if (sSpace.EqualsASCII("G"))
return CFX_Color(CFX_Color::kGray, d1);
float d2 = 0;
@@ -113,8 +112,7 @@
d3 = static_cast<float>(
pRuntime->ToDouble(pRuntime->GetArrayElement(array, 3)));
}
-
- if (sSpace == L"RGB")
+ if (sSpace.EqualsASCII("RGB"))
return CFX_Color(CFX_Color::kRGB, d1, d2, d3);
float d4 = 0;
@@ -122,7 +120,7 @@
d4 = static_cast<float>(
pRuntime->ToDouble(pRuntime->GetArrayElement(array, 4)));
}
- if (sSpace == L"CMYK")
+ if (sSpace.EqualsASCII("CMYK"))
return CFX_Color(CFX_Color::kCMYK, d1, d2, d3, d4);
return CFX_Color();
@@ -280,13 +278,13 @@
WideString sDestSpace = pRuntime->ToWideString(params[1]);
int nColorType = CFX_Color::kTransparent;
- if (sDestSpace == L"T")
+ if (sDestSpace.EqualsASCII("T"))
nColorType = CFX_Color::kTransparent;
- else if (sDestSpace == L"G")
+ else if (sDestSpace.EqualsASCII("G"))
nColorType = CFX_Color::kGray;
- else if (sDestSpace == L"RGB")
+ else if (sDestSpace.EqualsASCII("RGB"))
nColorType = CFX_Color::kRGB;
- else if (sDestSpace == L"CMYK")
+ else if (sDestSpace.EqualsASCII("CMYK"))
nColorType = CFX_Color::kCMYK;
CFX_Color color =
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 523d88e..57c5849 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -222,9 +222,10 @@
}
CJS_Result CJS_Global::QueryProperty(const wchar_t* propname) {
- if (WideString(propname) != L"setPersistent")
- return CJS_Result::Failure(JSMessage::kUnknownProperty);
- return CJS_Result::Success();
+ if (WideString(propname).EqualsASCII("setPersistent"))
+ return CJS_Result::Success();
+
+ return CJS_Result::Failure(JSMessage::kUnknownProperty);
}
CJS_Result CJS_Global::DelProperty(CJS_Runtime* pRuntime,
diff --git a/fxjs/xfa/cjx_boolean.cpp b/fxjs/xfa/cjx_boolean.cpp
index 7ca3889..1830894 100644
--- a/fxjs/xfa/cjx_boolean.cpp
+++ b/fxjs/xfa/cjx_boolean.cpp
@@ -23,8 +23,7 @@
bool bSetting,
XFA_Attribute eAttribute) {
if (!bSetting) {
- WideString wsValue = GetContent(true);
- pValue->SetBoolean(wsValue == L"1");
+ pValue->SetBoolean(GetContent(true).EqualsASCII("1"));
return;
}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index d22cf4e..a80bc44 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -57,7 +57,7 @@
WideString eventString = runtime->ToWideString(params[0]);
int32_t iRet =
execSingleEventByName(eventString.AsStringView(), XFA_Element::Field);
- if (eventString != L"validate")
+ if (!eventString.EqualsASCII("validate"))
return CJS_Result::Success();
return CJS_Result::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index 3c6f1e3..2bd6c67 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -227,12 +227,12 @@
return std::vector<CXFA_Node*>();
std::vector<CXFA_Node*> retArray;
- if (wsType == L"pageArea") {
+ if (wsType.EqualsASCII("pageArea")) {
if (pLayoutPage->GetFormNode())
retArray.push_back(pLayoutPage->GetFormNode());
return retArray;
}
- if (wsType == L"contentArea") {
+ if (wsType.EqualsASCII("contentArea")) {
for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
pItem = pItem->m_pNextSibling) {
if (pItem->GetFormNode()->GetElementType() == XFA_Element::ContentArea)
@@ -296,13 +296,13 @@
}
XFA_Element eType = XFA_Element::Unknown;
- if (wsType == L"field")
+ if (wsType.EqualsASCII("field"))
eType = XFA_Element::Field;
- else if (wsType == L"draw")
+ else if (wsType.EqualsASCII("draw"))
eType = XFA_Element::Draw;
- else if (wsType == L"subform")
+ else if (wsType.EqualsASCII("subform"))
eType = XFA_Element::Subform;
- else if (wsType == L"area")
+ else if (wsType.EqualsASCII("area"))
eType = XFA_Element::Area;
if (eType != XFA_Element::Unknown) {
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index d26b9b1..a37d5e4 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -335,8 +335,10 @@
if (params.size() > 1)
return CJS_Result::Failure(JSMessage::kParamError);
- if (params.size() == 1 && runtime->ToWideString(params[0]) != L"pretty")
+ if (params.size() == 1 &&
+ !runtime->ToWideString(params[0]).EqualsASCII("pretty")) {
return CJS_Result::Failure(JSMessage::kValueError);
+ }
// TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 98e6866..bfa3925 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -669,7 +669,7 @@
TryAttribute(XFA_Attribute::ContentType, false);
if (ret)
wsContentType = *ret;
- if (wsContentType == L"text/html") {
+ if (wsContentType.EqualsASCII("text/html")) {
wsContentType = L"";
SetAttribute(XFA_Attribute::ContentType, wsContentType.AsStringView(),
false);
@@ -680,7 +680,7 @@
if (!pContentRawDataNode) {
pContentRawDataNode =
ToNode(GetXFAObject())
- ->CreateSamePacketNode((wsContentType == L"text/xml")
+ ->CreateSamePacketNode(wsContentType.EqualsASCII("text/xml")
? XFA_Element::Sharpxml
: XFA_Element::Sharptext);
ToNode(GetXFAObject())->InsertChild(pContentRawDataNode, nullptr);
@@ -766,10 +766,10 @@
if (ToNode(GetXFAObject())->GetElementType() == XFA_Element::ExData) {
Optional<WideString> contentType =
TryAttribute(XFA_Attribute::ContentType, false);
- if (contentType) {
- if (*contentType == L"text/html")
+ if (contentType.has_value()) {
+ if (contentType.value().EqualsASCII("text/html"))
element = XFA_Element::SharpxHTML;
- else if (*contentType == L"text/xml")
+ else if (contentType.value().EqualsASCII("text/xml"))
element = XFA_Element::Sharpxml;
}
}
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index eeef004..622b5d6 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -262,20 +262,21 @@
while (ccf < lenf && strf[ccf] == symbol[0])
symbol += strf[ccf++];
- if (symbol == L"D" || symbol == L"DD") {
+ if (symbol.EqualsASCII("D") || symbol.EqualsASCII("DD")) {
day = 0;
if (!ExtractCountDigitsWithOptional(str, len, 1, cc, &day))
return false;
- } else if (symbol == L"J") {
+ } else if (symbol.EqualsASCII("J")) {
uint32_t val = 0;
ExtractCountDigits(str, len, 3, cc, &val);
- } else if (symbol == L"M" || symbol == L"MM") {
+ } else if (symbol.EqualsASCII("M") || symbol.EqualsASCII("MM")) {
month = 0;
if (!ExtractCountDigitsWithOptional(str, len, 1, cc, &month))
return false;
- } else if (symbol == L"MMM" || symbol == L"MMMM") {
+ } else if (symbol.EqualsASCII("MMM") || symbol.EqualsASCII("MMMM")) {
for (uint16_t i = 0; i < 12; i++) {
- WideString wsMonthName = pLocale->GetMonthName(i, symbol == L"MMM");
+ WideString wsMonthName =
+ pLocale->GetMonthName(i, symbol.EqualsASCII("MMM"));
if (wsMonthName.IsEmpty())
continue;
if (!wcsncmp(wsMonthName.c_str(), str + *cc, wsMonthName.GetLength())) {
@@ -284,9 +285,10 @@
break;
}
}
- } else if (symbol == L"EEE" || symbol == L"EEEE") {
+ } else if (symbol.EqualsASCII("EEE") || symbol.EqualsASCII("EEEE")) {
for (uint16_t i = 0; i < 7; i++) {
- WideString wsDayName = pLocale->GetDayName(i, symbol == L"EEE");
+ WideString wsDayName =
+ pLocale->GetDayName(i, symbol.EqualsASCII("EEE"));
if (wsDayName.IsEmpty())
continue;
if (!wcsncmp(wsDayName.c_str(), str + *cc, wsDayName.GetLength())) {
@@ -294,23 +296,23 @@
break;
}
}
- } else if (symbol == L"YY" || symbol == L"YYYY") {
+ } else if (symbol.EqualsASCII("YY") || symbol.EqualsASCII("YYYY")) {
if (*cc + pdfium::base::checked_cast<int32_t>(symbol.GetLength()) > len)
return false;
year = 0;
if (!ExtractCountDigits(str, len, symbol.GetLength(), cc, &year))
return false;
- if (symbol == L"YY") {
+ if (symbol.EqualsASCII("YY")) {
if (year <= 29)
year += 2000;
else
year += 1900;
}
- } else if (symbol == L"G") {
+ } else if (symbol.EqualsASCII("G")) {
*cc += 2;
- } else if (symbol == L"JJJ" || symbol == L"E" || symbol == L"e" ||
- symbol == L"w" || symbol == L"WW") {
+ } else if (symbol.EqualsASCII("JJJ") || symbol.EqualsASCIINoCase("E") ||
+ symbol.EqualsASCII("w") || symbol.EqualsASCII("WW")) {
*cc += symbol.GetLength();
}
}
@@ -383,40 +385,40 @@
while (ccf < lenf && strf[ccf] == symbol[0])
symbol += strf[ccf++];
- if (symbol == L"k" || symbol == L"K" || symbol == L"h" || symbol == L"H") {
+ if (symbol.EqualsASCIINoCase("k") || symbol.EqualsASCIINoCase("h")) {
hour = 0;
if (!ExtractCountDigitsWithOptional(str, len, 1, cc, &hour))
return false;
- if (symbol == L"K" && hour == 24)
+ if (symbol.EqualsASCII("K") && hour == 24)
hour = 0;
- } else if (symbol == L"kk" || symbol == L"KK" || symbol == L"hh" ||
- symbol == L"HH") {
+ } else if (symbol.EqualsASCIINoCase("kk") ||
+ symbol.EqualsASCIINoCase("hh")) {
hour = 0;
if (!ExtractCountDigits(str, len, 2, cc, &hour))
return false;
- if (symbol == L"KK" && hour == 24)
+ if (symbol.EqualsASCII("KK") && hour == 24)
hour = 0;
- } else if (symbol == L"M") {
+ } else if (symbol.EqualsASCII("M")) {
minute = 0;
if (!ExtractCountDigitsWithOptional(str, len, 1, cc, &minute))
return false;
- } else if (symbol == L"MM") {
+ } else if (symbol.EqualsASCII("MM")) {
minute = 0;
if (!ExtractCountDigits(str, len, 2, cc, &minute))
return false;
- } else if (symbol == L"S") {
+ } else if (symbol.EqualsASCII("S")) {
second = 0;
if (!ExtractCountDigitsWithOptional(str, len, 1, cc, &second))
return false;
- } else if (symbol == L"SS") {
+ } else if (symbol.EqualsASCII("SS")) {
second = 0;
if (!ExtractCountDigits(str, len, 2, cc, &second))
return false;
- } else if (symbol == L"FFF") {
+ } else if (symbol.EqualsASCII("FFF")) {
millisecond = 0;
if (!ExtractCountDigits(str, len, 3, cc, &millisecond))
return false;
- } else if (symbol == L"A") {
+ } else if (symbol.EqualsASCII("A")) {
WideString wsAM = pLocale->GetMeridiemName(true);
WideString wsPM = pLocale->GetMeridiemName(false);
if ((*cc + pdfium::base::checked_cast<int32_t>(wsAM.GetLength()) <=
@@ -431,14 +433,14 @@
bHasA = true;
bPM = true;
}
- } else if (symbol == L"Z") {
+ } else if (symbol.EqualsASCII("Z")) {
if (*cc + 3 > len)
continue;
WideString tz(str[(*cc)++]);
tz += str[(*cc)++];
tz += str[(*cc)++];
- if (tz == L"GMT") {
+ if (tz.EqualsASCII("GMT")) {
FX_TIMEZONE tzDiff;
tzDiff.tzHour = 0;
tzDiff.tzMinute = 0;
@@ -458,7 +460,7 @@
break;
}
}
- } else if (symbol == L"z") {
+ } else if (symbol.EqualsASCII("z")) {
if (str[*cc] != 'Z') {
FX_TIMEZONE tzDiff;
*cc += ParseTimeZone(str + *cc, len - *cc, &tzDiff);
@@ -588,34 +590,35 @@
while (ccf < lenf && strf[ccf] == symbol[0])
symbol += strf[ccf++];
- if (symbol == L"D" || symbol == L"DD") {
+ if (symbol.EqualsASCII("D") || symbol.EqualsASCII("DD")) {
wsResult += NumToString(symbol.GetLength(), day);
- } else if (symbol == L"J" || symbol == L"JJJ") {
+ } else if (symbol.EqualsASCII("J") || symbol.EqualsASCII("JJJ")) {
uint16_t nDays = 0;
for (int i = 1; i < month; i++)
nDays += GetSolarMonthDays(year, i);
nDays += day;
wsResult += NumToString(symbol.GetLength(), nDays);
- } else if (symbol == L"M" || symbol == L"MM") {
+ } else if (symbol.EqualsASCII("M") || symbol.EqualsASCII("MM")) {
wsResult += NumToString(symbol.GetLength(), month);
- } else if (symbol == L"MMM" || symbol == L"MMMM") {
- wsResult += pLocale->GetMonthName(month - 1, symbol == L"MMM");
- } else if (symbol == L"E" || symbol == L"e") {
+ } else if (symbol.EqualsASCII("MMM") || symbol.EqualsASCII("MMMM")) {
+ wsResult += pLocale->GetMonthName(month - 1, symbol.EqualsASCII("MMM"));
+ } else if (symbol.EqualsASCIINoCase("e")) {
uint16_t wWeekDay = GetWeekDay(year, month, day);
- wsResult += NumToString(
- 1, symbol == L"E" ? wWeekDay + 1 : (wWeekDay ? wWeekDay : 7));
- } else if (symbol == L"EEE" || symbol == L"EEEE") {
wsResult +=
- pLocale->GetDayName(GetWeekDay(year, month, day), symbol == L"EEE");
- } else if (symbol == L"G") {
+ NumToString(1, symbol.EqualsASCII("E") ? wWeekDay + 1
+ : (wWeekDay ? wWeekDay : 7));
+ } else if (symbol.EqualsASCII("EEE") || symbol.EqualsASCII("EEEE")) {
+ wsResult += pLocale->GetDayName(GetWeekDay(year, month, day),
+ symbol.EqualsASCII("EEE"));
+ } else if (symbol.EqualsASCII("G")) {
wsResult += pLocale->GetEraName(year > 0);
- } else if (symbol == L"YY") {
+ } else if (symbol.EqualsASCII("YY")) {
wsResult += NumToString(2, year % 100);
- } else if (symbol == L"YYYY") {
+ } else if (symbol.EqualsASCII("YYYY")) {
wsResult += NumToString(1, year);
- } else if (symbol == L"w") {
+ } else if (symbol.EqualsASCII("w")) {
wsResult += NumToString(1, GetWeekOfMonth(year, month, day));
- } else if (symbol == L"WW") {
+ } else if (symbol.EqualsASCII("WW")) {
wsResult += NumToString(2, GetWeekOfYear(year, month, day));
}
}
@@ -658,30 +661,29 @@
while (ccf < lenf && strf[ccf] == symbol[0])
symbol += strf[ccf++];
- if (symbol == L"h" || symbol == L"hh") {
+ if (symbol.EqualsASCII("h") || symbol.EqualsASCII("hh")) {
if (wHour > 12)
wHour -= 12;
wsResult += NumToString(symbol.GetLength(), wHour == 0 ? 12 : wHour);
- } else if (symbol == L"K" || symbol == L"KK") {
+ } else if (symbol.EqualsASCII("K") || symbol.EqualsASCII("KK")) {
wsResult += NumToString(symbol.GetLength(), wHour == 0 ? 24 : wHour);
- } else if (symbol == L"k" || symbol == L"kk") {
+ } else if (symbol.EqualsASCII("k") || symbol.EqualsASCII("kk")) {
if (wHour > 12)
wHour -= 12;
wsResult += NumToString(symbol.GetLength(), wHour);
- } else if (symbol == L"H" || symbol == L"HH") {
+ } else if (symbol.EqualsASCII("H") || symbol.EqualsASCII("HH")) {
wsResult += NumToString(symbol.GetLength(), wHour);
- } else if (symbol == L"M" || symbol == L"MM") {
+ } else if (symbol.EqualsASCII("M") || symbol.EqualsASCII("MM")) {
wsResult += NumToString(symbol.GetLength(), minute);
- } else if (symbol == L"S" || symbol == L"SS") {
+ } else if (symbol.EqualsASCII("S") || symbol.EqualsASCII("SS")) {
wsResult += NumToString(symbol.GetLength(), second);
- } else if (symbol == L"FFF") {
+ } else if (symbol.EqualsASCII("FFF")) {
wsResult += NumToString(3, millisecond);
- } else if (symbol == L"A") {
+ } else if (symbol.EqualsASCII("A")) {
wsResult += pLocale->GetMeridiemName(!bPM);
- } else if (symbol == L"Z" || symbol == L"z") {
- if (symbol == L"Z")
+ } else if (symbol.EqualsASCIINoCase("z")) {
+ if (symbol.EqualsASCII("Z"))
wsResult += L"GMT";
-
FX_TIMEZONE tz = pLocale->GetTimeZone();
if (tz.tzHour != 0 || tz.tzMinute != 0) {
wsResult += tz.tzHour < 0 ? L"-" : L"+";
@@ -989,7 +991,7 @@
wsCategory += pStr[ccf];
ccf++;
}
- if (wsCategory != L"num") {
+ if (!wsCategory.EqualsASCII("num")) {
bBrackOpen = true;
ccf = 0;
continue;
@@ -1578,15 +1580,15 @@
wsCategory += pStr[ccf];
ccf++;
}
- if (!(iFindCategory & 1) && wsCategory == L"date") {
+ if (!(iFindCategory & 1) && wsCategory.EqualsASCII("date")) {
iFindCategory |= 1;
eCategory = FX_LOCALECATEGORY_Date;
if (iFindCategory & 2)
iFindCategory = 4;
- } else if (!(iFindCategory & 2) && wsCategory == L"time") {
+ } else if (!(iFindCategory & 2) && wsCategory.EqualsASCII("time")) {
iFindCategory |= 2;
eCategory = FX_LOCALECATEGORY_Time;
- } else if (wsCategory == L"datetime") {
+ } else if (wsCategory.EqualsASCII("datetime")) {
iFindCategory = 3;
eCategory = FX_LOCALECATEGORY_DateTime;
} else {
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 07e0b1b..12c6cc1 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -159,7 +159,7 @@
return true;
WideString wsType = pDynamicRender->JSObject()->GetContent(false);
- if (wsType == L"required")
+ if (wsType.EqualsASCII("required"))
m_FormType = FormType::kXFAFull;
return true;
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index d90abef2..f019959 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -617,8 +617,10 @@
WideString wsValueRef = item->GetValueRef();
WideString wsLabelRef = item->GetLabelRef();
const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef;
- const bool bLabelUseContent = wsLabelRef.IsEmpty() || wsLabelRef == L"$";
- const bool bValueUseContent = wsValueRef.IsEmpty() || wsValueRef == L"$";
+ const bool bLabelUseContent =
+ wsLabelRef.IsEmpty() || wsLabelRef.EqualsASCII("$");
+ const bool bValueUseContent =
+ wsValueRef.IsEmpty() || wsValueRef.EqualsASCII("$");
WideString wsValue;
WideString wsLabel;
uint32_t uValueHash = FX_HashCode_GetW(wsValueRef.AsStringView(), false);
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 44a7c64..4c521ea 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -103,10 +103,9 @@
if (!pXMLElement)
continue;
WideString wsTag = pXMLElement->GetLocalTagName();
- if (wsTag == L"body" || wsTag == L"html")
+ if (wsTag.EqualsASCII("body") || wsTag.EqualsASCII("html"))
return pXMLChild;
}
-
return nullptr;
}
@@ -737,7 +736,7 @@
pElement = static_cast<const CFX_XMLElement*>(pXMLNode);
wsName = pElement->GetLocalTagName();
}
- if (wsName == L"ol") {
+ if (wsName.EqualsASCII("ol")) {
bIsOl = true;
bCurOl = true;
}
@@ -755,8 +754,9 @@
if ((eDisplay == CFX_CSSDisplay::Block ||
eDisplay == CFX_CSSDisplay::ListItem) &&
pStyle &&
- (wsName.IsEmpty() || (wsName != L"body" && wsName != L"html" &&
- wsName != L"ol" && wsName != L"ul"))) {
+ (wsName.IsEmpty() ||
+ !(wsName.EqualsASCII("body") || wsName.EqualsASCII("html") ||
+ wsName.EqualsASCII("ol") || wsName.EqualsASCII("ul")))) {
const CFX_CSSRect* pRect = pStyle->GetMarginWidth();
if (pRect) {
*pLinePos += pRect->top.GetValue();
@@ -764,7 +764,7 @@
}
}
- if (wsName == L"a") {
+ if (wsName.EqualsASCII("a")) {
ASSERT(pElement);
WideString wsLinkContent = pElement->GetAttribute(L"href");
if (!wsLinkContent.IsEmpty()) {
@@ -780,9 +780,9 @@
WideString wsText;
if (bContentNode && iTabCount == 0) {
wsText = ToXMLText(pXMLNode)->GetText();
- } else if (wsName == L"br") {
+ } else if (wsName.EqualsASCII("br")) {
wsText = L'\n';
- } else if (wsName == L"li") {
+ } else if (wsName.EqualsASCII("li")) {
bCurLi = true;
if (bIsOl)
wsText = WideString::Format(L"%d. ", iLiCount);
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 24276e1..f889686 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -237,8 +237,8 @@
return;
RetainPtr<CFX_CSSComputedStyle> pNewStyle;
- if ((tagProvider->GetTagName() != L"body") ||
- (tagProvider->GetTagName() != L"html")) {
+ if (!(tagProvider->GetTagName().EqualsASCII("body") &&
+ tagProvider->GetTagName().EqualsASCII("html"))) {
auto pTextContext = pdfium::MakeUnique<CXFA_TextParseContext>();
CFX_CSSDisplay eDisplay = CFX_CSSDisplay::Inline;
if (!tagProvider->m_bContent) {
@@ -330,11 +330,8 @@
bool CXFA_TextParser::IsSpaceRun(CFX_CSSComputedStyle* pStyle) const {
WideString wsValue;
- if (pStyle && pStyle->GetCustomStyle(L"xfa-spacerun", &wsValue)) {
- wsValue.MakeLower();
- return wsValue == L"yes";
- }
- return false;
+ return pStyle && pStyle->GetCustomStyle(L"xfa-spacerun", &wsValue) &&
+ wsValue.EqualsASCIINoCase("yes");
}
RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
@@ -438,7 +435,7 @@
WideString wsValue;
if (pStyle->GetCustomStyle(L"underlinePeriod", &wsValue)) {
- if (wsValue == L"word")
+ if (wsValue.EqualsASCII("word"))
iPeriod = XFA_AttributeEnum::Word;
} else if (font) {
iPeriod = font->GetUnderlinePeriod();
@@ -528,12 +525,12 @@
WideString ws =
GetLowerCaseElementAttributeOrDefault(pElement, L"xfa:embedType", L"som");
- if (ws != L"uri")
+ if (!ws.EqualsASCII("uri"))
return {};
ws = GetLowerCaseElementAttributeOrDefault(pElement, L"xfa:embedMode",
L"formatted");
- if (ws != L"raw" && ws != L"formatted")
+ if (!(ws.EqualsASCII("raw") || ws.EqualsASCII("formatted")))
return {};
return pTextProvider->GetEmbeddedObj(wsAttr);
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index add251c..943d9c4 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -50,8 +50,10 @@
if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) {
Optional<WideString> contentType = pChildNode->JSObject()->TryAttribute(
XFA_Attribute::ContentType, false);
- if (contentType && *contentType == L"text/html")
+ if (contentType.has_value() &&
+ contentType.value().EqualsASCII("text/html")) {
bRichText = true;
+ }
}
return pChildNode;
}
@@ -85,8 +87,10 @@
if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) {
Optional<WideString> contentType = pChildNode->JSObject()->TryAttribute(
XFA_Attribute::ContentType, false);
- if (contentType && *contentType == L"text/html")
+ if (contentType.has_value() &&
+ contentType.value().EqualsASCII("text/html")) {
bRichText = true;
+ }
}
return pChildNode;
}
@@ -99,9 +103,11 @@
CXFA_Node* pNode = pItemNode->GetFirstChild();
while (pNode) {
WideString wsName = pNode->JSObject()->GetCData(XFA_Attribute::Name);
- if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && wsName == L"rollover")
+ if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover &&
+ wsName.EqualsASCII("rollover")) {
return pNode;
- if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == L"down")
+ }
+ if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName.EqualsASCII("down"))
return pNode;
pNode = pNode->GetNextSibling();
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 24a03ed..f041a92 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -108,10 +108,10 @@
Optional<WideString> contentType =
pChildNode->JSObject()->TryAttribute(XFA_Attribute::ContentType,
false);
- if (contentType) {
- if (*contentType == L"text/html")
+ if (contentType.has_value()) {
+ if (contentType.value().EqualsASCII("text/html"))
element = XFA_Element::SharpxHTML;
- else if (*contentType == L"text/xml")
+ else if (contentType.value().EqualsASCII("text/xml"))
element = XFA_Element::Sharpxml;
}
}
@@ -349,7 +349,7 @@
bool bForceBind,
bool bUpLevel) {
uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
- if (bUpLevel || wsRef != L"name")
+ if (bUpLevel || !wsRef.EqualsASCII("name"))
dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
XFA_RESOLVENODE_RS rs;
@@ -753,8 +753,10 @@
continue;
Optional<WideString> ns = pDDGroupNode->JSObject()->TryNamespace();
- if (!ns || *ns != L"http://ns.adobe.com/data-description/")
+ if (!ns.has_value() ||
+ !ns.value().EqualsASCII("http://ns.adobe.com/data-description/")) {
continue;
+ }
}
CXFA_Node* pDDNode =
@@ -1254,8 +1256,10 @@
continue;
Optional<WideString> ns = pDDGroupNode->JSObject()->TryNamespace();
- if (!ns || *ns != L"http://ns.adobe.com/data-description/")
+ if (!ns.has_value() ||
+ !ns.value().EqualsASCII("http://ns.adobe.com/data-description/")) {
continue;
+ }
}
CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(dwNameHash);
@@ -1410,7 +1414,7 @@
m_dwDocFlags |= XFA_DOCFLAG_HasInteractive;
WideString wsInteractive = pFormFiller->JSObject()->GetContent(false);
- if (wsInteractive == L"1") {
+ if (wsInteractive.EqualsASCII("1")) {
m_dwDocFlags |= XFA_DOCFLAG_Interactive;
return true;
}
@@ -1547,7 +1551,6 @@
wsSOM = WideStringView(wsUseVal.c_str(), wsUseVal.GetLength());
}
}
-
if (!wsURI.IsEmpty() && wsURI != L".")
continue;
@@ -1656,10 +1659,12 @@
if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) {
Optional<WideString> namespaceURI =
pChildNode->JSObject()->TryNamespace();
- if (!namespaceURI)
+ if (!namespaceURI.has_value())
continue;
- if (*namespaceURI == L"http://ns.adobe.com/data-description/")
+ if (namespaceURI.value().EqualsASCII(
+ "http://ns.adobe.com/data-description/")) {
pDDRoot = pChildNode;
+ }
} else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) {
Optional<WideString> namespaceURI =
pChildNode->JSObject()->TryNamespace();
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 643695f..57a6e90 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -155,8 +155,8 @@
wsNSPrefix = wsAttrName.Left(wsAttrName.GetLength() -
wsLocalAttrName.GetLength() - 1);
}
- if (wsLocalAttrName == L"xmlns" || wsNSPrefix == L"xmlns" ||
- wsNSPrefix == L"xml") {
+ if (wsLocalAttrName.EqualsASCII("xmlns") || wsNSPrefix.EqualsASCII("xmlns") ||
+ wsNSPrefix.EqualsASCII("xml")) {
return false;
}
if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix,
@@ -307,8 +307,8 @@
} // namespace
bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode) {
- return pRichTextXMLNode &&
- pRichTextXMLNode->GetNamespaceURI() == L"http://www.w3.org/1999/xhtml";
+ return pRichTextXMLNode && pRichTextXMLNode->GetNamespaceURI().EqualsASCII(
+ "http://www.w3.org/1999/xhtml");
}
CXFA_DocumentParser::CXFA_DocumentParser(CXFA_Document* pFactory)
@@ -448,12 +448,13 @@
pXFARootNode->JSObject()->SetCData(XFA_Attribute::Name, L"xfa", false, false);
for (auto it : ToXMLElement(pXMLDocumentNode)->GetAttributes()) {
- if (it.first == L"uuid")
+ if (it.first.EqualsASCII("uuid")) {
pXFARootNode->JSObject()->SetCData(XFA_Attribute::Uuid, it.second, false,
false);
- else if (it.first == L"timeStamp")
+ } else if (it.first.EqualsASCII("timeStamp")) {
pXFARootNode->JSObject()->SetCData(XFA_Attribute::TimeStamp, it.second,
false, false);
+ }
}
CFX_XMLNode* pXMLConfigDOMRoot = nullptr;
@@ -796,7 +797,7 @@
for (auto it : pXMLElement->GetAttributes()) {
WideString wsAttrName;
GetAttributeLocalName(it.first.AsStringView(), wsAttrName);
- if (wsAttrName == L"nil" && it.second == L"true")
+ if (wsAttrName.EqualsASCII("nil") && it.second.EqualsASCII("true"))
IsNeedValue = false;
XFA_Attribute attr =
@@ -850,9 +851,9 @@
if (pXFANode->GetElementType() == XFA_Element::ExData) {
WideString wsContentType =
pXFANode->JSObject()->GetCData(XFA_Attribute::ContentType);
- if (wsContentType == L"text/html")
+ if (wsContentType.EqualsASCII("text/html"))
element = XFA_Element::SharpxHTML;
- else if (wsContentType == L"text/xml")
+ else if (wsContentType.EqualsASCII("text/xml"))
element = XFA_Element::Sharpxml;
}
if (element == XFA_Element::SharpxHTML)
@@ -907,13 +908,14 @@
switch (pXMLChild->GetType()) {
case FX_XMLNODE_Element: {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
- {
- WideString wsNamespaceURI = pXMLElement->GetNamespaceURI();
- if (wsNamespaceURI == L"http://www.xfa.com/schema/xfa-package/" ||
- wsNamespaceURI == L"http://www.xfa.org/schema/xfa-package/" ||
- wsNamespaceURI == L"http://www.w3.org/2001/XMLSchema-instance") {
- continue;
- }
+ WideString wsNamespaceURI = pXMLElement->GetNamespaceURI();
+ if (wsNamespaceURI.EqualsASCII(
+ "http://www.xfa.com/schema/xfa-package/") ||
+ wsNamespaceURI.EqualsASCII(
+ "http://www.xfa.org/schema/xfa-package/") ||
+ wsNamespaceURI.EqualsASCII(
+ "http://www.w3.org/2001/XMLSchema-instance")) {
+ continue;
}
XFA_Element eNodeType = XFA_Element::DataModel;
@@ -922,9 +924,9 @@
if (FindAttributeWithNS(pXMLElement, L"dataNode",
L"http://www.xfa.org/schema/xfa-data/1.0/",
wsDataNodeAttr)) {
- if (wsDataNodeAttr == L"dataGroup")
+ if (wsDataNodeAttr.EqualsASCII("dataGroup"))
eNodeType = XFA_Element::DataGroup;
- else if (wsDataNodeAttr == L"dataValue")
+ else if (wsDataNodeAttr.EqualsASCII("dataValue"))
eNodeType = XFA_Element::DataValue;
}
}
@@ -965,14 +967,14 @@
if (!ResolveAttribute(pXMLElement, it.first, wsName, wsNS)) {
continue;
}
- if (wsName == L"nil" && it.second == L"true") {
+ if (wsName.EqualsASCII("nil") && it.second.EqualsASCII("true")) {
bNeedValue = false;
continue;
}
- if (wsNS == L"http://www.xfa.com/schema/xfa-package/" ||
- wsNS == L"http://www.xfa.org/schema/xfa-package/" ||
- wsNS == L"http://www.w3.org/2001/XMLSchema-instance" ||
- wsNS == L"http://www.xfa.org/schema/xfa-data/1.0/") {
+ if (wsNS.EqualsASCII("http://www.xfa.com/schema/xfa-package/") ||
+ wsNS.EqualsASCII("http://www.xfa.org/schema/xfa-package/") ||
+ wsNS.EqualsASCII("http://www.w3.org/2001/XMLSchema-instance") ||
+ wsNS.EqualsASCII("http://www.xfa.org/schema/xfa-data/1.0/")) {
continue;
}
CXFA_Node* pXFAMetaData = m_pFactory->CreateNode(
@@ -1126,20 +1128,18 @@
CFX_XMLInstruction* pXMLInstruction,
XFA_PacketType ePacketID) {
const std::vector<WideString>& target_data = pXMLInstruction->GetTargetData();
-
if (pXMLInstruction->IsOriginalXFAVersion()) {
if (target_data.size() > 1 &&
(pXFANode->GetDocument()->RecognizeXFAVersionNumber(target_data[0]) !=
XFA_VERSION_UNKNOWN) &&
- target_data[1] == L"v2.7-scripting:1") {
+ target_data[1].EqualsASCII("v2.7-scripting:1")) {
pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, true);
}
return;
}
-
if (pXMLInstruction->IsAcrobat()) {
- if (target_data.size() > 1 && target_data[0] == L"JavaScript" &&
- target_data[1] == L"strictScoping") {
+ if (target_data.size() > 1 && target_data[0].EqualsASCII("JavaScript") &&
+ target_data[1].EqualsASCII("strictScoping")) {
pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_StrictScoping, true);
}
}
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index a7cbe42..e520684 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -81,17 +81,15 @@
WideString wsRelevant =
pFormItem->JSObject()->GetCData(XFA_Attribute::Relevant);
if (!wsRelevant.IsEmpty()) {
- if (wsRelevant == L"+print" || wsRelevant == L"print")
+ if (wsRelevant.EqualsASCII("+print") || wsRelevant.EqualsASCII("print"))
dwRelevant &= ~XFA_WidgetStatus_Viewable;
- else if (wsRelevant == L"-print")
+ else if (wsRelevant.EqualsASCII("-print"))
dwRelevant &= ~XFA_WidgetStatus_Printable;
}
-
if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) &&
(dwRelevant != XFA_WidgetStatus_Viewable)) {
dwRelevant &= ~XFA_WidgetStatus_Viewable;
}
-
if (!(dwParentRelvant & XFA_WidgetStatus_Printable) &&
(dwRelevant != XFA_WidgetStatus_Printable)) {
dwRelevant &= ~XFA_WidgetStatus_Printable;
@@ -188,9 +186,9 @@
return pNode;
} else if (bNewExprStyle) {
WideString wsProcessedTarget = wsExpr;
- if (wsExpr.Left(4) == L"som(" && wsExpr.Last() == L')') {
+ if (wsExpr.Left(4).EqualsASCII("som(") && wsExpr.Last() == L')')
wsProcessedTarget = wsExpr.Mid(4, wsExpr.GetLength() - 5);
- }
+
XFA_RESOLVENODE_RS rs;
bool iRet = pDocument->GetScriptContext()->ResolveObjects(
pPageSetRoot, wsProcessedTarget.AsStringView(), &rs,
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 4a5a911..1529a48 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -146,7 +146,7 @@
case FX_LOCALECATEGORY_Zero:
bRet = pFormat->ParseZero(wsValue, wsFormat);
if (!bRet)
- bRet = wsValue == L"0";
+ bRet = wsValue.EqualsASCII("0");
break;
case FX_LOCALECATEGORY_Num: {
WideString fNum;
@@ -353,7 +353,7 @@
bRet = pFormat->FormatNull(wsFormat, &wsResult);
break;
case FX_LOCALECATEGORY_Zero:
- if (m_wsValue == L"0")
+ if (m_wsValue.EqualsASCII("0"))
bRet = pFormat->FormatZero(wsFormat, &wsResult);
break;
case FX_LOCALECATEGORY_Num:
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 4c3f496..6347677 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -163,28 +163,26 @@
FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) {
WideString wsContentType(wsType);
- wsContentType.MakeLower();
-
- if (wsContentType == L"image/jpg")
+ if (wsContentType.EqualsASCIINoCase("image/jpg"))
return FXCODEC_IMAGE_JPG;
#ifdef PDF_ENABLE_XFA_BMP
- if (wsContentType == L"image/bmp")
+ if (wsContentType.EqualsASCIINoCase("image/bmp"))
return FXCODEC_IMAGE_BMP;
#endif // PDF_ENABLE_XFA_BMP
#ifdef PDF_ENABLE_XFA_GIF
- if (wsContentType == L"image/gif")
+ if (wsContentType.EqualsASCIINoCase("image/gif"))
return FXCODEC_IMAGE_GIF;
#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_PNG
- if (wsContentType == L"image/png")
+ if (wsContentType.EqualsASCIINoCase("image/png"))
return FXCODEC_IMAGE_PNG;
#endif // PDF_ENABLE_XFA_PNG
#ifdef PDF_ENABLE_XFA_TIFF
- if (wsContentType == L"image/tif")
+ if (wsContentType.EqualsASCII("image/tif"))
return FXCODEC_IMAGE_TIFF;
#endif // PDF_ENABLE_XFA_TIFF
@@ -220,7 +218,8 @@
}
} else {
WideString wsURL = wsHref;
- if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") {
+ if (!(wsURL.Left(7).EqualsASCII("http://") ||
+ wsURL.Left(6).EqualsASCII("ftp://"))) {
RetainPtr<CFX_DIBitmap> pBitmap =
pDoc->GetPDFNamedImage(wsURL.AsStringView(), iImageXDpi, iImageYDpi);
if (pBitmap) {
@@ -979,9 +978,9 @@
LocaleIface* CXFA_Node::GetLocale() {
Optional<WideString> localeName = GetLocaleName();
- if (!localeName)
+ if (!localeName.has_value())
return nullptr;
- if (localeName.value() == L"ambient")
+ if (localeName.value().EqualsASCII("ambient"))
return GetDocument()->GetLocaleMgr()->GetDefLocale();
return GetDocument()->GetLocaleMgr()->GetLocaleByName(localeName.value());
}
@@ -3554,8 +3553,11 @@
for (CXFA_Node* pText = pItems->GetFirstChild(); pText;
pText = pText->GetNextSibling()) {
- if (pText->JSObject()->GetCData(XFA_Attribute::Name) == L"rollover")
+ if (pText->JSObject()
+ ->GetCData(XFA_Attribute::Name)
+ .EqualsASCII("rollover")) {
return !pText->JSObject()->GetContent(false).IsEmpty();
+ }
}
return false;
}
@@ -3567,8 +3569,9 @@
for (CXFA_Node* pText = pItems->GetFirstChild(); pText;
pText = pText->GetNextSibling()) {
- if (pText->JSObject()->GetCData(XFA_Attribute::Name) == L"down")
+ if (pText->JSObject()->GetCData(XFA_Attribute::Name).EqualsASCII("down")) {
return !pText->JSObject()->GetContent(false).IsEmpty();
+ }
}
return false;
}
@@ -4328,7 +4331,7 @@
bSyncData = true;
}
} else if (eType == XFA_Element::NumericEdit) {
- if (wsNewText != L"0")
+ if (!wsNewText.EqualsASCII("0"))
wsNewText = NumericLimit(wsNewText);
bSyncData = true;
diff --git a/xfa/fxfa/parser/cxfa_xmllocale.cpp b/xfa/fxfa/parser/cxfa_xmllocale.cpp
index 7d3eb77..4658c75 100644
--- a/xfa/fxfa/parser/cxfa_xmllocale.cpp
+++ b/xfa/fxfa/parser/cxfa_xmllocale.cpp
@@ -42,7 +42,7 @@
for (auto* child = doc->GetRoot()->GetFirstChild(); child;
child = child->GetNextSibling()) {
CFX_XMLElement* elem = ToXMLElement(child);
- if (elem && elem->GetName() == L"locale") {
+ if (elem && elem->GetName().EqualsASCII("locale")) {
locale = elem;
break;
}
@@ -134,7 +134,7 @@
WideString abbr = elem->GetAttribute(L"abbr");
bool abbr_value = false;
if (!abbr.IsEmpty())
- abbr_value = abbr == L"1";
+ abbr_value = abbr.EqualsASCII("1");
if (abbr_value != bAbbr)
continue;
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index c7bdb81..a59d1c2 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -207,7 +207,8 @@
Optional<WideString> contentType =
pNode->JSObject()->TryAttribute(XFA_Attribute::ContentType, false);
if (pRawValueNode->GetElementType() == XFA_Element::SharpxHTML &&
- (contentType && *contentType == L"text/html")) {
+ contentType.has_value() &&
+ contentType.value().EqualsASCII("text/html")) {
CFX_XMLNode* pExDataXML = pNode->GetXMLMappingNode();
if (!pExDataXML)
break;
@@ -221,7 +222,8 @@
wsChildren += WideString::FromUTF8(
ByteStringView(pMemStream->GetBuffer(), pMemStream->GetSize()));
} else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&
- (contentType && *contentType == L"text/xml")) {
+ contentType.has_value() &&
+ contentType.value().EqualsASCII("text/xml")) {
Optional<WideString> rawValue = pRawValueNode->JSObject()->TryAttribute(
XFA_Attribute::Value, false);
if (!rawValue || rawValue->IsEmpty())