1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:04:59 +00:00

LibWeb: Port ProcessingInstruction from ByteString

This commit is contained in:
Shannon Booth 2023-12-24 15:41:50 +13:00 committed by Andreas Kling
parent 7ce3e113fa
commit 562e0d710c
4 changed files with 8 additions and 8 deletions

View file

@ -1427,7 +1427,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ProcessingInstruction>> Document::create_pr
// FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
// 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
return heap().allocate<ProcessingInstruction>(realm(), *this, data.to_byte_string(), target.to_byte_string());
return heap().allocate<ProcessingInstruction>(realm(), *this, data, target);
}
JS::NonnullGCPtr<Range> Document::create_range()

View file

@ -872,7 +872,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
auto processing_instruction = verify_cast<ProcessingInstruction>(this);
// Set copys target and data to those of node.
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data().to_byte_string(), processing_instruction->target());
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target());
copy = processing_instruction_copy;
}
// Otherwise, Do nothing.

View file

@ -13,8 +13,8 @@ namespace Web::DOM {
JS_DEFINE_ALLOCATOR(ProcessingInstruction);
ProcessingInstruction::ProcessingInstruction(Document& document, ByteString const& data, ByteString const& target)
: CharacterData(document, NodeType::PROCESSING_INSTRUCTION_NODE, MUST(String::from_byte_string(data)))
ProcessingInstruction::ProcessingInstruction(Document& document, String const& data, String const& target)
: CharacterData(document, NodeType::PROCESSING_INSTRUCTION_NODE, data)
, m_target(target)
{
}

View file

@ -17,16 +17,16 @@ class ProcessingInstruction final : public CharacterData {
public:
virtual ~ProcessingInstruction() override = default;
virtual FlyString node_name() const override { return MUST(FlyString::from_deprecated_fly_string(m_target)); }
virtual FlyString node_name() const override { return m_target; }
ByteString const& target() const { return m_target; }
String const& target() const { return m_target; }
private:
ProcessingInstruction(Document&, ByteString const& data, ByteString const& target);
ProcessingInstruction(Document&, String const& data, String const& target);
virtual void initialize(JS::Realm&) override;
ByteString m_target;
String m_target;
};
template<>