mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Port Selection interface from DeprecatedString to String
This commit is contained in:
parent
901220c588
commit
9f047819a5
3 changed files with 10 additions and 10 deletions
|
@ -104,13 +104,13 @@ unsigned Selection::range_count() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
DeprecatedString Selection::type() const
|
||||
String Selection::type() const
|
||||
{
|
||||
if (!m_range)
|
||||
return "None";
|
||||
return "None"_string;
|
||||
if (m_range->collapsed())
|
||||
return "Caret";
|
||||
return "Range";
|
||||
return "Caret"_string;
|
||||
return "Range"_string;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/selection-api/#dom-selection-getrangeat
|
||||
|
@ -421,13 +421,13 @@ bool Selection::contains_node(JS::NonnullGCPtr<DOM::Node> node, bool allow_parti
|
|||
&& (end_relative_position == DOM::RelativeBoundaryPointPosition::Equal || end_relative_position == DOM::RelativeBoundaryPointPosition::After);
|
||||
}
|
||||
|
||||
DeprecatedString Selection::to_deprecated_string() const
|
||||
String Selection::to_string() const
|
||||
{
|
||||
// FIXME: This needs more work to be compatible with other engines.
|
||||
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=10583
|
||||
if (!m_range)
|
||||
return DeprecatedString::empty();
|
||||
return m_range->to_deprecated_string();
|
||||
return String {};
|
||||
return String::from_deprecated_string(m_range->to_deprecated_string()).release_value();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> Selection::document() const
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
unsigned focus_offset() const;
|
||||
bool is_collapsed() const;
|
||||
unsigned range_count() const;
|
||||
DeprecatedString type() const;
|
||||
String type() const;
|
||||
WebIDL::ExceptionOr<JS::GCPtr<DOM::Range>> get_range_at(unsigned index);
|
||||
void add_range(JS::NonnullGCPtr<DOM::Range>);
|
||||
WebIDL::ExceptionOr<void> remove_range(JS::NonnullGCPtr<DOM::Range>);
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
delete_from_document();
|
||||
bool contains_node(JS::NonnullGCPtr<DOM::Node>, bool allow_partial_containment) const;
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
String to_string() const;
|
||||
|
||||
// Non-standard convenience accessor for the selection's range.
|
||||
JS::GCPtr<DOM::Range> range() const;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import <DOM/Node.idl>
|
||||
#import <DOM/Range.idl>
|
||||
|
||||
[Exposed=Window]
|
||||
[Exposed=Window, UseNewAKString]
|
||||
interface Selection {
|
||||
|
||||
readonly attribute Node? anchorNode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue