Make CFX_CSSSelector better match Chromium style.
Give methods and variables Chromium style names.
Change-Id: Iecf22c96f26af41b3da12eef04d0850e2681d7a9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70730
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/css/cfx_cssrulecollection.cpp b/core/fxcrt/css/cfx_cssrulecollection.cpp
index dcaba9a..b85d4e9 100644
--- a/core/fxcrt/css/cfx_cssrulecollection.cpp
+++ b/core/fxcrt/css/cfx_cssrulecollection.cpp
@@ -43,7 +43,7 @@
int32_t iSelectors = pStyleRule->CountSelectorLists();
for (int32_t i = 0; i < iSelectors; ++i) {
CFX_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
- m_TagRules[pSelector->GetNameHash()].push_back(
+ m_TagRules[pSelector->name_hash()].push_back(
std::make_unique<Data>(pSelector, pDeclaration));
m_iSelectors++;
}
diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp
index 99a8a40..a0f2fe2 100644
--- a/core/fxcrt/css/cfx_cssselector.cpp
+++ b/core/fxcrt/css/cfx_cssselector.cpp
@@ -26,7 +26,7 @@
} // namespace
CFX_CSSSelector::CFX_CSSSelector(const wchar_t* psz, int32_t iLen)
- : m_dwHash(
+ : name_hash_(
FX_HashCode_GetW(WideStringView(psz, iLen), /*bIgnoreCase=*/true)) {}
CFX_CSSSelector::~CFX_CSSSelector() = default;
@@ -55,8 +55,8 @@
int32_t iNameLen = wch == '*' ? 1 : GetCSSNameLen(psz, pEnd);
auto new_head = std::make_unique<CFX_CSSSelector>(psz, iNameLen);
if (head) {
- head->SetDescendentType();
- new_head->SetNext(std::move(head));
+ head->set_descendent_type();
+ new_head->set_next(std::move(head));
}
head = std::move(new_head);
psz += iNameLen;
diff --git a/core/fxcrt/css/cfx_cssselector.h b/core/fxcrt/css/cfx_cssselector.h
index 56414b7..65dbd79 100644
--- a/core/fxcrt/css/cfx_cssselector.h
+++ b/core/fxcrt/css/cfx_cssselector.h
@@ -20,20 +20,20 @@
CFX_CSSSelector(const wchar_t* psz, int32_t iLen);
~CFX_CSSSelector();
- CFX_CSSSelectorType GetType() const { return m_eType; }
- uint32_t GetNameHash() const { return m_dwHash; }
- const CFX_CSSSelector* GetNextSelector() const { return m_pNext.get(); }
+ CFX_CSSSelectorType type() const { return type_; }
+ uint32_t name_hash() const { return name_hash_; }
+ const CFX_CSSSelector* next_selector() const { return next_.get(); }
- void SetNext(std::unique_ptr<CFX_CSSSelector> pNext) {
- m_pNext = std::move(pNext);
+ void set_next(std::unique_ptr<CFX_CSSSelector> pNext) {
+ next_ = std::move(pNext);
}
private:
- void SetDescendentType() { m_eType = CFX_CSSSelectorType::Descendant; }
+ void set_descendent_type() { type_ = CFX_CSSSelectorType::Descendant; }
- CFX_CSSSelectorType m_eType = CFX_CSSSelectorType::Element;
- const uint32_t m_dwHash;
- std::unique_ptr<CFX_CSSSelector> m_pNext;
+ CFX_CSSSelectorType type_ = CFX_CSSSelectorType::Element;
+ const uint32_t name_hash_;
+ std::unique_ptr<CFX_CSSSelector> next_;
};
#endif // CORE_FXCRT_CSS_CFX_CSSSELECTOR_H_
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 260ce9b..a6430db 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -70,11 +70,11 @@
// 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
// just say we don't support them to simplify the code for now.
- if (!pSel || pSel->GetNextSelector() ||
- pSel->GetType() == CFX_CSSSelectorType::Descendant) {
+ if (!pSel || pSel->next_selector() ||
+ pSel->type() == CFX_CSSSelectorType::Descendant) {
return false;
}
- return pSel->GetNameHash() == FX_HashCode_GetW(tagname.AsStringView(), true);
+ return pSel->name_hash() == FX_HashCode_GetW(tagname.AsStringView(), true);
}
void CFX_CSSStyleSelector::ComputeStyle(
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index 90efc7d..87cb711 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -46,7 +46,7 @@
for (size_t i = 0; i < selectors.size(); i++) {
uint32_t hash = FX_HashCode_GetW(selectors[i].AsStringView(), true);
- EXPECT_EQ(hash, style->GetSelectorList(i)->GetNameHash());
+ EXPECT_EQ(hash, style->GetSelectorList(i)->name_hash());
}
decl_ = style->GetDeclaration();
@@ -132,7 +132,7 @@
bool found_selector = false;
uint32_t hash = FX_HashCode_GetW(L"a", true);
for (size_t i = 0; i < style->CountSelectorLists(); i++) {
- if (style->GetSelectorList(i)->GetNameHash() == hash) {
+ if (style->GetSelectorList(i)->name_hash() == hash) {
found_selector = true;
break;
}
@@ -156,7 +156,7 @@
found_selector = false;
hash = FX_HashCode_GetW(L"b", true);
for (size_t i = 0; i < style->CountSelectorLists(); i++) {
- if (style->GetSelectorList(i)->GetNameHash() == hash) {
+ if (style->GetSelectorList(i)->name_hash() == hash) {
found_selector = true;
break;
}
@@ -179,17 +179,17 @@
const auto* sel = style->GetSelectorList(0);
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"c", true), sel->GetNameHash());
+ EXPECT_EQ(FX_HashCode_GetW(L"c", true), sel->name_hash());
- sel = sel->GetNextSelector();
+ sel = sel->next_selector();
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"b", true), sel->GetNameHash());
+ EXPECT_EQ(FX_HashCode_GetW(L"b", true), sel->name_hash());
- sel = sel->GetNextSelector();
+ sel = sel->next_selector();
ASSERT_TRUE(sel);
- EXPECT_EQ(FX_HashCode_GetW(L"a", true), sel->GetNameHash());
+ EXPECT_EQ(FX_HashCode_GetW(L"a", true), sel->name_hash());
- sel = sel->GetNextSelector();
+ sel = sel->next_selector();
EXPECT_FALSE(sel);
decl_ = style->GetDeclaration();