mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Implement getting the traversable navigable of a navigable
This commit is contained in:
parent
16ef5e2631
commit
05dc1da321
Notes:
sideshowbarker
2024-07-18 05:37:06 +09:00
Author: https://github.com/awesomekling
Commit: 05dc1da321
Pull-request: https://github.com/SerenityOS/serenity/pull/18471
2 changed files with 17 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <LibWeb/HTML/DocumentState.h>
|
||||
#include <LibWeb/HTML/Navigable.h>
|
||||
#include <LibWeb/HTML/SessionHistoryEntry.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -80,4 +81,18 @@ void Navigable::set_container(JS::GCPtr<NavigableContainer> container)
|
|||
m_container = container;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-traversable
|
||||
JS::GCPtr<TraversableNavigable> Navigable::traversable_navigable()
|
||||
{
|
||||
// 1. Let navigable be inputNavigable.
|
||||
auto navigable = this;
|
||||
|
||||
// 2. While navigable is not a traversable navigable, set navigable to navigable's parent.
|
||||
while (navigable && !is<TraversableNavigable>(*navigable))
|
||||
navigable = navigable->parent();
|
||||
|
||||
// 3. Return navigable.
|
||||
return static_cast<TraversableNavigable*>(navigable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
JS::GCPtr<NavigableContainer> container() const;
|
||||
void set_container(JS::GCPtr<NavigableContainer>);
|
||||
|
||||
JS::GCPtr<TraversableNavigable> traversable_navigable();
|
||||
|
||||
protected:
|
||||
Navigable();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue