Replace uint32_t with CFX_CSSValueTypeMask
Use a more meaningful type.
-- Comment some raw pointer usage in nearby structs.
Change-Id: I58b3f4a838cf6a701ad3ca94f4b289a6cdd4766d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83731
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/css/cfx_css.h b/core/fxcrt/css/cfx_css.h
index 534ed1f..b2b0121 100644
--- a/core/fxcrt/css/cfx_css.h
+++ b/core/fxcrt/css/cfx_css.h
@@ -9,6 +9,8 @@
#include <stdint.h>
+#include <type_traits>
+
enum CFX_CSSVALUETYPE {
CFX_CSSVALUETYPE_Primitive = 1 << 0,
CFX_CSSVALUETYPE_List = 1 << 1,
@@ -19,6 +21,7 @@
CFX_CSSVALUETYPE_MaybeString = 1 << 7,
CFX_CSSVALUETYPE_MaybeColor = 1 << 8
};
+using CFX_CSSValueTypeMask = std::underlying_type<CFX_CSSVALUETYPE>::type;
// Any entries added/removed here, will need to be mirrored in
// propertyValueTable, in core/fxcrt/css/cfx_cssdata.cpp.
diff --git a/core/fxcrt/css/cfx_cssdata.h b/core/fxcrt/css/cfx_cssdata.h
index b0d81d4..6e1162e 100644
--- a/core/fxcrt/css/cfx_cssdata.h
+++ b/core/fxcrt/css/cfx_cssdata.h
@@ -18,7 +18,7 @@
struct Property {
CFX_CSSProperty eName;
uint32_t dwHash; // Hashed as wide string.
- uint32_t dwType;
+ CFX_CSSValueTypeMask dwTypes;
};
struct PropertyValue {
@@ -27,12 +27,12 @@
};
struct LengthUnit {
- const wchar_t* value;
+ const wchar_t* value; // Raw, POD struct.
CFX_CSSNumberValue::Unit type;
};
struct Color {
- const wchar_t* name;
+ const wchar_t* name; // Raw, POD struct.
FX_ARGB value;
};
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index 9319f59..8c12fac 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -179,7 +179,7 @@
bImportant = true;
}
- const uint32_t dwType = property->dwType;
+ const CFX_CSSValueTypeMask dwType = property->dwTypes;
switch (dwType & 0x0F) {
case CFX_CSSVALUETYPE_Primitive: {
static constexpr CFX_CSSVALUETYPE kValueGuessOrder[] = {
@@ -188,8 +188,8 @@
CFX_CSSVALUETYPE_MaybeColor,
CFX_CSSVALUETYPE_MaybeString,
};
- for (uint32_t guess : kValueGuessOrder) {
- const uint32_t dwMatch = dwType & guess;
+ for (CFX_CSSVALUETYPE guess : kValueGuessOrder) {
+ const CFX_CSSValueTypeMask dwMatch = dwType & guess;
if (dwMatch == 0)
continue;
@@ -332,7 +332,7 @@
(pProperty->eName == CFX_CSSProperty::FontFamily) ? ',' : ' ';
CFX_CSSValueListParser parser(pszValue, iValueLen, separator);
- const uint32_t dwType = pProperty->dwType;
+ const CFX_CSSValueTypeMask dwType = pProperty->dwTypes;
CFX_CSSValue::PrimitiveType eType;
std::vector<RetainPtr<CFX_CSSValue>> list;
while (parser.NextValue(&eType, &pszValue, &iValueLen)) {