Changed: Change long if blocks to early exits

--HG--
branch : develop
This commit is contained in:
Nimetu 2019-04-30 22:52:38 +03:00
parent 4fcd71d7ba
commit ff3b4cfabd

View file

@ -5539,12 +5539,15 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::htmlIMG(const CHtmlElement &elm)
{
// Get the string name
if (elm.hasNonEmptyAttribute("src"))
std::string src = trim(elm.getAttribute("src"));
if (src.empty())
{
// no 'src' attribute, or empty
return;
}
float tmpf;
std::string id = elm.getAttribute("id");
std::string src = elm.getAttribute("src");
if (elm.hasNonEmptyAttribute("width"))
getPercentage(_Style.Current.Width, tmpf, elm.getAttribute("width").c_str());
@ -5599,7 +5602,6 @@ namespace NLGUI
addImage(id, elm.getAttribute("src"), reloadImg, _Style.Current);
}
}
}
// ***************************************************************************
void CGroupHTML::htmlINPUT(const CHtmlElement &elm)
@ -5619,9 +5621,14 @@ namespace NLGUI
// Widget minimal width
string minWidth = elm.getAttribute("z_input_width");
// Get the type
if (elm.hasNonEmptyAttribute("type"))
// <input type="...">
std::string type = trim(elm.getAttribute("type"));
if (type.empty())
{
// no 'type' attribute, or empty
return;
}
// Global color flag
if (elm.hasAttribute("global_color"))
_Style.Current.GlobalColor = true;
@ -5633,7 +5640,6 @@ namespace NLGUI
if (!strtooltip.empty())
tooltip = strtooltip.c_str();
string type = toLower(elm.getAttribute("type"));
if (type == "image")
{
// The submit button
@ -5835,7 +5841,6 @@ namespace NLGUI
}
}
}
}
// ***************************************************************************
void CGroupHTML::htmlLI(const CHtmlElement &elm)
@ -5908,8 +5913,11 @@ namespace NLGUI
std::string httpEquiv = elm.getAttribute("http-equiv");
std::string httpContent = elm.getAttribute("content");
if (!httpEquiv.empty() && !httpContent.empty())
if (httpEquiv.empty() || httpContent.empty())
{
return;
}
// only first http-equiv="refresh" should be handled
if (_RefreshUrl.empty() && httpEquiv == "refresh")
{
@ -5934,7 +5942,6 @@ namespace NLGUI
_NextRefreshTime += timeSec;
}
}
}
// ***************************************************************************
void CGroupHTML::htmlOBJECT(const CHtmlElement &elm)
@ -6298,8 +6305,18 @@ namespace NLGUI
}
CGroupTable *table = getTable();
if (table)
if (!table)
{
// <td> appears to be outside <table>
return;
}
if (_Cells.empty())
{
// <table> not started
return;
}
if (_Style.hasStyle("padding"))
{
uint32 a;
@ -6308,8 +6325,6 @@ namespace NLGUI
table->CellPadding = a;
}
if (!_Cells.empty())
{
_Cells.back() = new CGroupCell(CViewBase::TCtorParam());
if (_Style.checkStyle("background-repeat", "1") || _Style.checkStyle("background-repeat", "repeat"))
@ -6376,8 +6391,6 @@ namespace NLGUI
renderPseudoElement(":before", elm);
}
}
}
void CGroupHTML::htmlTDend(const CHtmlElement &elm)
{
@ -6391,11 +6404,9 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::htmlTEXTAREA(const CHtmlElement &elm)
{
_PRE.push_back(true);
if (_Forms.empty())
return;
// Got one form ?
if (!(_Forms.empty()))
{
// read general property
string templateName;
@ -6420,14 +6431,11 @@ namespace NLGUI
_TextAreaTemplate = !templateName.empty() ? templateName : DefaultFormTextAreaGroup;
_TextArea = true;
}
_PRE.push_back(true);
}
void CGroupHTML::htmlTEXTAREAend(const CHtmlElement &elm)
{
_TextArea = false;
popIfNotEmpty (_PRE);
if (_Forms.empty())
return;
@ -6440,6 +6448,9 @@ namespace NLGUI
entry.TextArea = textArea;
_Forms.back().Entries.push_back (entry);
}
_TextArea = false;
popIfNotEmpty (_PRE);
}
// ***************************************************************************