From bc4d1cb7dcbbab9bca7f75e2e0c70d54493aae0b Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 13 Nov 2014 18:08:18 +0100 Subject: started to implement the CSSParser. First iteration only contains the CSS Specificity. --- src/core/utils/CSSParser.cpp | 27 +++++++++++++++++++ src/core/utils/CSSParser.hpp | 64 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/core/utils/CSSParser.cpp create mode 100644 src/core/utils/CSSParser.hpp (limited to 'src/core/utils') diff --git a/src/core/utils/CSSParser.cpp b/src/core/utils/CSSParser.cpp new file mode 100644 index 0000000..6ac98fa --- /dev/null +++ b/src/core/utils/CSSParser.cpp @@ -0,0 +1,27 @@ +/* + Ousía + Copyright (C) 2014 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "CSSParser.hpp" + +namespace ousia { +namespace utils { + + + +} +} diff --git a/src/core/utils/CSSParser.hpp b/src/core/utils/CSSParser.hpp new file mode 100644 index 0000000..4e82371 --- /dev/null +++ b/src/core/utils/CSSParser.hpp @@ -0,0 +1,64 @@ +/* + Ousía + Copyright (C) 2014 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _OUSIA_UTILS_CSS_PARSER_HPP_ +#define _OUSIA_UTILS_CSS_PARSER_HPP_ + +#include +#include + +namespace ousia { +namespace utils { + +/* + * The Specificity or Precedence of a CSS RuleSet, which decides which + * rules are applied when different RuleSets contain conflicting information. + * + * The Specificity is calculated using the official W3C recommendation + * http://www.w3.org/TR/CSS2/cascade.html#specificity + * + * Note that we do not need to use the integer 'a', since we do not allow + * local style definitions for single nodes. + */ +struct Specificity { + +int b; +int c; +int d; + +Specificity(int b, int c, int d): b(b), c(c), d(d) {} + +}; + + +bool operator< (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) < std::tie(y.b, y.c, y.d); +} + +bool operator> (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) > std::tie(y.b, y.c, y.d); +} + +bool operator== (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) == std::tie(y.b, y.c, y.d); +} + +} +} + +#endif -- cgit v1.2.3