mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibPDF: Propagate errors in Parser and Document
This commit is contained in:
parent
7e1c823725
commit
73cf8205b4
16 changed files with 472 additions and 420 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Matthew Olsson <mattco@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -60,14 +60,15 @@ RefPtr<CalRGBColorSpace> CalRGBColorSpace::create(RefPtr<Document> document, Vec
|
|||
return {};
|
||||
|
||||
auto param = parameters[0];
|
||||
if (!param.has<NonnullRefPtr<Object>>() || !param.get<NonnullRefPtr<Object>>()->is_dict())
|
||||
if (!param.has<NonnullRefPtr<Object>>() || !param.get<NonnullRefPtr<Object>>()->is<DictObject>())
|
||||
return {};
|
||||
|
||||
auto dict = object_cast<DictObject>(param.get<NonnullRefPtr<Object>>());
|
||||
auto dict = param.get<NonnullRefPtr<Object>>()->cast<DictObject>();
|
||||
if (!dict->contains(CommonNames::WhitePoint))
|
||||
return {};
|
||||
|
||||
auto white_point_array = dict->get_array(document, CommonNames::WhitePoint);
|
||||
// FIXME: Propagate errors
|
||||
auto white_point_array = MUST(dict->get_array(document, CommonNames::WhitePoint));
|
||||
if (white_point_array->size() != 3)
|
||||
return {};
|
||||
|
||||
|
@ -81,7 +82,7 @@ RefPtr<CalRGBColorSpace> CalRGBColorSpace::create(RefPtr<Document> document, Vec
|
|||
return {};
|
||||
|
||||
if (dict->contains(CommonNames::BlackPoint)) {
|
||||
auto black_point_array = dict->get_array(document, CommonNames::BlackPoint);
|
||||
auto black_point_array = MUST(dict->get_array(document, CommonNames::BlackPoint));
|
||||
if (black_point_array->size() == 3) {
|
||||
color_space->m_blackpoint[0] = black_point_array->at(0).to_float();
|
||||
color_space->m_blackpoint[1] = black_point_array->at(1).to_float();
|
||||
|
@ -90,7 +91,7 @@ RefPtr<CalRGBColorSpace> CalRGBColorSpace::create(RefPtr<Document> document, Vec
|
|||
}
|
||||
|
||||
if (dict->contains(CommonNames::Gamma)) {
|
||||
auto gamma_array = dict->get_array(document, CommonNames::Gamma);
|
||||
auto gamma_array = MUST(dict->get_array(document, CommonNames::Gamma));
|
||||
if (gamma_array->size() == 3) {
|
||||
color_space->m_gamma[0] = gamma_array->at(0).to_float();
|
||||
color_space->m_gamma[1] = gamma_array->at(1).to_float();
|
||||
|
@ -99,7 +100,7 @@ RefPtr<CalRGBColorSpace> CalRGBColorSpace::create(RefPtr<Document> document, Vec
|
|||
}
|
||||
|
||||
if (dict->contains(CommonNames::Matrix)) {
|
||||
auto matrix_array = dict->get_array(document, CommonNames::Matrix);
|
||||
auto matrix_array = MUST(dict->get_array(document, CommonNames::Matrix));
|
||||
if (matrix_array->size() == 3) {
|
||||
color_space->m_matrix[0] = matrix_array->at(0).to_float();
|
||||
color_space->m_matrix[1] = matrix_array->at(1).to_float();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue