From 2191d21bce8dab5cda243da56d555c5a0cb7f13d Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 13 Feb 2020 15:39:18 +0200 Subject: [PATCH] Fixed: html button with empty formid attribute --- code/nel/include/nel/gui/group_html.h | 3 +++ code/nel/src/gui/group_html.cpp | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index d1091cec0..590c43a89 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -683,6 +683,8 @@ namespace NLGUI std::vector Entries; }; std::vector _Forms; + // if
element has been closed or not + bool _FormOpen; // submit buttons added to from struct SFormSubmitButton @@ -953,6 +955,7 @@ namespace NLGUI //void htmlEM(const CHtmlElement &elm); void htmlFONT(const CHtmlElement &elm); void htmlFORM(const CHtmlElement &elm); + void htmlFORMend(const CHtmlElement &elm); void htmlH(const CHtmlElement &elm); void htmlHend(const CHtmlElement &elm); void htmlHEAD(const CHtmlElement &elm); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9bebac4e5..166da4719 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1201,7 +1201,7 @@ namespace NLGUI case HTML_DT: htmlDTend(elm); break; case HTML_EM: renderPseudoElement(":after", elm);break; case HTML_FONT: break; - case HTML_FORM: renderPseudoElement(":after", elm);break; + case HTML_FORM: htmlFORMend(elm); break; case HTML_H1://no-break case HTML_H2://no-break case HTML_H3://no-break @@ -1456,6 +1456,7 @@ namespace NLGUI _RenderNextTime = false; _WaitingForStylesheet = false; _AutoIdSeq = 0; + _FormOpen = false; // Register CWidgetManager::getInstance()->registerClockMsgTarget(this); @@ -3274,6 +3275,7 @@ namespace NLGUI _Cells.clear(); _TR.clear(); _Forms.clear(); + _FormOpen = false; _FormSubmit.clear(); _Groups.clear(); _Divs.clear(); @@ -5579,6 +5581,11 @@ namespace NLGUI std::string tooltip = elm.getAttribute("tooltip"); bool disabled = elm.hasAttribute("disabled"); + if (formId.empty() && _FormOpen) + { + formId = _Forms.back().id; + } + if (!formAction.empty()) { formAction = getAbsoluteUrl(formAction); @@ -5851,6 +5858,8 @@ namespace NLGUI // *************************************************************************** void CGroupHTML::htmlFORM(const CHtmlElement &elm) { + _FormOpen = true; + // Build the form CGroupHTML::CForm form; // id check is case sensitive and auto id's are uppercase @@ -5875,6 +5884,12 @@ namespace NLGUI renderPseudoElement(":before", elm); } + void CGroupHTML::htmlFORMend(const CHtmlElement &elm) + { + _FormOpen = false; + renderPseudoElement(":after", elm); + } + // *************************************************************************** void CGroupHTML::htmlH(const CHtmlElement &elm) {