1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibPDF: Make DeviceCMYKColorSpace::the() fallible

No behavior change.
This commit is contained in:
Nico Weber 2024-01-30 20:59:50 -05:00 committed by Andrew Kaster
parent 79b73b7fbb
commit f840fb6b4e
3 changed files with 5 additions and 5 deletions

View file

@ -53,7 +53,7 @@ PDFErrorOr<NonnullRefPtr<ColorSpace>> ColorSpace::create(DeprecatedFlyString con
if (name == CommonNames::DeviceRGB) if (name == CommonNames::DeviceRGB)
return DeviceRGBColorSpace::the(); return DeviceRGBColorSpace::the();
if (name == CommonNames::DeviceCMYK) if (name == CommonNames::DeviceCMYK)
return DeviceCMYKColorSpace::the(); return TRY(DeviceCMYKColorSpace::the());
if (name == CommonNames::Pattern) if (name == CommonNames::Pattern)
return Error::rendering_unsupported_error("Pattern color spaces not yet implemented"); return Error::rendering_unsupported_error("Pattern color spaces not yet implemented");
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
@ -134,7 +134,7 @@ Vector<float> DeviceRGBColorSpace::default_decode() const
return { 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }; return { 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f };
} }
NonnullRefPtr<DeviceCMYKColorSpace> DeviceCMYKColorSpace::the() ErrorOr<NonnullRefPtr<DeviceCMYKColorSpace>> DeviceCMYKColorSpace::the()
{ {
static auto instance = adopt_ref(*new DeviceCMYKColorSpace()); static auto instance = adopt_ref(*new DeviceCMYKColorSpace());
return instance; return instance;

View file

@ -112,7 +112,7 @@ private:
class DeviceCMYKColorSpace final : public ColorSpace { class DeviceCMYKColorSpace final : public ColorSpace {
public: public:
static NonnullRefPtr<DeviceCMYKColorSpace> the(); static ErrorOr<NonnullRefPtr<DeviceCMYKColorSpace>> the();
~DeviceCMYKColorSpace() override = default; ~DeviceCMYKColorSpace() override = default;

View file

@ -695,14 +695,14 @@ RENDERER_HANDLER(set_painting_color_and_space_to_rgb)
RENDERER_HANDLER(set_stroking_color_and_space_to_cmyk) RENDERER_HANDLER(set_stroking_color_and_space_to_cmyk)
{ {
state().stroke_color_space = DeviceCMYKColorSpace::the(); state().stroke_color_space = TRY(DeviceCMYKColorSpace::the());
state().stroke_style = TRY(state().stroke_color_space->style(args)); state().stroke_style = TRY(state().stroke_color_space->style(args));
return {}; return {};
} }
RENDERER_HANDLER(set_painting_color_and_space_to_cmyk) RENDERER_HANDLER(set_painting_color_and_space_to_cmyk)
{ {
state().paint_color_space = DeviceCMYKColorSpace::the(); state().paint_color_space = TRY(DeviceCMYKColorSpace::the());
state().paint_style = TRY(state().paint_color_space->style(args)); state().paint_style = TRY(state().paint_color_space->style(args));
return {}; return {};
} }