mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-18 05:11:42 +00:00
Changed: Refactor DL
This commit is contained in:
parent
4cc23633fb
commit
ca54fa4a5a
2 changed files with 43 additions and 34 deletions
|
@ -439,13 +439,17 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// DL list
|
// DL list
|
||||||
std::vector<bool> _DL;
|
class HTMLDListElement {
|
||||||
inline bool getDL() const
|
public:
|
||||||
{
|
HTMLDListElement()
|
||||||
if (_DL.empty())
|
: DT(false), DD(false)
|
||||||
return false;
|
{ }
|
||||||
return _DL.back();
|
|
||||||
}
|
public:
|
||||||
|
bool DT;
|
||||||
|
bool DD;
|
||||||
|
};
|
||||||
|
std::vector<HTMLDListElement> _DL;
|
||||||
|
|
||||||
// OL and UL
|
// OL and UL
|
||||||
class HTMLOListElement {
|
class HTMLOListElement {
|
||||||
|
@ -473,7 +477,6 @@ namespace NLGUI
|
||||||
|
|
||||||
// IL mode
|
// IL mode
|
||||||
bool _LI;
|
bool _LI;
|
||||||
bool _DT;
|
|
||||||
|
|
||||||
// Current text color
|
// Current text color
|
||||||
std::vector<NLMISC::CRGBA> _TextColor;
|
std::vector<NLMISC::CRGBA> _TextColor;
|
||||||
|
|
|
@ -1930,7 +1930,7 @@ namespace NLGUI
|
||||||
else
|
else
|
||||||
_UL.push_back(HTMLOListElement(1, "square"));
|
_UL.push_back(HTMLOListElement(1, "square"));
|
||||||
// if LI is already present
|
// if LI is already present
|
||||||
_LI = _UL.size() > 1 || getDL();
|
_LI = _UL.size() > 1 || _DL.size() > 1;
|
||||||
_Indent += ULIndent;
|
_Indent += ULIndent;
|
||||||
endParagraph();
|
endParagraph();
|
||||||
break;
|
break;
|
||||||
|
@ -1991,17 +1991,17 @@ namespace NLGUI
|
||||||
_IgnoreText = true;
|
_IgnoreText = true;
|
||||||
break;
|
break;
|
||||||
case HTML_DL:
|
case HTML_DL:
|
||||||
_DL.push_back(true);
|
_DL.push_back(HTMLDListElement());
|
||||||
_LI = _DL.size() > 1 || !_UL.empty();
|
_LI = _DL.size() > 1 || !_UL.empty();
|
||||||
endParagraph();
|
endParagraph();
|
||||||
break;
|
break;
|
||||||
case HTML_DT:
|
case HTML_DT:
|
||||||
if (getDL())
|
if (!_DL.empty())
|
||||||
{
|
{
|
||||||
// see if this is the first <dt>, closing tag not required
|
// see if this is the first <dt>, closing tag not required
|
||||||
if (!_DT)
|
if (!_DL.back().DT)
|
||||||
{
|
{
|
||||||
_DT = true;
|
_DL.back().DT = true;
|
||||||
_FontWeight.push_back(FONT_WEIGHT_BOLD);
|
_FontWeight.push_back(FONT_WEIGHT_BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2017,16 +2017,21 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_DD:
|
case HTML_DD:
|
||||||
if (getDL())
|
if (!_DL.empty())
|
||||||
{
|
{
|
||||||
// if there was no closing tag for <dt>, then remove <dt> style
|
// if there was no closing tag for <dt>, then remove <dt> style
|
||||||
if (_DT)
|
if (_DL.back().DT)
|
||||||
{
|
{
|
||||||
_DT = false;
|
_DL.back().DT = false;
|
||||||
popIfNotEmpty (_FontWeight);
|
popIfNotEmpty (_FontWeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_DL.back().DD)
|
||||||
|
{
|
||||||
_Indent += ULIndent;
|
_Indent += ULIndent;
|
||||||
|
_DL.back().DD = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_LI)
|
if (!_LI)
|
||||||
{
|
{
|
||||||
_LI = true;
|
_LI = true;
|
||||||
|
@ -2050,7 +2055,7 @@ namespace NLGUI
|
||||||
|
|
||||||
_UL.push_back(HTMLOListElement(start, type));
|
_UL.push_back(HTMLOListElement(start, type));
|
||||||
// if LI is already present
|
// if LI is already present
|
||||||
_LI = _UL.size() > 1 || getDL();
|
_LI = _UL.size() > 1 || _DL.size() > 1;
|
||||||
_Indent += ULIndent;
|
_Indent += ULIndent;
|
||||||
endParagraph();
|
endParagraph();
|
||||||
}
|
}
|
||||||
|
@ -2237,41 +2242,44 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_DL:
|
case HTML_DL:
|
||||||
if (getDL())
|
if (!_DL.empty())
|
||||||
{
|
{
|
||||||
endParagraph();
|
endParagraph();
|
||||||
if (getDL())
|
|
||||||
|
// unclosed DT
|
||||||
|
if (_DL.back().DT)
|
||||||
|
{
|
||||||
|
popIfNotEmpty (_FontWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unclosed DD
|
||||||
|
if (_DL.back().DD)
|
||||||
{
|
{
|
||||||
if (_Indent > ULIndent)
|
if (_Indent > ULIndent)
|
||||||
_Indent = _Indent - ULIndent;
|
_Indent = _Indent - ULIndent;
|
||||||
else
|
else
|
||||||
_Indent = 0;
|
_Indent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
popIfNotEmpty (_DL);
|
popIfNotEmpty (_DL);
|
||||||
if (_DT) {
|
|
||||||
_DT = false;
|
|
||||||
popIfNotEmpty (_FontWeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_DT:
|
case HTML_DT:
|
||||||
if (getDL())
|
if (!_DL.empty())
|
||||||
{
|
{
|
||||||
if (_DT)
|
_DL.back().DT = false;
|
||||||
{
|
|
||||||
_DT = false;
|
|
||||||
popIfNotEmpty (_FontWeight);
|
popIfNotEmpty (_FontWeight);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case HTML_DD:
|
case HTML_DD:
|
||||||
// style not changed
|
if (!_DL.empty())
|
||||||
if (getDL())
|
|
||||||
{
|
{
|
||||||
if (_Indent > ULIndent)
|
if (_Indent > ULIndent)
|
||||||
_Indent = _Indent - ULIndent;
|
_Indent = _Indent - ULIndent;
|
||||||
else
|
else
|
||||||
_Indent = 0;
|
_Indent = 0;
|
||||||
|
|
||||||
|
_DL.back().DD = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_SPAN:
|
case HTML_SPAN:
|
||||||
|
@ -2383,7 +2391,6 @@ namespace NLGUI
|
||||||
_CurrentViewImage = NULL;
|
_CurrentViewImage = NULL;
|
||||||
_Indent = 0;
|
_Indent = 0;
|
||||||
_LI = false;
|
_LI = false;
|
||||||
_DT = false;
|
|
||||||
_SelectOption = false;
|
_SelectOption = false;
|
||||||
_GroupListAdaptor = NULL;
|
_GroupListAdaptor = NULL;
|
||||||
_UrlFragment.clear();
|
_UrlFragment.clear();
|
||||||
|
@ -4062,7 +4069,6 @@ namespace NLGUI
|
||||||
_FontStrikeThrough.clear();
|
_FontStrikeThrough.clear();
|
||||||
_Indent = 0;
|
_Indent = 0;
|
||||||
_LI = false;
|
_LI = false;
|
||||||
_DT = false;
|
|
||||||
_UL.clear();
|
_UL.clear();
|
||||||
_DL.clear();
|
_DL.clear();
|
||||||
_A.clear();
|
_A.clear();
|
||||||
|
|
Loading…
Reference in a new issue