Coder Social home page Coder Social logo

litehtml / litehtml Goto Github PK

View Code? Open in Web Editor NEW
1.8K 87.0 226.0 9.37 MB

Fast and lightweight HTML/CSS rendering engine

Home Page: http://www.litehtml.com/

License: BSD 3-Clause "New" or "Revised" License

C++ 42.53% C 27.62% CMake 0.23% Ragel 3.00% HTML 26.55% CSS 0.08%
html rendering-engine gumbo-parser css-properties gumbo css-standards litehtml css html-renderer

litehtml's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

litehtml's Issues

strings.h not available in msvc 2015

I can't compile litehtml since there is no strings.h on msvc.
This can be solved by using:

#ifndef _WIN32
#include <strings.h>
#endif

Should be added to every sourcefile including strings.h

stylesheet parsing bug? @charset "UTF-8";

while parsing the following stylesheet:

<style type="text/css">
	@charset "UTF-8";
	body
	{
		margin:0;
		padding:0;
		color:#303030;
		background-color:#2d323f;
	}

	img.screenshot
	{
		border:0px;
		padding:0px;
	}
</style>

the stylesheet parser will perfectly skip the "body" section and go directly to its following part "img.screenshot".

while debugging i found the problem is here in stylesheet.cpp (void litehtml::css::parse_stylesheet)

while(pos != tstring::npos && text[pos] == _t('@'))
{
	tstring::size_type sPos = pos;
	pos = text.find_first_of(_t("{"), pos); // <---- why not trying to find matching ';' for @charset 'UTF-8'
	if(pos != tstring::npos && text[pos] == _t('{'))
	{
		pos = find_close_bracket(text, pos, _t('{'), _t('}'));
	}
	if(pos != tstring::npos)
	{
		parse_atrule(text.substr(sPos, pos - sPos + 1), baseurl, doc, media);
	} else
	{
		parse_atrule(text.substr(sPos), baseurl, doc, media);
	}

	if(pos != tstring::npos)
	{
		pos = text.find_first_not_of(_t(" \n\r\t"), pos + 1);
	}
}

thank you.

Newbie help!

Ok, just trying to get this working, and everything is compiling and I even have some text rendering, but all it seems to be doing is stripping out the html tags, eg: this:

<html><body><h1>Hello World!</h1><p>Paragraph1<br><br><p>Paragraph2</body></html>

...simply draws...

Hello World!Paragraph1Paragraph2

...on a singe line.

I'm not sure I'm using it right, as the docs are a little thin. Apart from implementing document_container, the only document methods I'm using are render(), draw() and createFromUTF8(). Is this all I need to do?

Thanks in advance for any hints you can provide.

background-position: right bottom doesn't work

I'm trying to make a background image that floats in the lower bottom corner of the screen, but unfortunately it looks like background-position: right bottom option is just ignored. Am I right?

If I'm not right maybe my draw_background implementation is wrong. I'm using position_x and position_y and that doesn't work.

cmake did not defaults to any build type, what causes build error

Hello!

Cmake scripts did not defaults to any build type, and no any compiler flags applied, what causes not very understandable build errors.
I.e. it will be good to have something like in CMakeLists.txt:

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "No build type selected, default to Debug")
  set(CMAKE_BUILD_TYPE "Debug")
endif()

In this case no errors will be produces, what are more user friendly.

Add better support for ordered lists

Currently litehtml does not render the ordinal of a list item in an ordered list. It would be nice to have at least support for list_style_type_decimal. I'd like to use litehtml with a markdown to html converter and ordered lists seem to be the only thing that is missing.

I'd suggest to extend the list_marker struct with a font and a value member, such that document_container::draw_list_marker can cope with list_style_type_decimal.

I extended litehtml::html_tag::draw_list_marker in a prototypical manner (see nafest@d42d938) to set these two members, but I am not quite sure if this is the right place for this logic.

vw and vh are not supported

