1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 17:15:08 +00:00

LibWeb+WebContent: Convert BrowsingContext to new pixel units

This fixes a few glitches. We no longer give the page double the width
it should have, and we mark the correct area of the page as needing
repainting.
This commit is contained in:
Sam Atkins 2022-11-03 12:49:54 +00:00 committed by Linus Groh
parent 8fb7c32ec3
commit affc8a22ca
23 changed files with 68 additions and 70 deletions

View file

@ -616,7 +616,7 @@ int Window::inner_width() const
// The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any),
// or zero if there is no viewport.
if (auto const* browsing_context = associated_document().browsing_context())
return browsing_context->viewport_rect().width();
return browsing_context->viewport_rect().width().value();
return 0;
}
@ -626,7 +626,7 @@ int Window::inner_height() const
// The innerHeight attribute must return the viewport height including the size of a rendered scroll bar (if any),
// or zero if there is no viewport.
if (auto const* browsing_context = associated_document().browsing_context())
return browsing_context->viewport_rect().height();
return browsing_context->viewport_rect().height().value();
return 0;
}
@ -767,7 +767,7 @@ Optional<CSS::MediaFeatureValue> Window::query_media_feature(CSS::MediaFeatureID
float Window::scroll_x() const
{
if (auto* page = this->page())
return page->top_level_browsing_context().viewport_scroll_offset().x();
return page->top_level_browsing_context().viewport_scroll_offset().x().value();
return 0;
}
@ -775,7 +775,7 @@ float Window::scroll_x() const
float Window::scroll_y() const
{
if (auto* page = this->page())
return page->top_level_browsing_context().viewport_scroll_offset().y();
return page->top_level_browsing_context().viewport_scroll_offset().y().value();
return 0;
}
@ -823,7 +823,7 @@ int Window::screen_x() const
// The screenX and screenLeft attributes must return the x-coordinate, relative to the origin of the Web-exposed screen area,
// of the left of the client window as number of CSS pixels, or zero if there is no such thing.
if (auto* page = this->page())
return page->window_position().x();
return page->window_position().x().value();
return 0;
}
@ -833,7 +833,7 @@ int Window::screen_y() const
// The screenY and screenTop attributes must return the y-coordinate, relative to the origin of the screen of the Web-exposed screen area,
// of the top of the client window as number of CSS pixels, or zero if there is no such thing.
if (auto* page = this->page())
return page->window_position().y();
return page->window_position().y().value();
return 0;
}
@ -842,7 +842,7 @@ int Window::outer_width() const
{
// The outerWidth attribute must return the width of the client window. If there is no client window this attribute must return zero.
if (auto* page = this->page())
return page->window_size().width();
return page->window_size().width().value();
return 0;
}
@ -851,7 +851,7 @@ int Window::outer_height() const
{
// The outerHeight attribute must return the height of the client window. If there is no client window this attribute must return zero.
if (auto* page = this->page())
return page->window_size().height();
return page->window_size().height().value();
return 0;
}
@ -1703,7 +1703,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll)
return JS::js_undefined();
auto& page = *impl->page();
auto viewport_rect = page.top_level_browsing_context().viewport_rect();
auto viewport_rect = page.top_level_browsing_context().viewport_rect().to_type<float>();
auto x_value = JS::Value(viewport_rect.x());
auto y_value = JS::Value(viewport_rect.y());
DeprecatedString behavior_string = "auto";
@ -1778,9 +1778,9 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by)
left = JS::Value(left).is_finite_number() ? left : 0.0;
top = JS::Value(top).is_finite_number() ? top : 0.0;
auto current_scroll_position = page.top_level_browsing_context().viewport_scroll_offset();
left = left + current_scroll_position.x();
top = top + current_scroll_position.y();
auto current_scroll_position = page.top_level_browsing_context().viewport_scroll_offset().to_type<float>();
left = left + static_cast<double>(current_scroll_position.x());
top = top + static_cast<double>(current_scroll_position.y());
auto behavior_string_value = TRY(options->get("behavior"));
auto behavior_string = behavior_string_value.is_undefined() ? "auto" : TRY(behavior_string_value.to_string(vm));