Author: jmb
Date: Fri Jan 23 13:29:03 2009
New Revision: 6183
URL: http://source.netsurf-browser.org?rev=6183&view=rev
Log:
Introduce fixed point constants.
Range check azimuth angles.
Added:
trunk/libcss/src/utils/fpconstants.h
Modified:
trunk/libcss/src/parse/properties.c
trunk/libcss/src/utils/fpmath.h
Modified: trunk/libcss/src/parse/properties.c
URL:
http://source.netsurf-browser.org/trunk/libcss/src/parse/properties.c?rev=6183&r1=6182&r2=6183&view=diff
==============================================================================
--- trunk/libcss/src/parse/properties.c (original)
+++ trunk/libcss/src/parse/properties.c Fri Jan 23 13:29:03 2009
@@ -571,6 +571,18 @@
if ((unit & UNIT_ANGLE) == false)
return CSS_INVALID;
+ /* Valid angles lie between -360 and 360 degrees */
+ if (unit == UNIT_DEG) {
+ if (length < FMULI(F_360, -1) || length > F_360)
+ return CSS_INVALID;
+ } else if (unit == UNIT_GRAD) {
+ if (length < FMULI(F_100, -1) || length > F_100)
+ return CSS_INVALID;
+ } else if (unit == UNIT_RAD) {
+ if (length < FMULI(F_2PI, -1) || length > F_2PI)
+ return CSS_INVALID;
+ }
+
value = AZIMUTH_ANGLE;
}
Added: trunk/libcss/src/utils/fpconstants.h
URL:
http://source.netsurf-browser.org/trunk/libcss/src/utils/fpconstants.h?rev=6183&view=auto
==============================================================================
--- trunk/libcss/src/utils/fpconstants.h (added)
+++ trunk/libcss/src/utils/fpconstants.h Fri Jan 23 13:29:03 2009
@@ -1,0 +1,20 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 John-Mark Bell <[email protected]>
+ */
+
+#ifndef css_utils_fpconstants_h_
+#define css_utils_fpconstants_h_
+
+/* Useful angles */
+#define F_PI 0x00000c91 /* 3.1415 (PI) */
+#define F_2PI 0x00001922 /* 2 PI */
+
+#define F_360 0x0005a000 /* 360 */
+
+#define F_100 0x00019000 /* 100 */
+
+#endif
+
Modified: trunk/libcss/src/utils/fpmath.h
URL:
http://source.netsurf-browser.org/trunk/libcss/src/utils/fpmath.h?rev=6183&r1=6182&r2=6183&view=diff
==============================================================================
--- trunk/libcss/src/utils/fpmath.h (original)
+++ trunk/libcss/src/utils/fpmath.h Fri Jan 23 13:29:03 2009
@@ -41,5 +41,7 @@
/* Convert a fixed point value to an integer */
#define FIXTOINT(a) ((a) >> 10)
+#include "utils/fpconstants.h"
+
#endif
_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org