mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibWeb: Add HTML::TraversableNavigable
This is the "traversable navigable" concept from the HTML spec. Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
This commit is contained in:
parent
2d602dcb34
commit
74a6f50c91
4 changed files with 81 additions and 0 deletions
|
@ -349,6 +349,7 @@ set(SOURCES
|
|||
HTML/Timer.cpp
|
||||
HTML/TimeRanges.cpp
|
||||
HTML/TrackEvent.cpp
|
||||
HTML/TraversableNavigable.cpp
|
||||
HTML/VideoTrack.cpp
|
||||
HTML/VideoTrackList.cpp
|
||||
HTML/Window.cpp
|
||||
|
|
|
@ -385,6 +385,7 @@ class TextMetrics;
|
|||
class Timer;
|
||||
class TimeRanges;
|
||||
class TrackEvent;
|
||||
class TraversableNavigable;
|
||||
class VideoTrack;
|
||||
class VideoTrackList;
|
||||
class Window;
|
||||
|
|
30
Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
Normal file
30
Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/SessionHistoryEntry.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
TraversableNavigable::TraversableNavigable() = default;
|
||||
|
||||
TraversableNavigable::~TraversableNavigable() = default;
|
||||
|
||||
void TraversableNavigable::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& entry : m_session_history_entries)
|
||||
visitor.visit(entry);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-traversable
|
||||
bool TraversableNavigable::is_top_level_traversable() const
|
||||
{
|
||||
// A top-level traversable is a traversable navigable with a null parent.
|
||||
return parent() == nullptr;
|
||||
}
|
||||
|
||||
}
|
49
Userland/Libraries/LibWeb/HTML/TraversableNavigable.h
Normal file
49
Userland/Libraries/LibWeb/HTML/TraversableNavigable.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/HTML/Navigable.h>
|
||||
#include <LibWeb/HTML/VisibilityState.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#traversable-navigable
|
||||
class TraversableNavigable final : public Navigable {
|
||||
JS_CELL(TraversableNavigable, Navigable);
|
||||
|
||||
public:
|
||||
virtual ~TraversableNavigable() override;
|
||||
|
||||
bool is_top_level_traversable() const;
|
||||
|
||||
int current_session_history_step() const { return m_current_session_history_step; };
|
||||
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> const& session_history_entries() const { return m_session_history_entries; };
|
||||
bool running_nested_apply_history_step() const { return m_running_nested_apply_history_step; };
|
||||
VisibilityState system_visibility_state() const { return m_system_visibility_state; };
|
||||
|
||||
private:
|
||||
TraversableNavigable();
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
|
||||
int m_current_session_history_step { 0 };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-entries
|
||||
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> m_session_history_entries;
|
||||
|
||||
// FIXME: https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-running-nested-apply-history-step
|
||||
bool m_running_nested_apply_history_step { false };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#system-visibility-state
|
||||
VisibilityState m_system_visibility_state { VisibilityState::Visible };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue