2024-01-12 21:25:05 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-07-25 09:34:41 -04:00
|
|
|
#include <AK/Utf16View.h>
|
2025-02-02 15:55:26 +01:00
|
|
|
#include <LibGfx/TextLayout.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2024-01-12 21:25:05 +01:00
|
|
|
#include <LibWeb/Layout/Node.h>
|
2025-02-02 15:55:26 +01:00
|
|
|
#include <LibWeb/Painting/ShadowData.h>
|
2024-01-12 21:25:05 +01:00
|
|
|
#include <LibWeb/PixelUnits.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API PaintableFragment {
|
2024-07-22 18:43:01 +03:00
|
|
|
friend class PaintableWithLines;
|
2024-01-13 10:38:07 +01:00
|
|
|
|
2024-01-12 21:25:05 +01:00
|
|
|
public:
|
|
|
|
|
explicit PaintableFragment(Layout::LineBoxFragment const&);
|
|
|
|
|
|
|
|
|
|
Layout::Node const& layout_node() const { return m_layout_node; }
|
2024-10-16 15:19:32 +02:00
|
|
|
Paintable const& paintable() const { return *m_layout_node->first_paintable(); }
|
2024-01-12 21:25:05 +01:00
|
|
|
|
2025-07-25 09:34:41 -04:00
|
|
|
size_t start_offset() const { return m_start_offset; }
|
|
|
|
|
size_t length_in_code_units() const { return m_length_in_code_units; }
|
2024-01-12 21:25:05 +01:00
|
|
|
|
|
|
|
|
CSSPixels baseline() const { return m_baseline; }
|
|
|
|
|
CSSPixelPoint offset() const { return m_offset; }
|
|
|
|
|
void set_offset(CSSPixelPoint offset) { m_offset = offset; }
|
|
|
|
|
CSSPixelSize size() const { return m_size; }
|
|
|
|
|
|
2024-01-13 10:38:07 +01:00
|
|
|
Vector<ShadowData> const& shadows() const { return m_shadows; }
|
|
|
|
|
void set_shadows(Vector<ShadowData>&& shadows) { m_shadows = shadows; }
|
|
|
|
|
|
2024-01-12 21:25:05 +01:00
|
|
|
CSSPixelRect const absolute_rect() const;
|
|
|
|
|
|
2024-06-29 17:14:23 +02:00
|
|
|
RefPtr<Gfx::GlyphRun> glyph_run() const { return m_glyph_run; }
|
2024-10-29 14:29:00 +00:00
|
|
|
Gfx::Orientation orientation() const;
|
2024-01-12 21:25:05 +01:00
|
|
|
|
2024-12-05 17:54:05 +00:00
|
|
|
CSSPixelRect selection_rect() const;
|
2025-07-03 21:28:49 +02:00
|
|
|
CSSPixelRect range_rect(Paintable::SelectionState selection_state, size_t start_offset_in_code_units, size_t end_offset_in_code_units) const;
|
2024-01-12 21:25:05 +01:00
|
|
|
|
|
|
|
|
CSSPixels width() const { return m_size.width(); }
|
|
|
|
|
CSSPixels height() const { return m_size.height(); }
|
|
|
|
|
|
2025-06-12 13:19:52 +02:00
|
|
|
size_t index_in_node_for_point(CSSPixelPoint) const;
|
2024-01-12 21:25:05 +01:00
|
|
|
|
2025-07-25 09:34:41 -04:00
|
|
|
Utf16View text() const;
|
2024-03-18 10:25:57 +01:00
|
|
|
|
2025-03-16 18:05:38 +01:00
|
|
|
CSSPixels text_decoration_thickness() const { return m_text_decoration_thickness; }
|
|
|
|
|
void set_text_decoration_thickness(CSSPixels thickness) { m_text_decoration_thickness = thickness; }
|
|
|
|
|
|
2024-01-12 21:25:05 +01:00
|
|
|
private:
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<Layout::Node const> m_layout_node;
|
2024-01-12 21:25:05 +01:00
|
|
|
CSSPixelPoint m_offset;
|
|
|
|
|
CSSPixelSize m_size;
|
|
|
|
|
CSSPixels m_baseline;
|
2025-07-25 09:34:41 -04:00
|
|
|
size_t m_start_offset { 0 };
|
|
|
|
|
size_t m_length_in_code_units { 0 };
|
2024-06-29 17:14:23 +02:00
|
|
|
RefPtr<Gfx::GlyphRun> m_glyph_run;
|
2024-10-29 14:29:00 +00:00
|
|
|
CSS::WritingMode m_writing_mode;
|
2024-01-13 10:38:07 +01:00
|
|
|
Vector<ShadowData> m_shadows;
|
2025-03-16 18:05:38 +01:00
|
|
|
CSSPixels m_text_decoration_thickness { 0 };
|
2024-01-12 21:25:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|