diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 1dd2502731..3ce472d49c 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -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 diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h index b653c05746..751d1ccac0 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h @@ -8,7 +8,6 @@ #include #include -#include #include namespace Web::Layout { diff --git a/Userland/Libraries/LibWeb/Layout/LayoutPosition.cpp b/Userland/Libraries/LibWeb/Layout/LayoutPosition.cpp deleted file mode 100644 index a44cc343e7..0000000000 --- a/Userland/Libraries/LibWeb/Layout/LayoutPosition.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include - -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(*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 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()); -} - -} diff --git a/Userland/Libraries/LibWeb/Layout/LayoutPosition.h b/Userland/Libraries/LibWeb/Layout/LayoutPosition.h deleted file mode 100644 index 755e6dd01a..0000000000 --- a/Userland/Libraries/LibWeb/Layout/LayoutPosition.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include -#include -#include - -namespace Web::Layout { - -class Node; - -struct LayoutPosition { - JS::Handle 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 to_dom_range() const; - -private: - LayoutPosition m_start; - LayoutPosition m_end; -}; - -} diff --git a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp index d5369010de..1c4fe08dc3 100644 --- a/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EditEventHandler.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include namespace Web {