mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:22:43 +00:00 
			
		
		
		
	 269810b954
			
		
	
	
		269810b954
		
	
	
	
	
		
			
			This means deviating slightly from the spec in order to construct a fully-initialized Declaration instead of creating an empty one and then poking at its internals. DeclarationOrAtRule should probably use a Variant, but for now, making its Declaration member optional is quick and easy.
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			797 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			797 B
		
	
	
	
		
			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/Declaration.h>
 | |
| #include <LibWeb/CSS/Serialize.h>
 | |
| 
 | |
| namespace Web::CSS::Parser {
 | |
| 
 | |
| Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important)
 | |
|     : m_name(move(name))
 | |
|     , m_values(move(values))
 | |
|     , m_important(move(important))
 | |
| {
 | |
| }
 | |
| 
 | |
| Declaration::~Declaration() = default;
 | |
| 
 | |
| String Declaration::to_string() const
 | |
| {
 | |
|     StringBuilder builder;
 | |
| 
 | |
|     serialize_an_identifier(builder, m_name);
 | |
|     builder.append(": ");
 | |
|     builder.join(" ", m_values);
 | |
| 
 | |
|     if (m_important == Important::Yes)
 | |
|         builder.append(" !important");
 | |
| 
 | |
|     return builder.to_string();
 | |
| }
 | |
| 
 | |
| }
 |