First of all, thank you very much for your awesome engine. I've decided to use it in my http://github.com/bigfatbrowncat/zetes project. And I'll donate some money to you as soon as I earn some with it :)

But there is a small feature that I miss much. It's the viewport units vw and vh. http://www.w3schools.com/cssref/css_units.asp, http://caniuse.com/#feat=viewport-units. It's very useful especially when you try to make a solid web-application-like UI with relative positioning of some views.

As I found out in your code, implementing it is not too hard, but I'm afraid of doing it by myself - no one knows the code better than the author.

Would you be so kind to do that?

box-shadow support

Basicly i dont really need to add anything extra as the title says it all 😄

'box' class is missing virtual dtor declaration

The box class is missing a virtual destructor declaration. There are several classes derived from box, and, because of the missing declaration, these are not destroyed correctly when used via box::ptr, and thus leak memory.

Adding this line is enough to solve the problem:

virtual ~box() {}

Questions: implementation + html parser adapter

Hi,
just found out about this lib, and it seems very interesting. What I really like is the render-agnostic approach!

I have a couple of questions that I hope you can answer:

  1. am I right in thinking that gumbo is only used for html parsing, and this lib leverages it by in turn taking care of css (computing rendering positions/size/clipping/etc.)?
  2. would you think it would be feasible to adapt the library to use something like BeautifulSoup/JSoup for the html parsing instead of gumbo?
  3. would you mind if I (try to) port the lib to another language (obviously crediting you and including your license)?

Thanks and keep up the good work!

PS: oh... and in any case I'de be really glad if you can manage to implement floats for rendering positions (as suggested in another issue). I see it's not a trivial task though!

Compile and get it to run?

Hi! I was interested in Litehtml and decided to try it out for myself.

I downloaded the .zip, ran cmake, then make. There were no errors. I ended up with a folder CMakeFiles which had all compiled files under /litehtml.dir/src, and a new file liblitehtml.a which my archive manager refuses to open. How do I run this software? I see no executable. What am I missing? Thanks, and sorry if this is a trivial question.

