From cbe4bf33d66d7512a22fa69ce946ff11c39b3819 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 30 Apr 2019 22:52:38 +0300 Subject: [PATCH 1/5] Changed: Use table width used min-width and allow table cells to properly fit --HG-- branch : develop --- code/nel/src/gui/group_table.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index b10114a18..45c3b7e1e 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -843,6 +843,19 @@ namespace NLGUI ratio -= _Columns[i].TableRatio; } + // force table width to fit all columns + // if width is set, then use column min width + if (ForceWidthMin > 0) + tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableWidth)); + else + tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableMaxContentWidth)); + + if (tableWidthMax < 0) + tableWidthMax = 0; + + if (tableWidthMax < tableWidthMin) + std::swap(tableWidthMin, tableWidthMax); + // Eval table size with all percent cells resized sint32 tableWidthSizeAfterPercent = tableWidth; for (i=0; i<_Columns.size(); i++) From 536937359197a70218df0069cfd50dbf4a06f8df Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 30 Apr 2019 22:52:38 +0300 Subject: [PATCH 2/5] Changed: Increase default max curl connections to 5 --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 2 +- code/ryzom/client/src/client_cfg.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index c4a5c8a34..dedf3a0bf 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -69,7 +69,7 @@ namespace NLGUI /// Maximum concurrent MultiCurl connections per CGroupHTML instance sint32 curlMaxConnections; - SWebOptions(): curlMaxConnections(2) + SWebOptions(): curlMaxConnections(5) { } }; diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 2e7531d07..52e08463d 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -436,7 +436,7 @@ CClientConfig::CClientConfig() WebIgTrustedDomains.push_back(WebIgMainDomain); WebIgNotifInterval = 10; // time in minutes - CurlMaxConnections = 2; + CurlMaxConnections = 5; CurlCABundle.clear(); RingReleaseNotePath = "http://" + WebIgMainDomain + "/releasenotes_ring/index.php"; From 2e84381bfaf24296438ff4330da0f9d38710b4b6 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 30 Apr 2019 22:52:38 +0300 Subject: [PATCH 3/5] Changed: Do not show spinning cursor for image downloads --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 24baac399..af2b6fd0b 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -2519,9 +2519,10 @@ namespace NLGUI bool CGroupHTML::isBrowsing() { + // do not show spinning cursor for image downloads (!Curls.empty()) return _BrowseNextTime || _PostNextTime || _RenderNextTime || _Browsing || _WaitingForStylesheet || - _CurlWWW || !Curls.empty(); + _CurlWWW; } // *************************************************************************** From 4fcd71d7ba97e97acec0a01f7794817763f0b849 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 30 Apr 2019 22:52:38 +0300 Subject: [PATCH 4/5] Changed: Use lower connection timeout for css/img/data downloads --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 3 ++- code/nel/src/gui/group_html.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index dedf3a0bf..e5a2670a4 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -746,7 +746,7 @@ namespace NLGUI { public: CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage) - : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0) + : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0), ConnectionTimeout(60) { if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype)); } @@ -762,6 +762,7 @@ namespace NLGUI uint32 redirects; FILE *fp; std::vector imgs; + uint32 ConnectionTimeout; }; std::list Curls; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index af2b6fd0b..90fd48c5c 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -546,6 +546,9 @@ namespace NLGUI download.data = new CCurlWWWData(curl, download.url); download.fp = fp; + // initial connection timeout, curl default is 300sec + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, download.ConnectionTimeout); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); curl_easy_setopt(curl, CURLOPT_URL, download.url.c_str()); From ff3b4cfabd6ea4ea4ec9e90e71e6e9e124893a2c Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 30 Apr 2019 22:52:38 +0300 Subject: [PATCH 5/5] Changed: Change long if blocks to early exits --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 701 ++++++++++++++++---------------- 1 file changed, 356 insertions(+), 345 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 90fd48c5c..218ff06cf 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5539,65 +5539,67 @@ 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()) { - float tmpf; - std::string id = elm.getAttribute("id"); - std::string src = elm.getAttribute("src"); + // no 'src' attribute, or empty + return; + } - if (elm.hasNonEmptyAttribute("width")) - getPercentage(_Style.Current.Width, tmpf, elm.getAttribute("width").c_str()); - if (elm.hasNonEmptyAttribute("height")) - getPercentage(_Style.Current.Height, tmpf, elm.getAttribute("height").c_str()); + float tmpf; + std::string id = elm.getAttribute("id"); - // Get the global color name - if (elm.hasAttribute("global_color")) - _Style.Current.GlobalColor = true; + if (elm.hasNonEmptyAttribute("width")) + getPercentage(_Style.Current.Width, tmpf, elm.getAttribute("width").c_str()); + if (elm.hasNonEmptyAttribute("height")) + getPercentage(_Style.Current.Height, tmpf, elm.getAttribute("height").c_str()); - // Tooltip - // keep "alt" attribute for backward compatibility - std::string strtooltip = elm.getAttribute("alt"); - // tooltip - if (elm.hasNonEmptyAttribute("title")) - strtooltip = elm.getAttribute("title"); + // Get the global color name + if (elm.hasAttribute("global_color")) + _Style.Current.GlobalColor = true; - const char *tooltip = NULL; - // note: uses pointer to string data - if (!strtooltip.empty()) - tooltip = strtooltip.c_str(); + // Tooltip + // keep "alt" attribute for backward compatibility + std::string strtooltip = elm.getAttribute("alt"); + // tooltip + if (elm.hasNonEmptyAttribute("title")) + strtooltip = elm.getAttribute("title"); - // Mouse over image - string overSrc = elm.getAttribute("data-over-src"); + const char *tooltip = NULL; + // note: uses pointer to string data + if (!strtooltip.empty()) + tooltip = strtooltip.c_str(); - if (getA() && getParent () && getParent ()->getParent()) - { - string params = "name=" + getId() + "|url=" + getLink (); - addButton(CCtrlButton::PushButton, id, src, src, overSrc, "browse", params.c_str(), tooltip, _Style.Current); - } - else - if (tooltip || !overSrc.empty()) - { - addButton(CCtrlButton::PushButton, id, src, src, overSrc, "", "", tooltip, _Style.Current); - } - else - { - // Get the option to reload (class==reload) - bool reloadImg = false; + // Mouse over image + string overSrc = elm.getAttribute("data-over-src"); - if (elm.hasNonEmptyAttribute("style")) - { - string styleString = elm.getAttribute("style"); - TStyle styles = parseStyle(styleString); - TStyle::iterator it; + if (getA() && getParent () && getParent ()->getParent()) + { + string params = "name=" + getId() + "|url=" + getLink (); + addButton(CCtrlButton::PushButton, id, src, src, overSrc, "browse", params.c_str(), tooltip, _Style.Current); + } + else + if (tooltip || !overSrc.empty()) + { + addButton(CCtrlButton::PushButton, id, src, src, overSrc, "", "", tooltip, _Style.Current); + } + else + { + // Get the option to reload (class==reload) + bool reloadImg = false; - it = styles.find("reload"); - if (it != styles.end() && (*it).second == "1") - reloadImg = true; - } + if (elm.hasNonEmptyAttribute("style")) + { + string styleString = elm.getAttribute("style"); + TStyle styles = parseStyle(styleString); + TStyle::iterator it; - addImage(id, elm.getAttribute("src"), reloadImg, _Style.Current); + it = styles.find("reload"); + if (it != styles.end() && (*it).second == "1") + reloadImg = true; } + + addImage(id, elm.getAttribute("src"), reloadImg, _Style.Current); } } @@ -5619,220 +5621,223 @@ namespace NLGUI // Widget minimal width string minWidth = elm.getAttribute("z_input_width"); - // Get the type - if (elm.hasNonEmptyAttribute("type")) + // + std::string type = trim(elm.getAttribute("type")); + if (type.empty()) { - // Global color flag - if (elm.hasAttribute("global_color")) - _Style.Current.GlobalColor = true; + // no 'type' attribute, or empty + return; + } + + // Global color flag + if (elm.hasAttribute("global_color")) + _Style.Current.GlobalColor = true; - // Tooltip - std::string strtooltip = elm.getAttribute("alt"); - const char *tooltip = NULL; - // note: uses pointer to strtooltip data - if (!strtooltip.empty()) - tooltip = strtooltip.c_str(); + // Tooltip + std::string strtooltip = elm.getAttribute("alt"); + const char *tooltip = NULL; + // note: uses pointer to strtooltip data + if (!strtooltip.empty()) + tooltip = strtooltip.c_str(); - string type = toLower(elm.getAttribute("type")); - if (type == "image") - { - // The submit button - string name = elm.getAttribute("name"); - string normal = elm.getAttribute("src"); - string pushed; - string over; + if (type == "image") + { + // The submit button + string name = elm.getAttribute("name"); + string normal = elm.getAttribute("src"); + string pushed; + string over; - // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" - string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image"; + // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" + string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image"; - // Add the ctrl button - addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - "html_submit_form", param.c_str(), tooltip, _Style.Current); - } - else if (type == "button" || type == "submit") + // Add the ctrl button + addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, + "html_submit_form", param.c_str(), tooltip, _Style.Current); + } + else if (type == "button" || type == "submit") + { + // The submit button + string name = elm.getAttribute("name"); + string normal = elm.getAttribute("src"); + string text = elm.getAttribute("value"); + string pushed; + string over; + + string buttonTemplate(!templateName.empty() ? templateName : DefaultButtonGroup ); + + // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" + string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit"; + if (!text.empty()) { - // The submit button - string name = elm.getAttribute("name"); - string normal = elm.getAttribute("src"); - string text = elm.getAttribute("value"); - string pushed; - string over; + // escape AH param separator + string tmp = text; + while(NLMISC::strFindReplace(tmp, "|", "|")) + ; + param = param + "|submit_button_value=" + tmp; + } - string buttonTemplate(!templateName.empty() ? templateName : DefaultButtonGroup ); + // Add the ctrl button + if (!_Paragraph) + { + newParagraph (0); + paragraphChange (); + } - // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" - string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit"; - if (!text.empty()) - { - // escape AH param separator - string tmp = text; - while(NLMISC::strFindReplace(tmp, "|", "|")) - ; - param = param + "|submit_button_value=" + tmp; - } + typedef pair TTmplParam; + vector tmplParams; + tmplParams.push_back(TTmplParam("id", name)); + tmplParams.push_back(TTmplParam("onclick", "html_submit_form")); + tmplParams.push_back(TTmplParam("onclick_param", param)); + //tmplParams.push_back(TTmplParam("text", text)); + tmplParams.push_back(TTmplParam("active", "true")); + if (!minWidth.empty()) + tmplParams.push_back(TTmplParam("wmin", minWidth)); + CInterfaceGroup *buttonGroup = CWidgetManager::getInstance()->getParser()->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); + if (buttonGroup) + { // Add the ctrl button - if (!_Paragraph) - { - newParagraph (0); - paragraphChange (); - } - - typedef pair TTmplParam; - vector tmplParams; - tmplParams.push_back(TTmplParam("id", name)); - tmplParams.push_back(TTmplParam("onclick", "html_submit_form")); - tmplParams.push_back(TTmplParam("onclick_param", param)); - //tmplParams.push_back(TTmplParam("text", text)); - tmplParams.push_back(TTmplParam("active", "true")); - if (!minWidth.empty()) - tmplParams.push_back(TTmplParam("wmin", minWidth)); - CInterfaceGroup *buttonGroup = CWidgetManager::getInstance()->getParser()->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); - if (buttonGroup) + CCtrlTextButton *ctrlButton = dynamic_cast(buttonGroup->getCtrl("button")); + if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); + if (ctrlButton) { + ctrlButton->setModulateGlobalColorAll (_Style.Current.GlobalColor); - // Add the ctrl button - CCtrlTextButton *ctrlButton = dynamic_cast(buttonGroup->getCtrl("button")); - if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); - if (ctrlButton) + // Translate the tooltip + if (tooltip) { - ctrlButton->setModulateGlobalColorAll (_Style.Current.GlobalColor); - - // Translate the tooltip - if (tooltip) + if (CI18N::hasTranslation(tooltip)) { - if (CI18N::hasTranslation(tooltip)) - { - ctrlButton->setDefaultContextHelp(CI18N::get(tooltip)); - } - else - { - ctrlButton->setDefaultContextHelp(ucstring(tooltip)); - } + ctrlButton->setDefaultContextHelp(CI18N::get(tooltip)); + } + else + { + ctrlButton->setDefaultContextHelp(ucstring(tooltip)); } + } - ctrlButton->setText(ucstring::makeFromUtf8(text)); + ctrlButton->setText(ucstring::makeFromUtf8(text)); - setTextButtonStyle(ctrlButton, _Style.Current); - } - getParagraph()->addChild (buttonGroup); - paragraphChange (); + setTextButtonStyle(ctrlButton, _Style.Current); } + getParagraph()->addChild (buttonGroup); + paragraphChange (); } - else if (type == "text") - { - // Get the string name - string name = elm.getAttribute("name"); - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); + } + else if (type == "text") + { + // Get the string name + string name = elm.getAttribute("name"); + ucstring ucValue; + ucValue.fromUtf8(elm.getAttribute("value")); + + uint size = 120; + uint maxlength = 1024; + if (elm.hasNonEmptyAttribute("size")) + fromString(elm.getAttribute("size"), size); + if (elm.hasNonEmptyAttribute("maxlength")) + fromString(elm.getAttribute("maxlength"), maxlength); - uint size = 120; - uint maxlength = 1024; - if (elm.hasNonEmptyAttribute("size")) - fromString(elm.getAttribute("size"), size); - if (elm.hasNonEmptyAttribute("maxlength")) - fromString(elm.getAttribute("maxlength"), maxlength); - - string textTemplate(!templateName.empty() ? templateName : DefaultFormTextGroup); - // Add the editbox - CInterfaceGroup *textArea = addTextArea (textTemplate, name.c_str (), 1, size/12, false, ucValue, maxlength); - if (textArea) - { - // Add the text area to the form - CGroupHTML::CForm::CEntry entry; - entry.Name = name; - entry.TextArea = textArea; - _Forms.back().Entries.push_back (entry); - } - } - else if (type == "checkbox" || type == "radio") + string textTemplate(!templateName.empty() ? templateName : DefaultFormTextGroup); + // Add the editbox + CInterfaceGroup *textArea = addTextArea (textTemplate, name.c_str (), 1, size/12, false, ucValue, maxlength); + if (textArea) { - renderPseudoElement(":before", elm); + // Add the text area to the form + CGroupHTML::CForm::CEntry entry; + entry.Name = name; + entry.TextArea = textArea; + _Forms.back().Entries.push_back (entry); + } + } + else if (type == "checkbox" || type == "radio") + { + renderPseudoElement(":before", elm); - CCtrlButton::EType btnType; - string name = elm.getAttribute("name"); - string normal = elm.getAttribute("src"); - string pushed; - string over; - ucstring ucValue = ucstring("on"); - bool checked = elm.hasAttribute("checked"); + CCtrlButton::EType btnType; + string name = elm.getAttribute("name"); + string normal = elm.getAttribute("src"); + string pushed; + string over; + ucstring ucValue = ucstring("on"); + bool checked = elm.hasAttribute("checked"); - // TODO: unknown if empty attribute should override or not - if (elm.hasNonEmptyAttribute("value")) - ucValue.fromUtf8(elm.getAttribute("value")); + // TODO: unknown if empty attribute should override or not + if (elm.hasNonEmptyAttribute("value")) + ucValue.fromUtf8(elm.getAttribute("value")); - if (type == "radio") - { - btnType = CCtrlButton::RadioButton; - normal = DefaultRadioButtonBitmapNormal; - pushed = DefaultRadioButtonBitmapPushed; - over = DefaultRadioButtonBitmapOver; - } - else - { - btnType = CCtrlButton::ToggleButton; - normal = DefaultCheckBoxBitmapNormal; - pushed = DefaultCheckBoxBitmapPushed; - over = DefaultCheckBoxBitmapOver; - } + if (type == "radio") + { + btnType = CCtrlButton::RadioButton; + normal = DefaultRadioButtonBitmapNormal; + pushed = DefaultRadioButtonBitmapPushed; + over = DefaultRadioButtonBitmapOver; + } + else + { + btnType = CCtrlButton::ToggleButton; + normal = DefaultCheckBoxBitmapNormal; + pushed = DefaultCheckBoxBitmapPushed; + over = DefaultCheckBoxBitmapOver; + } - // Add the ctrl button - CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, _Style.Current); - if (checkbox) + // Add the ctrl button + CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, _Style.Current); + if (checkbox) + { + if (btnType == CCtrlButton::RadioButton) { - if (btnType == CCtrlButton::RadioButton) + // override with 'id' because radio buttons share same name + if (!id.empty()) + checkbox->setId(id); + + // group together buttons with same name + CForm &form = _Forms.back(); + bool notfound = true; + for (uint i=0; isetId(id); - - // group together buttons with same name - CForm &form = _Forms.back(); - bool notfound = true; - for (uint i=0; igetType() == CCtrlButton::RadioButton) - { - checkbox->initRBRefFromRadioButton(form.Entries[i].Checkbox); - notfound = false; - break; - } - } - if (notfound) + if (form.Entries[i].Name == name && form.Entries[i].Checkbox->getType() == CCtrlButton::RadioButton) { - // this will start a new group (initRBRef() would take first button in group container otherwise) - checkbox->initRBRefFromRadioButton(checkbox); + checkbox->initRBRefFromRadioButton(form.Entries[i].Checkbox); + notfound = false; + break; } } + if (notfound) + { + // this will start a new group (initRBRef() would take first button in group container otherwise) + checkbox->initRBRefFromRadioButton(checkbox); + } + } - checkbox->setPushed (checked); + checkbox->setPushed (checked); - // Add the button to the form - CGroupHTML::CForm::CEntry entry; - entry.Name = name; - entry.Value = decodeHTMLEntities(ucValue); - entry.Checkbox = checkbox; - _Forms.back().Entries.push_back (entry); - } - renderPseudoElement(":after", elm); + // Add the button to the form + CGroupHTML::CForm::CEntry entry; + entry.Name = name; + entry.Value = decodeHTMLEntities(ucValue); + entry.Checkbox = checkbox; + _Forms.back().Entries.push_back (entry); } - else if (type == "hidden") + renderPseudoElement(":after", elm); + } + else if (type == "hidden") + { + if (elm.hasNonEmptyAttribute("name")) { - if (elm.hasNonEmptyAttribute("name")) - { - // Get the name - string name = elm.getAttribute("name"); - - // Get the value - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); - - // Add an entry - CGroupHTML::CForm::CEntry entry; - entry.Name = name; - entry.Value = decodeHTMLEntities(ucValue); - _Forms.back().Entries.push_back (entry); - } + // Get the name + string name = elm.getAttribute("name"); + + // Get the value + ucstring ucValue; + ucValue.fromUtf8(elm.getAttribute("value")); + + // Add an entry + CGroupHTML::CForm::CEntry entry; + entry.Name = name; + entry.Value = decodeHTMLEntities(ucValue); + _Forms.back().Entries.push_back (entry); } } } @@ -5908,31 +5913,33 @@ 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()) { - // only first http-equiv="refresh" should be handled - if (_RefreshUrl.empty() && httpEquiv == "refresh") - { - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - double timeSec = times.thisFrameMs / 1000.0f; + return; + } - string::size_type pos = httpContent.find_first_of(";"); - if (pos == string::npos) - { - fromString(httpContent, _NextRefreshTime); - _RefreshUrl = _URL; - } - else - { - fromString(httpContent.substr(0, pos), _NextRefreshTime); + // only first http-equiv="refresh" should be handled + if (_RefreshUrl.empty() && httpEquiv == "refresh") + { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + double timeSec = times.thisFrameMs / 1000.0f; - pos = toLower(httpContent).find("url="); - if (pos != string::npos) - _RefreshUrl = getAbsoluteUrl(httpContent.substr(pos + 4)); - } + string::size_type pos = httpContent.find_first_of(";"); + if (pos == string::npos) + { + fromString(httpContent, _NextRefreshTime); + _RefreshUrl = _URL; + } + else + { + fromString(httpContent.substr(0, pos), _NextRefreshTime); - _NextRefreshTime += timeSec; + pos = toLower(httpContent).find("url="); + if (pos != string::npos) + _RefreshUrl = getAbsoluteUrl(httpContent.substr(pos + 4)); } + + _NextRefreshTime += timeSec; } } @@ -6298,85 +6305,91 @@ namespace NLGUI } CGroupTable *table = getTable(); - if (table) + if (!table) { - if (_Style.hasStyle("padding")) - { - uint32 a; - // TODO: cssLength - if (fromString(_Style.getStyle("padding"), a)) - table->CellPadding = a; - } + // appears to be outside + return; + } - if (!_Cells.empty()) - { - _Cells.back() = new CGroupCell(CViewBase::TCtorParam()); + if (_Cells.empty()) + { + //
not started + return; + } - if (_Style.checkStyle("background-repeat", "1") || _Style.checkStyle("background-repeat", "repeat")) - _Cells.back()->setTextureTile(true); + if (_Style.hasStyle("padding")) + { + uint32 a; + // TODO: cssLength + if (fromString(_Style.getStyle("padding"), a)) + table->CellPadding = a; + } - if (_Style.checkStyle("background-scale", "1") || _Style.checkStyle("background-size", "cover")) - _Cells.back()->setTextureScale(true); + _Cells.back() = new CGroupCell(CViewBase::TCtorParam()); - if (_Style.hasStyle("background-image")) - { - string image = _Style.getStyle("background-image"); + if (_Style.checkStyle("background-repeat", "1") || _Style.checkStyle("background-repeat", "repeat")) + _Cells.back()->setTextureTile(true); - string::size_type texExt = toLower(image).find("url("); - // Url image - if (texExt != string::npos) - { - // Remove url() - image = image.substr(4, image.size()-5); - addImageDownload(image, _Cells.back()); - // Image in BNP - } - else - { - _Cells.back()->setTexture(image); - } - } + if (_Style.checkStyle("background-scale", "1") || _Style.checkStyle("background-size", "cover")) + _Cells.back()->setTextureScale(true); - if (elm.hasNonEmptyAttribute("colspan")) - fromString(elm.getAttribute("colspan"), _Cells.back()->ColSpan); - if (elm.hasNonEmptyAttribute("rowspan")) - fromString(elm.getAttribute("rowspan"), _Cells.back()->RowSpan); - - _Cells.back()->BgColor = _CellParams.back().BgColor; - _Cells.back()->Align = _CellParams.back().Align; - _Cells.back()->VAlign = _CellParams.back().VAlign; - _Cells.back()->LeftMargin = _CellParams.back().LeftMargin; - _Cells.back()->NoWrap = _CellParams.back().NoWrap; - _Cells.back()->ColSpan = std::max(1, _Cells.back()->ColSpan); - _Cells.back()->RowSpan = std::max(1, _Cells.back()->RowSpan); - - float temp; - if (_Style.hasStyle("width")) - getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, _Style.getStyle("width").c_str()); - else if (elm.hasNonEmptyAttribute("width")) - getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, elm.getAttribute("width").c_str()); - - if (_Style.hasStyle("height")) - getPercentage (_Cells.back()->Height, temp, _Style.getStyle("height").c_str()); - else if (elm.hasNonEmptyAttribute("height")) - getPercentage (_Cells.back()->Height, temp, elm.getAttribute("height").c_str()); + if (_Style.hasStyle("background-image")) + { + string image = _Style.getStyle("background-image"); + + string::size_type texExt = toLower(image).find("url("); + // Url image + if (texExt != string::npos) + { + // Remove url() + image = image.substr(4, image.size()-5); + addImageDownload(image, _Cells.back()); + // Image in BNP + } + else + { + _Cells.back()->setTexture(image); + } + } - _Cells.back()->NewLine = getTR(); - table->addChild (_Cells.back()); + if (elm.hasNonEmptyAttribute("colspan")) + fromString(elm.getAttribute("colspan"), _Cells.back()->ColSpan); + if (elm.hasNonEmptyAttribute("rowspan")) + fromString(elm.getAttribute("rowspan"), _Cells.back()->RowSpan); - // reusing indent pushed by table - _Indent.back() = 0; + _Cells.back()->BgColor = _CellParams.back().BgColor; + _Cells.back()->Align = _CellParams.back().Align; + _Cells.back()->VAlign = _CellParams.back().VAlign; + _Cells.back()->LeftMargin = _CellParams.back().LeftMargin; + _Cells.back()->NoWrap = _CellParams.back().NoWrap; + _Cells.back()->ColSpan = std::max(1, _Cells.back()->ColSpan); + _Cells.back()->RowSpan = std::max(1, _Cells.back()->RowSpan); - newParagraph(TDBeginSpace); - // indent is already 0, getParagraph()->setMarginLeft(0); // maybe setIndent(0) if LI is using one + float temp; + if (_Style.hasStyle("width")) + getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, _Style.getStyle("width").c_str()); + else if (elm.hasNonEmptyAttribute("width")) + getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, elm.getAttribute("width").c_str()); + + if (_Style.hasStyle("height")) + getPercentage (_Cells.back()->Height, temp, _Style.getStyle("height").c_str()); + else if (elm.hasNonEmptyAttribute("height")) + getPercentage (_Cells.back()->Height, temp, elm.getAttribute("height").c_str()); - // Reset TR flag - if (!_TR.empty()) - _TR.back() = false; + _Cells.back()->NewLine = getTR(); + table->addChild (_Cells.back()); - renderPseudoElement(":before", elm); - } - } + // reusing indent pushed by table + _Indent.back() = 0; + + newParagraph(TDBeginSpace); + // indent is already 0, getParagraph()->setMarginLeft(0); // maybe setIndent(0) if LI is using one + + // Reset TR flag + if (!_TR.empty()) + _TR.back() = false; + + renderPseudoElement(":before", elm); } void CGroupHTML::htmlTDend(const CHtmlElement &elm) @@ -6391,43 +6404,38 @@ namespace NLGUI // *************************************************************************** void CGroupHTML::htmlTEXTAREA(const CHtmlElement &elm) { - _PRE.push_back(true); - - // Got one form ? - if (!(_Forms.empty())) - { - // read general property - string templateName; + if (_Forms.empty()) + return; - // Widget template name - if (elm.hasNonEmptyAttribute("z_input_tmpl")) - templateName = elm.getAttribute("z_input_tmpl"); + // read general property + string templateName; - // Get the string name - _TextAreaName.clear(); - _TextAreaRow = 1; - _TextAreaCols = 10; - _TextAreaContent.clear(); - _TextAreaMaxLength = 1024; - if (elm.hasNonEmptyAttribute("name")) - _TextAreaName = elm.getAttribute("name"); - if (elm.hasNonEmptyAttribute("rows")) - fromString(elm.getAttribute("rows"), _TextAreaRow); - if (elm.hasNonEmptyAttribute("cols")) - fromString(elm.getAttribute("cols"), _TextAreaCols); - if (elm.hasNonEmptyAttribute("maxlength")) - fromString(elm.getAttribute("maxlength"), _TextAreaMaxLength); + // Widget template name + if (elm.hasNonEmptyAttribute("z_input_tmpl")) + templateName = elm.getAttribute("z_input_tmpl"); - _TextAreaTemplate = !templateName.empty() ? templateName : DefaultFormTextAreaGroup; - _TextArea = true; - } + // Get the string name + _TextAreaName.clear(); + _TextAreaRow = 1; + _TextAreaCols = 10; + _TextAreaContent.clear(); + _TextAreaMaxLength = 1024; + if (elm.hasNonEmptyAttribute("name")) + _TextAreaName = elm.getAttribute("name"); + if (elm.hasNonEmptyAttribute("rows")) + fromString(elm.getAttribute("rows"), _TextAreaRow); + if (elm.hasNonEmptyAttribute("cols")) + fromString(elm.getAttribute("cols"), _TextAreaCols); + if (elm.hasNonEmptyAttribute("maxlength")) + fromString(elm.getAttribute("maxlength"), _TextAreaMaxLength); + + _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); } // ***************************************************************************