From 15433b263bd4ee5607d25d1e9d8f24baa6b4d075 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 13 Feb 2020 12:55:29 +0200 Subject: [PATCH 1/3] Changed: Add proper ids to groups in webig --- code/nel/include/nel/gui/group_html.h | 4 ++++ code/nel/src/gui/group_html.cpp | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 17a138eee..c240caa63 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -357,6 +357,10 @@ namespace NLGUI // Delete page content and prepare next page void removeContent (); + // Counter to number html elements without id attribute + uint32 getNextAutoIdSeq() { return _AutoIdSeq++; } + uint32 _AutoIdSeq; + // Current URL for relative links in page std::string _URL; // Current URL diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 23bd2e671..592b7da70 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1443,6 +1443,7 @@ namespace NLGUI _LastRefreshTime = 0.0; _RenderNextTime = false; _WaitingForStylesheet = false; + _AutoIdSeq = 0; // Register CWidgetManager::getInstance()->registerClockMsgTarget(this); @@ -2531,6 +2532,7 @@ namespace NLGUI { // Add a new paragraph CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); + newParagraph->setId(getCurrentGroup()->getId() + ":PARAGRAPH" + toString(getNextAutoIdSeq())); newParagraph->setResizeFromChildH(true); newParagraph->setMarginLeft(getIndent()); @@ -3251,6 +3253,7 @@ namespace NLGUI _ReadingHeadTag = false; _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; + _AutoIdSeq = 0; paragraphChange (); @@ -4327,6 +4330,7 @@ namespace NLGUI if (!_GroupListAdaptor) { _GroupListAdaptor = new CGroupListAdaptor(CViewBase::TCtorParam()); // deleted by the list + _GroupListAdaptor->setId(getList()->getId() + ":GLA"); _GroupListAdaptor->setResizeFromChildH(true); getList()->addChild (_GroupListAdaptor, true); } @@ -5643,6 +5647,8 @@ namespace NLGUI { string style = elm.getAttribute("style"); string id = elm.getAttribute("id"); + if (id.empty()) + id = "DIV" + toString(getNextAutoIdSeq()); typedef pair TTmplParam; vector tmplParams; @@ -5675,10 +5681,10 @@ namespace NLGUI parentId = _Paragraph->getId(); } - CInterfaceGroup *inst = CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName, this->_Id+":"+id, tmplParams); + CInterfaceGroup *inst = CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName, parentId, tmplParams); if (inst) { - inst->setId(this->_Id+":"+id); + inst->setId(parentId+":"+id); inst->updateCoords(); if (haveParentDiv) { @@ -6607,6 +6613,10 @@ namespace NLGUI CGroupTable *table = new CGroupTable(TCtorParam()); table->BgColor = _CellParams.back().BgColor; + if (elm.hasNonEmptyAttribute("id")) + table->setId(getCurrentGroup()->getId() + ":" + elm.getAttribute("id")); + else + table->setId(getCurrentGroup()->getId() + ":TABLE" + toString(getNextAutoIdSeq())); // TODO: border-spacing: 2em; { @@ -6767,6 +6777,10 @@ namespace NLGUI } _Cells.back() = new CGroupCell(CViewBase::TCtorParam()); + if (elm.hasNonEmptyAttribute("id")) + _Cells.back()->setId(getCurrentGroup()->getId() + ":TD" + elm.getAttribute("id")); + else + _Cells.back()->setId(getCurrentGroup()->getId() + ":TD" + toString(getNextAutoIdSeq())); if (_Style.checkStyle("background-repeat", "repeat")) _Cells.back()->setTextureTile(true); From 8f59a71e3c828b1e50182b15f48feb955f8f715e Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 13 Feb 2020 15:39:18 +0200 Subject: [PATCH 2/3] 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 c240caa63..0a4e26c79 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -680,6 +680,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 @@ -950,6 +952,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 592b7da70..0a6a1b2c8 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1189,7 +1189,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 @@ -1444,6 +1444,7 @@ namespace NLGUI _RenderNextTime = false; _WaitingForStylesheet = false; _AutoIdSeq = 0; + _FormOpen = false; // Register CWidgetManager::getInstance()->registerClockMsgTarget(this); @@ -3240,6 +3241,7 @@ namespace NLGUI _Cells.clear(); _TR.clear(); _Forms.clear(); + _FormOpen = false; _FormSubmit.clear(); _Groups.clear(); _Divs.clear(); @@ -5545,6 +5547,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); @@ -5817,6 +5824,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 @@ -5841,6 +5850,12 @@ namespace NLGUI renderPseudoElement(":before", elm); } + void CGroupHTML::htmlFORMend(const CHtmlElement &elm) + { + _FormOpen = false; + renderPseudoElement(":after", elm); + } + // *************************************************************************** void CGroupHTML::htmlH(const CHtmlElement &elm) { From 7856e937238589d2fb3181b7ee28bfe68fac54a0 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 13 Feb 2020 16:04:41 +0200 Subject: [PATCH 3/3] Fixed: ah:html_submit_form without caller object --- .../ryzom/client/src/interface_v3/action_handler_help.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index ac1480e0c..f15985706 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -1116,8 +1116,8 @@ class CHandlerHTMLSubmitForm : public IActionHandler return; } - sint32 x = pCaller->getEventX(); - sint32 y = pCaller->getEventY(); + sint32 x = pCaller ? pCaller->getEventX() : 0; + sint32 y = pCaller ? pCaller->getEventY() : 0; CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); { @@ -1127,6 +1127,10 @@ class CHandlerHTMLSubmitForm : public IActionHandler { groupHtml->submitForm(button, x, y); } + else + { + nlwarning("CGroupHTML with id '%s' not found.", container.c_str()); + } } } };