mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +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
|
@ -64,12 +64,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create(JS::Realm&
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button)
|
||||
{
|
||||
MouseEventInit event_init {};
|
||||
event_init.offset_x = static_cast<double>(offset.x().value());
|
||||
event_init.offset_y = static_cast<double>(offset.y().value());
|
||||
event_init.client_x = static_cast<double>(client_offset.x().value());
|
||||
event_init.client_y = static_cast<double>(client_offset.y().value());
|
||||
event_init.page_x = static_cast<double>(page_offset.x().value());
|
||||
event_init.page_y = static_cast<double>(page_offset.y().value());
|
||||
event_init.offset_x = offset.x().to_double();
|
||||
event_init.offset_y = offset.y().to_double();
|
||||
event_init.client_x = client_offset.x().to_double();
|
||||
event_init.client_y = client_offset.y().to_double();
|
||||
event_init.page_x = page_offset.x().to_double();
|
||||
event_init.page_y = page_offset.y().to_double();
|
||||
event_init.button = determine_button(mouse_button);
|
||||
event_init.buttons = buttons;
|
||||
return MouseEvent::create(realm, event_name, event_init);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue