1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:27:44 +00:00

LibWeb: Remove now-unused LayoutRange and LayoutPosition classes :^)

This commit is contained in:
Andreas Kling 2023-01-11 20:22:41 +01:00
parent 9c7e26b8d4
commit 0e53003f72
5 changed files with 0 additions and 108 deletions

View file

@ -327,7 +327,6 @@ set(SOURCES
Layout/InlineNode.cpp
Layout/Label.cpp
Layout/LabelableNode.cpp
Layout/LayoutPosition.cpp
Layout/LayoutState.cpp
Layout/LineBox.cpp
Layout/LineBoxFragment.cpp

View file

@ -8,7 +8,6 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/LayoutPosition.h>
#include <LibWeb/Selection/Selection.h>
namespace Web::Layout {

View file

@ -1,46 +0,0 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Position.h>
#include <LibWeb/DOM/Range.h>
#include <LibWeb/Layout/LayoutPosition.h>
namespace Web::Layout {
DOM::Position LayoutPosition::to_dom_position() const
{
if (!layout_node)
return {};
// FIXME: Verify that there are no shenanigans going on.
return { const_cast<DOM::Node&>(*layout_node->dom_node()), (unsigned)index_in_node };
}
LayoutRange LayoutRange::normalized() const
{
if (!is_valid())
return {};
if (m_start.layout_node.ptr() == m_end.layout_node.ptr()) {
if (m_start.index_in_node < m_end.index_in_node)
return *this;
return { m_end, m_start };
}
if (m_start.layout_node->is_before(*m_end.layout_node))
return *this;
return { m_end, m_start };
}
JS::NonnullGCPtr<DOM::Range> LayoutRange::to_dom_range() const
{
VERIFY(is_valid());
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());
}
}

View file

@ -1,59 +0,0 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefPtr.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/Node.h>
namespace Web::Layout {
class Node;
struct LayoutPosition {
JS::Handle<Layout::Node> layout_node;
int index_in_node { 0 };
DOM::Position to_dom_position() const;
};
class LayoutRange {
public:
LayoutRange() = default;
LayoutRange(LayoutPosition const& start, LayoutPosition const& end)
: m_start(start)
, m_end(end)
{
}
bool is_valid() const { return m_start.layout_node && m_end.layout_node; }
void set(LayoutPosition const& start, LayoutPosition const& end)
{
m_start = start;
m_end = end;
}
void set_start(LayoutPosition const& start) { m_start = start; }
void set_end(LayoutPosition const& end) { m_end = end; }
LayoutPosition const& start() const { return m_start; }
LayoutPosition& start() { return m_start; }
LayoutPosition const& end() const { return m_end; }
LayoutPosition& end() { return m_end; }
LayoutRange normalized() const;
JS::NonnullGCPtr<DOM::Range> to_dom_range() const;
private:
LayoutPosition m_start;
LayoutPosition m_end;
};
}

View file

@ -12,7 +12,6 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/LayoutPosition.h>
#include <LibWeb/Page/EditEventHandler.h>
namespace Web {