mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Make DOM::Range more suitable for JS.
This commit is contained in:
parent
4df0eeaa3d
commit
10f9c85090
Notes:
sideshowbarker
2024-07-19 00:56:55 +09:00
Author: https://github.com/asynts
Commit: 10f9c85090
Pull-request: https://github.com/SerenityOS/serenity/pull/4318
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/linusg
11 changed files with 186 additions and 69 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/DOM/Position.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/Layout/LayoutPosition.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
|
||||
|
@ -53,12 +54,14 @@ LayoutRange LayoutRange::normalized() const
|
|||
return { m_end, m_start };
|
||||
}
|
||||
|
||||
DOM::Range LayoutRange::to_dom_range() const
|
||||
NonnullRefPtr<DOM::Range> LayoutRange::to_dom_range() const
|
||||
{
|
||||
if (!is_valid())
|
||||
return {};
|
||||
ASSERT(is_valid());
|
||||
|
||||
return { m_start.to_dom_position(), m_end.to_dom_position() };
|
||||
auto start = m_start.to_dom_position();
|
||||
auto end = m_end.to_dom_position();
|
||||
|
||||
return DOM::Range::create(*start.node(), start.offset(), *end.node(), end.offset());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue