diff --git a/include/litehtml/line_box.h b/include/litehtml/line_box.h index e2897372..cd96eab0 100644 --- a/include/litehtml/line_box.h +++ b/include/litehtml/line_box.h @@ -59,7 +59,8 @@ namespace litehtml virtual pixel_t left() const; virtual element_type get_type() const { return type_text_part; } virtual pixel_t get_rendered_min_width() const { return m_rendered_min_width; } - virtual void set_rendered_min_width(pixel_t min_width) { m_rendered_min_width = min_width; } + virtual void set_rendered_min_width(pixel_t min_width) { m_rendered_min_width = min_width; } + virtual void y_shift(pixel_t shift); void reset_items_height() { m_items_top = m_items_bottom = 0; } void add_item_height(pixel_t item_top, pixel_t item_bottom) @@ -101,6 +102,7 @@ namespace litehtml pixel_t right() const override; pixel_t left() const override; element_type get_type() const override { return type_inline_end; } + void y_shift(pixel_t) override {} }; class lbi_continue : public lbi_start diff --git a/include/litehtml/render_inline.h b/include/litehtml/render_inline.h index ac0af5da..e51beb0c 100644 --- a/include/litehtml/render_inline.h +++ b/include/litehtml/render_inline.h @@ -2,6 +2,7 @@ #define LITEHTML_RENDER_INLINE_H #include "render_item.h" +#include "types.h" namespace litehtml { @@ -31,6 +32,17 @@ namespace litehtml { return std::make_shared(src_el()); } + virtual void y_shift(pixel_t shift) override + { + if(css().get_display() == display_inline_text) + { + render_item::y_shift(shift); + } + for(auto& box : m_boxes) + { + box.y += shift; + } + } }; } diff --git a/include/litehtml/render_item.h b/include/litehtml/render_item.h index 85d11f4f..20a73484 100644 --- a/include/litehtml/render_item.h +++ b/include/litehtml/render_item.h @@ -424,7 +424,8 @@ namespace litehtml std::shared_ptr get_element_by_point(pixel_t x, pixel_t y, pixel_t client_x, pixel_t client_y); bool is_point_inside( pixel_t x, pixel_t y ); void dump(litehtml::dumper& cout); - position get_placement() const; + position get_placement() const; + virtual void y_shift(pixel_t shift); /** * Returns the boxes of rendering element. All coordinates are absolute * diff --git a/src/line_box.cpp b/src/line_box.cpp index f29bf4ca..f44db5a7 100644 --- a/src/line_box.cpp +++ b/src/line_box.cpp @@ -51,6 +51,11 @@ litehtml::pixel_t litehtml::line_box_item::height() const return m_element->height(); } +void litehtml::line_box_item::y_shift(pixel_t shift) +{ + m_element->y_shift(shift); +} + ////////////////////////////////////////////////////////////////////////////////////////// litehtml::lbi_start::lbi_start(const std::shared_ptr& element) : line_box_item(element) @@ -820,10 +825,10 @@ litehtml::pixel_t litehtml::line_box::bottom_margin() const void litehtml::line_box::y_shift( pixel_t shift ) { m_top += shift; - for (auto& el : m_items) - { - el->pos().y += shift; - } + for (auto& el : m_items) + { + el->y_shift(shift); + } } bool litehtml::line_box::is_break_only() const diff --git a/src/render_item.cpp b/src/render_item.cpp index 6df9c594..bfe1d604 100644 --- a/src/render_item.cpp +++ b/src/render_item.cpp @@ -1360,3 +1360,8 @@ std::tuple litehtml::render_item::element_ return {offset_x, offset_y}; } + +void litehtml::render_item::y_shift(pixel_t delta) +{ + m_pos.y += delta; +} \ No newline at end of file