mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
LibWeb+WebContent: Forbid access to underlying type of CSSPixels
Although DistinctNumeric, which is supposed to abstract the underlying type, was used to represent CSSPixels, we have a whole bunch of places in the layout code that assume CSSPixels::value() returns a floating-point type. This assumption makes it difficult to replace the underlying type in CSSPixels with a non-floating type. To make it easier to transition CSSPixels to fixed-point math, one step we can take is to prevent access to the underlying type using value() and instead use explicit conversions with the to_float(), to_double(), and to_int() methods.
This commit is contained in:
parent
5a54c686a7
commit
147c3b3d97
43 changed files with 340 additions and 220 deletions
|
@ -503,21 +503,21 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
auto box_model = box->box_model();
|
||||
StringBuilder builder;
|
||||
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
MUST(serializer.add("padding_top"sv, box_model.padding.top.value()));
|
||||
MUST(serializer.add("padding_right"sv, box_model.padding.right.value()));
|
||||
MUST(serializer.add("padding_bottom"sv, box_model.padding.bottom.value()));
|
||||
MUST(serializer.add("padding_left"sv, box_model.padding.left.value()));
|
||||
MUST(serializer.add("margin_top"sv, box_model.margin.top.value()));
|
||||
MUST(serializer.add("margin_right"sv, box_model.margin.right.value()));
|
||||
MUST(serializer.add("margin_bottom"sv, box_model.margin.bottom.value()));
|
||||
MUST(serializer.add("margin_left"sv, box_model.margin.left.value()));
|
||||
MUST(serializer.add("border_top"sv, box_model.border.top.value()));
|
||||
MUST(serializer.add("border_right"sv, box_model.border.right.value()));
|
||||
MUST(serializer.add("border_bottom"sv, box_model.border.bottom.value()));
|
||||
MUST(serializer.add("border_left"sv, box_model.border.left.value()));
|
||||
MUST(serializer.add("padding_top"sv, box_model.padding.top.to_double()));
|
||||
MUST(serializer.add("padding_right"sv, box_model.padding.right.to_double()));
|
||||
MUST(serializer.add("padding_bottom"sv, box_model.padding.bottom.to_double()));
|
||||
MUST(serializer.add("padding_left"sv, box_model.padding.left.to_double()));
|
||||
MUST(serializer.add("margin_top"sv, box_model.margin.top.to_double()));
|
||||
MUST(serializer.add("margin_right"sv, box_model.margin.right.to_double()));
|
||||
MUST(serializer.add("margin_bottom"sv, box_model.margin.bottom.to_double()));
|
||||
MUST(serializer.add("margin_left"sv, box_model.margin.left.to_double()));
|
||||
MUST(serializer.add("border_top"sv, box_model.border.top.to_double()));
|
||||
MUST(serializer.add("border_right"sv, box_model.border.right.to_double()));
|
||||
MUST(serializer.add("border_bottom"sv, box_model.border.bottom.to_double()));
|
||||
MUST(serializer.add("border_left"sv, box_model.border.left.to_double()));
|
||||
if (auto* paintable_box = box->paintable_box()) {
|
||||
MUST(serializer.add("content_width"sv, paintable_box->content_width().value()));
|
||||
MUST(serializer.add("content_height"sv, paintable_box->content_height().value()));
|
||||
MUST(serializer.add("content_width"sv, paintable_box->content_width().to_double()));
|
||||
MUST(serializer.add("content_height"sv, paintable_box->content_height().to_double()));
|
||||
} else {
|
||||
MUST(serializer.add("content_width"sv, 0));
|
||||
MUST(serializer.add("content_height"sv, 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue