LibPDF: Add ColorSpaceFamily::operator==

No behavior change.
This commit is contained in:
Nico Weber 2023-11-06 13:23:48 +01:00 committed by Andreas Kling
parent 4f8e915ef8
commit 0f07049935
Notes: sideshowbarker 2024-07-17 08:43:11 +09:00
2 changed files with 7 additions and 2 deletions

View File

@ -621,7 +621,7 @@ PDFErrorOr<NonnullRefPtr<ColorSpace>> IndexedColorSpace::create(Document* docume
auto base_object = param0.get<NonnullRefPtr<Object>>();
auto base = TRY(ColorSpace::create(document, base_object));
if (base->family().name() == ColorSpaceFamily::Pattern.name() || base->family().name() == ColorSpaceFamily::Indexed.name())
if (base->family() == ColorSpaceFamily::Pattern || base->family() == ColorSpaceFamily::Indexed)
return Error { Error::Type::MalformedPDF, "Indexed color space has invalid base color space" };
// "The hival parameter is an integer that specifies the maximum valid index value. In other words,
@ -713,7 +713,7 @@ PDFErrorOr<NonnullRefPtr<SeparationColorSpace>> SeparationColorSpace::create(Doc
auto alternate_space = TRY(ColorSpace::create(document, alternate_space_object));
auto family = alternate_space->family();
if (family.name() == ColorSpaceFamily::Pattern.name() || family.name() == ColorSpaceFamily::Indexed.name() || family.name() == ColorSpaceFamily::Separation.name() || family.name() == ColorSpaceFamily::DeviceN.name())
if (family == ColorSpaceFamily::Pattern || family == ColorSpaceFamily::Indexed || family == ColorSpaceFamily::Separation || family == ColorSpaceFamily::DeviceN)
return Error { Error::Type::MalformedPDF, "Separation color space has invalid alternate color space" };
// "The tintTransform parameter must be a function"

View File

@ -44,6 +44,11 @@ public:
ENUMERATE_COLOR_SPACE_FAMILIES(ENUMERATE)
#undef ENUMERATE
bool operator==(ColorSpaceFamily const& other) const
{
return m_name == other.m_name;
}
private:
DeprecatedFlyString m_name;
bool m_may_be_specified_directly;