`$ cmake .
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- No build type selected, default to Release
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ekansh/Downloads/litehtml-320810f2f4faa78626fc6df8130bae9de42ba988

$ make
Scanning dependencies of target litehtml
[ 2%] Building CXX object CMakeFiles/litehtml.dir/src/background.cpp.o
[ 4%] Building CXX object CMakeFiles/litehtml.dir/src/box.cpp.o
[ 6%] Building CXX object CMakeFiles/litehtml.dir/src/context.cpp.o
[ 8%] Building CXX object CMakeFiles/litehtml.dir/src/css_length.cpp.o
[ 10%] Building CXX object CMakeFiles/litehtml.dir/src/css_selector.cpp.o
[ 12%] Building CXX object CMakeFiles/litehtml.dir/src/document.cpp.o
[ 14%] Building CXX object CMakeFiles/litehtml.dir/src/el_anchor.cpp.o
[ 17%] Building CXX object CMakeFiles/litehtml.dir/src/el_base.cpp.o
[ 19%] Building CXX object CMakeFiles/litehtml.dir/src/el_before_after.cpp.o
[ 21%] Building CXX object CMakeFiles/litehtml.dir/src/el_body.cpp.o
[ 23%] Building CXX object CMakeFiles/litehtml.dir/src/el_break.cpp.o
[ 25%] Building CXX object CMakeFiles/litehtml.dir/src/el_cdata.cpp.o
[ 27%] Building CXX object CMakeFiles/litehtml.dir/src/el_comment.cpp.o
[ 29%] Building CXX object CMakeFiles/litehtml.dir/src/el_div.cpp.o
[ 31%] Building CXX object CMakeFiles/litehtml.dir/src/element.cpp.o
[ 34%] Building CXX object CMakeFiles/litehtml.dir/src/el_font.cpp.o
[ 36%] Building CXX object CMakeFiles/litehtml.dir/src/el_image.cpp.o
[ 38%] Building CXX object CMakeFiles/litehtml.dir/src/el_link.cpp.o
[ 40%] Building CXX object CMakeFiles/litehtml.dir/src/el_para.cpp.o
[ 42%] Building CXX object CMakeFiles/litehtml.dir/src/el_script.cpp.o
[ 44%] Building CXX object CMakeFiles/litehtml.dir/src/el_space.cpp.o
[ 46%] Building CXX object CMakeFiles/litehtml.dir/src/el_style.cpp.o
[ 48%] Building CXX object CMakeFiles/litehtml.dir/src/el_table.cpp.o
[ 51%] Building CXX object CMakeFiles/litehtml.dir/src/el_td.cpp.o
[ 53%] Building CXX object CMakeFiles/litehtml.dir/src/el_text.cpp.o
[ 55%] Building CXX object CMakeFiles/litehtml.dir/src/el_title.cpp.o
[ 57%] Building CXX object CMakeFiles/litehtml.dir/src/el_tr.cpp.o
[ 59%] Building CXX object CMakeFiles/litehtml.dir/src/html.cpp.o
[ 61%] Building CXX object CMakeFiles/litehtml.dir/src/html_tag.cpp.o
[ 63%] Building CXX object CMakeFiles/litehtml.dir/src/iterators.cpp.o
[ 65%] Building CXX object CMakeFiles/litehtml.dir/src/media_query.cpp.o
[ 68%] Building CXX object CMakeFiles/litehtml.dir/src/style.cpp.o
[ 70%] Building CXX object CMakeFiles/litehtml.dir/src/stylesheet.cpp.o
[ 72%] Building CXX object CMakeFiles/litehtml.dir/src/table.cpp.o
[ 74%] Building CXX object CMakeFiles/litehtml.dir/src/utf8_strings.cpp.o
[ 76%] Building CXX object CMakeFiles/litehtml.dir/src/web_color.cpp.o
[ 78%] Building C object CMakeFiles/litehtml.dir/src/gumbo/attribute.c.o
[ 80%] Building C object CMakeFiles/litehtml.dir/src/gumbo/char_ref.c.o
[ 82%] Building C object CMakeFiles/litehtml.dir/src/gumbo/error.c.o
[ 85%] Building C object CMakeFiles/litehtml.dir/src/gumbo/parser.c.o
[ 87%] Building C object CMakeFiles/litehtml.dir/src/gumbo/string_buffer.c.o
[ 89%] Building C object CMakeFiles/litehtml.dir/src/gumbo/string_piece.c.o
[ 91%] Building C object CMakeFiles/litehtml.dir/src/gumbo/tag.c.o
[ 93%] Building C object CMakeFiles/litehtml.dir/src/gumbo/tokenizer.c.o
[ 95%] Building C object CMakeFiles/litehtml.dir/src/gumbo/utf8.c.o
[ 97%] Building C object CMakeFiles/litehtml.dir/src/gumbo/util.c.o
[100%] Building C object CMakeFiles/litehtml.dir/src/gumbo/vector.c.o
Linking CXX static library liblitehtml.a
[100%] Built target litehtml
$`

Here is the output for cmake and make commands.

Padding on body not working

With CSS:
body { padding: 1em; }

the padding will apply only on the left, not the right.

Workaround: create a div inside body and put the padding on that instead.

"fit to the document" doesn't work in practice

I have been working on using litehtml to render tooltips. I have made good progress, but I'm stumped on how to fit the tooltip size to the document. The wiki says,

If you don't have the fixed size window to draw HTML, you need to get the HTML best width. It is very easy: document::render returns the best width for you.

I call render like this:

    _width = document->render(900);
    if (_width < max_width)
        _width = document->render(_width);

The problem is that render always returns the width I set in document_container::get_client_rect no matter how small the HTML is. I tried not setting a width in get_client_rect, but then litehtml tries to render in the minimum width possible, wrapping text at every word.

