mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:17:35 +00:00
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
This commit is contained in:
parent
689ca370d4
commit
359d6e7b0b
111 changed files with 517 additions and 503 deletions
|
@ -22,15 +22,15 @@ DeprecatedString ContainerBlock::render_to_html(bool tight) const
|
|||
StringBuilder builder;
|
||||
|
||||
for (size_t i = 0; i + 1 < m_blocks.size(); ++i) {
|
||||
auto s = m_blocks[i].render_to_html(tight);
|
||||
auto s = m_blocks[i]->render_to_html(tight);
|
||||
builder.append(s);
|
||||
}
|
||||
|
||||
// I don't like this edge case.
|
||||
if (m_blocks.size() != 0) {
|
||||
auto& block = m_blocks[m_blocks.size() - 1];
|
||||
auto s = block.render_to_html(tight);
|
||||
if (tight && dynamic_cast<Paragraph const*>(&block)) {
|
||||
auto s = block->render_to_html(tight);
|
||||
if (tight && dynamic_cast<Paragraph const*>(block.ptr())) {
|
||||
builder.append(s.substring_view(0, s.length() - 1));
|
||||
} else {
|
||||
builder.append(s);
|
||||
|
@ -45,7 +45,7 @@ Vector<DeprecatedString> ContainerBlock::render_lines_for_terminal(size_t view_w
|
|||
Vector<DeprecatedString> lines;
|
||||
|
||||
for (auto& block : m_blocks) {
|
||||
for (auto& line : block.render_lines_for_terminal(view_width))
|
||||
for (auto& line : block->render_lines_for_terminal(view_width))
|
||||
lines.append(move(line));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ RecursionDecision ContainerBlock::walk(Visitor& visitor) const
|
|||
return rd;
|
||||
|
||||
for (auto const& block : m_blocks) {
|
||||
rd = block.walk(visitor);
|
||||
rd = block->walk(visitor);
|
||||
if (rd == RecursionDecision::Break)
|
||||
return rd;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ RecursionDecision ContainerBlock::walk(Visitor& visitor) const
|
|||
}
|
||||
|
||||
template<class CodeBlock>
|
||||
static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blocks, Heading* current_section)
|
||||
static bool try_parse_block(LineIterator& lines, Vector<NonnullOwnPtr<Block>>& blocks, Heading* current_section)
|
||||
{
|
||||
OwnPtr<CodeBlock> block = CodeBlock::parse(lines, current_section);
|
||||
if (!block)
|
||||
|
@ -78,7 +78,7 @@ static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blo
|
|||
}
|
||||
|
||||
template<typename BlockType>
|
||||
static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blocks)
|
||||
static bool try_parse_block(LineIterator& lines, Vector<NonnullOwnPtr<Block>>& blocks)
|
||||
{
|
||||
OwnPtr<BlockType> block = BlockType::parse(lines);
|
||||
if (!block)
|
||||
|
@ -89,7 +89,7 @@ static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blo
|
|||
|
||||
OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
|
||||
{
|
||||
NonnullOwnPtrVector<Block> blocks;
|
||||
Vector<NonnullOwnPtr<Block>> blocks;
|
||||
|
||||
StringBuilder paragraph_text;
|
||||
Heading* current_section = nullptr;
|
||||
|
@ -121,7 +121,7 @@ OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
|
|||
|
||||
bool heading = false;
|
||||
if ((heading = try_parse_block<Heading>(lines, blocks)))
|
||||
current_section = dynamic_cast<Heading*>(&blocks.last());
|
||||
current_section = dynamic_cast<Heading*>(blocks.last().ptr());
|
||||
|
||||
bool any = heading
|
||||
|| try_parse_block<Table>(lines, blocks)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Markdown {
|
|||
|
||||
class ContainerBlock final : public Block {
|
||||
public:
|
||||
ContainerBlock(NonnullOwnPtrVector<Block> blocks, bool has_blank_lines, bool has_trailing_blank_lines)
|
||||
ContainerBlock(Vector<NonnullOwnPtr<Block>> blocks, bool has_blank_lines, bool has_trailing_blank_lines)
|
||||
: m_blocks(move(blocks))
|
||||
, m_has_blank_lines(has_blank_lines)
|
||||
, m_has_trailing_blank_lines(has_trailing_blank_lines)
|
||||
|
@ -35,10 +35,10 @@ public:
|
|||
bool has_blank_lines() const { return m_has_blank_lines; }
|
||||
bool has_trailing_blank_lines() const { return m_has_trailing_blank_lines; }
|
||||
|
||||
NonnullOwnPtrVector<Block> const& blocks() const { return m_blocks; }
|
||||
Vector<NonnullOwnPtr<Block>> const& blocks() const { return m_blocks; }
|
||||
|
||||
private:
|
||||
NonnullOwnPtrVector<Block> m_blocks;
|
||||
Vector<NonnullOwnPtr<Block>> m_blocks;
|
||||
bool m_has_blank_lines;
|
||||
bool m_has_trailing_blank_lines;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ DeprecatedString List::render_to_html(bool) const
|
|||
|
||||
for (auto& item : m_items) {
|
||||
builder.append("<li>"sv);
|
||||
if (!m_is_tight || (item->blocks().size() != 0 && !dynamic_cast<Paragraph const*>(&(item->blocks()[0]))))
|
||||
if (!m_is_tight || (item->blocks().size() != 0 && !dynamic_cast<Paragraph const*>(item->blocks()[0].ptr())))
|
||||
builder.append('\n');
|
||||
builder.append(item->render_to_html(m_is_tight));
|
||||
builder.append("</li>\n"sv);
|
||||
|
|
|
@ -194,14 +194,14 @@ RecursionDecision Text::LinkNode::walk(Visitor& visitor) const
|
|||
void Text::MultiNode::render_to_html(StringBuilder& builder) const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
child.render_to_html(builder);
|
||||
child->render_to_html(builder);
|
||||
}
|
||||
}
|
||||
|
||||
void Text::MultiNode::render_for_terminal(StringBuilder& builder) const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
child.render_for_terminal(builder);
|
||||
child->render_for_terminal(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ size_t Text::MultiNode::terminal_length() const
|
|||
{
|
||||
size_t length = 0;
|
||||
for (auto& child : children) {
|
||||
length += child.terminal_length();
|
||||
length += child->terminal_length();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ RecursionDecision Text::MultiNode::walk(Visitor& visitor) const
|
|||
return rd;
|
||||
|
||||
for (auto const& child : children) {
|
||||
rd = child.walk(visitor);
|
||||
rd = child->walk(visitor);
|
||||
if (rd == RecursionDecision::Break)
|
||||
return rd;
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ NonnullOwnPtr<Text::Node> Text::parse_code(Vector<Token>::ConstIterator& tokens)
|
|||
|
||||
// Strip first and last space, when appropriate.
|
||||
if (!is_all_whitespace) {
|
||||
auto& first = dynamic_cast<TextNode&>(code->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(code->children.last());
|
||||
auto& first = dynamic_cast<TextNode&>(*code->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(*code->children.last());
|
||||
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
|
||||
first.text = first.text.substring(1);
|
||||
last.text = last.text.substring(0, last.text.length() - 1);
|
||||
|
@ -653,8 +653,8 @@ NonnullOwnPtr<Text::Node> Text::parse_strike_through(Vector<Token>::ConstIterato
|
|||
tokens = iterator;
|
||||
|
||||
if (!is_all_whitespace) {
|
||||
auto& first = dynamic_cast<TextNode&>(striked_text->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(striked_text->children.last());
|
||||
auto& first = dynamic_cast<TextNode&>(*striked_text->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(*striked_text->children.last());
|
||||
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
|
||||
first.text = first.text.substring(1);
|
||||
last.text = last.text.substring(0, last.text.length() - 1);
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
class MultiNode : public Node {
|
||||
public:
|
||||
NonnullOwnPtrVector<Node> children;
|
||||
Vector<NonnullOwnPtr<Node>> children;
|
||||
|
||||
virtual void render_to_html(StringBuilder& builder) const override;
|
||||
virtual void render_for_terminal(StringBuilder& builder) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue