mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 73fdbba59c
			
		
	
	
		73fdbba59c
		
	
	
	
	
		
			
			This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <AK/String.h>
 | |
| 
 | |
| class Length {
 | |
| public:
 | |
|     enum class Type {
 | |
|         Auto,
 | |
|         Absolute,
 | |
|     };
 | |
| 
 | |
|     Length() {}
 | |
|     Length(int value, Type type)
 | |
|         : m_type(type)
 | |
|         , m_value(value)
 | |
|     {
 | |
|     }
 | |
|     ~Length() {}
 | |
| 
 | |
|     bool is_auto() const { return m_type == Type::Auto; }
 | |
|     bool is_absolute() const { return m_type == Type::Absolute; }
 | |
| 
 | |
|     int value() const { return m_value; }
 | |
| 
 | |
|     String to_string() const
 | |
|     {
 | |
|         if (is_auto())
 | |
|             return "auto";
 | |
|         return String::format("%d [Length/Absolute]", m_value);
 | |
|     }
 | |
| 
 | |
|     int to_px() const
 | |
|     {
 | |
|         if (is_auto())
 | |
|             return 0;
 | |
|         return m_value;
 | |
|     }
 | |
| 
 | |
| private:
 | |
|     Type m_type { Type::Auto };
 | |
|     int m_value { 0 };
 | |
| };
 | |
| 
 | |
| inline const LogStream& operator<<(const LogStream& stream, const Length& value)
 | |
| {
 | |
|     return stream << value.to_string();
 | |
| }
 |