diff options
Diffstat (limited to 'core/fxcrt/css')
21 files changed, 88 insertions, 92 deletions
diff --git a/core/fxcrt/css/cfx_csscomputedstyle.cpp b/core/fxcrt/css/cfx_csscomputedstyle.cpp index 953c107ec3..aae88a364a 100644 --- a/core/fxcrt/css/cfx_csscomputedstyle.cpp +++ b/core/fxcrt/css/cfx_csscomputedstyle.cpp @@ -14,8 +14,8 @@ CFX_CSSComputedStyle::CFX_CSSComputedStyle() {} CFX_CSSComputedStyle::~CFX_CSSComputedStyle() {} -bool CFX_CSSComputedStyle::GetCustomStyle(const CFX_WideString& wsName, - CFX_WideString& wsValue) const { +bool CFX_CSSComputedStyle::GetCustomStyle(const WideString& wsName, + WideString& wsValue) const { for (auto iter = m_CustomProperties.rbegin(); iter != m_CustomProperties.rend(); iter++) { if (wsName == iter->name()) { @@ -32,7 +32,7 @@ int32_t CFX_CSSComputedStyle::CountFontFamilies() const { : 0; } -const CFX_WideString CFX_CSSComputedStyle::GetFontFamily(int32_t index) const { +const WideString CFX_CSSComputedStyle::GetFontFamily(int32_t index) const { return m_InheritedData.m_pFontFamily->GetValue(index) .As<CFX_CSSStringValue>() ->Value(); diff --git a/core/fxcrt/css/cfx_csscomputedstyle.h b/core/fxcrt/css/cfx_csscomputedstyle.h index bb4b62bc2b..b05339ac02 100644 --- a/core/fxcrt/css/cfx_csscomputedstyle.h +++ b/core/fxcrt/css/cfx_csscomputedstyle.h @@ -56,7 +56,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { }; int32_t CountFontFamilies() const; - const CFX_WideString GetFontFamily(int32_t index) const; + const WideString GetFontFamily(int32_t index) const; uint16_t GetFontWeight() const; CFX_CSSFontVariant GetFontVariant() const; CFX_CSSFontStyle GetFontStyle() const; @@ -91,8 +91,7 @@ class CFX_CSSComputedStyle : public CFX_Retainable { void SetLetterSpacing(const CFX_CSSLength& letterSpacing); void AddCustomStyle(const CFX_CSSCustomProperty& prop); - bool GetCustomStyle(const CFX_WideString& wsName, - CFX_WideString& wsValue) const; + bool GetCustomStyle(const WideString& wsName, WideString& wsValue) const; InheritedData m_InheritedData; NonInheritedData m_NonInheritedData; diff --git a/core/fxcrt/css/cfx_csscustomproperty.cpp b/core/fxcrt/css/cfx_csscustomproperty.cpp index 8bfb9d961e..353facd5f0 100644 --- a/core/fxcrt/css/cfx_csscustomproperty.cpp +++ b/core/fxcrt/css/cfx_csscustomproperty.cpp @@ -4,8 +4,8 @@ #include "core/fxcrt/css/cfx_csscustomproperty.h" -CFX_CSSCustomProperty::CFX_CSSCustomProperty(const CFX_WideString& name, - const CFX_WideString& value) +CFX_CSSCustomProperty::CFX_CSSCustomProperty(const WideString& name, + const WideString& value) : name_(name), value_(value) {} CFX_CSSCustomProperty::CFX_CSSCustomProperty(const CFX_CSSCustomProperty& prop) diff --git a/core/fxcrt/css/cfx_csscustomproperty.h b/core/fxcrt/css/cfx_csscustomproperty.h index e062c3e953..15c3eca124 100644 --- a/core/fxcrt/css/cfx_csscustomproperty.h +++ b/core/fxcrt/css/cfx_csscustomproperty.h @@ -11,17 +11,16 @@ class CFX_CSSCustomProperty { public: - CFX_CSSCustomProperty(const CFX_WideString& name, - const CFX_WideString& value); + CFX_CSSCustomProperty(const WideString& name, const WideString& value); CFX_CSSCustomProperty(const CFX_CSSCustomProperty& prop); ~CFX_CSSCustomProperty(); - CFX_WideString name() const { return name_; } - CFX_WideString value() const { return value_; } + WideString name() const { return name_; } + WideString value() const { return value_; } private: - CFX_WideString name_; - CFX_WideString value_; + WideString name_; + WideString value_; }; #endif // CORE_FXCRT_CSS_CFX_CSSCUSTOMPROPERTY_H_ diff --git a/core/fxcrt/css/cfx_cssdatatable.cpp b/core/fxcrt/css/cfx_cssdatatable.cpp index 833b81b93b..53617b6a48 100644 --- a/core/fxcrt/css/cfx_cssdatatable.cpp +++ b/core/fxcrt/css/cfx_cssdatatable.cpp @@ -122,7 +122,7 @@ static_assert(g_iCSSPropertyCount == "Property table differs in size from property enum"); const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName( - const CFX_WideStringC& wsName) { + const WideStringView& wsName) { ASSERT(!wsName.IsEmpty()); uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = g_iCSSPropertyCount; diff --git a/core/fxcrt/css/cfx_cssdatatable.h b/core/fxcrt/css/cfx_cssdatatable.h index 43310c7d5c..63c303488e 100644 --- a/core/fxcrt/css/cfx_cssdatatable.h +++ b/core/fxcrt/css/cfx_cssdatatable.h @@ -23,7 +23,7 @@ struct CFX_CSSPropertyTable { }; const CFX_CSSPropertyTable* CFX_GetCSSPropertyByName( - const CFX_WideStringC& wsName); + const WideStringView& wsName); const CFX_CSSPropertyTable* CFX_GetCSSPropertyByEnum(CFX_CSSProperty eName); #endif // CORE_FXCRT_CSS_CFX_CSSDATATABLE_H_ diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp index 344fc842c4..f2c7d3930b 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.cpp +++ b/core/fxcrt/css/cfx_cssdeclaration.cpp @@ -113,7 +113,7 @@ const CFX_CSSColorTable g_CFX_CSSColors[] = { }; const CFX_CSSPropertyValueTable* GetCSSPropertyValueByName( - const CFX_WideStringC& wsName) { + const WideStringView& wsName) { ASSERT(!wsName.IsEmpty()); uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = g_iCSSPropertyValueCount; @@ -134,7 +134,7 @@ const CFX_CSSPropertyValueTable* GetCSSPropertyValueByName( } const CFX_CSSLengthUnitTable* GetCSSLengthUnitByName( - const CFX_WideStringC& wsName) { + const WideStringView& wsName) { ASSERT(!wsName.IsEmpty()); uint16_t wHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = @@ -155,7 +155,7 @@ const CFX_CSSLengthUnitTable* GetCSSLengthUnitByName( return nullptr; } -const CFX_CSSColorTable* GetCSSColorByName(const CFX_WideStringC& wsName) { +const CFX_CSSColorTable* GetCSSColorByName(const WideStringView& wsName) { ASSERT(!wsName.IsEmpty()); uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = sizeof(g_CFX_CSSColors) / sizeof(CFX_CSSColorTable) - 1; @@ -192,7 +192,7 @@ bool ParseCSSNumber(const wchar_t* pszValue, eUnit = CFX_CSSNumberType::Percent; } else if (iValueLen == 2) { const CFX_CSSLengthUnitTable* pUnit = - GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2)); + GetCSSLengthUnitByName(WideStringView(pszValue, 2)); if (pUnit) eUnit = pUnit->wValue; } @@ -273,7 +273,7 @@ bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue, } const CFX_CSSColorTable* pColor = - GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSColorByName(WideStringView(pszValue, iValueLen)); if (!pColor) return false; @@ -308,7 +308,7 @@ void CFX_CSSDeclaration::AddPropertyHolder(CFX_CSSProperty eProperty, } void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, - const CFX_WideStringC& value) { + const WideStringView& value) { ASSERT(!value.IsEmpty()); const wchar_t* pszValue = value.unterminated_c_str(); @@ -422,8 +422,8 @@ void CFX_CSSDeclaration::AddProperty(const CFX_CSSPropertyTable* pTable, } } -void CFX_CSSDeclaration::AddProperty(const CFX_WideString& prop, - const CFX_WideString& value) { +void CFX_CSSDeclaration::AddProperty(const WideString& prop, + const WideString& value) { custom_properties_.push_back( pdfium::MakeUnique<CFX_CSSCustomProperty>(prop, value)); } @@ -442,7 +442,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum( const wchar_t* pszValue, int32_t iValueLen) { const CFX_CSSPropertyValueTable* pValue = - GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); return pValue ? pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName) : nullptr; } @@ -466,7 +466,7 @@ CFX_RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseString( return nullptr; return pdfium::MakeRetain<CFX_CSSStringValue>( - CFX_WideString(pszValue + iOffset, iValueLen)); + WideString(pszValue + iOffset, iValueLen)); } void CFX_CSSDeclaration::ParseValueListProperty( @@ -502,7 +502,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( } if (dwType & CFX_CSSVALUETYPE_MaybeEnum) { const CFX_CSSPropertyValueTable* pValue = - GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); if (pValue) { list.push_back(pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName)); continue; @@ -510,7 +510,7 @@ void CFX_CSSDeclaration::ParseValueListProperty( } if (dwType & CFX_CSSVALUETYPE_MaybeString) { list.push_back(pdfium::MakeRetain<CFX_CSSStringValue>( - CFX_WideString(pszValue, iValueLen))); + WideString(pszValue, iValueLen))); } break; case CFX_CSSPrimitiveType::RGB: @@ -614,12 +614,12 @@ bool CFX_CSSDeclaration::ParseBorderProperty( } case CFX_CSSPrimitiveType::String: { const CFX_CSSColorTable* pColorItem = - GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSColorByName(WideStringView(pszValue, iValueLen)); if (pColorItem) continue; const CFX_CSSPropertyValueTable* pValue = - GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); if (!pValue) continue; @@ -661,7 +661,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue, switch (eType) { case CFX_CSSPrimitiveType::String: { const CFX_CSSPropertyValueTable* pValue = - GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen)); + GetCSSPropertyValueByName(WideStringView(pszValue, iValueLen)); if (pValue) { switch (pValue->eName) { case CFX_CSSPropertyValue::XxSmall: @@ -710,7 +710,7 @@ void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue, } if (pFontSize) { familyList.push_back(pdfium::MakeRetain<CFX_CSSStringValue>( - CFX_WideString(pszValue, iValueLen))); + WideString(pszValue, iValueLen))); } parser.m_Separator = ','; break; diff --git a/core/fxcrt/css/cfx_cssdeclaration.h b/core/fxcrt/css/cfx_cssdeclaration.h index 7b39daef7e..dba1d44fc7 100644 --- a/core/fxcrt/css/cfx_cssdeclaration.h +++ b/core/fxcrt/css/cfx_cssdeclaration.h @@ -48,8 +48,8 @@ class CFX_CSSDeclaration { bool empty() const { return properties_.empty(); } void AddProperty(const CFX_CSSPropertyTable* pTable, - const CFX_WideStringC& value); - void AddProperty(const CFX_WideString& prop, const CFX_WideString& value); + const WideStringView& value); + void AddProperty(const WideString& prop, const WideString& value); size_t PropertyCountForTesting() const; diff --git a/core/fxcrt/css/cfx_cssrulecollection.cpp b/core/fxcrt/css/cfx_cssrulecollection.cpp index 635ca91c72..2030518b69 100644 --- a/core/fxcrt/css/cfx_cssrulecollection.cpp +++ b/core/fxcrt/css/cfx_cssrulecollection.cpp @@ -28,7 +28,7 @@ void CFX_CSSRuleCollection::Clear() { } const std::vector<std::unique_ptr<CFX_CSSRuleCollection::Data>>* -CFX_CSSRuleCollection::GetTagRuleData(const CFX_WideString& tagname) const { +CFX_CSSRuleCollection::GetTagRuleData(const WideString& tagname) const { auto it = m_TagRules.find(FX_HashCode_GetW(tagname.c_str(), true)); return it != m_TagRules.end() ? &it->second : nullptr; } diff --git a/core/fxcrt/css/cfx_cssrulecollection.h b/core/fxcrt/css/cfx_cssrulecollection.h index 6b91c6bcd5..72ae58c55f 100644 --- a/core/fxcrt/css/cfx_cssrulecollection.h +++ b/core/fxcrt/css/cfx_cssrulecollection.h @@ -36,7 +36,7 @@ class CFX_CSSRuleCollection { int32_t CountSelectors() const { return m_iSelectors; } const std::vector<std::unique_ptr<Data>>* GetTagRuleData( - const CFX_WideString& tagname) const; + const WideString& tagname) const; private: void AddRulesFrom(const CFX_CSSStyleSheet* pStyleSheet, diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp index 6ee81f5610..3993dcae5c 100644 --- a/core/fxcrt/css/cfx_cssselector.cpp +++ b/core/fxcrt/css/cfx_cssselector.cpp @@ -31,7 +31,7 @@ CFX_CSSSelector::CFX_CSSSelector(CFX_CSSSelectorType eType, int32_t iLen, bool bIgnoreCase) : m_eType(eType), - m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)) {} + m_dwHash(FX_HashCode_GetW(WideStringView(psz, iLen), bIgnoreCase)) {} CFX_CSSSelector::~CFX_CSSSelector() {} @@ -49,7 +49,7 @@ CFX_CSSSelector* CFX_CSSSelector::GetNextSelector() const { // static. std::unique_ptr<CFX_CSSSelector> CFX_CSSSelector::FromString( - const CFX_WideStringC& str) { + const WideStringView& str) { ASSERT(!str.IsEmpty()); const wchar_t* psz = str.unterminated_c_str(); diff --git a/core/fxcrt/css/cfx_cssselector.h b/core/fxcrt/css/cfx_cssselector.h index 9fff42a850..62f8b166cc 100644 --- a/core/fxcrt/css/cfx_cssselector.h +++ b/core/fxcrt/css/cfx_cssselector.h @@ -15,8 +15,7 @@ class CFX_CSSSelector { public: - static std::unique_ptr<CFX_CSSSelector> FromString( - const CFX_WideStringC& str); + static std::unique_ptr<CFX_CSSSelector> FromString(const WideStringView& str); CFX_CSSSelector(CFX_CSSSelectorType eType, const wchar_t* psz, diff --git a/core/fxcrt/css/cfx_cssstringvalue.cpp b/core/fxcrt/css/cfx_cssstringvalue.cpp index b66c54505f..6ff2a33c9b 100644 --- a/core/fxcrt/css/cfx_cssstringvalue.cpp +++ b/core/fxcrt/css/cfx_cssstringvalue.cpp @@ -6,7 +6,7 @@ #include "core/fxcrt/css/cfx_cssstringvalue.h" -CFX_CSSStringValue::CFX_CSSStringValue(const CFX_WideString& value) +CFX_CSSStringValue::CFX_CSSStringValue(const WideString& value) : CFX_CSSValue(CFX_CSSPrimitiveType::String), value_(value) {} CFX_CSSStringValue::~CFX_CSSStringValue() {} diff --git a/core/fxcrt/css/cfx_cssstringvalue.h b/core/fxcrt/css/cfx_cssstringvalue.h index 7680360973..d72078a630 100644 --- a/core/fxcrt/css/cfx_cssstringvalue.h +++ b/core/fxcrt/css/cfx_cssstringvalue.h @@ -11,13 +11,13 @@ class CFX_CSSStringValue : public CFX_CSSValue { public: - explicit CFX_CSSStringValue(const CFX_WideString& value); + explicit CFX_CSSStringValue(const WideString& value); ~CFX_CSSStringValue() override; - const CFX_WideString Value() const { return value_; } + const WideString Value() const { return value_; } private: - const CFX_WideString value_; + const WideString value_; }; #endif // CORE_FXCRT_CSS_CFX_CSSSTRINGVALUE_H_ diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp index 9a2bc8c498..9ae2b876f7 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.cpp +++ b/core/fxcrt/css/cfx_cssstyleselector.cpp @@ -50,7 +50,7 @@ void CFX_CSSStyleSelector::UpdateStyleIndex() { } std::vector<const CFX_CSSDeclaration*> CFX_CSSStyleSelector::MatchDeclarations( - const CFX_WideString& tagname) { + const WideString& tagname) { std::vector<const CFX_CSSDeclaration*> matchedDecls; if (m_UARules.CountSelectors() == 0 || tagname.IsEmpty()) return matchedDecls; @@ -66,7 +66,7 @@ std::vector<const CFX_CSSDeclaration*> CFX_CSSStyleSelector::MatchDeclarations( return matchedDecls; } -bool CFX_CSSStyleSelector::MatchSelector(const CFX_WideString& tagname, +bool CFX_CSSStyleSelector::MatchSelector(const WideString& tagname, CFX_CSSSelector* pSel) { // TODO(dsinclair): The code only supports a single level of selector at this // point. None of the code using selectors required the complexity so lets @@ -80,8 +80,8 @@ bool CFX_CSSStyleSelector::MatchSelector(const CFX_WideString& tagname, void CFX_CSSStyleSelector::ComputeStyle( const std::vector<const CFX_CSSDeclaration*>& declArray, - const CFX_WideString& styleString, - const CFX_WideString& alignString, + const WideString& styleString, + const WideString& alignString, CFX_CSSComputedStyle* pDest) { std::unique_ptr<CFX_CSSDeclaration> pDecl; if (!styleString.IsEmpty() || !alignString.IsEmpty()) { @@ -91,7 +91,7 @@ void CFX_CSSStyleSelector::ComputeStyle( AppendInlineStyle(pDecl.get(), styleString); if (!alignString.IsEmpty()) { pDecl->AddProperty(CFX_GetCSSPropertyByEnum(CFX_CSSProperty::TextAlign), - alignString.AsStringC()); + alignString.AsStringView()); } } ApplyDeclarations(declArray, pDecl.get(), pDest); @@ -137,29 +137,29 @@ void CFX_CSSStyleSelector::ExtractValues( } void CFX_CSSStyleSelector::AppendInlineStyle(CFX_CSSDeclaration* pDecl, - const CFX_WideString& style) { + const WideString& style) { ASSERT(pDecl && !style.IsEmpty()); auto pSyntax = pdfium::MakeUnique<CFX_CSSSyntaxParser>( style.c_str(), style.GetLength(), 32, true); int32_t iLen2 = 0; const CFX_CSSPropertyTable* table = nullptr; - CFX_WideString wsName; + WideString wsName; while (1) { CFX_CSSSyntaxStatus eStatus = pSyntax->DoSyntaxParse(); if (eStatus == CFX_CSSSyntaxStatus::PropertyName) { - CFX_WideStringC strValue = pSyntax->GetCurrentString(); + WideStringView strValue = pSyntax->GetCurrentString(); table = CFX_GetCSSPropertyByName(strValue); if (!table) - wsName = CFX_WideString(strValue); + wsName = WideString(strValue); } else if (eStatus == CFX_CSSSyntaxStatus::PropertyValue) { if (table || iLen2 > 0) { - CFX_WideStringC strValue = pSyntax->GetCurrentString(); + WideStringView strValue = pSyntax->GetCurrentString(); if (!strValue.IsEmpty()) { if (table) pDecl->AddProperty(table, strValue); else if (iLen2 > 0) - pDecl->AddProperty(wsName, CFX_WideString(strValue)); + pDecl->AddProperty(wsName, WideString(strValue)); } } } else { diff --git a/core/fxcrt/css/cfx_cssstyleselector.h b/core/fxcrt/css/cfx_cssstyleselector.h index 143e51ee68..b59e3048d6 100644 --- a/core/fxcrt/css/cfx_cssstyleselector.h +++ b/core/fxcrt/css/cfx_cssstyleselector.h @@ -39,18 +39,17 @@ class CFX_CSSStyleSelector { // adds non-inherited data from the parent style. Attempting to copy // internally will fail as you'll lose the non-inherited data. void ComputeStyle(const std::vector<const CFX_CSSDeclaration*>& declArray, - const CFX_WideString& styleString, - const CFX_WideString& alignString, + const WideString& styleString, + const WideString& alignString, CFX_CSSComputedStyle* pDestStyle); std::vector<const CFX_CSSDeclaration*> MatchDeclarations( - const CFX_WideString& tagname); + const WideString& tagname); private: - bool MatchSelector(const CFX_WideString& tagname, CFX_CSSSelector* pSel); + bool MatchSelector(const WideString& tagname, CFX_CSSSelector* pSel); - void AppendInlineStyle(CFX_CSSDeclaration* pDecl, - const CFX_WideString& style); + void AppendInlineStyle(CFX_CSSDeclaration* pDecl, const WideString& style); void ApplyDeclarations( const std::vector<const CFX_CSSDeclaration*>& declArray, const CFX_CSSDeclaration* extraDecl, diff --git a/core/fxcrt/css/cfx_cssstylesheet.cpp b/core/fxcrt/css/cfx_cssstylesheet.cpp index 9bd25c044f..183765f3b0 100644 --- a/core/fxcrt/css/cfx_cssstylesheet.cpp +++ b/core/fxcrt/css/cfx_cssstylesheet.cpp @@ -63,32 +63,32 @@ CFX_CSSSyntaxStatus CFX_CSSStyleSheet::LoadStyleRule( CFX_CSSStyleRule* pStyleRule = nullptr; int32_t iValueLen = 0; const CFX_CSSPropertyTable* propertyTable = nullptr; - CFX_WideString wsName; + WideString wsName; while (1) { switch (pSyntax->DoSyntaxParse()) { case CFX_CSSSyntaxStatus::Selector: { - CFX_WideStringC strValue = pSyntax->GetCurrentString(); + WideStringView strValue = pSyntax->GetCurrentString(); auto pSelector = CFX_CSSSelector::FromString(strValue); if (pSelector) selectors.push_back(std::move(pSelector)); break; } case CFX_CSSSyntaxStatus::PropertyName: { - CFX_WideStringC strValue = pSyntax->GetCurrentString(); + WideStringView strValue = pSyntax->GetCurrentString(); propertyTable = CFX_GetCSSPropertyByName(strValue); if (!propertyTable) - wsName = CFX_WideString(strValue); + wsName = WideString(strValue); break; } case CFX_CSSSyntaxStatus::PropertyValue: { if (propertyTable || iValueLen > 0) { - CFX_WideStringC strValue = pSyntax->GetCurrentString(); + WideStringView strValue = pSyntax->GetCurrentString(); auto* decl = pStyleRule->GetDeclaration(); if (!strValue.IsEmpty()) { if (propertyTable) { decl->AddProperty(propertyTable, strValue); } else { - decl->AddProperty(wsName, CFX_WideString(strValue)); + decl->AddProperty(wsName, WideString(strValue)); } } } diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp index 4194a70490..abcd2f6972 100644 --- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp +++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp @@ -28,7 +28,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { void TearDown() override { decl_ = nullptr; } void LoadAndVerifyDecl(const wchar_t* buf, - const std::vector<CFX_WideString>& selectors, + const std::vector<WideString>& selectors, size_t decl_count) { ASSERT(sheet_); @@ -39,7 +39,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { EXPECT_EQ(selectors.size(), style->CountSelectorLists()); for (size_t i = 0; i < selectors.size(); i++) { - uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringC(), true); + uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringView(), true); EXPECT_EQ(hash, style->GetSelectorList(i)->GetNameHash()); } diff --git a/core/fxcrt/css/cfx_csssyntaxparser.cpp b/core/fxcrt/css/cfx_csssyntaxparser.cpp index c8082e87fb..066b82b5d6 100644 --- a/core/fxcrt/css/cfx_csssyntaxparser.cpp +++ b/core/fxcrt/css/cfx_csssyntaxparser.cpp @@ -223,6 +223,6 @@ bool CFX_CSSSyntaxParser::RestoreMode() { return true; } -CFX_WideStringC CFX_CSSSyntaxParser::GetCurrentString() const { - return CFX_WideStringC(m_TextData.GetBuffer(), m_iTextDataLen); +WideStringView CFX_CSSSyntaxParser::GetCurrentString() const { + return WideStringView(m_TextData.GetBuffer(), m_iTextDataLen); } diff --git a/core/fxcrt/css/cfx_csssyntaxparser.h b/core/fxcrt/css/cfx_csssyntaxparser.h index 9ddedfe4a7..778f9a3272 100644 --- a/core/fxcrt/css/cfx_csssyntaxparser.h +++ b/core/fxcrt/css/cfx_csssyntaxparser.h @@ -47,7 +47,7 @@ class CFX_CSSSyntaxParser { ~CFX_CSSSyntaxParser(); CFX_CSSSyntaxStatus DoSyntaxParse(); - CFX_WideStringC GetCurrentString() const; + WideStringView GetCurrentString() const; protected: void SwitchMode(CFX_CSSSyntaxMode eMode); diff --git a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp index 510c96251d..62a542bc52 100644 --- a/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp +++ b/core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp @@ -18,25 +18,25 @@ TEST(CFX_CSSValueListParserTest, rgb_short) { auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abc", 4, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"#abc", CFX_WideString(start, len)); + EXPECT_EQ(L"#abc", WideString(start, len)); EXPECT_FALSE(parser->NextValue(type, start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdef", 7, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"#abcdef", CFX_WideString(start, len)); + EXPECT_EQ(L"#abcdef", WideString(start, len)); EXPECT_FALSE(parser->NextValue(type, start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"rgb(1, 255, 4)", 14, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"rgb(1, 255, 4)", CFX_WideString(start, len)); + EXPECT_EQ(L"rgb(1, 255, 4)", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"#abcdefghij", 11, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Unknown, type); - EXPECT_EQ(L"#abcdefghij", CFX_WideString(start, len)); + EXPECT_EQ(L"#abcdefghij", WideString(start, len)); EXPECT_FALSE(parser->NextValue(type, start, len)); } @@ -48,38 +48,38 @@ TEST(CFX_CSSValueListParserTest, number_parsing) { auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1234", 4, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"1234", CFX_WideString(start, len)); + EXPECT_EQ(L"1234", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"-1234", 5, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"-1234", CFX_WideString(start, len)); + EXPECT_EQ(L"-1234", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"+1234", 5, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"+1234", CFX_WideString(start, len)); + EXPECT_EQ(L"+1234", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L".1234", 5, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L".1234", CFX_WideString(start, len)); + EXPECT_EQ(L".1234", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.1234", 9, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4321.1234", CFX_WideString(start, len)); + EXPECT_EQ(L"4321.1234", WideString(start, len)); // TODO(dsinclair): These should probably fail but currently don't. parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"4321.12.34", 10, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4321.12.34", CFX_WideString(start, len)); + EXPECT_EQ(L"4321.12.34", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"43a1.12.34", 10, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"43a1.12.34", CFX_WideString(start, len)); + EXPECT_EQ(L"43a1.12.34", WideString(start, len)); } TEST(CFX_CSSValueListParserTest, string_parsing) { @@ -91,18 +91,18 @@ TEST(CFX_CSSValueListParserTest, string_parsing) { pdfium::MakeUnique<CFX_CSSValueListParser>(L"'string'", 8, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::String, type); - EXPECT_EQ(L"string", CFX_WideString(start, len)); + EXPECT_EQ(L"string", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"\"another string\"", 16, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::String, type); - EXPECT_EQ(L"another string", CFX_WideString(start, len)); + EXPECT_EQ(L"another string", WideString(start, len)); parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"standalone", 10, L' '); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::String, type); - EXPECT_EQ(L"standalone", CFX_WideString(start, len)); + EXPECT_EQ(L"standalone", WideString(start, len)); } TEST(CFX_CSSValueListParserTest, multiparsing) { @@ -113,15 +113,15 @@ TEST(CFX_CSSValueListParserTest, multiparsing) { auto parser = pdfium::MakeUnique<CFX_CSSValueListParser>(L"1, 2, 3", 7, L','); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"1", CFX_WideString(start, len)); + EXPECT_EQ(L"1", WideString(start, len)); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"2", CFX_WideString(start, len)); + EXPECT_EQ(L"2", WideString(start, len)); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"3", CFX_WideString(start, len)); + EXPECT_EQ(L"3", WideString(start, len)); EXPECT_FALSE(parser->NextValue(type, start, len)); @@ -129,13 +129,13 @@ TEST(CFX_CSSValueListParserTest, multiparsing) { 22, L','); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::String, type); - EXPECT_EQ(L"str", CFX_WideString(start, len)); + EXPECT_EQ(L"str", WideString(start, len)); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::RGB, type); - EXPECT_EQ(L"rgb(1, 2, 3)", CFX_WideString(start, len)); + EXPECT_EQ(L"rgb(1, 2, 3)", WideString(start, len)); EXPECT_TRUE(parser->NextValue(type, start, len)); EXPECT_EQ(CFX_CSSPrimitiveType::Number, type); - EXPECT_EQ(L"4", CFX_WideString(start, len)); + EXPECT_EQ(L"4", WideString(start, len)); } |