mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibWeb: Port Comment interface from DeprecatedString to String
This commit is contained in:
parent
4da1f4e836
commit
cc1e4c5cb3
6 changed files with 14 additions and 14 deletions
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
Comment::Comment(Document& document, DeprecatedString const& data)
|
Comment::Comment(Document& document, String const& data)
|
||||||
: CharacterData(document, NodeType::COMMENT_NODE, data)
|
: CharacterData(document, NodeType::COMMENT_NODE, data.to_deprecated_string())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-comment-comment
|
// https://dom.spec.whatwg.org/#dom-comment-comment
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> Comment::construct_impl(JS::Realm& realm, String const& data)
|
||||||
{
|
{
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||||
return realm.heap().allocate<Comment>(realm, window.associated_document(), data);
|
return realm.heap().allocate<Comment>(realm, window.associated_document(), data);
|
||||||
|
|
|
@ -15,13 +15,13 @@ class Comment final : public CharacterData {
|
||||||
WEB_PLATFORM_OBJECT(Comment, CharacterData);
|
WEB_PLATFORM_OBJECT(Comment, CharacterData);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> construct_impl(JS::Realm&, DeprecatedString const& data);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> construct_impl(JS::Realm&, String const& data);
|
||||||
virtual ~Comment() override = default;
|
virtual ~Comment() override = default;
|
||||||
|
|
||||||
virtual DeprecatedFlyString node_name() const override { return "#comment"; }
|
virtual DeprecatedFlyString node_name() const override { return "#comment"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Comment(Document&, DeprecatedString const&);
|
Comment(Document&, String const&);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#import <DOM/CharacterData.idl>
|
#import <DOM/CharacterData.idl>
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#comment
|
// https://dom.spec.whatwg.org/#comment
|
||||||
[Exposed=Window, UseDeprecatedAKString]
|
[Exposed=Window]
|
||||||
interface Comment : CharacterData {
|
interface Comment : CharacterData {
|
||||||
constructor(optional DOMString data = "");
|
constructor(optional DOMString data = "");
|
||||||
};
|
};
|
||||||
|
|
|
@ -1427,7 +1427,7 @@ JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
|
||||||
|
|
||||||
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
||||||
{
|
{
|
||||||
return heap().allocate<Comment>(realm(), *this, data);
|
return heap().allocate<Comment>(realm(), *this, MUST(String::from_deprecated_string(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||||
|
|
|
@ -812,7 +812,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
||||||
auto comment = verify_cast<Comment>(this);
|
auto comment = verify_cast<Comment>(this);
|
||||||
|
|
||||||
// Set copy’s data to that of node.
|
// Set copy’s data to that of node.
|
||||||
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data());
|
auto comment_copy = heap().allocate<Comment>(realm(), *document, MUST(String::from_deprecated_string(comment->data())));
|
||||||
copy = move(comment_copy);
|
copy = move(comment_copy);
|
||||||
} else if (is<ProcessingInstruction>(this)) {
|
} else if (is<ProcessingInstruction>(this)) {
|
||||||
// ProcessingInstruction
|
// ProcessingInstruction
|
||||||
|
|
|
@ -490,7 +490,7 @@ void HTMLParser::handle_initial(HTMLToken& token)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.is_comment()) {
|
if (token.is_comment()) {
|
||||||
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
|
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), MUST(String::from_deprecated_string(token.comment())));
|
||||||
MUST(document().append_child(*comment));
|
MUST(document().append_child(*comment));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ void HTMLParser::handle_before_html(HTMLToken& token)
|
||||||
// -> A comment token
|
// -> A comment token
|
||||||
if (token.is_comment()) {
|
if (token.is_comment()) {
|
||||||
// Insert a comment as the last child of the Document object.
|
// Insert a comment as the last child of the Document object.
|
||||||
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
|
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), MUST(String::from_deprecated_string(token.comment())));
|
||||||
MUST(document().append_child(*comment));
|
MUST(document().append_child(*comment));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -822,7 +822,7 @@ AnythingElse:
|
||||||
void HTMLParser::insert_comment(HTMLToken& token)
|
void HTMLParser::insert_comment(HTMLToken& token)
|
||||||
{
|
{
|
||||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||||
adjusted_insertion_location.parent->insert_before(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling);
|
adjusted_insertion_location.parent->insert_before(realm().heap().allocate<DOM::Comment>(realm(), document(), MUST(String::from_deprecated_string(token.comment()))), adjusted_insertion_location.insert_before_sibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLParser::handle_in_head(HTMLToken& token)
|
void HTMLParser::handle_in_head(HTMLToken& token)
|
||||||
|
@ -1142,7 +1142,7 @@ void HTMLParser::handle_after_body(HTMLToken& token)
|
||||||
|
|
||||||
if (token.is_comment()) {
|
if (token.is_comment()) {
|
||||||
auto& insertion_location = m_stack_of_open_elements.first();
|
auto& insertion_location = m_stack_of_open_elements.first();
|
||||||
MUST(insertion_location.append_child(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment())));
|
MUST(insertion_location.append_child(realm().heap().allocate<DOM::Comment>(realm(), document(), MUST(String::from_deprecated_string(token.comment())))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,7 +1178,7 @@ void HTMLParser::handle_after_body(HTMLToken& token)
|
||||||
void HTMLParser::handle_after_after_body(HTMLToken& token)
|
void HTMLParser::handle_after_after_body(HTMLToken& token)
|
||||||
{
|
{
|
||||||
if (token.is_comment()) {
|
if (token.is_comment()) {
|
||||||
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
|
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), MUST(String::from_deprecated_string(token.comment())));
|
||||||
MUST(document().append_child(*comment));
|
MUST(document().append_child(*comment));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3407,7 +3407,7 @@ void HTMLParser::handle_after_frameset(HTMLToken& token)
|
||||||
void HTMLParser::handle_after_after_frameset(HTMLToken& token)
|
void HTMLParser::handle_after_after_frameset(HTMLToken& token)
|
||||||
{
|
{
|
||||||
if (token.is_comment()) {
|
if (token.is_comment()) {
|
||||||
auto comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), token.comment());
|
auto comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), MUST(String::from_deprecated_string(token.comment())));
|
||||||
MUST(document().append_child(comment));
|
MUST(document().append_child(comment));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue