From 9f2970caec897c40b91bd010c04dfe1f19d11108 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 1 Apr 2016 10:23:04 -0700 Subject: Remove CFX_{Byte,Wide}String::Equal in favor of "==". Makes the code slightly cleaner. Review URL: https://codereview.chromium.org/1846083002 --- xfa/fxfa/app/xfa_ffdoc.cpp | 4 +- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 6 +-- xfa/fxfa/app/xfa_fontmgr.cpp | 11 ++--- xfa/fxfa/app/xfa_textlayout.cpp | 2 +- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 62 ++++++++++++------------- xfa/fxfa/fm2js/xfa_simpleexpression.cpp | 16 +++---- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 4 +- xfa/fxfa/parser/xfa_document_serialize.cpp | 4 +- xfa/fxfa/parser/xfa_object_imp.cpp | 19 ++++---- xfa/fxfa/parser/xfa_objectacc_imp.cpp | 2 +- xfa/fxfa/parser/xfa_parser_imp.cpp | 2 +- 11 files changed, 63 insertions(+), 69 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 94f035251e..ed4f94cd77 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -59,7 +59,7 @@ FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, CFX_WideString wsTagName; CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetTagName(wsTagName); - if (wsTagName.Equal(FX_WSTRC(L"document"))) { + if (wsTagName == FX_WSTRC(L"document")) { pDocumentElement = pXMLElement; break; } @@ -76,7 +76,7 @@ FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, CFX_WideString wsTagName; CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->GetTagName(wsTagName); - if (wsTagName.Equal(FX_WSTRC(L"chunk"))) { + if (wsTagName == FX_WSTRC(L"chunk")) { pChunkElement = pXMLElement; break; } diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index fc8b38f458..5c2e6c354b 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -1583,7 +1583,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { CFX_WideString wsContentType; m_pTextNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { bRichText = TRUE; } } @@ -1599,7 +1599,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { CFX_WideString wsContentType; pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { bRichText = TRUE; } } @@ -1634,7 +1634,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) { if (pChildNode && pChildNode->GetClassID() == XFA_ELEMENT_ExData) { CFX_WideString wsContentType; pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { bRichText = TRUE; } } diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index fb6fd39249..e915dcbaf7 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -1960,8 +1960,8 @@ FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( } if (iDifferLength > 1) { CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength); - if (bsDRTailer.Equal("MT") || bsDRTailer.Equal("PSMT") || - bsDRTailer.Equal("Regular") || bsDRTailer.Equal("Reg")) { + if (bsDRTailer == "MT" || bsDRTailer == "PSMT" || + bsDRTailer == "Regular" || bsDRTailer == "Reg") { return TRUE; } if (bBoldFont || bItalicFont) { @@ -1970,18 +1970,17 @@ FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( FX_BOOL bMatch = FALSE; switch (bsPsName.GetAt(iPsLen - 1)) { case 'L': { - if (bsDRName.Right(5).Equal("Light")) { + if (bsDRName.Right(5) == "Light") { bMatch = TRUE; } } break; case 'R': { - if (bsDRName.Right(7).Equal("Regular") || - bsDRName.Right(3).Equal("Reg")) { + if (bsDRName.Right(7) == "Regular" || bsDRName.Right(3) == "Reg") { bMatch = TRUE; } } break; case 'M': { - if (bsDRName.Right(5).Equal("Medium")) { + if (bsDRName.Right(5) == "Medium") { bMatch = TRUE; } } break; diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index f60ed26c64..07a353e287 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -729,7 +729,7 @@ CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { CFDE_XMLElement* pXMLElement = static_cast(pXMLChild); CFX_WideString wsTag; pXMLElement->GetLocalTagName(wsTag); - if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { + if (wsTag == FX_WSTRC(L"body") || wsTag == FX_WSTRC(L"html")) { pXMLContainer = pXMLChild; break; } diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 971c09d6f3..73eaed6f5b 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -3542,65 +3542,62 @@ void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis, strUnit = strFirstUnit; } FX_DOUBLE dResult = 0; - if (strFirstUnit.Equal("in") || strFirstUnit.Equal("inches")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + if (strFirstUnit == "in" || strFirstUnit == "inches") { + if (strUnit == "mm" || strUnit == "millimeters") { dResult = dFirstNumber * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + } else if (strUnit == "cm" || strUnit == "centimeters") { dResult = dFirstNumber * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + } else if (strUnit == "pt" || strUnit == "points") { dResult = dFirstNumber / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + } else if (strUnit == "mp" || strUnit == "millipoints") { dResult = dFirstNumber / 72000; } else { dResult = dFirstNumber; } - } else if (strFirstUnit.Equal("mm") || - strFirstUnit.Equal("millimeters")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + } else if (strFirstUnit == "mm" || strFirstUnit == "millimeters") { + if (strUnit == "mm" || strUnit == "millimeters") { dResult = dFirstNumber; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + } else if (strUnit == "cm" || strUnit == "centimeters") { dResult = dFirstNumber / 10; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + } else if (strUnit == "pt" || strUnit == "points") { dResult = dFirstNumber / 25.4 / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + } else if (strUnit == "mp" || strUnit == "millipoints") { dResult = dFirstNumber / 25.4 / 72000; } else { dResult = dFirstNumber / 25.4; } - } else if (strFirstUnit.Equal("cm") || - strFirstUnit.Equal("centimeters")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + } else if (strFirstUnit == "cm" || strFirstUnit == "centimeters") { + if (strUnit == "mm" || strUnit == "millimeters") { dResult = dFirstNumber * 10; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + } else if (strUnit == "cm" || strUnit == "centimeters") { dResult = dFirstNumber; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + } else if (strUnit == "pt" || strUnit == "points") { dResult = dFirstNumber / 2.54 / 72; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + } else if (strUnit == "mp" || strUnit == "millipoints") { dResult = dFirstNumber / 2.54 / 72000; } else { dResult = dFirstNumber / 2.54; } - } else if (strFirstUnit.Equal("pt") || strFirstUnit.Equal("points")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + } else if (strFirstUnit == "pt" || strFirstUnit == "points") { + if (strUnit == "mm" || strUnit == "millimeters") { dResult = dFirstNumber / 72 * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + } else if (strUnit == "cm" || strUnit == "centimeters") { dResult = dFirstNumber / 72 * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + } else if (strUnit == "pt" || strUnit == "points") { dResult = dFirstNumber; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + } else if (strUnit == "mp" || strUnit == "millipoints") { dResult = dFirstNumber * 1000; } else { dResult = dFirstNumber / 72; } - } else if (strFirstUnit.Equal("mp") || - strFirstUnit.Equal("millipoints")) { - if (strUnit.Equal("mm") || strUnit.Equal("millimeters")) { + } else if (strFirstUnit == "mp" || strFirstUnit == "millipoints") { + if (strUnit == "mm" || strUnit == "millimeters") { dResult = dFirstNumber / 72000 * 25.4; - } else if (strUnit.Equal("cm") || strUnit.Equal("centimeters")) { + } else if (strUnit == "cm" || strUnit == "centimeters") { dResult = dFirstNumber / 72000 * 2.54; - } else if (strUnit.Equal("pt") || strUnit.Equal("points")) { + } else if (strUnit == "pt" || strUnit == "points") { dResult = dFirstNumber / 1000; - } else if (strUnit.Equal("mp") || strUnit.Equal("millipoints")) { + } else if (strUnit == "mp" || strUnit == "millipoints") { dResult = dFirstNumber; } else { dResult = dFirstNumber / 72000; @@ -5710,7 +5707,7 @@ void CXFA_FM2JSContext::equality_operator(FXJSE_HOBJECT hThis, FXJSE_Value_ToUTF8String(argFirst, firstOutput); FXJSE_Value_ToUTF8String(argSecond, secondOutput); FXJSE_Value_SetInteger(args.GetReturnValue(), - firstOutput.Equal(secondOutput) ? 1 : 0); + firstOutput == secondOutput); } else { FX_DOUBLE first = HValueToDouble(hThis, argFirst); FX_DOUBLE second = HValueToDouble(hThis, argSecond); @@ -5748,12 +5745,11 @@ void CXFA_FM2JSContext::notequality_operator(FXJSE_HOBJECT hThis, FXJSE_Value_ToUTF8String(argFirst, firstOutput); FXJSE_Value_ToUTF8String(argSecond, secondOutput); FXJSE_Value_SetInteger(args.GetReturnValue(), - firstOutput.Equal(secondOutput) ? 0 : 1); + firstOutput != secondOutput); } else { FX_DOUBLE first = HValueToDouble(hThis, argFirst); FX_DOUBLE second = HValueToDouble(hThis, argSecond); - FXJSE_Value_SetInteger(args.GetReturnValue(), - (first == second) ? 0 : 1); + FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); } FXJSE_Value_Release(argFirst); FXJSE_Value_Release(argSecond); @@ -6694,7 +6690,7 @@ FX_BOOL CXFA_FM2JSContext::simpleValueCompare(FXJSE_HOBJECT hThis, CFX_ByteString firstString, secondString; HValueToUTF8String(firstValue, firstString); HValueToUTF8String(secondValue, secondString); - bReturn = firstString.Equal(secondString); + bReturn = firstString == secondString; } else if (FXJSE_Value_IsNumber(firstValue)) { FX_FLOAT first = HValueToFloat(hThis, firstValue); FX_FLOAT second = HValueToFloat(hThis, secondValue); diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp index 113fbfb536..f1e1137459 100644 --- a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp +++ b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp @@ -178,21 +178,21 @@ CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { CFX_WideString tempStr = m_wsIdentifier; - if (tempStr.Equal(FX_WSTRC(L"$"))) { + if (tempStr == FX_WSTRC(L"$")) { tempStr = FX_WSTRC(L"this"); - } else if (tempStr.Equal(FX_WSTRC(L"!"))) { + } else if (tempStr == FX_WSTRC(L"!")) { tempStr = FX_WSTRC(L"xfa.datasets"); - } else if (tempStr.Equal(FX_WSTRC(L"$data"))) { + } else if (tempStr == FX_WSTRC(L"$data")) { tempStr = FX_WSTRC(L"xfa.datasets.data"); - } else if (tempStr.Equal(FX_WSTRC(L"$event"))) { + } else if (tempStr == FX_WSTRC(L"$event")) { tempStr = FX_WSTRC(L"xfa.event"); - } else if (tempStr.Equal(FX_WSTRC(L"$form"))) { + } else if (tempStr == FX_WSTRC(L"$form")) { tempStr = FX_WSTRC(L"xfa.form"); - } else if (tempStr.Equal(FX_WSTRC(L"$host"))) { + } else if (tempStr == FX_WSTRC(L"$host")) { tempStr = FX_WSTRC(L"xfa.host"); - } else if (tempStr.Equal(FX_WSTRC(L"$layout"))) { + } else if (tempStr == FX_WSTRC(L"$layout")) { tempStr = FX_WSTRC(L"xfa.layout"); - } else if (tempStr.Equal(FX_WSTRC(L"$template"))) { + } else if (tempStr == FX_WSTRC(L"$template")) { tempStr = FX_WSTRC(L"xfa.template"); } else if (tempStr[0] == L'!') { tempStr = EXCLAMATION_IN_IDENTIFIER + tempStr.Mid(1); diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index e525532f7c..5d371619e4 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -79,9 +79,9 @@ static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent( CFX_WideString wsContentType; pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { element = XFA_ELEMENT_SharpxHTML; - } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + } else if (wsContentType == FX_WSTRC(L"text/xml")) { element = XFA_ELEMENT_Sharpxml; } } diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index f207b32263..448acbdd1d 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -242,7 +242,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( CFX_WideString wsContentType; pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); if (pRawValueNode->GetClassID() == XFA_ELEMENT_SharpxHTML && - wsContentType.Equal(FX_WSTRC(L"text/html"))) { + wsContentType == FX_WSTRC(L"text/html")) { CFDE_XMLNode* pExDataXML = pNode->GetXMLMappingNode(); if (!pExDataXML) { break; @@ -264,7 +264,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( pTempStream->Release(); pMemStream->Release(); } else if (pRawValueNode->GetClassID() == XFA_ELEMENT_Sharpxml && - wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + wsContentType == FX_WSTRC(L"text/xml")) { CFX_WideString wsRawValue; pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, FALSE); if (wsRawValue.IsEmpty()) { diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index 0bd114b6c4..15f21c8a23 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -1078,7 +1078,7 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { FX_BOOL bPrettyMode = FALSE; if (iLength == 1) { CFX_ByteString bsPretty = pArguments->GetUTF8String(0); - if (!bsPretty.Equal("pretty")) { + if (bsPretty != "pretty") { ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); return; } @@ -1259,7 +1259,7 @@ void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { TryNamespace(wsNodeNameSpace); FXJSE_HVALUE hValue = pArguments->GetReturnValue(); if (hValue) { - FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace.Equal(wsNameSpace)); + FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace == wsNameSpace); } } void CXFA_Node::Script_ModelClass_Context(FXJSE_HVALUE hValue, @@ -1748,7 +1748,7 @@ void CXFA_Node::Script_Boolean_Value(FXJSE_HVALUE hValue, SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); } else { CFX_WideString wsValue = GetScriptContent(TRUE); - FXJSE_Value_SetBoolean(hValue, wsValue.Equal(FX_WSTRC(L"1"))); + FXJSE_Value_SetBoolean(hValue, wsValue == FX_WSTRC(L"1")); } } struct XFA_ExecEventParaInfo { @@ -4303,17 +4303,16 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent, CFX_WideString wsContentType; if (GetClassID() == XFA_ELEMENT_ExData) { GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { wsContentType = FX_WSTRC(L""); SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType); } } CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); if (!pContentRawDataNode) { - pContentRawDataNode = - CreateSamePacketNode((wsContentType.Equal(FX_WSTRC(L"text/xml"))) - ? XFA_ELEMENT_Sharpxml - : XFA_ELEMENT_Sharptext); + pContentRawDataNode = CreateSamePacketNode( + (wsContentType == FX_WSTRC(L"text/xml")) ? XFA_ELEMENT_Sharpxml + : XFA_ELEMENT_Sharptext); InsertChild(pContentRawDataNode); } return pContentRawDataNode->SetScriptContent( @@ -4409,9 +4408,9 @@ FX_BOOL CXFA_Node::TryContent(CFX_WideString& wsContent, if (GetClassID() == XFA_ELEMENT_ExData) { CFX_WideString wsContentType; GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); - if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { + if (wsContentType == FX_WSTRC(L"text/html")) { element = XFA_ELEMENT_SharpxHTML; - } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { + } else if (wsContentType == FX_WSTRC(L"text/xml")) { element = XFA_ELEMENT_Sharpxml; } } diff --git a/xfa/fxfa/parser/xfa_objectacc_imp.cpp b/xfa/fxfa/parser/xfa_objectacc_imp.cpp index b634746ef4..8c438c5634 100644 --- a/xfa/fxfa/parser/xfa_objectacc_imp.cpp +++ b/xfa/fxfa/parser/xfa_objectacc_imp.cpp @@ -2273,7 +2273,7 @@ IFX_Locale* CXFA_WidgetData::GetLocal() { CFX_WideString wsLocaleName; bLocale = m_pNode->GetLocaleName(wsLocaleName); if (bLocale) { - if (wsLocaleName.Equal(FX_WSTRC(L"ambient"))) { + if (wsLocaleName == FX_WSTRC(L"ambient")) { pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale(); } else { pLocale = diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp index a2c2ae7909..71c37755f9 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -1456,7 +1456,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { } m_pParser->GetTagName(m_ws1); static_cast(m_pChild)->GetTagName(m_ws2); - if (m_ws1.GetLength() > 0 && !m_ws1.Equal(m_ws2)) { + if (m_ws1.GetLength() > 0 && m_ws1 != m_ws2) { m_dwStatus = FDE_XMLSYNTAXSTATUS_Error; break; } -- cgit v1.2.3