mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibWeb: Frame/Position: Implement cursor increment/decrement methods
This introduces methods to increment and decrement the cursor position. This is non-trivial as the cursor position is specified in bytes rather than codepoints. Thus, it sometimes needs to be incremented or decremented by more than one, depending on the codepoint to "jump over". Because the cursor blink cycle needs to be reset after moving the cursor, methods calling the ones in DOM::Position are implemented in Frame. Furthermore, this allows the cursor_position() getter to stay const. :^) Additionally, it adds a offset_is_at_end_of_node() method which checks if the current offset points to the end of the node.
This commit is contained in:
parent
08d09c4afb
commit
7181cb3a9c
4 changed files with 77 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -25,7 +26,10 @@ public:
|
|||
const Node* node() const { return m_node; }
|
||||
|
||||
unsigned offset() const { return m_offset; }
|
||||
bool offset_is_at_end_of_node() const;
|
||||
void set_offset(unsigned value) { m_offset = value; }
|
||||
bool increment_offset();
|
||||
bool decrement_offset();
|
||||
|
||||
bool operator==(const Position& other) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue