diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-04-02 23:42:55 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-04-02 23:42:55 +0200 |
commit | 6afddbd7a6a41c9a2c27a88749a3ed6dc082bbfd (patch) | |
tree | 3ea3728964fd92330751a8fcd4feee930ee0fd96 /src/css.hh | |
parent | e69c87143a4bd364a197d6a86c97680a4e356537 (diff) |
add CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
* Add an additional CssValueType CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
which can be a length, a percentage, or a number without unit.
* Numbers without units are represented as CssLength of type
CSS_LENGTH_TYPE_NONE.
* Properly detect numbers without unit in cases where they are not
allowed (see testcase below). For lengths only '0' can be
specified without unit.
Testcase:
<html>
<head>
<style tyoe="text/css">
div {border: solid black 2px}
</style>
</head>
<body>
<!-- correct - border-width should be set to 0 -> no border -->
<div style="border-width: 0">foo bar</div>
<!-- false - border-width should be left untouched -> 2px border -->
<div style="border-width: 40">foo bar</div>
<!-- false - border-width should be left untouched -> 2px border -->
<div style="border-width: 40 px">foo bar</div>
</body>
</html>
Diffstat (limited to 'src/css.hh')
-rw-r--r-- | src/css.hh | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -36,6 +36,7 @@ typedef enum { in this particular case (e.g. 'margin-*-width'). */ CSS_TYPE_SIGNED_LENGTH, /* As CSS_TYPE_LENGTH but may be negative. */ + CSS_TYPE_LENGTH_PERCENTAGE_NUMBER, /* <length> or <percentage>, or <number> */ CSS_TYPE_COLOR, /* Represented as integer. */ CSS_TYPE_FONT_WEIGHT, /* this very special and only used by 'font-weight' */ @@ -70,6 +71,7 @@ typedef enum { typedef int CssLength; typedef enum { + CSS_LENGTH_TYPE_NONE, CSS_LENGTH_TYPE_PX, CSS_LENGTH_TYPE_MM, /* "cm", "in", "pt" and "pc" are converted into millimeters. */ @@ -94,6 +96,7 @@ inline CssLength CSS_CREATE_LENGTH (float v, CssLengthType t) { else if (iv < -CSS_LENGTH_INT_MAX) iv = -CSS_LENGTH_INT_MAX; return iv << 3 | t; + case CSS_LENGTH_TYPE_NONE: case CSS_LENGTH_TYPE_MM: case CSS_LENGTH_TYPE_EM: case CSS_LENGTH_TYPE_EX: @@ -120,6 +123,7 @@ inline float CSS_LENGTH_VALUE (CssLength l) { switch (CSS_LENGTH_TYPE(l)) { case CSS_LENGTH_TYPE_PX: return (float) (l >> 3); + case CSS_LENGTH_TYPE_NONE: case CSS_LENGTH_TYPE_MM: case CSS_LENGTH_TYPE_EM: case CSS_LENGTH_TYPE_EX: |