mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
LibWeb: Paint the text selection :^)
Text selection currently works at the LayoutNode level. The root of the layout tree has a LayoutRange selection() which in turn has two LayoutPosition objects: start() and end(). A LayoutPosition is a LayoutNode + a text offset into that node. We handle the selection painting in LayoutText::paint_fragment(), after the normal painting is finished. The basic mechanism is that each LayoutFragment is queried for its selection_rect(), and if a non-empty rect is returned, we clip to it and paint the text once more.
This commit is contained in:
parent
2762e3d80a
commit
706fc3d1aa
3 changed files with 88 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibGfx/FloatRect.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -68,6 +69,8 @@ public:
|
|||
|
||||
int text_index_at(float x) const;
|
||||
|
||||
Gfx::FloatRect selection_rect(const Gfx::Font&) const;
|
||||
|
||||
private:
|
||||
const LayoutNode& m_layout_node;
|
||||
int m_start { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue