Added rendering of html string

This commit is contained in:
Adam Fowler 2020-01-01 10:44:08 -05:00
parent a3f0c1ca14
commit eb433d8d66
2 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,9 @@
/*
* Copyright 2019-2020 Haiku Inc.
* All rights reserved. Distributed under the terms of the BSD 3-clause license.
* Constributors
* 2019-2020 Adam Fowler <adamfowleruk@gmail.com>
*/
#include "container_haiku.h"
#include <string>
@ -67,9 +73,17 @@ LiteHtmlView::RenderFile(const char* localFilePath)
set_base_url(dirPath.Path());
//std::cout << " base url now:" << m_base_url << std::endl;
RenderHTML(html);
}
void
LiteHtmlView::RenderHTML(const std::string& htmlText)
{
std::cout << "RenderHTML" << std::endl;
// now use this string
m_html = litehtml::document::createFromString(
html.c_str(), this, fContext);
htmlText.c_str(), this, fContext);
if (m_html)
{
std::cout << "Successfully read html" << std::endl;

View File

@ -1,3 +1,9 @@
/*
* Copyright 2019-2020 Haiku Inc.
* All rights reserved. Distributed under the terms of the BSD 3-clause license.
* Constributors
* 2019-2020 Adam Fowler <adamfowleruk@gmail.com>
*/
#ifndef LITEHTMLVIEW_H
#define LITEHTMLVIEW_H
@ -26,6 +32,7 @@ public:
void SetContext(litehtml::context* ctx);
void RenderFile(const char* localFilePath);
void RenderHTML(const std::string& htmlText);
virtual litehtml::uint_ptr create_font(const litehtml::tchar_t* faceName, int size, int weight, litehtml::font_style italic, unsigned int decoration, litehtml::font_metrics* fm) override;