From 388110a44123e60e00f3c57848c3ea1dae1e7959 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 13 Apr 2015 20:51:39 +0300 Subject: [PATCH] Remove libwww dependency from CGroupHTML::addLink() signature --- code/nel/include/nel/gui/group_html.h | 3 ++- code/nel/src/gui/group_html.cpp | 25 +++++++++++++------------ code/nel/src/gui/libwww.cpp | 5 ++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 920c58948..7b974257a 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -228,7 +228,7 @@ namespace NLGUI virtual void addText (const char * buf, int len); // A link has been parsed - virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); + virtual void addLink (uint element_number, const BOOL *present, const char **value); // A new begin HTML element has been parsed ( for exemple) virtual void beginElement (uint element_number, const BOOL *present, const char **value); @@ -699,6 +699,7 @@ namespace NLGUI void checkImageDownload(); void addImageDownload(const std::string &url, CViewBase *img); std::string localImageName(const std::string &url); + std::string getAbsoluteUrl(const std::string &url); bool isTrustedDomain(const std::string &domain); void setImage(CViewBase *view, const std::string &file); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 4dd9ea7ac..f1c699a63 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -570,7 +570,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTChildAnchor *anchor, const BOOL *present, const char **value) + void CGroupHTML::addLink (uint element_number, const BOOL *present, const char **value) { if (_Browsing) { @@ -591,16 +591,8 @@ namespace NLGUI } else { - HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor); - if (dest) - { - C3WSmartPtr uri = HTAnchor_address(dest); - _Link.push_back ((const char*)uri); - } - else - { - _Link.push_back(""); - } + // convert href from "?key=val" into "http://domain.com/?key=val" + _Link.push_back(getAbsoluteUrl(suri)); } for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++) @@ -4516,7 +4508,7 @@ namespace NLGUI beginElement(element_number, &present[0], &value[0]); if (element_number == HTML_A) - addLink(element_number, 0, NULL, &present[0], &value[0]); + addLink(element_number, &present[0], &value[0]); return 0; } @@ -4650,6 +4642,15 @@ namespace NLGUI return result; } + // *************************************************************************** + std::string CGroupHTML::getAbsoluteUrl(const std::string &url) + { + if (HTURL_isAbsolute(url.c_str())) + return url; + + return std::string(HTParse(url.c_str(), _URL.c_str(), PARSE_ALL)); + } + // *************************************************************************** // CGroupHTML::CStyleParams style; // style.FontSize; // font-size: 10px; diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 14e921aea..09f3a0cea 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -322,7 +322,10 @@ namespace NLGUI const char ** value) { // Do the work in the class - me->Parent->addLink (element_number, attribute_number, anchor, present, value); + if (element_number == HTML_A) + { + me->Parent->addLink (element_number, present, value); + } } // ***************************************************************************