Commit Graph

267 Commits

Author SHA1 Message Date
Yuri Kobets
9bc386df9b Fixed: (min/max) width/height calculating with percent units. 2023-03-29 02:28:18 +03:00
stasoid
f7e10d0985 remove background.cpp 2023-02-25 12:23:23 +06:00
stasoid
8ef9ec8275 fix: "inherit" doesn't work 2023-02-25 12:08:29 +06:00
stasoid
28a2831518 support multiple background images 2023-02-25 10:33:42 +06:00
Yuri Kobets
eca6a7439d don't inherit font-size, font-weight and font-style properties for table
Related to the issue #233
2023-02-18 16:00:25 +03:00
Yuri Kobets
2c5077f351
Merge pull request #253 from litehtml/inline_render_fix
Inline render improvements
2023-02-16 18:59:46 +03:00
Yuri Kobets
4500b2d175 New tests and fixes for inline rendering
* test10.htm - test for issue #247
 * test11.htm - test for issue #249
 * test12.htm - inline text rendering
 * test13.htm - vertical align test
2023-02-16 18:40:17 +03:00
Yuri Kobets
40d2071bd8 Improved support for the vertical-align property (inline elements)
Supported values:
  * baseline
  * top
  * bottom
  * text-top
  * text-bottom
  * middle
  * sub
  * super
