mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +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
				
			
		|  | @ -153,7 +153,7 @@ RefPtr<Core::MimeData> SheetModel::mime_data(const GUI::ModelSelection& selectio | |||
|     VERIFY(cursor); | ||||
| 
 | ||||
|     Position cursor_position { (size_t)cursor->column(), (size_t)cursor->row() }; | ||||
|     auto mime_data_buffer = mime_data->data("text/x-spreadsheet-data"); | ||||
|     auto mime_data_buffer = mime_data->data("text/x-spreadsheet-data"sv); | ||||
|     auto new_data = DeprecatedString::formatted("{}\n{}", | ||||
|         cursor_position.to_url(m_sheet).to_deprecated_string(), | ||||
|         StringView(mime_data_buffer)); | ||||
|  |  | |||
|  | @ -420,8 +420,8 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) | |||
| 
 | ||||
|         ScopeGuard update_after_drop { [this] { update(); } }; | ||||
| 
 | ||||
|         if (event.mime_data().has_format("text/x-spreadsheet-data")) { | ||||
|             auto const& data = event.mime_data().data("text/x-spreadsheet-data"); | ||||
|         if (event.mime_data().has_format("text/x-spreadsheet-data"sv)) { | ||||
|             auto const& data = event.mime_data().data("text/x-spreadsheet-data"sv); | ||||
|             StringView urls { data.data(), data.size() }; | ||||
|             Vector<Position> source_positions, target_positions; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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
	
	 Karol Kosek
						Karol Kosek