|
|
@ -858,21 +858,16 @@ namespace NLGUI
|
|
|
|
CFile::createDirectory( pathName );
|
|
|
|
CFile::createDirectory( pathName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addStylesheetDownload(std::vector<std::string> links)
|
|
|
|
void CGroupHTML::addStylesheetDownload(const std::vector<CHtmlParser::StyleLink> links)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(uint i = 0; i < links.size(); ++i)
|
|
|
|
for(uint i = 0; i < links.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string url = getAbsoluteUrl(links[i]);
|
|
|
|
_StylesheetQueue.push_back(links[i]);
|
|
|
|
std::string local = localImageName(url);
|
|
|
|
std::string url = getAbsoluteUrl(links[i].Url);
|
|
|
|
|
|
|
|
_StylesheetQueue.back().Url = url;
|
|
|
|
|
|
|
|
|
|
|
|
// insert only if url not already downloading
|
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator it = std::find(_StylesheetQueue.begin(), _StylesheetQueue.end(), url);
|
|
|
|
|
|
|
|
if (it == _StylesheetQueue.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_StylesheetQueue.push_back(url);
|
|
|
|
|
|
|
|
// push to the front of the queue
|
|
|
|
// push to the front of the queue
|
|
|
|
Curls.push_front(CDataDownload(url, local, StylesheetType, NULL, "", ""));
|
|
|
|
Curls.push_front(CDataDownload(url, localImageName(url), StylesheetType, NULL, "", ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pumpCurlQueue();
|
|
|
|
pumpCurlQueue();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4184,19 +4179,28 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupHTML::cssDownloadFinished(const std::string &url, const std::string &local)
|
|
|
|
void CGroupHTML::cssDownloadFinished(const std::string &url, const std::string &local)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// remove file from download queue
|
|
|
|
for(std::vector<CHtmlParser::StyleLink>::iterator it = _StylesheetQueue.begin();
|
|
|
|
std::vector<std::string>::iterator it = std::find(_StylesheetQueue.begin(), _StylesheetQueue.end(), url);
|
|
|
|
it != _StylesheetQueue.end(); ++it)
|
|
|
|
if (it != _StylesheetQueue.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_StylesheetQueue.erase(it);
|
|
|
|
if (it->Url == url)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CFile::fileExists(local))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
// read downloaded file into HtmlStyles
|
|
|
|
|
|
|
|
if (CFile::fileExists(local) && it->Index < _HtmlStyles.size())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CIFile in;
|
|
|
|
|
|
|
|
if (in.open(local))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!in.readAll(_HtmlStyles[it->Index]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Failed to read downloaded css file(%s), url(%s)", local.c_str(), url.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
parseStylesheetFile(local);
|
|
|
|
_StylesheetQueue.erase(it);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::renderDocument()
|
|
|
|
void CGroupHTML::renderDocument()
|
|
|
@ -4214,6 +4218,16 @@ namespace NLGUI
|
|
|
|
beginBuild();
|
|
|
|
beginBuild();
|
|
|
|
removeContent();
|
|
|
|
removeContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// process all <style> and <link rel=stylesheet> elements
|
|
|
|
|
|
|
|
for(uint i = 0; i < _HtmlStyles.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_HtmlStyles[i].empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.parseStylesheet(_HtmlStyles[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_HtmlStyles.clear();
|
|
|
|
|
|
|
|
|
|
|
|
std::list<CHtmlElement>::iterator it = _HtmlDOM.Children.begin();
|
|
|
|
std::list<CHtmlElement>::iterator it = _HtmlDOM.Children.begin();
|
|
|
|
while(it != _HtmlDOM.Children.end())
|
|
|
|
while(it != _HtmlDOM.Children.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -4821,9 +4835,6 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
bool CGroupHTML::parseHtml(const std::string &htmlString)
|
|
|
|
bool CGroupHTML::parseHtml(const std::string &htmlString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::vector<std::string> links;
|
|
|
|
|
|
|
|
std::string styleString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHtmlElement *parsedDOM;
|
|
|
|
CHtmlElement *parsedDOM;
|
|
|
|
if (_CurrentHTMLElement == NULL)
|
|
|
|
if (_CurrentHTMLElement == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -4836,16 +4847,28 @@ namespace NLGUI
|
|
|
|
parsedDOM = _CurrentHTMLElement;
|
|
|
|
parsedDOM = _CurrentHTMLElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<CHtmlParser::StyleLink> links;
|
|
|
|
|
|
|
|
|
|
|
|
CHtmlParser parser;
|
|
|
|
CHtmlParser parser;
|
|
|
|
parser.getDOM(htmlString, *parsedDOM, styleString, links);
|
|
|
|
parser.getDOM(htmlString, *parsedDOM, _HtmlStyles, links);
|
|
|
|
|
|
|
|
|
|
|
|
if (!styleString.empty())
|
|
|
|
// <link> elements inserted from lua::parseHtml are ignored
|
|
|
|
|
|
|
|
if (_CurrentHTMLElement == NULL && !links.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_Style.parseStylesheet(styleString);
|
|
|
|
addStylesheetDownload(links);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!links.empty())
|
|
|
|
else if (_CurrentHTMLElement != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
addStylesheetDownload(links);
|
|
|
|
// Called from active element (lua)
|
|
|
|
|
|
|
|
// <style> order is not preserved as document is already being rendered
|
|
|
|
|
|
|
|
for(uint i = 0; i < _HtmlStyles.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_HtmlStyles[i].empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.parseStylesheet(_HtmlStyles[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_HtmlStyles.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this should rarely fail as first element should be <html>
|
|
|
|
// this should rarely fail as first element should be <html>
|
|
|
@ -4856,7 +4879,7 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->Type == CHtmlElement::ELEMENT_NODE && it->Value == "html")
|
|
|
|
if (it->Type == CHtmlElement::ELEMENT_NODE && it->Value == "html")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// more newly parsed childs from <body> into siblings
|
|
|
|
// move newly parsed childs from <body> into siblings
|
|
|
|
if (_CurrentHTMLElement) {
|
|
|
|
if (_CurrentHTMLElement) {
|
|
|
|
std::list<CHtmlElement>::iterator it2 = it->Children.begin();
|
|
|
|
std::list<CHtmlElement>::iterator it2 = it->Children.begin();
|
|
|
|
while(it2 != it->Children.end())
|
|
|
|
while(it2 != it->Children.end())
|
|
|
|