mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibWeb: Support Element.client{Top,Left,Width,Height}
This commit is contained in:
parent
9d852623f2
commit
3006e15c94
3 changed files with 42 additions and 0 deletions
|
@ -358,4 +358,36 @@ NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
|
||||||
return Geometry::DOMRect::create(box.absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
|
return Geometry::DOMRect::create(box.absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Element::client_top() const
|
||||||
|
{
|
||||||
|
if (!layout_node() || !layout_node()->is_box())
|
||||||
|
return 0;
|
||||||
|
auto& box = static_cast<Layout::Box const&>(*layout_node());
|
||||||
|
return box.absolute_rect().top();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Element::client_left() const
|
||||||
|
{
|
||||||
|
if (!layout_node() || !layout_node()->is_box())
|
||||||
|
return 0;
|
||||||
|
auto& box = static_cast<Layout::Box const&>(*layout_node());
|
||||||
|
return box.absolute_rect().left();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Element::client_width() const
|
||||||
|
{
|
||||||
|
if (!layout_node() || !layout_node()->is_box())
|
||||||
|
return 0;
|
||||||
|
auto& box = static_cast<Layout::Box const&>(*layout_node());
|
||||||
|
return box.absolute_rect().width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Element::client_height() const
|
||||||
|
{
|
||||||
|
if (!layout_node() || !layout_node()->is_box())
|
||||||
|
return 0;
|
||||||
|
auto& box = static_cast<Layout::Box const&>(*layout_node());
|
||||||
|
return box.absolute_rect().height();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,11 @@ public:
|
||||||
|
|
||||||
DOM::ExceptionOr<bool> matches(StringView selectors) const;
|
DOM::ExceptionOr<bool> matches(StringView selectors) const;
|
||||||
|
|
||||||
|
int client_top() const;
|
||||||
|
int client_left() const;
|
||||||
|
int client_width() const;
|
||||||
|
int client_height() const;
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_attribute(Callback callback) const
|
void for_each_attribute(Callback callback) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,11 @@ interface Element : Node {
|
||||||
|
|
||||||
DOMRect getBoundingClientRect();
|
DOMRect getBoundingClientRect();
|
||||||
|
|
||||||
|
readonly attribute long clientTop;
|
||||||
|
readonly attribute long clientLeft;
|
||||||
|
readonly attribute long clientWidth;
|
||||||
|
readonly attribute long clientHeight;
|
||||||
|
|
||||||
// FIXME: This should come from a ChildNode mixin
|
// FIXME: This should come from a ChildNode mixin
|
||||||
[CEReactions, Unscopable, ImplementedAs=remove_binding] undefined remove();
|
[CEReactions, Unscopable, ImplementedAs=remove_binding] undefined remove();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue