aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-12 22:23:00 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-12 22:23:00 +0100
commit8d041ff283a940eb3b2abddcc2693eda2ab8dc97 (patch)
treefa476929fac610d7881fbfb3eaffc2b27e47d09a /src
parent6110dbfaaf79dad91b089edf273bf839f229b76e (diff)
replace CSS_LENGTH_* macros with inline functions
Diffstat (limited to 'src')
-rw-r--r--src/css.hh18
-rw-r--r--src/cssparser.cc4
2 files changed, 15 insertions, 7 deletions
diff --git a/src/css.hh b/src/css.hh
index 49a33896..57314955 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -56,7 +56,7 @@ typedef enum {
typedef int CssLength;
-enum {
+typedef enum {
CSS_LENGTH_TYPE_PX,
CSS_LENGTH_TYPE_MM, /* "cm", "in", "pt" and "pc" are converted into
millimeters. */
@@ -66,11 +66,19 @@ enum {
CSS_LENGTH_TYPE_RELATIVE, /* This does not exist in CSS but
is used in HTML */
CSS_LENGTH_TYPE_AUTO /* This can be used as a simple value. */
-};
+} CssLengthType;
+
+inline CssLength CSS_CREATE_LENGTH (float v, CssLengthType t) {
+ return ((int) (v * (1 << 19)) & ~7 ) | t;
+}
+
+inline float CSS_LENGTH_VALUE (CssLength l) {
+ return ((float)(l & ~7)) / (1 << 19);
+}
-#define CSS_CREATE_LENGTH(v, t) ( ( (int)((v) * (1 << 19)) & ~7 ) | (t) )
-#define CSS_LENGTH_VALUE(l) ( ( (float)((l) & ~7) ) / (1 << 19) )
-#define CSS_LENGTH_TYPE(l) ((l) & 7)
+inline CssLengthType CSS_LENGTH_TYPE (CssLength l) {
+ return (CssLengthType) (l & 7);
+}
typedef enum {
CSS_PROPERTY_BACKGROUND_ATTACHMENT,
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 0fb0d3d8..87d58dbd 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -670,10 +670,10 @@ static bool Css_parse_value(CssParser * parser,
CssValueType type,
CssPropertyValue * val)
{
- int i, lentype;
+ CssLengthType lentype;
bool found, ret = false;
float fval;
- int ival, err = 1;
+ int i, ival, err = 1;
switch (type) {
case CSS_TYPE_ENUM: