mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-03 23:00:58 +00:00 
			
		
		
		
	This will be used to differentiate between serialization for resolved style (i.e window.getComputedStyle()) and serialization for all other purposes.
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
 | 
						|
 * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
 | 
						|
 * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
 | 
						|
 * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#include "StyleValueList.h"
 | 
						|
 | 
						|
namespace Web::CSS {
 | 
						|
 | 
						|
bool StyleValueList::Properties::operator==(Properties const& other) const
 | 
						|
{
 | 
						|
    return separator == other.separator && values.span() == other.values.span();
 | 
						|
}
 | 
						|
 | 
						|
String StyleValueList::to_string(SerializationMode mode) const
 | 
						|
{
 | 
						|
    auto separator = ""sv;
 | 
						|
    switch (m_properties.separator) {
 | 
						|
    case Separator::Space:
 | 
						|
        separator = " "sv;
 | 
						|
        break;
 | 
						|
    case Separator::Comma:
 | 
						|
        separator = ", "sv;
 | 
						|
        break;
 | 
						|
    default:
 | 
						|
        VERIFY_NOT_REACHED();
 | 
						|
    }
 | 
						|
 | 
						|
    StringBuilder builder;
 | 
						|
    for (size_t i = 0; i < m_properties.values.size(); ++i) {
 | 
						|
        builder.append(m_properties.values[i]->to_string(mode));
 | 
						|
        if (i != m_properties.values.size() - 1)
 | 
						|
            builder.append(separator);
 | 
						|
    }
 | 
						|
    return MUST(builder.to_string());
 | 
						|
}
 | 
						|
 | 
						|
}
 |