Is there a practical way to make use of the "optimal width" feature?

integrating litehtml with a UI framework

Hi, I'm trying to integrate litehtml with the UI framework JUCE. I don't just want to render some HTML, but I want to render UI dialogs with all their UI sub-elements like buttons etc using litehtml.
I need litehtml to tell me the sizes and positions of the sub-elements so I can position them correctly when the user resizes the dialog. Would this be possible somehow?
I'm not sure how I could map the dialog element hierarchy to litehtml/HTML/CSS.
Should every dialog element get its own HTML file to render its content or should I just render the whole dialog and all its elements with one HTML file and make the actual JUCE dialog elements transparent?
Any advice appreciated!

incorrect table size

this html creates box 52x52 px in litebrowser, should be 50x50 px:

<style>

    table { 
        border: 1px solid black;
        width: 50px; height: 50px; 
    }

</style>

<table><tr><td></table>

this issue becomes more evident in this example, where it creates unnecessary scrollbars:

<style>

    html, body { height: 100%; width: 100%; }
    body { margin: 0; }

    table { 
        border: 1px solid black;
        width: 100%; height: 100%; 
    }

</style>

<table><tr><td></table>

Problem: incorrect image size

I've tried to load page http://wbp.wotb.com.wots.iv/en/news/blitz-client/11111/nastya19/?width=612 and have a problem with image size:
fadinmedal
The same image has normal size in Chrome:
fadinmedalnormal
Tag "Div" which contains image, has max-width property 40%; image has 100%.
During page rendering, html_tag::render_box method calculates width of div element (150px * 0.4 == 66px) and use it for rendering of their children (img element).
I don't know how to fix this problem correctly. Any suggestions?

A couple of improvement ideas

I would recommend to reconsider:

  1. children() method that returns plain list - the modification of this list could lead to an inconsistent structure (for example if someone adds an item to it without setting parent of the item), so maybe it should be a constant method returning constant link? (all manipulations would be made with additional methods)
  2. Maybe elements_vector should be changed from std::vector to std::list - there are many use cases that add, iterate or remove items from it, but I see no cases that uses items indexes. Adding (or removing) to the middle of a vector is not quite a cheap thing...

web site: Typos/suggestions

It's unclear if http://www.litehtml.com/ 's sources are in the git repo here on github to submit pull request, so some suggestions:

The popular HTML engines like WebKit is too complicated

are too complicated

Developer must be crazy to use something like WebKit

A developer. And who knows, maybe someone should be crazy to give litehtml a try, if there're well-known solutions like WebKit exist ;-). So, suggested to rewrite this whole sentence as:

"For example, it may be too cumbersome to use WebKit to show some tooltips or pages in HTML format."

Feature request: Custom memory allocators

Hi litehtml team,

For the use case that I am interested in (game UI) litehtml seems quite promising. There is a slight problem though. Most game engines (including mine) use custom memory allocation schemes. Litehtml seems to be using the default STL's allocator and that complicates things.

Are there any plans to include custom memory allocator support?

A problem with style updating

I'm calling

element::ptr el = doc->root()->get_element_by_point(x, y, x, y);
el->set_attr("style", "background: red;");

then I'm calling doc->render() just as always.

But the style is never updated. Am I doing something wrong?

Updating the DOM and rendering the result

Hi,

Browsers allow the DOM to be updated through JS through code like

document.write(Date())
document.getElementById(id).innerHTML = new HTML etc

Does litehtml have the DOM in memory, that it used to render the html document? If so, then can it be updated on the fly and just the changed part re-rendered?

For example if I want to change some text shown within the h1 tags at runtime, then could I retrieve it in C++ by using some sort of ID and update the text.

percentages are rounded down causing pixel offsets

