mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 11:27:35 +00:00
LibWeb: Make factory methods of Geometry::DOMRect fallible
This commit is contained in:
parent
9b190b9509
commit
ec0049441c
4 changed files with 9 additions and 8 deletions
|
@ -657,12 +657,12 @@ JS::NonnullGCPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
|
||||||
// FIXME: Support inline layout nodes as well.
|
// FIXME: Support inline layout nodes as well.
|
||||||
auto* paint_box = this->paint_box();
|
auto* paint_box = this->paint_box();
|
||||||
if (!paint_box)
|
if (!paint_box)
|
||||||
return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0);
|
return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0).release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
||||||
VERIFY(document().browsing_context());
|
VERIFY(document().browsing_context());
|
||||||
auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
|
auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
|
||||||
|
|
||||||
return Geometry::DOMRect::create(realm(), paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>());
|
return Geometry::DOMRect::create(realm(), paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>()).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
||||||
|
|
|
@ -1139,7 +1139,7 @@ WebIDL::ExceptionOr<void> Range::delete_contents()
|
||||||
JS::NonnullGCPtr<Geometry::DOMRect> Range::get_bounding_client_rect() const
|
JS::NonnullGCPtr<Geometry::DOMRect> Range::get_bounding_client_rect() const
|
||||||
{
|
{
|
||||||
dbgln("(STUBBED) Range::get_bounding_client_rect()");
|
dbgln("(STUBBED) Range::get_bounding_client_rect()");
|
||||||
return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0);
|
return Geometry::DOMRect::construct_impl(realm(), 0, 0, 0, 0).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,16 @@
|
||||||
|
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Geometry/DOMRect.h>
|
#include <LibWeb/Geometry/DOMRect.h>
|
||||||
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
namespace Web::Geometry {
|
namespace Web::Geometry {
|
||||||
|
|
||||||
JS::NonnullGCPtr<DOMRect> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height).release_allocated_value_but_fixme_should_propagate_errors();
|
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
|
||||||
{
|
{
|
||||||
return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height());
|
return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ class DOMRect final : public DOMRectReadOnly {
|
||||||
WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
|
WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<DOMRect> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
|
||||||
static JS::NonnullGCPtr<DOMRect> create(JS::Realm&, Gfx::FloatRect const&);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> create(JS::Realm&, Gfx::FloatRect const&);
|
||||||
|
|
||||||
virtual ~DOMRect() override;
|
virtual ~DOMRect() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue