mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:32:44 +00:00 
			
		
		
		
	 57dc179b1f
			
		
	
	
		57dc179b1f
		
	
	
	
	
		
			
			This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
		
			
				
	
	
		
			58 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/Layout/AvailableSpace.h>
 | |
| #include <math.h>
 | |
| 
 | |
| namespace Web::Layout {
 | |
| 
 | |
| AvailableSize AvailableSize::make_definite(float value)
 | |
| {
 | |
|     return AvailableSize { Type::Definite, value };
 | |
| }
 | |
| 
 | |
| AvailableSize AvailableSize::make_indefinite()
 | |
| {
 | |
|     return AvailableSize { Type::Indefinite, INFINITY };
 | |
| }
 | |
| 
 | |
| AvailableSize AvailableSize::make_min_content()
 | |
| {
 | |
|     return AvailableSize { Type::MinContent, 0 };
 | |
| }
 | |
| 
 | |
| AvailableSize AvailableSize::make_max_content()
 | |
| {
 | |
|     return AvailableSize { Type::MaxContent, INFINITY };
 | |
| }
 | |
| 
 | |
| DeprecatedString AvailableSize::to_deprecated_string() const
 | |
| {
 | |
|     switch (m_type) {
 | |
|     case Type::Definite:
 | |
|         return DeprecatedString::formatted("definite({})", m_value);
 | |
|     case Type::Indefinite:
 | |
|         return "indefinite";
 | |
|     case Type::MinContent:
 | |
|         return "min-content";
 | |
|     case Type::MaxContent:
 | |
|         return "max-content";
 | |
|     }
 | |
|     VERIFY_NOT_REACHED();
 | |
| }
 | |
| 
 | |
| DeprecatedString AvailableSpace::to_deprecated_string() const
 | |
| {
 | |
|     return DeprecatedString::formatted("{} x {}", width, height);
 | |
| }
 | |
| 
 | |
| AvailableSize::AvailableSize(Type type, float value)
 | |
|     : m_type(type)
 | |
|     , m_value(value)
 | |
| {
 | |
| }
 | |
| 
 | |
| }
 |