mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
LibWeb: Basic support for display:inline-block with width:auto
We now implement the somewhat fuzzy shrink-to-fit algorithm when laying out inline-block elements with both block and inline children. Shrink-to-fit works by doing two speculative layouts of the entire subtree inside the current block, to compute two things: 1. Preferred minimum width: If we made a line break at every chance we had, how wide would the widest line be? 2. Preferred width: We break only when explicitly told to (e.g "<br>") How wide would the widest line be? We then shrink the width of the inline-block element to an appropriate value based on the above, taking the available width in the containing block into consideration (sans all the box model fluff.) To make the speculative layouts possible, plumb a LayoutMode enum throughout the layout system since it needs to be respected in various places. Note that this is quite hackish and I'm sure there are smarter ways to do a lot of this. But it does kinda work! :^)
This commit is contained in:
parent
4e8bcda4d1
commit
f01af62313
24 changed files with 184 additions and 97 deletions
|
@ -48,15 +48,15 @@ public:
|
|||
|
||||
void render_fragment(RenderingContext&, const LineBoxFragment&) const;
|
||||
|
||||
virtual void split_into_lines(LayoutBlock& container) override;
|
||||
virtual void split_into_lines(LayoutBlock& container, LayoutMode) override;
|
||||
|
||||
const StyleProperties& style() const { return parent()->style(); }
|
||||
|
||||
private:
|
||||
void split_into_lines_by_rules(LayoutBlock& container, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);
|
||||
void split_into_lines_by_rules(LayoutBlock& container, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_chunk(Callback, bool do_wrap_lines, bool do_wrap_breaks) const;
|
||||
void for_each_chunk(Callback, LayoutMode, bool do_wrap_lines, bool do_wrap_breaks) const;
|
||||
|
||||
String m_text_for_rendering;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue