Changed: use css display: block instead hardcoded endParagraph()

--HG--
branch : develop
kaetemi-develop
Nimetu 6 years ago
parent 0676cd0d2b
commit d0616ac579

@ -57,6 +57,7 @@ namespace NLGUI
Underlined=false;
StrikeThrough=false;
GlobalColor=false;
DisplayBlock=false;
Width=-1;
Height=-1;
MaxWidth=-1;
@ -87,6 +88,7 @@ namespace NLGUI
bool GlobalColor;
bool Underlined;
bool StrikeThrough;
bool DisplayBlock;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
@ -172,6 +174,7 @@ namespace NLGUI
styleStackIndex++;
_StyleStack.push_back(Current);
Current.DisplayBlock = false;
Current.Width=-1;
Current.Height=-1;
Current.MaxWidth=-1;

@ -569,14 +569,6 @@ namespace NLGUI
return _LinkClass.back().c_str();
}
std::vector<bool> _BlockLevelElement;
inline bool isBlockLevelElement() const
{
if (_BlockLevelElement.empty())
return false;
return _BlockLevelElement.back();
}
// Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const

@ -456,6 +456,14 @@ namespace NLGUI
if (pos != style.StyleRules.end())
style.StyleRules.erase(pos);
}
else
if (it->first == "display")
{
if (it->second == "inherit")
style.DisplayBlock = current.DisplayBlock;
else
style.DisplayBlock = (it->second == "block" || it->second == "table");
}
}
}

@ -1072,6 +1072,11 @@ namespace NLGUI
_AnchorName.push_back(elm.getAttribute("id"));
}
if (_Style.Current.DisplayBlock)
{
endParagraph();
}
switch(elm.ID)
{
case HTML_A: htmlA(elm); break;
@ -1189,6 +1194,10 @@ namespace NLGUI
break;
}
if (_Style.Current.DisplayBlock)
{
endParagraph();
}
_Style.popStyle();
}
@ -4881,6 +4890,11 @@ namespace NLGUI
css += "small { font-size: smaller;}";
css += "dt { font-weight: bold; }";
css += "hr { color: rgb(120, 120, 120);}";
// block level elements
css += "address, article, aside, blockquote, details, dialog, dd, div, dl, dt, fieldset, figcaption, figure,";
css += "footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, li, main, nav, ol, p, pre, section, table,";
css += "ul { display: block; }";
css += "table { display: table; }";
// td { padding: 1px;} - overwrites cellpadding attribute
// table { border-spacing: 2px;} - overwrites cellspacing attribute
css += "table { border-collapse: separate;}";
@ -5515,8 +5529,6 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::htmlDIV(const CHtmlElement &elm)
{
_BlockLevelElement.push_back(true);
_DivName = elm.getAttribute("name");
string instClass = elm.getAttribute("class");
@ -5539,8 +5551,6 @@ namespace NLGUI
{
if ((*it).first == "template")
templateName = (*it).second;
else if ((*it).first == "display" && (*it).second == "inline-block")
_BlockLevelElement.back() = false;
else
tmplParams.push_back(TTmplParam((*it).first, (*it).second));
}
@ -5573,8 +5583,6 @@ namespace NLGUI
inst->setPosRef(Hotspot_TL);
inst->setParentPosRef(Hotspot_TL);
getDiv()->addGroup(inst);
_BlockLevelElement.back() = false;
}
else
{
@ -5586,25 +5594,14 @@ namespace NLGUI
}
}
if (isBlockLevelElement())
{
newParagraph(0);
}
renderPseudoElement(":before", elm);
}
void CGroupHTML::htmlDIVend(const CHtmlElement &elm)
{
renderPseudoElement(":after", elm);
if (isBlockLevelElement())
{
endParagraph();
}
_DivName.clear();
popIfNotEmpty(_Divs);
popIfNotEmpty(_BlockLevelElement);
}
// ***************************************************************************
@ -5612,7 +5609,6 @@ namespace NLGUI
{
_DL.push_back(HTMLDListElement());
_LI = _DL.size() > 1 || !_UL.empty();
endParagraph();
renderPseudoElement(":before", elm);
}
@ -5624,8 +5620,6 @@ namespace NLGUI
renderPseudoElement(":after", elm);
endParagraph();
// unclosed DT
if (_DL.back().DT)
{
@ -5746,7 +5740,6 @@ namespace NLGUI
void CGroupHTML::htmlHend(const CHtmlElement &elm)
{
renderPseudoElement(":after", elm);
endParagraph();
}
// ***************************************************************************
@ -5764,8 +5757,6 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::htmlHR(const CHtmlElement &elm)
{
endParagraph();
CInterfaceGroup *sep = CWidgetManager::getInstance()->getParser()->createGroupInstance("html_hr", "", NULL, 0);
if (sep)
{
@ -5789,8 +5780,6 @@ namespace NLGUI
renderPseudoElement(":before", elm);
addHtmlGroup(sep, 0);
renderPseudoElement(":after", elm);
endParagraph();
}
}
@ -6238,7 +6227,6 @@ namespace NLGUI
// if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1;
_Indent.push_back(getIndent() + ULIndent);
endParagraph();
renderPseudoElement(":before", elm);
}
@ -6348,7 +6336,6 @@ namespace NLGUI
void CGroupHTML::htmlPend(const CHtmlElement &elm)
{
renderPseudoElement(":after", elm);
endParagraph();
}
// ***************************************************************************
@ -6364,7 +6351,6 @@ namespace NLGUI
{
renderPseudoElement(":after", elm);
endParagraph();
popIfNotEmpty(_PRE);
}
@ -6581,7 +6567,6 @@ namespace NLGUI
popIfNotEmpty(_Indent);
renderPseudoElement(":after", elm);
endParagraph();
}
// ***************************************************************************
@ -6799,7 +6784,6 @@ namespace NLGUI
// if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1;
_Indent.push_back(getIndent() + ULIndent);
endParagraph();
renderPseudoElement(":before", elm);
}
@ -6811,7 +6795,6 @@ namespace NLGUI
renderPseudoElement(":after", elm);
endParagraph();
popIfNotEmpty(_UL);
popIfNotEmpty(_Indent);
}

Loading…
Cancel
Save