The calc_percent( int width ) function in css_length.h casts percentages down to integers. In a way this is fine ( for rendering ) but it looks like these integer values are being used in calculations for relative positioned divs. Here's an example:

______________________________________________________
|     ___________           __________               |
|     | div 1   |           | div 2  |         ...   |
|     -----------           ----------               |
|                                                    |
|                                                    |
------------------------------------------------------

Imagine div 1 is positioned at 33,3px from the left side of the screen. it has a width of 56,9px, div 2 is positioned 60,8px from div1.
If you keep the fractions, you get a final position for div 2 of : 33.3 + 56.9 + 60.8 = 151
If you round down each value however, you get a final position of 33 + 56 + 60 = 149

This is already a difference of 2 pixels..

_Possible solutions:_

  • keep the fraction during the position calculations and round them down when rendering
  • Use integers but use 32 units to represent 1 pixel. then you can divide by 32 ( or shift ) when you render, to use the rounded position.

p with floated box to left places text incorrectly

document:

<html>
  <head>
    <style type="text/css">
      section {
        background-color: peachpuff;
        margin: 12px;
        padding: 3px;
      }

      h3 {
        font-size: 1em;
        float: left;
        text-align: right;
        width: 140px;
      }

      p {
        border-left: 1px solid dimgrey;
        margin: 0 0 0 152px;
        padding: 0 0 0 12px;
      }
    </style>
  </head>
  <body>
    <section>
      <h3>Header</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar ante et purus dapibus, ut ullamcorper eros eleifend. Vivamus quam dui, imperdiet a malesuada eu, blandit in sapien. Aliquam ut ipsum eu leo imperdiet efficitur. Sed rutrum vehicula dapibus.</p>
    </section>
  </body>
</html>

image

Input element request

I think an input element would be great for this ive tried implementing this for lite_browser but with no luck all the math just goes over my head :) i got so far input text/ backspace to remove text but when it came to supporting text longer than input box and scrollbars etc i just got lost 😃 i would be willing to add all html5 input types if i had a base editor to go off. Let me know thanks 😃

<tr> height: 100% doesn't work

this html doesn't work properly:

<style>
    table, td { border: 1px solid black; }
    table { width: 100px; height: 100px; }
    #stretch { height: 100%; }
</style>

<table>
  <tr>
    <td>text</td>
  </tr>
  <tr id="stretch">
    <td>stretch</td>
  </tr>
</table>

litebrowser:
image
chromium:
image

document_container::create_font parameter size is 0

Hello, i am implementing my own doc_container right now and for some reason the parameter size of doc_container::create_font is 0. The documentation says that this paramater should specify the size of the font in pixels though. What could possibly be the reason for this?

Global locale modified

Litehtml modifies global locale which leads to a crash in an app which uses it.

Also std::locale::global returns previous locale, so the first call to litehtml::html_tag::set_tagName() or litehtml::html_tag::set_attr() would use previous locale, not classic.

el_text set_text()

Hi, I'm making a set_text() method in the text element, much in the way you would normally call this from js. However, After i set the text, it seems that the positions have to be updated ( text width will not be the same anymore, stuff like that. Could you give a hint as to what I should call in this method to display the document correctly?

void litehtml::el_text::set_text( const tstring& text )
{
    m_text = text;
    parse_styles( true );
    // How do I update the element placement here?
}

Thanks in advance @tordex

Feature request: Make coordinate types configurable as float

Currently, all coordinates are implemented as ints, which is perfectly fine for static pages.

The problem begins, when you begin to animate things. A perfectly smooth animation in a typical render loop is impossible using int output, since you always have frame time fractions, which lead to a jitter of the movement due to the conversion to int.

But I assume, litehtml often will be used as a UI support library, and at least in game UI smooth animation is crucial.

There could be a preprocessor switch for this, which could be set if you use float capable output like cairo and if you need it for animation, so that a coord_t could be either int or float/double.

