Remove CFX_CSSSelectorType.
A properly named boolean replacement is just as readable.
Change-Id: Ib7d3eb0677694dae961ff4595e0d7179ef30999d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70731
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/css/cfx_css.h b/core/fxcrt/css/cfx_css.h
index 30d9ff8..7336052 100644
--- a/core/fxcrt/css/cfx_css.h
+++ b/core/fxcrt/css/cfx_css.h
@@ -124,8 +124,6 @@
MarginTop,
};
-enum class CFX_CSSSelectorType : uint8_t { Element = 0, Descendant };
-
enum class CFX_CSSLengthUnit : uint8_t {
Auto,
None,
diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp
index a0f2fe2..9f3eeb5 100644
--- a/core/fxcrt/css/cfx_cssselector.cpp
+++ b/core/fxcrt/css/cfx_cssselector.cpp
@@ -55,7 +55,7 @@
int32_t iNameLen = wch == '*' ? 1 : GetCSSNameLen(psz, pEnd);
auto new_head = std::make_unique<CFX_CSSSelector>(psz, iNameLen);
if (head) {
- head->set_descendent_type();
+ head->set_is_descendant();
new_head->set_next(std::move(head));
}
head = std::move(new_head);
diff --git a/core/fxcrt/css/cfx_cssselector.h b/core/fxcrt/css/cfx_cssselector.h
index 65dbd79..5839779 100644
--- a/core/fxcrt/css/cfx_cssselector.h
+++ b/core/fxcrt/css/cfx_cssselector.h
@@ -10,7 +10,6 @@
#include <memory>
#include <utility>
-#include "core/fxcrt/css/cfx_css.h"
#include "core/fxcrt/fx_string.h"
class CFX_CSSSelector {
@@ -20,7 +19,7 @@
CFX_CSSSelector(const wchar_t* psz, int32_t iLen);
~CFX_CSSSelector();
- CFX_CSSSelectorType type() const { return type_; }
+ bool is_descendant() const { return is_descendant_; }
uint32_t name_hash() const { return name_hash_; }
const CFX_CSSSelector* next_selector() const { return next_.get(); }
@@ -29,9 +28,9 @@
}
private:
- void set_descendent_type() { type_ = CFX_CSSSelectorType::Descendant; }
+ void set_is_descendant() { is_descendant_ = true; }
- CFX_CSSSelectorType type_ = CFX_CSSSelectorType::Element;
+ bool is_descendant_ = false;
const uint32_t name_hash_;
std::unique_ptr<CFX_CSSSelector> next_;
};
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index a6430db..b567fef 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -70,10 +70,8 @@
// 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->next_selector() ||
- pSel->type() == CFX_CSSSelectorType::Descendant) {
+ if (!pSel || pSel->next_selector() || pSel->is_descendant())
return false;
- }
return pSel->name_hash() == FX_HashCode_GetW(tagname.AsStringView(), true);
}