|
|
|
@ -434,7 +434,7 @@ namespace NLGUI
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "background")
|
|
|
|
|
{
|
|
|
|
|
parseBackgroundShorthand(it->second, style);
|
|
|
|
|
expandBackgroundShorthand(it->second, style.StyleRules);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "background-repeat")
|
|
|
|
@ -464,25 +464,25 @@ namespace NLGUI
|
|
|
|
|
|| it->first == "border-bottom" || it->first == "border-left")
|
|
|
|
|
{
|
|
|
|
|
// TODO: use enum or bitmap constant instead of passing a string name (it->first)
|
|
|
|
|
parseBorderShorthand(it->second, style, it->first);
|
|
|
|
|
expandBorderShorthand(it->first, it->second, style.StyleRules);
|
|
|
|
|
keep = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "border-width")
|
|
|
|
|
{
|
|
|
|
|
tryBorderWidthShorthand(it->second, style, it->first);
|
|
|
|
|
tryBorderWidthShorthand(it->first, it->second, style.StyleRules);
|
|
|
|
|
keep = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "border-style")
|
|
|
|
|
{
|
|
|
|
|
tryBorderStyleShorthand(it->second, style, it->first);
|
|
|
|
|
tryBorderStyleShorthand(it->first, it->second, style.StyleRules);
|
|
|
|
|
keep = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "border-color")
|
|
|
|
|
{
|
|
|
|
|
tryBorderColorShorthand(it->second, style, it->first);
|
|
|
|
|
tryBorderColorShorthand(it->first, it->second, style.StyleRules);
|
|
|
|
|
keep = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -496,7 +496,7 @@ namespace NLGUI
|
|
|
|
|
else
|
|
|
|
|
if (it->first == "padding")
|
|
|
|
|
{
|
|
|
|
|
parsePaddingShorthand(it->second, style);
|
|
|
|
|
expandPaddingShorthand(it->second, style.StyleRules);
|
|
|
|
|
keep = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -983,7 +983,7 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CCssStyle::parseBackgroundShorthand(const std::string &value, CStyleParams &style) const
|
|
|
|
|
void CCssStyle::expandBackgroundShorthand(const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
// background: url(image.jpg) top center / 200px 200px no-repeat fixed padding-box content-box red;
|
|
|
|
|
// background-image : url(image.jpg)
|
|
|
|
@ -1261,16 +1261,16 @@ namespace NLGUI
|
|
|
|
|
{
|
|
|
|
|
if (props[i] == "background-position")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules["background-position-x"] = bgPositionX;
|
|
|
|
|
style.StyleRules["background-position-y"] = bgPositionY;
|
|
|
|
|
style["background-position-x"] = bgPositionX;
|
|
|
|
|
style["background-position-y"] = bgPositionY;
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-clip")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules["background-clip"] = bgClipValue;
|
|
|
|
|
style["background-clip"] = bgClipValue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = values[i];
|
|
|
|
|
style[props[i]] = values[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -1278,40 +1278,40 @@ namespace NLGUI
|
|
|
|
|
// fill in default if one is set
|
|
|
|
|
if (props[i] == "background-image")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "none";
|
|
|
|
|
style[props[i]] = "none";
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-position")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "0% 0%";
|
|
|
|
|
style.StyleRules["background-position-x"] = "left 0%";
|
|
|
|
|
style.StyleRules["background-position-y"] = "top 0%";
|
|
|
|
|
style[props[i]] = "0% 0%";
|
|
|
|
|
style["background-position-x"] = "left 0%";
|
|
|
|
|
style["background-position-y"] = "top 0%";
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-size")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "auto auto";
|
|
|
|
|
style[props[i]] = "auto auto";
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-repeat")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "repeat";
|
|
|
|
|
style[props[i]] = "repeat";
|
|
|
|
|
}
|
|
|
|
|
else if(props[i] == "background-attachment")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "scroll";
|
|
|
|
|
style[props[i]] = "scroll";
|
|
|
|
|
}
|
|
|
|
|
else if(props[i] == "background-origin")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "padding-box";
|
|
|
|
|
style[props[i]] = "padding-box";
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-clip")
|
|
|
|
|
{
|
|
|
|
|
if (bgClipFound)
|
|
|
|
|
style.StyleRules[props[i]] = bgClipValue;
|
|
|
|
|
style[props[i]] = bgClipValue;
|
|
|
|
|
else
|
|
|
|
|
style.StyleRules[props[i]] = "border-box";
|
|
|
|
|
style[props[i]] = "border-box";
|
|
|
|
|
}
|
|
|
|
|
else if (props[i] == "background-color")
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[props[i]] = "transparent";
|
|
|
|
|
style[props[i]] = "transparent";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1349,7 +1349,7 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
bool CCssStyle::tryBorderWidthShorthand(const std::string &value, CStyleParams &style, const std::string &prop) const
|
|
|
|
|
bool CCssStyle::tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
NLMISC::splitString(toLower(value), " ", parts);
|
|
|
|
@ -1378,15 +1378,15 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
uint8 t, r, b, l;
|
|
|
|
|
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-width"] = parts[t];
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-width"] = parts[r];
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-width"] = parts[b];
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-width"] = parts[l];
|
|
|
|
|
if (hasTop) style["border-top-width"] = parts[t];
|
|
|
|
|
if (hasRight) style["border-right-width"] = parts[r];
|
|
|
|
|
if (hasBottom) style["border-bottom-width"] = parts[b];
|
|
|
|
|
if (hasLeft) style["border-left-width"] = parts[l];
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
bool CCssStyle::tryBorderStyleShorthand(const std::string &value, CStyleParams &style, const std::string &prop) const
|
|
|
|
|
bool CCssStyle::tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
NLMISC::splitString(toLower(value), " ", parts);
|
|
|
|
@ -1427,15 +1427,15 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
uint8 t, r, b, l;
|
|
|
|
|
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-style"] = parts[t];
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-style"] = parts[r];
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-style"] = parts[b];
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-style"] = parts[l];
|
|
|
|
|
if (hasTop) style["border-top-style"] = parts[t];
|
|
|
|
|
if (hasRight) style["border-right-style"] = parts[r];
|
|
|
|
|
if (hasBottom) style["border-bottom-style"] = parts[b];
|
|
|
|
|
if (hasLeft) style["border-left-style"] = parts[l];
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
bool CCssStyle::tryBorderColorShorthand(const std::string &value, CStyleParams &style, const std::string &prop) const
|
|
|
|
|
bool CCssStyle::tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
NLMISC::splitString(toLower(value), " ", parts);
|
|
|
|
@ -1460,16 +1460,16 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
uint8 t, r, b, l;
|
|
|
|
|
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-color"] = parts[t];
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-color"] = parts[r];
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-color"] = parts[b];
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-color"] = parts[l];
|
|
|
|
|
if (hasTop) style["border-top-color"] = parts[t];
|
|
|
|
|
if (hasRight) style["border-right-color"] = parts[r];
|
|
|
|
|
if (hasBottom) style["border-bottom-color"] = parts[b];
|
|
|
|
|
if (hasLeft) style["border-left-color"] = parts[l];
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CCssStyle::parseBorderShorthand(const std::string &value, CStyleParams &style, const std::string &prop) const
|
|
|
|
|
void CCssStyle::expandBorderShorthand(const std::string &prop, const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
// border: 1px solid #000;
|
|
|
|
|
bool hasTop = (prop == "border" || prop == "border-top");
|
|
|
|
@ -1481,7 +1481,7 @@ namespace NLGUI
|
|
|
|
|
bool foundStyle = false;
|
|
|
|
|
bool foundColor = false;
|
|
|
|
|
|
|
|
|
|
CStyleParams borderStyle;
|
|
|
|
|
TStyle borderStyle;
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
NLMISC::splitString(toLower(value), " ", parts);
|
|
|
|
|
|
|
|
|
@ -1490,17 +1490,17 @@ namespace NLGUI
|
|
|
|
|
bool matched = false;
|
|
|
|
|
if (!foundWidth)
|
|
|
|
|
{
|
|
|
|
|
matched = foundWidth = tryBorderWidthShorthand(parts[index], borderStyle, prop);
|
|
|
|
|
matched = foundWidth = tryBorderWidthShorthand(prop, parts[index], borderStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!matched && !foundStyle)
|
|
|
|
|
{
|
|
|
|
|
matched = foundStyle = tryBorderStyleShorthand(parts[index], borderStyle, prop);
|
|
|
|
|
matched = foundStyle = tryBorderStyleShorthand(prop, parts[index], borderStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!matched && !foundColor)
|
|
|
|
|
{
|
|
|
|
|
matched = foundColor = tryBorderColorShorthand(parts[index], borderStyle, prop);
|
|
|
|
|
matched = foundColor = tryBorderColorShorthand(prop, parts[index], borderStyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// invalid rule if nothing gets matched
|
|
|
|
@ -1511,41 +1511,41 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// apply rules that are present
|
|
|
|
|
TStyle::const_iterator it = borderStyle.StyleRules.begin();
|
|
|
|
|
while(it != borderStyle.StyleRules.end())
|
|
|
|
|
TStyle::const_iterator it = borderStyle.begin();
|
|
|
|
|
while(it != borderStyle.end())
|
|
|
|
|
{
|
|
|
|
|
style.StyleRules[it->first] = it->second;
|
|
|
|
|
style[it->first] = it->second;
|
|
|
|
|
++it;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reset those not present
|
|
|
|
|
if (!foundWidth)
|
|
|
|
|
{
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-width"] = "medium";
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-width"] = "medium";
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-width"] = "medium";
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-width"] = "medium";
|
|
|
|
|
if (hasTop) style["border-top-width"] = "medium";
|
|
|
|
|
if (hasRight) style["border-right-width"] = "medium";
|
|
|
|
|
if (hasBottom) style["border-bottom-width"] = "medium";
|
|
|
|
|
if (hasLeft) style["border-left-width"] = "medium";
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (!foundStyle)
|
|
|
|
|
{
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-style"] = "none";
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-style"] = "none";
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-style"] = "none";
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-style"] = "none";
|
|
|
|
|
if (hasTop) style["border-top-style"] = "none";
|
|
|
|
|
if (hasRight) style["border-right-style"] = "none";
|
|
|
|
|
if (hasBottom) style["border-bottom-style"] = "none";
|
|
|
|
|
if (hasLeft) style["border-left-style"] = "none";
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (!foundColor)
|
|
|
|
|
{
|
|
|
|
|
if (hasTop) style.StyleRules["border-top-color"] = "currentcolor";
|
|
|
|
|
if (hasRight) style.StyleRules["border-right-color"] = "currentcolor";
|
|
|
|
|
if (hasBottom) style.StyleRules["border-bottom-color"] = "currentcolor";
|
|
|
|
|
if (hasLeft) style.StyleRules["border-left-color"] = "currentcolor";
|
|
|
|
|
if (hasTop) style["border-top-color"] = "currentcolor";
|
|
|
|
|
if (hasRight) style["border-right-color"] = "currentcolor";
|
|
|
|
|
if (hasBottom) style["border-bottom-color"] = "currentcolor";
|
|
|
|
|
if (hasLeft) style["border-left-color"] = "currentcolor";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CCssStyle::parsePaddingShorthand(const std::string &value, CStyleParams &style) const
|
|
|
|
|
void CCssStyle::expandPaddingShorthand(const std::string &value, TStyle &style) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
NLMISC::splitString(toLower(value), " ", parts);
|
|
|
|
@ -1554,10 +1554,10 @@ namespace NLGUI
|
|
|
|
|
if (!getShorthandIndices(parts.size(), t, r, b, l))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
style.StyleRules["padding-top"] = parts[t];
|
|
|
|
|
style.StyleRules["padding-right"] = parts[r];
|
|
|
|
|
style.StyleRules["padding-bottom"] = parts[b];
|
|
|
|
|
style.StyleRules["padding-left"] = parts[l];
|
|
|
|
|
style["padding-top"] = parts[t];
|
|
|
|
|
style["padding-right"] = parts[r];
|
|
|
|
|
style["padding-bottom"] = parts[b];
|
|
|
|
|
style["padding-left"] = parts[l];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|