@@ -26,7 +26,12 @@ namespace litehtml
26
26
bool m_skip;
27
27
std::vector<std::shared_ptr<render_item>> m_positioned;
28
28
29
- virtual int _render (int x, int y, int max_width, bool second_pass) { return 0 ; }
29
+ virtual int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) { return 0 ; }
30
+ containing_block_context calculate_containing_block_context (const containing_block_context& cb_context);
31
+ void calc_cb_length (const css_length& len,
32
+ int percent_base,
33
+ int & out_value,
34
+ containing_block_context::cbc_value_type& out_type);
30
35
31
36
public:
32
37
explicit render_item (std::shared_ptr<element> src_el);
@@ -237,9 +242,9 @@ namespace litehtml
237
242
ri->parent (shared_from_this ());
238
243
}
239
244
240
- int render (int x, int y, int max_width)
245
+ int render (int x, int y, int max_width, const containing_block_context& containing_block_size )
241
246
{
242
- return _render (x, y, max_width, false );
247
+ return _render (x, y, max_width, containing_block_size, false );
243
248
}
244
249
245
250
bool have_parent () const
@@ -272,9 +277,9 @@ namespace litehtml
272
277
return !(m_skip || src_el ()->css ().get_display () == display_none || src_el ()->css ().get_visibility () != visibility_visible);
273
278
}
274
279
275
- int calc_width (int defVal) const ;
276
- bool get_predefined_height (int & p_height) const ;
277
- void apply_relative_shift (int parent_width );
280
+ int calc_width (int defVal, int containing_block_width ) const ;
281
+ bool get_predefined_height (int & p_height, int containing_block_height ) const ;
282
+ void apply_relative_shift (const containing_block_context &containing_block_size );
278
283
void calc_outlines ( int parent_width );
279
284
void calc_auto_margins (int parent_width);
280
285
@@ -334,7 +339,7 @@ namespace litehtml
334
339
int_int_cache m_cache_line_left;
335
340
int_int_cache m_cache_line_right;
336
341
337
- int _render (int x, int y, int max_width, bool second_pass) override ;
342
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override ;
338
343
339
344
/* *
340
345
* Render block content.
@@ -346,9 +351,9 @@ namespace litehtml
346
351
* @param ret_width - input minimal width.
347
352
* @return return value is the minimal width of the content in block. Must be greater or equal to ret_width parameter
348
353
*/
349
- virtual int _render_content (int x, int y, int max_width, bool second_pass, int ret_width) {return ret_width;}
354
+ virtual int _render_content (int x, int y, int max_width, bool second_pass, int ret_width, const containing_block_context &containing_block_size ) {return ret_width;}
350
355
351
- int place_float (const std::shared_ptr<render_item> &el, int top, int max_width);
356
+ int place_float (const std::shared_ptr<render_item> &el, int top, int max_width, const containing_block_context &containing_block_size );
352
357
int get_floats_height (element_float el_float = float_none) const override ;
353
358
int get_left_floats_height () const override ;
354
359
int get_right_floats_height () const override ;
@@ -358,7 +363,9 @@ namespace litehtml
358
363
void add_float (const std::shared_ptr<render_item> &el, int x, int y) override ;
359
364
int get_cleared_top (const std::shared_ptr<render_item> &el, int line_top) const ;
360
365
int find_next_line_top ( int top, int width, int def_right ) override ;
361
- virtual void fix_line_width ( int max_width, element_float flt ) {}
366
+ virtual void fix_line_width (int max_width, element_float flt,
367
+ const containing_block_context &containing_block_size)
368
+ {}
362
369
void update_floats (int dy, const std::shared_ptr<render_item> &_parent) override ;
363
370
public:
364
371
explicit render_item_block (std::shared_ptr<element> src_el) : render_item(std::move(src_el))
@@ -379,7 +386,8 @@ namespace litehtml
379
386
class render_item_block_context : public render_item_block
380
387
{
381
388
protected:
382
- int _render_content (int x, int y, int max_width, bool second_pass, int ret_width) override ;
389
+ int _render_content (int x, int y, int max_width, bool second_pass, int ret_width,
390
+ const containing_block_context &containing_block_size) override ;
383
391
384
392
public:
385
393
explicit render_item_block_context (std::shared_ptr<element> src_el) : render_item_block(std::move(src_el))
@@ -417,12 +425,14 @@ namespace litehtml
417
425
std::vector<std::unique_ptr<litehtml::line_box> > m_line_boxes;
418
426
int m_max_line_width;
419
427
420
- int _render_content (int x, int y, int max_width, bool second_pass, int ret_width) override ;
421
- void fix_line_width ( int max_width, element_float flt ) override ;
428
+ int _render_content (int x, int y, int max_width, bool second_pass, int ret_width,
429
+ const containing_block_context &containing_block_size) override ;
430
+ void fix_line_width (int max_width, element_float flt,
431
+ const containing_block_context &containing_block_size) override ;
422
432
423
- std::list<std::unique_ptr<line_box_item> > finish_last_box (bool end_of_render, int max_width);
424
- void place_inline (std::unique_ptr<line_box_item> item, int max_width);
425
- int new_box (const std::unique_ptr<line_box_item>& el, int max_width, line_context& line_ctx);
433
+ std::list<std::unique_ptr<line_box_item> > finish_last_box (bool end_of_render, int max_width, const containing_block_context &containing_block_size );
434
+ void place_inline (std::unique_ptr<line_box_item> item, int max_width, const containing_block_context &containing_block_size );
435
+ int new_box (const std::unique_ptr<line_box_item>& el, int max_width, line_context& line_ctx, const containing_block_context &containing_block_size );
426
436
void apply_vertical_align () override ;
427
437
public:
428
438
explicit render_item_inline_context (std::shared_ptr<element> src_el) : render_item_block(std::move(src_el)), m_max_line_width(0 )
@@ -444,7 +454,7 @@ namespace litehtml
444
454
int m_border_spacing_x;
445
455
int m_border_spacing_y;
446
456
447
- int _render (int x, int y, int max_width, bool second_pass) override ;
457
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override ;
448
458
449
459
public:
450
460
explicit render_item_table (std::shared_ptr<element> src_el);
@@ -464,7 +474,7 @@ namespace litehtml
464
474
explicit render_item_table_part (std::shared_ptr<element> src_el) : render_item(std::move(src_el))
465
475
{}
466
476
467
- int _render (int x, int y, int max_width, bool second_pass) override
477
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override
468
478
{return 0 ;}
469
479
std::shared_ptr<render_item> clone () override
470
480
{
@@ -478,7 +488,7 @@ namespace litehtml
478
488
explicit render_item_table_row (std::shared_ptr<element> src_el) : render_item(std::move(src_el))
479
489
{}
480
490
481
- int _render (int x, int y, int max_width, bool second_pass) override
491
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override
482
492
{return 0 ;}
483
493
std::shared_ptr<render_item> clone () override
484
494
{
@@ -492,7 +502,7 @@ namespace litehtml
492
502
protected:
493
503
position::vector m_boxes;
494
504
495
- int _render (int x, int y, int max_width, bool second_pass) override ;
505
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override ;
496
506
public:
497
507
explicit render_item_inline (std::shared_ptr<element> src_el) : render_item(std::move(src_el))
498
508
{}
@@ -512,8 +522,8 @@ namespace litehtml
512
522
class render_item_image : public render_item
513
523
{
514
524
protected:
515
- int _render (int x, int y, int max_width, bool second_pass) override ;
516
- int calc_max_height (int image_height);
525
+ int _render (int x, int y, int max_width, const containing_block_context &containing_block_size, bool second_pass) override ;
526
+ int calc_max_height (int image_height, int containing_block_height );
517
527
518
528
public:
519
529
explicit render_item_image (std::shared_ptr<element> src_el) : render_item(std::move(src_el))
@@ -548,7 +558,8 @@ namespace litehtml
548
558
protected:
549
559
std::list<std::unique_ptr<flex_item>> m_flex_items;
550
560
551
- int _render_content (int x, int y, int max_width, bool second_pass, int ret_width) override ;
561
+ int _render_content (int x, int y, int max_width, bool second_pass, int ret_width,
562
+ const containing_block_context &containing_block_size) override ;
552
563
553
564
public:
554
565
explicit render_item_flex (std::shared_ptr<element> src_el) : render_item_block(std::move(src_el))
0 commit comments