mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 1feacd4b52
			
		
	
	
		1feacd4b52
		
	
	
	
	
		
			
			Avoid unintentionally converting between float and double multiple times by just using double everywhere. Also, remove the unused `int` versions of their constructors.
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			609 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			609 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "Ratio.h"
 | |
| #include <math.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| Ratio::Ratio(double first, double second)
 | |
|     : m_first_value(first)
 | |
|     , m_second_value(second)
 | |
| {
 | |
| }
 | |
| 
 | |
| // https://www.w3.org/TR/css-values-4/#degenerate-ratio
 | |
| bool Ratio::is_degenerate() const
 | |
| {
 | |
|     return !isfinite(m_first_value) || m_first_value == 0
 | |
|         || !isfinite(m_second_value) || m_second_value == 0;
 | |
| }
 | |
| 
 | |
| ErrorOr<String> Ratio::to_string() const
 | |
| {
 | |
|     return String::formatted("{} / {}", m_first_value, m_second_value);
 | |
| }
 | |
| 
 | |
| }
 |