2 #include "css_length.h"
4 void litehtml::css_length::fromString( const string
& str
, const string
& predefs
, int defValue
)
6 // TODO: Make support for calc
7 if(str
.substr(0, 4) == "calc")
9 m_is_predefined
= true;
14 int predef
= value_index(str
, predefs
, -1);
17 m_is_predefined
= true;
21 m_is_predefined
= false;
30 if(t_isdigit(chr
) || chr
== '.' || chr
== '+' || chr
== '-')
45 m_value
= t_strtof(num
);
46 m_units
= (css_units
) value_index(un
, css_units_strings
, css_units_none
);
49 // not a number so it is predefined
50 m_is_predefined
= true;
56 litehtml::css_length
litehtml::css_length::from_string(const string
& str
, const string
& predefs
, int defValue
)
59 len
.fromString(str
, predefs
, defValue
);
63 litehtml::string
litehtml::css_length::to_string() const
67 return "def(" + std::to_string(m_predef
) + ")";
69 return std::to_string(m_value
) + "{" + index_value(m_units
, css_units_strings
) + "}";
72 litehtml::css_length
litehtml::css_length::predef_value(int val
)