The jitter effect is subtle, and I am not sure if it is worth the effort.
But smooth animations are a sign of quality at least in game development, and I wanted to post this just as a basis for discussion.

Flexbox support?

Flexbox support (as seen in react-native) would be amazing. Any chance of that? Or hints as to how it could be implemented?

Can't get it working consistently.

I've got this working OK on Mac, but for some reason I can't get it working consistently on Windows/Linux.

The page I'm trying to load is here:

http://www.monkey-x.com/docs/html/Home.html

Each time I load it, something is slightly wong, like a border is added to the top table, or margins are 0, or font size is wrong. This seems like it must be an uninitialized var issue, but I can't find anything - even checked with valgrind.

The page works OK(ish) in litebrowser - but then, that didn't appear to leak memory either. Is litebrowser built with exactly the same version of litehtml as the one in github? The windows container code in the github source seems slightly wrong - eg: it uses cssborder instead of border in places etc. Is that out of date?

Bug in margin / padding with position: absolute

The following code produces a margin that is twice what is was set:

<!DOCTYPE html>
<html>
<head>
<style>
div {
  position: absolute;
  width: 100px;
  height: 100px;
  margin-left: 100px;
  background-color: red;
}
</style>
</head>
<body>

<div></div>

</body>
</html>

It only happens with position: absolute and when left is not set

Please see the difference between litebrowser (top) and chrome (bottow), that properly displays the 100px margin

image

BaseUrl question

Hi @tordex,

