diff --git a/code/nel/include/nel/gui/css_parser.h b/code/nel/include/nel/gui/css_parser.h index cfaf03caa..a6dc92022 100644 --- a/code/nel/include/nel/gui/css_parser.h +++ b/code/nel/include/nel/gui/css_parser.h @@ -31,7 +31,7 @@ namespace NLGUI class CCssParser { public: // parse style declaration, eg "color: red; font-size: 10px;" - static TStyle parseDecls(const std::string &styleString); + static TStyleVec parseDecls(const std::string &styleString); // parse css stylesheet void parseStylesheet(const std::string &cssString, std::vector &rules); diff --git a/code/nel/include/nel/gui/css_style.h b/code/nel/include/nel/gui/css_style.h index b553881d1..4eabe26ba 100644 --- a/code/nel/include/nel/gui/css_style.h +++ b/code/nel/include/nel/gui/css_style.h @@ -27,6 +27,8 @@ namespace NLGUI class CHtmlElement; typedef std::map TStyle; + typedef std::pair TStylePair; + typedef std::vector TStyleVec; /** * \brief CSS style rules @@ -118,7 +120,7 @@ namespace NLGUI struct SStyleRule { std::vector Selector; - TStyle Properties; + TStyleVec Properties; // pseudo element like ':before' std::string PseudoElement; @@ -153,7 +155,7 @@ namespace NLGUI void apply(CStyleParams &style, const CStyleParams ¤t) const; // merge src into dest by overwriting key in dest - void merge(TStyle &dst, const TStyle &src) const; + void merge(TStyle &dst, const TStyleVec &src) const; // match selector to dom path bool match(const std::vector &selector, const CHtmlElement &elm) const; diff --git a/code/nel/src/gui/css_parser.cpp b/code/nel/src/gui/css_parser.cpp index 39a4496bc..e59cf832b 100644 --- a/code/nel/src/gui/css_parser.cpp +++ b/code/nel/src/gui/css_parser.cpp @@ -35,9 +35,9 @@ namespace NLGUI // // key is converted to lowercase // value is left as is - TStyle CCssParser::parseDecls(const std::string &styleString) + TStyleVec CCssParser::parseDecls(const std::string &styleString) { - TStyle styles; + TStyleVec styles; std::vector elements; NLMISC::splitString(styleString, ";", elements); @@ -49,7 +49,7 @@ namespace NLGUI { std::string key = trim(toLower(elements[i].substr(0, pos))); std::string value = trim(elements[i].substr(pos+1)); - styles[key] = value; + styles.push_back(TStylePair(key, value)); } } @@ -94,7 +94,7 @@ namespace NLGUI std::vector selectors; NLMISC::explode(selectorString, ucstring(","), selectors); - TStyle props; + TStyleVec props; props = parseDecls(styleString.toUtf8()); // duplicate props to each selector in selector list, diff --git a/code/nel/src/gui/css_style.cpp b/code/nel/src/gui/css_style.cpp index 3f13dbb10..4555de6c9 100644 --- a/code/nel/src/gui/css_style.cpp +++ b/code/nel/src/gui/css_style.cpp @@ -102,7 +102,9 @@ namespace NLGUI } else { - elm.setPseudo(i->PseudoElement, i->Properties); + TStyle props; + merge(props, i->Properties); + elm.setPseudo(i->PseudoElement, props); } } } @@ -110,17 +112,18 @@ namespace NLGUI // style from "style" attribute overrides