1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

LibWeb: Propagate errors from CSS Parser construction

This requires Parser to be movable, so we remove the `default`
destructors from Parser and TokenStream, and give them both move
constructors. Since TokenStream only holds a reference to its tokens,
(and it needs to, to avoid copying when given eg a function's contents,)
we add a manual move constructor for Parser which creates a new
TokenStream from the new Parser's tokens, and then manually copies the
old TokenStream's state.
This commit is contained in:
Sam Atkins 2023-03-06 17:17:08 +00:00 committed by Andreas Kling
parent 235018046e
commit ca30914fe9
3 changed files with 47 additions and 22 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020-2021, the SerenityOS developers.
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -60,8 +60,7 @@ public:
{
}
TokenStream(TokenStream<T> const&) = delete;
~TokenStream() = default;
TokenStream(TokenStream<T>&&) = default;
bool has_next_token()
{
@ -123,6 +122,11 @@ public:
}
}
void copy_state(Badge<Parser>, TokenStream<T> const& other)
{
m_iterator_offset = other.m_iterator_offset;
}
private:
Vector<T> const& m_tokens;
int m_iterator_offset { -1 };