It seems like there are 2 ways the <base> tag is implemented. There is the set_base_url method of the container ( so the client has to cache the url ), and there is the baseurl argument in methods like load_image, get_image_size and so on. Isn't it the same thing?
Is it ok to remove the second implementation? ( It's pretty complex with the custom styles like background-image-baseurl

Thanks

Problem with a protected method

An architecture problem.
I'm trying to create a custom tag that lays out elements inside. I want to subclass el_div and add some features (I want to make a scrollable div block).

  1. I can't find any el_div.h, but that isn't a problem - el_div is very simple, I can subclass from html_tag directly.
  2. I'm trying to create place_element() implementation to modify each sub-element's m_pos. But I can't access el->m_pos from my class.

What should I do? How to accomplish this in a right way?

Compilation on Linux (Ubuntu Vivid) fails

Hi

I cannot compile litebrowser-linux (and litehtml) on Ubuntu Vivid

most of errors say things like 'shared_ptr' is not a memb
er of 'std'

$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/golubovsky/src/litebrowser-linux

$ make

In file included from /home/golubovsky/src/litebrowser-linux/litehtml/src/html.h:12:0,
from /home/golubovsky/src/litebrowser-linux/litehtml/src/background.cpp:1:
/home/golubovsky/src/litebrowser-linux/litehtml/src/types.h:14:23: error: 'shared_ptr' is not a member of 'std'
typedef std::vector< std::shared_ptrlitehtml::element > elements_vector;
^
/home/golubovsky/src/litebrowser-linux/litehtml/src/types.h:14:23: error: 'shared_ptr' is not a member of 'std'
/home/golubovsky/src/litebrowser-linux/litehtml/src/types.h:14:56: error: template argument 1 is invalid
typedef std::vector< std::shared_ptrlitehtml::element > elements_vector;
^
...

$ g++ --version
g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I do not program in C++ so cannot give further diagnostics, and sorry for stupid questions. My plans are to integrate litehtml with another language (possibly Haskell) via standard FFI tools, but I need to compile it first.

For e. g. shared_ptr I have files defining it installed:

/usr/include/c++/4.9/bits/shared_ptr.h
/usr/include/c++/4.9/tr1/shared_ptr.h
/usr/include/boost/asio/detail/shared_ptr.hpp
/usr/include/boost/serialization/shared_ptr.hpp
/usr/include/boost/smart_ptr/shared_ptr.hpp
/usr/include/boost/interprocess/smart_ptr/shared_ptr.hpp
/usr/include/boost/shared_ptr.hpp

My understanding is that I do not pass proper options to g++. What extra options need to be given to compile on Linux?

Thanks.

need help with draw_background implementation

Dear Yuri,

could you add some more documentation to the Wiki explaining how to implement the various functions in a document_container? I'm in the process of implementing my own document_container-derived class and I'm kind of stuck in the draw_background function right now.
Could you explain the meaning of the elements in the background_paint class?
Thank you!

fonts+line-height

Hi,

I'm trying to implementing 'zooming' for a litehtml based project but have a minor problem.

In my document_container::create_font() method, I scale the font size I'm passed by the current zoom factor, load my font and fill in the font_metrics struct with the scaled height.

This works in that I get a bigger font, however the lines are always vertically spaced the same so they start overlapping when the font gets too large.

I'm guessing the problem is that litehtml is always using 16px to calculate line height (which is what I have specified as font-height in the css) and not what I put in font_metrics, but how do I get around this?

Or am I doing something wrong?

Bye!
Mark

Table rendering issues

I have some big issues with rendering tables.

I use this code to display a table:

<style type="text/css" media="screen">
    body {
      background-color: black;
    }

  .text_container {
    position: absolute;
    height: 80%;
    width: 90%;
    left:5%;
    top: 10%;
    display: table;
    background-image: url('../images/box_leaderboard.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border: solid;
    border-width: 2px;
  }

  .container_left_text {
    display: table-row;
    vertical-align: middle;
    z-index: 0;
    border: solid;
    border-width: 2px;
  }

  .text_left {
    display: table-column;
    text-align: left;
    font-size: 2em;
    font-family: sansation-regular;
    vertical-align: middle;
    color: white;
    padding-left: 1%;
    width: 50%;
    border: solid;
    border-width: 2px;
  }

  .text_right {
    display: table-column;
    text-align: right;
    font-size: 2em;
    font-family: sansation-regular;
    vertical-align: middle;
    color: white;
    padding-right: 2%;
    width: 50%;
    border: solid;
    border-width: 2px;
  }
</style>

<body>
  <table class="text_container">
    <tr></tr> <!-- Empty tr so we can hide all others -->
    <tr class="container_left_text" id="parent0">
      <td class="text_left" id="title0">Test
      </td>
      <td class="text_right" id="value0">Test
      </td>
    </tr>
    <tr class="container_left_text" id="parent1">
      <td class="text_left" id="title1">Test
      </td>
      <td class="text_right" id="value1">Test
      </td>
    </tr>
    <tr class="container_left_text" id="parent2" >
      <td class="text_left" id="title2">Test
      </td>
      <td class="text_right" id="value2">Test
      </td>
    </tr>
    <tr class="container_left_text" id="parent3">
      <td class="text_left" id="title3">Test
      </td>
      <td class="text_right" id="value3">Test
      </td>
    </tr>
</table>
</body>

It is rendered quite wrong in litebrowser with the latest litehtml code.

Besides that, if I resize the window ( re - render ), it looks like my <td> elements are moved down, so there is something being summed...

Also I noticed that in my implementation, if I added float: left and float: right properties to .text_left and .text_right respectively, the rendering would become extremely slow. I did not test this in litebrowser though.

Memory leak...

Hi,

litehtml::box needs a virtual destructor, or derived classes will leak their containers.

Took a good 3+ hours to find that one!

Bye,
Mark

Would this work for video game UI?

html/css is perfect to describe UI's and it would work great for video games since it's so standard. The question is, do these callbacks get called every frame because that's generally why a video game UI requires/does so that it can be redrawn on top of the 3D game part and be animated each frame. Has anyone tried litehtml with something like SDL for rendering?

Support for CSS "direction" property

Does litehtml support CSS "direction" property.
It's not processed under;
void litehtml::html_tag::parse_styles(bool is_reparse)

Is element attribute "dir" not supported as well?

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.