mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
Userland: Take StringView in MimeData::data() and has_{format,text,urls}
This commit is contained in:
parent
d054116012
commit
4f638d3af2
4 changed files with 9 additions and 9 deletions
|
@ -20,19 +20,19 @@ class MimeData : public EventReceiver {
|
|||
public:
|
||||
virtual ~MimeData() = default;
|
||||
|
||||
ByteBuffer data(DeprecatedString const& mime_type) const { return m_data.get(mime_type).value_or({}); }
|
||||
ByteBuffer data(StringView mime_type) const { return m_data.get(mime_type).value_or({}); }
|
||||
void set_data(DeprecatedString const& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); }
|
||||
|
||||
bool has_format(DeprecatedString const& mime_type) const { return m_data.contains(mime_type); }
|
||||
bool has_format(StringView mime_type) const { return m_data.contains(mime_type); }
|
||||
Vector<DeprecatedString> formats() const;
|
||||
|
||||
// Convenience helpers for "text/plain"
|
||||
bool has_text() const { return has_format("text/plain"); }
|
||||
bool has_text() const { return has_format("text/plain"sv); }
|
||||
DeprecatedString text() const;
|
||||
void set_text(DeprecatedString const&);
|
||||
|
||||
// Convenience helpers for "text/uri-list"
|
||||
bool has_urls() const { return has_format("text/uri-list"); }
|
||||
bool has_urls() const { return has_format("text/uri-list"sv); }
|
||||
Vector<URL> urls() const;
|
||||
ErrorOr<void> set_urls(Vector<URL> const&);
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ DragOperation::Outcome DragOperation::exec()
|
|||
VERIFY(m_mime_data);
|
||||
|
||||
Gfx::ShareableBitmap drag_bitmap;
|
||||
if (m_mime_data->has_format("image/x-raw-bitmap")) {
|
||||
auto data = m_mime_data->data("image/x-raw-bitmap");
|
||||
if (m_mime_data->has_format("image/x-raw-bitmap"sv)) {
|
||||
auto data = m_mime_data->data("image/x-raw-bitmap"sv);
|
||||
auto bitmap = Gfx::Bitmap::create_from_serialized_byte_buffer(move(data)).release_value_but_fixme_should_propagate_errors();
|
||||
drag_bitmap = bitmap->to_shareable_bitmap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue