ladybird/Libraries/LibWeb/Layout/Viewport.h
Shannon Booth f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00

49 lines
1.1 KiB
C++

/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class Viewport final : public BlockContainer {
GC_CELL(Viewport, BlockContainer);
GC_DECLARE_ALLOCATOR(Viewport);
public:
explicit Viewport(DOM::Document&, CSS::StyleProperties);
virtual ~Viewport() override;
struct TextPosition {
GC::Ref<DOM::Text> dom_node;
size_t start_offset { 0 };
};
struct TextBlock {
String text;
Vector<TextPosition> positions;
};
Vector<TextBlock> const& text_blocks();
const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); }
virtual void visit_edges(Visitor&) override;
private:
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
void update_text_blocks();
virtual bool is_viewport() const override { return true; }
Optional<Vector<TextBlock>> m_text_blocks;
};
template<>
inline bool Node::fast_is<Viewport>() const { return is_viewport(); }
}