mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 17:37:34 +00:00
LibWeb: Rename wrap_breaks to respect_linebreaks
This more clearly expresses the purpose of this flag. Since only CSS::WhiteSpace::Nowrap sets this value to false and it does not respect linebreaks, this made the most sense as a flag name.
This commit is contained in:
parent
0342fe4e0c
commit
27c5eb66f1
2 changed files with 15 additions and 15 deletions
|
@ -196,7 +196,7 @@ void TextNode::compute_text_for_rendering(bool collapse, bool previous_is_empty_
|
||||||
m_text_for_rendering = builder.to_string();
|
m_text_for_rendering = builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, LayoutMode layout_mode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks)
|
void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, LayoutMode layout_mode, bool do_collapse, bool do_wrap_lines, bool do_respect_linebreaks)
|
||||||
{
|
{
|
||||||
auto& containing_block = context.containing_block();
|
auto& containing_block = context.containing_block();
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou
|
||||||
float available_width = context.available_width_at_line(line_boxes.size() - 1) - line_boxes.last().width();
|
float available_width = context.available_width_at_line(line_boxes.size() - 1) - line_boxes.last().width();
|
||||||
|
|
||||||
compute_text_for_rendering(do_collapse, line_boxes.last().is_empty_or_ends_in_whitespace());
|
compute_text_for_rendering(do_collapse, line_boxes.last().is_empty_or_ends_in_whitespace());
|
||||||
ChunkIterator iterator(m_text_for_rendering, layout_mode, do_wrap_lines, do_wrap_breaks);
|
ChunkIterator iterator(m_text_for_rendering, layout_mode, do_wrap_lines, do_respect_linebreaks);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto chunk_opt = iterator.next();
|
auto chunk_opt = iterator.next();
|
||||||
|
@ -251,7 +251,7 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou
|
||||||
available_width = context.available_width_at_line(line_boxes.size() - 1);
|
available_width = context.available_width_at_line(line_boxes.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_wrap_breaks && chunk.has_breaking_newline) {
|
if (do_respect_linebreaks && chunk.has_breaking_newline) {
|
||||||
containing_block.add_line_box();
|
containing_block.add_line_box();
|
||||||
available_width = context.available_width_at_line(line_boxes.size() - 1);
|
available_width = context.available_width_at_line(line_boxes.size() - 1);
|
||||||
}
|
}
|
||||||
|
@ -262,27 +262,27 @@ void TextNode::split_into_lines(InlineFormattingContext& context, LayoutMode lay
|
||||||
{
|
{
|
||||||
bool do_collapse = true;
|
bool do_collapse = true;
|
||||||
bool do_wrap_lines = true;
|
bool do_wrap_lines = true;
|
||||||
bool do_wrap_breaks = false;
|
bool do_respect_linebreaks = false;
|
||||||
|
|
||||||
if (computed_values().white_space() == CSS::WhiteSpace::Nowrap) {
|
if (computed_values().white_space() == CSS::WhiteSpace::Nowrap) {
|
||||||
do_collapse = true;
|
do_collapse = true;
|
||||||
do_wrap_lines = false;
|
do_wrap_lines = false;
|
||||||
do_wrap_breaks = false;
|
do_respect_linebreaks = false;
|
||||||
} else if (computed_values().white_space() == CSS::WhiteSpace::Pre) {
|
} else if (computed_values().white_space() == CSS::WhiteSpace::Pre) {
|
||||||
do_collapse = false;
|
do_collapse = false;
|
||||||
do_wrap_lines = false;
|
do_wrap_lines = false;
|
||||||
do_wrap_breaks = true;
|
do_respect_linebreaks = true;
|
||||||
} else if (computed_values().white_space() == CSS::WhiteSpace::PreLine) {
|
} else if (computed_values().white_space() == CSS::WhiteSpace::PreLine) {
|
||||||
do_collapse = true;
|
do_collapse = true;
|
||||||
do_wrap_lines = true;
|
do_wrap_lines = true;
|
||||||
do_wrap_breaks = true;
|
do_respect_linebreaks = true;
|
||||||
} else if (computed_values().white_space() == CSS::WhiteSpace::PreWrap) {
|
} else if (computed_values().white_space() == CSS::WhiteSpace::PreWrap) {
|
||||||
do_collapse = false;
|
do_collapse = false;
|
||||||
do_wrap_lines = true;
|
do_wrap_lines = true;
|
||||||
do_wrap_breaks = true;
|
do_respect_linebreaks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
split_into_lines_by_rules(context, layout_mode, do_collapse, do_wrap_lines, do_wrap_breaks);
|
split_into_lines_by_rules(context, layout_mode, do_collapse, do_wrap_lines, do_respect_linebreaks);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextNode::wants_mouse_events() const
|
bool TextNode::wants_mouse_events() const
|
||||||
|
@ -317,10 +317,10 @@ void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& positi
|
||||||
verify_cast<Label>(*parent()).handle_mousemove_on_label({}, position, button);
|
verify_cast<Label>(*parent()).handle_mousemove_on_label({}, position, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextNode::ChunkIterator::ChunkIterator(StringView const& text, LayoutMode layout_mode, bool wrap_lines, bool wrap_breaks)
|
TextNode::ChunkIterator::ChunkIterator(StringView const& text, LayoutMode layout_mode, bool wrap_lines, bool respect_linebreaks)
|
||||||
: m_layout_mode(layout_mode)
|
: m_layout_mode(layout_mode)
|
||||||
, m_wrap_lines(wrap_lines)
|
, m_wrap_lines(wrap_lines)
|
||||||
, m_wrap_breaks(wrap_breaks)
|
, m_respect_linebreaks(respect_linebreaks)
|
||||||
, m_utf8_view(text)
|
, m_utf8_view(text)
|
||||||
, m_iterator(m_utf8_view.begin())
|
, m_iterator(m_utf8_view.begin())
|
||||||
{
|
{
|
||||||
|
@ -365,7 +365,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
|
||||||
// can't output two chunks at once, we store this information as a
|
// can't output two chunks at once, we store this information as a
|
||||||
// flag to output the newline immediately at the earliest
|
// flag to output the newline immediately at the earliest
|
||||||
// opportunity.
|
// opportunity.
|
||||||
if (m_wrap_breaks && *m_iterator == '\n') {
|
if (m_respect_linebreaks && *m_iterator == '\n') {
|
||||||
m_last_was_newline = true;
|
m_last_was_newline = true;
|
||||||
if (auto result = try_commit_chunk(start_of_chunk, m_iterator, false); result.has_value()) {
|
if (auto result = try_commit_chunk(start_of_chunk, m_iterator, false); result.has_value()) {
|
||||||
return result.release_value();
|
return result.release_value();
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
class ChunkIterator {
|
class ChunkIterator {
|
||||||
public:
|
public:
|
||||||
ChunkIterator(StringView const& text, LayoutMode, bool wrap_lines, bool wrap_breaks);
|
ChunkIterator(StringView const& text, LayoutMode, bool wrap_lines, bool respect_linebreaks);
|
||||||
Optional<Chunk> next();
|
Optional<Chunk> next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
|
|
||||||
const LayoutMode m_layout_mode;
|
const LayoutMode m_layout_mode;
|
||||||
const bool m_wrap_lines;
|
const bool m_wrap_lines;
|
||||||
const bool m_wrap_breaks;
|
const bool m_respect_linebreaks;
|
||||||
bool m_last_was_space { false };
|
bool m_last_was_space { false };
|
||||||
bool m_last_was_newline { false };
|
bool m_last_was_newline { false };
|
||||||
Utf8View m_utf8_view;
|
Utf8View m_utf8_view;
|
||||||
|
@ -60,7 +60,7 @@ private:
|
||||||
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
||||||
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
||||||
virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
||||||
void split_into_lines_by_rules(InlineFormattingContext&, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);
|
void split_into_lines_by_rules(InlineFormattingContext&, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_respect_linebreaks);
|
||||||
void paint_cursor_if_needed(PaintContext&, const LineBoxFragment&) const;
|
void paint_cursor_if_needed(PaintContext&, const LineBoxFragment&) const;
|
||||||
void paint_text_decoration(Gfx::Painter&, LineBoxFragment const&) const;
|
void paint_text_decoration(Gfx::Painter&, LineBoxFragment const&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue