mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibWeb: Implement Selection::direction
This commit is contained in:
parent
eec2602424
commit
a7953f5e09
Notes:
github-actions[bot]
2024-10-13 07:48:08 +00:00
Author: https://github.com/Gingeh
Commit: a7953f5e09
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1765
3 changed files with 11 additions and 0 deletions
|
@ -119,6 +119,15 @@ String Selection::type() const
|
|||
return "Range"_string;
|
||||
}
|
||||
|
||||
String Selection::direction() const
|
||||
{
|
||||
if (!m_range || m_direction == Direction::Directionless)
|
||||
return "none"_string;
|
||||
if (m_direction == Direction::Forwards)
|
||||
return "forward"_string;
|
||||
return "backward"_string;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/selection-api/#dom-selection-getrangeat
|
||||
WebIDL::ExceptionOr<JS::GCPtr<DOM::Range>> Selection::get_range_at(unsigned index)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
bool is_collapsed() const;
|
||||
unsigned range_count() const;
|
||||
String type() const;
|
||||
String direction() const;
|
||||
WebIDL::ExceptionOr<JS::GCPtr<DOM::Range>> get_range_at(unsigned index);
|
||||
void add_range(JS::NonnullGCPtr<DOM::Range>);
|
||||
WebIDL::ExceptionOr<void> remove_range(JS::NonnullGCPtr<DOM::Range>);
|
||||
|
|
|
@ -12,6 +12,7 @@ interface Selection {
|
|||
readonly attribute boolean isCollapsed;
|
||||
readonly attribute unsigned long rangeCount;
|
||||
readonly attribute DOMString type;
|
||||
readonly attribute DOMString direction;
|
||||
Range getRangeAt(unsigned long index);
|
||||
undefined addRange(Range range);
|
||||
undefined removeRange(Range range);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue