mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	This migrates TextNode::text_for_rendering() to Utf16String and deals
with the fallout. As a consequence, this effectively reverts commit
3df83dade8.
The layout test expecation file updates are because we now express text
lengths and offsets in UTF-16 code units.
The selection-over-multiple-code-units expectation file update actually
represents a correctness fix. Our result now matches Firefox.
		
	
			
		
			
				
	
	
		
			68 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <AK/Utf16View.h>
 | 
						|
#include <LibGfx/TextLayout.h>
 | 
						|
#include <LibWeb/Layout/Node.h>
 | 
						|
#include <LibWeb/Painting/ShadowData.h>
 | 
						|
#include <LibWeb/PixelUnits.h>
 | 
						|
 | 
						|
namespace Web::Painting {
 | 
						|
 | 
						|
class PaintableFragment {
 | 
						|
    friend class PaintableWithLines;
 | 
						|
 | 
						|
public:
 | 
						|
    explicit PaintableFragment(Layout::LineBoxFragment const&);
 | 
						|
 | 
						|
    Layout::Node const& layout_node() const { return m_layout_node; }
 | 
						|
    Paintable const& paintable() const { return *m_layout_node->first_paintable(); }
 | 
						|
 | 
						|
    size_t start_offset() const { return m_start_offset; }
 | 
						|
    size_t length_in_code_units() const { return m_length_in_code_units; }
 | 
						|
 | 
						|
    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; }
 | 
						|
 | 
						|
    Vector<ShadowData> const& shadows() const { return m_shadows; }
 | 
						|
    void set_shadows(Vector<ShadowData>&& shadows) { m_shadows = shadows; }
 | 
						|
 | 
						|
    CSSPixelRect const absolute_rect() const;
 | 
						|
 | 
						|
    RefPtr<Gfx::GlyphRun> glyph_run() const { return m_glyph_run; }
 | 
						|
    Gfx::Orientation orientation() const;
 | 
						|
 | 
						|
    CSSPixelRect selection_rect() const;
 | 
						|
    CSSPixelRect range_rect(Paintable::SelectionState selection_state, size_t start_offset_in_code_units, size_t end_offset_in_code_units) const;
 | 
						|
 | 
						|
    CSSPixels width() const { return m_size.width(); }
 | 
						|
    CSSPixels height() const { return m_size.height(); }
 | 
						|
 | 
						|
    size_t index_in_node_for_point(CSSPixelPoint) const;
 | 
						|
 | 
						|
    Utf16View text() const;
 | 
						|
 | 
						|
    CSSPixels text_decoration_thickness() const { return m_text_decoration_thickness; }
 | 
						|
    void set_text_decoration_thickness(CSSPixels thickness) { m_text_decoration_thickness = thickness; }
 | 
						|
 | 
						|
private:
 | 
						|
    GC::Ref<Layout::Node const> m_layout_node;
 | 
						|
    CSSPixelPoint m_offset;
 | 
						|
    CSSPixelSize m_size;
 | 
						|
    CSSPixels m_baseline;
 | 
						|
    size_t m_start_offset { 0 };
 | 
						|
    size_t m_length_in_code_units { 0 };
 | 
						|
    RefPtr<Gfx::GlyphRun> m_glyph_run;
 | 
						|
    CSS::WritingMode m_writing_mode;
 | 
						|
    Vector<ShadowData> m_shadows;
 | 
						|
    CSSPixels m_text_decoration_thickness { 0 };
 | 
						|
};
 | 
						|
 | 
						|
}
 |