It works for text as well as for inline boxes.
2023-02-16 03:50:12 +03:00
Yuri Kobets
10fb697ff2 fixes in calculating line box width 2023-02-06 03:53:07 +03:00
Yuri Kobets
fbe68e1676 optimization: removing std::dynamic_pointer_cast 2023-02-05 16:51:07 +03:00
Yuri Kobets
4ea92870e8 optimizing inline rendering 2023-02-05 04:36:07 +03:00
Yuri Kobets
756b247ecd Redesigned inline elements rendering 2023-02-01 03:42:58 +03:00
Ryan Schmidt
1e803393bd Add styles for ins, del, s, and strike elements 2023-01-05 21:12:19 +03:00
Ryan Schmidt
89a7d36df8 Add styles for cite element 2023-01-05 19:58:33 +03:00
Ryan Schmidt
d8f23728a8 Add styles for u element 2023-01-05 19:58:16 +03:00
Yuri Kobets
636ba5163a fixed: line-height calculation for line box. (#243) 2023-01-05 03:55:58 +03:00
stasoid
a75a38df71 stop using std::stringstream because it is actually slower than std::string
proof: https://tio.run/##rVPLbtswEDyLX7FlkICE5cDtUVJ876kf0BSCyofK2iINkkrRBv71qstQjmUEKFKkJ0n7mNmZXYnDYd0LMU1Xxor9KBU0D0pE57fkHAnRG9tfRDCkumEZEt@8s25LxoC1EKKsqtxXE3IllTZWwbALzHaDKjE/as3vSfFUmHtTg@rkz1bsndhVVTSDag/O2AhfVW8s3MFfqq37wXj9hIjQ9auhlZWvBD6gmqgZvQ4VXH@USc29pSWcFC0Q5Oi7aJxtRRdic5EajPAuKOGsDFuW2NdZHr8VbrSRcY6OkQdnJHzHCdvsYhsCy283SOVLQIAQM2ve2GlNNxDdTtlwLsldUu3NwMnjbEwO5z1CCDUptPPAgvml2ggGPdnU@GhmtNuUQB/ArFacFIhSGA3MwDss5AgATZMpEKnIn7nzs/mCoWOi9clphIoekcjxpcr/KDFxUfpWWQizulvoyt@XwlDHDI@3nk5q6IxlZ6cvZ5@b2fvNpgQqg9ZSB6lp2nr6P@hyMbSc50@wi@GxebOcOfekcdOUL8@mfDaMQmIqij7pwMzJgCSEE/K4GOHN5P/AjOfhVRy9TR4eyTT9Fnrf9WFaf/rwBw
The situation is similar in clang and VS.
2022-12-15 00:23:04 +06:00
stasoid
778a6e2c63 Add render tests
Render tests are .htm files in litehtml/test directory.
Tests starting with "-" are disabled.

Correct rendering is in corresponding .htm.png file.
To generate .png file, run ctest from litehtml/build. The test will fail
and create xxx.htm-FAILED.png file. Rename it to xxx.htm.png

One ASCII raster font with 3 sizes is supported, see litehtml/containers/test/fonts. This should be enough for tests.
Border painting is supported, only solid borders.
Backgrounds, images and list markers are not supported.
2022-12-11 04:20:48 +06:00
stasoid
c46240eb7c distinguish between computed and used line-height (fixes #232) 2022-12-09 21:58:44 +06:00
Yuri Kobets
315ff22304
Merge pull request #235 from stasoid/master
fix links with black background on Obama wiki + some other changes
2022-12-06 00:04:30 +03:00
stasoid
2660bcff03 create html_tag constructor for anonymous wrapper boxes
changed css_properties::compute signature because shared_from_this cannot be called during construction of *this
2022-12-05 15:28:37 +06:00
stasoid
18fc38e66e add functions for easier debugging
it is now possible to write el->select("#a") or el->id() == _a_
2022-12-05 14:43:40 +06:00
mgambrell
4d82733621 add missing virtual destructors 2022-12-02 18:12:11 -05:00
stasoid
758c51cf6e make web_color::is_color return false for identifiers that don't represent color
this fixes links with black background on Obama wiki
2022-12-01 18:50:39 +06:00
stasoid
c38cff9e4e readd var() support
I don't see any performance degradation on Obama wiki (which does not use vars)
2022-11-27 04:37:18 +06:00
stasoid
de4893f0b6 document::createFromString optimization:
Move css property parsing from css_properties::parse (which is called from html_tag::parse_styles for every tree node)
to style::add_property (which is called during stylesheet parsing).
document::createFromString: 1287 ms -> 1048 ms on Obama wiki
2022-11-27 02:48:04 +06:00
stasoid
25773b4943 This basically reverts commit 5a00888b "var()" to improve performance.
I'll readd var() support later in a way that doesn't hurt performance so much.
document::createFromString: 1730 ms -> 1287 ms on Obama wiki
2022-11-21 23:32:07 +06:00
stasoid
0ba38c6bde remove style::m_valid_values 2022-11-18 19:50:07 +06:00
stasoid
56c31aac10 remove attributes.h 2022-11-17 05:38:58 +06:00
stasoid
e02ac9ce74 add element::tag() method 2022-11-16 09:07:27 +06:00
stasoid
a060e727c8 move pseudo-class parameter parsing to css_element_selector::parse 2022-11-16 08:26:02 +06:00
stasoid
7df81ba288 use string_id for tag names
apply_stylesheet: 1050 ms

I've changed _s to return const string& instead of string not because of performance, but because of this code in get_tagName:
return _s(m_tag).c_str();
2022-11-15 21:13:30 +06:00
stasoid
17f6854348 use string_id for class names
I've kept m_str_classes too for convenience.
apply_stylesheet: 1300 ms -> 1200 ms
I don't understand why the gain is so small. This commit replaces string comparisons with int comparisons on a very hot path.
2022-11-15 19:35:50 +06:00
stasoid
5707cf8a46 preparation before switching class names to string_id 2022-11-15 16:01:15 +06:00
stasoid
78bb7b21c4 separate #name from [id=name]
apply_stylesheet: 1300 ms
2022-11-15 15:34:53 +06:00
stasoid
5a60cb868e separate .name from [class=name] 2022-11-15 15:25:22 +06:00
stasoid
e14622ad9e create select_attribute method 2022-11-15 07:12:08 +06:00
stasoid
4dae578b09 create select_pseudoclass method to improve readability
this also speeds up apply_stylesheet: 1710 ms -> 1550 ms on Obama wiki
About 2/3 of the speedup is because parent() is not called every time. I don't know where the rest of the speedup comes from.
2022-11-14 09:38:55 +06:00
stasoid
5ab0448dd5 rename m_class_values -> m_classes 2022-11-12 05:54:01 +06:00
stasoid
3cfa3b2155 remove css_attribute_selector::class_val
each .class has its own css_attribute_selector
2022-11-11 22:36:43 +06:00
stasoid
d3335a4f16 cosmetics 2022-11-07 23:46:35 +06:00
stasoid
8c7621034f parse_styles optimization: use string_id for CSS property names
decreases parse_styles time by 37% (750 ms -> 468 ms on Obama wiki on my machine)
2022-11-07 22:11:00 +06:00
Yuri Kobets
1a8b4c987e apply user css in document::append_children_from_string 2022-10-31 22:50:18 +03:00
TobiasBohnen
d5ff5eb375
added missing font weights to enum and string 2022-10-31 18:43:48 +01:00
stasoid
d00f5d032b create document_container.h/cpp 2022-10-30 19:07:55 +06:00
stasoid
8927a44515 Remove litehtml::context, replace master.css -> master_css.h and make document::createFromString receive master/user css as strings
closes issue #219
2022-10-30 16:25:56 +06:00
stasoid
a6177d1d5e remove wchar support
closes issue #217
2022-10-21 17:51:29 +06:00
stasoid
8e21841ad9 Update win32_container and gdiplus_container 2022-10-18 09:13:45 +06:00
Yuri Kobets
7e9fda4a86 parsing flex related CSS properties 2022-10-11 23:57:05 +03:00
Yuri Kobets
e4d2ff9931 don't create rendering item for comments 2022-10-11 23:07:50 +03:00
Yuri Kobets
b418ffa60e Windows: replace _snwprintf/snprintf with _snwprintf_s/_snprintf_s 2022-09-17 23:55:42 +03:00
Yuri Kobets
ff0e7c73bd Fixed: compilation is failed on Windows 2022-09-17 23:44:43 +03:00
Yuri Kobets
a4aae391fa
Merge pull request #211 from tig/fix_litehtmlsharp
Fixes LiteHtmlSharp build
2022-09-14 00:57:45 +03:00
Yuri Kobets
e56cd9b730
Internal refactoring (#212)
* Refactored CSS properties

All CSS related properties are moved into the separate class css_properties.
Getters and setters are removed from classes element and html_tag.
Access to the css_properties rleased via css() [ro] and css_w() [rw] methods

* fix: el_text don't have to copy all css properties from parent

* Refactored rendering code

* Added flex and inline_flex values for display css property

* Implementing box generation

https://www.w3.org/TR/CSS22/visuren.html#box-gen

* Split inlines on block box inside

* Split parsing and rendering trees.

* Fixed some bugs

* Fixed: impossible to click urls on Obama wiki's toc

* Make element::get_placement work again

* Fixed: incorrect rendering table captions

* find_styles_changes function returned to the element class

* set parent correctly during render items split

* fixed urls on https://en.cppreference.com/w/cpp/container/vector

* fixed rendering blocks with width in percents

Example:
https://web.archive.org/web/20110101155107/http://www.unicode.org/
Issue #208

* Fixed placement of blocks with "overflow: hidden" with floating boxes.

* refactoring of rendering block

* Selectors :before and :after returned back with fixed behaviour.

* fixed render_item::is_last_child_inline

* fixed: text inside nested inlines has extra paddings/margins

* fixed documet test
2022-09-14 00:39:44 +03:00
Tig Kindel
acd5615383 Fixes building LiteHtmlSharp post separating src/indlude dirs 2022-08-10 16:35:13 -06:00
stasoid
6b55a1b852 cosmetics 2022-03-26 20:36:05 +06:00
stasoid
5a00888bbc var() 2022-03-17 10:37:42 +06:00
stasoid
315738cc4d fix blockquote 2022-03-08 20:48:26 +06:00
stasoid
c8a4ee6f72 fix #194
Also fixes rendering of this HTML:
<table width=100px border=1>
<tr><td>aaa<td style="display:none">bbb<td>ccc

and this HTML:
<style>p{display:table-cell}</style>
<p>aaa</p><!----><p>bbb</p>

and improves rendering of this HTML:
<style>
p{display:table-cell}
span{white-space:pre}
</style>
<span>
<p>aaa</p>  <p>bbb</p>
2022-03-04 21:21:24 +06:00
cotn666
f27e69b0b3
Fix MinGW build 2022-02-22 10:44:25 +01:00
wih1hi
e91823d438 fixed style property 'white-space: pre-wrap' 2021-12-28 13:13:06 +01:00
Yuri Kobets
b4903811fc Fixed compilation error on Windows 2021-11-15 01:31:54 +03:00
Yuri Kobets
6617ab7188 Refactoring 2021-11-11 00:12:38 +03:00
Yuri Kobets
7d234d9a7e Use pango library as text renderer for container_linux 2021-11-07 03:53:00 +03:00
Yuri Kobets
cd72813881 Fixed parsing of escape sequence for :before and :after classes 2021-11-05 20:20:26 +03:00
Yuri Kobets
d4209476bc Add t_ prefix for functions litehtml::strcasecmp, litehtml::strncasecmp, litehtml::tolower and litehtml::isdigit 2021-11-05 02:32:49 +03:00
g4mba5
4dc1a18fc3
Add custom implementations of 'strcasecmp', 'strncasecmp', 'tolower' and 'isdigit' that ignore the current locale (#178)
Add custom implementations of 'strcasecmp', 'strncasecmp', 'tolower' and 'isdigit' that ignore the current locale
2021-11-05 02:16:30 +03:00
Yuri Kobets
bb04a50f93 Add a custom 'strtod' implementation that ignores the current locale. 2021-11-04 23:22:54 +03:00
Yuri Kobets
f00bc949f7 Revert "Add a custom 'strtod' implementation that ignores the current locale." 2021-11-04 16:54:12 +03:00
Yuri Kobets
d45cbbb558
Merge branch 'master' into g4mba5-patch-strtod 2021-11-04 16:44:19 +03:00
Yuri Kobets
1f36d26f30 Added document_container::split_text to use custom text splitting engines 2021-11-01 02:53:40 +03:00
Yuri Kobets
ac6bbc7d2a Added table caption support 2021-11-01 01:25:35 +03:00
g4mba5
0fea186f0e
'strtod' declaration 2021-10-30 21:56:41 +02:00
g4mba5
2164e69327
The custom 'strtod' will be implemented directly in 'litehtml' namespace 2021-10-30 21:55:46 +02:00
g4mba5
626f5a34a0
Make 't_strtod' points at its implementation in 'document.cpp' 2021-10-30 21:11:19 +02:00
Evgeniy A. Dushistov
971eadced8 fix "scaring" warnings
1. usage of virtual functions without destructor,
   not public not-virtual destructor + final convinced compiler that
   all ok
2. couple of unused variables and arguments (the most noisy one)
3. extra copy in cycle
4. std::move prevent copy elision warning
2021-10-28 13:56:59 +03:00
ericLemanissier
af9061a2c8
include cstdint int os_types
it is needed for uintptr_t
2021-10-27 14:02:23 +02:00
Mark Jan van Kampen
131f207e01
Adds ptrdiff_t include to tstring_view.h
On some platforms ptrdiff_t is included through other system headers, on
others not. By including cstddef the code should compile on all platforms
that comply with the standard.
2021-10-27 10:43:50 +02:00
Mark Jan van Kampen
bb01af1c36
Adds missing includes to utf8_strings.h 2021-10-27 06:49:11 +02:00
John Poole
463cfc2de1
Merge branch 'master' into url-class 2021-09-25 20:26:05 -04:00
John Poole
527fbe3413 Extend URL path resolution to handle relative paths
This is implemented using several URL path helper functions.  The
functions aren't strictly necessary, but the functions make it easier
to implement and test the resolution functionality.
2021-09-25 13:52:56 -04:00
John Poole
d3c368458d Add a url class
The url class is a URL parser and container class that makes working
with URLs easier.  In particular, the resolve() function makes working
with base URLs and possibly relative URLs easier.

url instances are meant to be immutable.  If users need to modify a
url instance they can do so by creating a new url instance.  See the
resolve() implementation for a non-trivial example of how to build a
new url instance using existing url instances.

Note that the current implementation is inefficient due to each URL
component requiring its own separate memory allocation.  We should
consider re-writing this to use tstring_view once that branch is
merged into master.
2021-09-25 11:58:31 -04:00
John Poole
3147b4fc78 Add codepoint utility functions, tests
Add codepoint utility functions that test whether a codepoint belongs
to a set of codepoints (e.g., the valid codepoints for a URL scheme).
Most of these functions are implemented using a compact lookup table
so should be reasonably fast.

The functions are based on similar functions from the css-parser branch
that were introduced in commit 1698324920.  We'll want to merge these
sets of functions together once the branches are merged.
2021-09-25 11:57:52 -04:00
John Poole
14e2001376 Add tstring_view, a string reference type
tstring_view is a string reference type that provides a view into a
string that is owned elsewhere (e.g., by a std::string object).

tstring_view implements the same interface as std::base_string_view in
the standard library.  When litehtml moves to C++17 consider replacing
the tstring_view implementation with the standard library
implementations (e.g., via a using statement).
2021-09-23 14:56:34 -04:00
Unknown
da53571a47 Added support for loading HTML into an existing element 2020-06-14 01:13:51 +01:00
Yuri Kobets
58e92d6dc6 Extended support for ordered lists.
Supported list-style-type: decimal, decimal-leading-zero, lower/upper-latin, lower/upper-alpha, lower/upper-roman, lower-greek
2020-05-10 02:55:34 +03:00
Alex Zhondin
259d96c2e1 added missing files 2020-05-09 13:44:24 +03:00
Alex Zhondin
948930ad35 support ordered lists 2020-05-09 13:44:24 +03:00
Eike Ziller
42ceb48b4b Fix build with MSVC 2019 and CMake
The WIN32 define is missing with MSVC 2019, use _WIN32
2019-10-28 14:10:50 +01:00
great90
c218b3153e delete repeated include
delete repeated include of "litehtml/stylesheet.h" and "litehtml/html_tag.h"
2019-10-12 09:52:15 +08:00
Yuri Kobets
72fcde2dd3 Fixed: image with max-height percent causes 0 height
Closes #93
2019-09-29 17:34:09 +03:00
Yuri Kobets
94996b27af Removed gumbo.h from document.h, moved VS project into top directory, compile fix in src/html_tag.cpp 2019-09-29 14:30:14 +03:00
Martin Miralles-Cordal
fa610010b3 Moved src headers into discrete folders and updated include paths. 2019-09-22 16:59:03 -04:00
NikitaFeodonit
3320aa4898 Fixes for compilation for many platforms.
Split gubmo and litehtml to different CMake projects with different
compile languages.
Move 'src/strings.h' to 'src/gumbo/visualc/include/strings.h'.
Remove '../src/' in '#include' directive in litehtml.h and
add target_include_directories() in CMake project.
Set C/C++ standard flags by set_target_properties() in CMake project.
Do not set build type and C/C++ compiler flags in library project.
2018-05-25 20:24:53 +03:00
NikitaFeodonit
5515b347a4 Replace '#pragme once' to '#ifndef' because of Eclipse code parser. 2018-05-25 18:21:58 +03:00
NikitaFeodonit
3104c078dc Convert line delimiters to Unix style. 2018-05-25 17:05:49 +03:00
Yuri Kobets
30409bd842 Rollback the pull request #13 - hardcoded styles are not very good.
The same effect can be achieved via master.css. When render html into the source with calculated
width/height (like tooltips) we can set width/height into "auto" to get valid width instead of the maximum width.
2015-06-06 04:45:57 +03:00
Yuri Kobets
81207e27b7 Fix for tag <br clear="all"> 2015-05-22 22:49:59 +03:00
Yuri Kobets
4da59f1a89 tokenize function is replaced to split_string.
some fixes in CSS parsing.
2014-10-21 00:10:16 +04:00
yuri.kobets@gmail.com
9dd887c109 Position of floating boxes is incorrect inside inline/float boxes
Relative positioning is fixed
2014-08-24 15:28:13 +00:00
yuri.kobets@gmail.com
909e17b1d7 * Added support for CSS selectors:
:first-of-type
:last-of-type
:only-of-type
:only-child
:nth-of-type(n)
:nth-last-of-type(n)
:not(selector)
:link
2014-01-21 19:40:39 +00:00
yuri.kobets@gmail.com
ce278122ce Improved tables rendering. Added border-collapse CSS property. 2014-01-06 04:50:25 +00:00
yuri.kobets@gmail.com
827af63f58 Fixed some layout rendering bugs to show web page https://mail.google.com/mail/ correctly.
Half handling of CSS pseudo-elements (started with ::) - currently just removed from processing.
Added document_container::create_element - here you can create own implementation for elements.
2013-09-17 11:28:09 +00:00
yuri.kobets@gmail.com
30fc0c1527 Calculating heights, margins and padding with percentages value are brought into compliance CSS standards.
Fixed the position calculating of absolute positioned elements.
2013-08-31 22:00:08 +00:00
yuri.kobets@gmail.com
b7ed5e573c some changes in master.css 2013-08-11 00:19:57 +00:00
yuri.kobets@gmail.com
c8ec750368 Reduced memory usage.
litehtml::element is now lightweight. litehtml::el_text is inherited from litehtml::element. The old code with pre-parsed styles implementation was moved into litehtml::html_tag class.
2013-08-09 21:22:07 +00:00
yuri.kobets@gmail.com
c04df5716d Improved font sizes. Added <font> tag and align property of <div> tag. 2013-07-14 23:42:00 +00:00
yuri.kobets@gmail.com
857f909fcd Fixed: Some links are not working because element::get_inline_boxes don't ignore the skipped elements.
Added the "nowrap" styles into <td> and <th> tags (see master.css).
2013-07-12 22:26:55 +00:00
yuri.kobets@gmail.com
cd77c14ea3 Added support for white-space CSS property. 2013-07-10 21:15:50 +00:00
yuri.kobets@gmail.com
cc4e5b02fa Added external projects for litebrowser. Some changes in the folder structure. 2013-06-11 23:42:02 +00:00
yuri.kobets@gmail.com
b8d0631334 * The litebrowser is switched to cairo engine (including fonts)
* Added handling the !important in CSS
2013-06-09 01:37:06 +00:00
yuri.kobets@gmail.com
5d213c98b0 1. Removed m_inlines array, now elements are rendered from m_children array.
2. Improved positions of the absolute elements: correct handling auto value for left, top, right, bottom
3. Calculating CSS selectors specificity and sorting selectors with by specificity.
2012-07-21 10:23:31 +00:00
yuri.kobets@gmail.com
900ac9dd95 2012-06-24 00:28:03 +00:00
yuri.kobets@gmail.com
b3b2dc7252 2012-06-17 23:40:01 +00:00
yuri.kobets@gmail.com
f44c6acd80 2012-05-27 21:02:20 +00:00
yuri.kobets@gmail.com
eca5cfca94 2012-05-19 19:34:59 +00:00
yuri.kobets@gmail.com
b5417526f2 2012-05-01 22:08:37 +00:00