mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 476ec563bc
			
		
	
	
		476ec563bc
		
	
	
	
	
		
			
			Using from_utf8_short_string() for all cases that are <= 3 bytes long. Which is almost all of the static ones.
		
			
				
	
	
		
			51 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020-2021, the SerenityOS developers.
 | |
|  * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/CSS/Parser/Block.h>
 | |
| #include <LibWeb/CSS/Parser/ComponentValue.h>
 | |
| #include <LibWeb/CSS/Parser/Function.h>
 | |
| 
 | |
| namespace Web::CSS::Parser {
 | |
| 
 | |
| ComponentValue::ComponentValue(Token token)
 | |
|     : m_value(token)
 | |
| {
 | |
| }
 | |
| ComponentValue::ComponentValue(NonnullRefPtr<Function> function)
 | |
|     : m_value(function)
 | |
| {
 | |
| }
 | |
| ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
 | |
|     : m_value(block)
 | |
| {
 | |
| }
 | |
| 
 | |
| ComponentValue::~ComponentValue() = default;
 | |
| 
 | |
| DeprecatedString ComponentValue::to_deprecated_string() const
 | |
| {
 | |
|     return m_value.visit(
 | |
|         [](Token const& token) { return token.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); },
 | |
|         [](NonnullRefPtr<Block> const& block) { return block->to_deprecated_string(); },
 | |
|         [](NonnullRefPtr<Function> const& function) { return function->to_deprecated_string(); });
 | |
| }
 | |
| 
 | |
| ErrorOr<String> ComponentValue::to_debug_string() const
 | |
| {
 | |
|     return m_value.visit(
 | |
|         [](Token const& token) -> ErrorOr<String> {
 | |
|             return String::formatted("Token: {}", TRY(token.to_debug_string()));
 | |
|         },
 | |
|         [](NonnullRefPtr<Block> const& block) -> ErrorOr<String> {
 | |
|             return String::formatted("Block: {}", block->to_deprecated_string());
 | |
|         },
 | |
|         [](NonnullRefPtr<Function> const& function) -> ErrorOr<String> {
 | |
|             return String::formatted("Function: {}", function->to_deprecated_string());
 | |
|         });
 | |
| }
 | |
| 
 | |
| }
 |