Truly independent web browser
LibWebView+UI/Qt: Show an icon for where the omnibox would go
Andreas Kling2f00bb0ea2d7
diff --git a/Libraries/LibWebView/Omnibox.cpp b/Libraries/LibWebView/Omnibox.cppindex 3c4a05f0ef7..33b5e6de851 100644--- a/Libraries/LibWebView/Omnibox.cpp+++ b/Libraries/LibWebView/Omnibox.cpp@@ -161,6 +161,7 @@ void Omnibox::begin_editing(String text){m_is_editing = true;m_is_suspended = false;+ m_delivery_held_while_suspended = {};m_provenance = TextProvenance::UserText;m_query = text;m_display_text = move(text);@@ -170,6 +171,8 @@ void Omnibox::begin_editing(String text)m_completion_suppression = Empty {};m_user_rejected_completion = false;m_active_query_id = {};+ // NB: Local files may have changed since the last session.+ m_query_classification = {};// A fresh editing session must not inherit the previous session's popup rows or act on deliveries// still in flight for the previous query.@@ -189,6 +192,7 @@ void Omnibox::end_editing()m_is_editing = false;m_is_suspended = false;+ m_delivery_held_while_suspended = {};m_completion_suppression = Empty {};m_user_rejected_completion = false;m_retained_engagement_input = {};@@ -270,6 +274,7 @@ void Omnibox::start_query()++m_next_query_id;VERIFY(m_next_query_id != 0);m_active_query_id = m_next_query_id;+ m_delivery_held_while_suspended = {};m_provider->query(*m_active_query_id, m_query, default_autocomplete_suggestion_limit);}@@ -307,7 +312,14 @@ void Omnibox::set_suspended(bool suspended){if (!m_is_editing)return;+ auto was_suspended = m_is_suspended;m_is_suspended = suspended;++ // NB: The rows that arrived while suspended are shown now, as one more delivery.+ if (was_suspended && !suspended) {+ if (auto held_delivery = exchange(m_delivery_held_while_suspended, {}); held_delivery.has_value())+ received_suggestions(held_delivery->query_id, move(held_delivery->suggestions));+ }}void Omnibox::will_delete_text()@@ -330,8 +342,12 @@ bool Omnibox::selection_is_explicit() constvoid Omnibox::received_suggestions(AutocompleteQueryID query_id, Vector<AutocompleteSuggestion> suggestions){- if (!m_is_editing || m_is_suspended || m_active_query_id != query_id)+ if (!m_is_editing || m_active_query_id != query_id)+ return;+ if (m_is_suspended) {+ m_delivery_held_while_suspended = HeldDelivery { query_id, move(suggestions) };return;+ }auto is_same_generation_refresh = m_popup_query_id == query_id;AutocompleteSuggestion const* previous_explicit_selection = nullptr;@@ -351,6 +367,8 @@ void Omnibox::received_suggestions(AutocompleteQueryID query_id, Vector<Autocompm_popup_query_id = query_id;m_popup_query = m_query;m_suggestions = move(suggestions);+ // NB: The selection indexes the old rows, and the chrome may read it while a completion is shown below.+ m_selection = {};if (preserved_selection.has_value()) {// The fresh selection is published to the chrome by the popup repaint below, not via@@ -360,7 +378,6 @@ void Omnibox::received_suggestions(AutocompleteQueryID query_id, Vector<Autocomp} else if (previous_explicit_selection) {// A previewed or explicitly selected row that vanished must stop being displayed. Enter must// not silently fall through to a different automatic result.- m_selection = {};restore_query_display();} else {m_selection = update_completion_for_suggestions(m_suggestions).map([](auto index) {@@ -369,13 +386,12 @@ void Omnibox::received_suggestions(AutocompleteQueryID query_id, Vector<Autocomp}if (m_suggestions.is_empty()) {- if (m_popup_visible) {- m_popup_visible = false;- m_selection = {};- if (on_suggestions_change)- on_suggestions_change();- }+ m_popup_visible = false;+ m_selection = {};restore_query_display();+ // NB: The chrome is told even if the popup was closed, since the editing icon may change.+ if (on_suggestions_change)+ on_suggestions_change();} else {// Repaint even when the popup is already visible: the rows changed under it.m_popup_visible = true;@@ -588,6 +604,7 @@ void Omnibox::abandon_popup_session(){m_user_rejected_completion = false;m_active_query_id = {};+ m_delivery_held_while_suspended = {};close_popup();m_provider->cancel();}@@ -731,6 +748,37 @@ void Omnibox::apply_completion(String suggestion_text, String completion_text)set_display(move(completion_text), completion_start);}+Omnibox::EditingIcon Omnibox::editing_icon() const+{+ static constexpr EditingIcon search_icon { .kind = EditingIcon::Kind::Search, .favicon_png = {} };++ // An empty field is a place to search from.+ if (m_display_text.is_empty())+ return search_icon;++ if (auto suggestion = suggestion_for_return(); suggestion.has_value()) {+ if (suggestion->source == AutocompleteSuggestionSource::Search || suggestion->source == AutocompleteSuggestionSource::ChooseSearchEngine)+ return search_icon;+ Optional<ByteBuffer const&> favicon_png;+ if (suggestion->favicon_png.has_value())+ favicon_png = *suggestion->favicon_png;+ return { .kind = EditingIcon::Kind::Page, .favicon_png = favicon_png };+ }++ // NB: The icon is asked for several times per key press, and classifying looks at the file system.+ if (!m_query_classification.has_value() || m_query_classification->query != m_query)+ m_query_classification = QueryClassification { m_query, classify_user_input(m_query).classification == UserInputClassification::Search };+ if (m_query_classification->is_search)+ return search_icon;+ return { .kind = EditingIcon::Kind::Page, .favicon_png = {} };+}++bool Omnibox::should_keep_editing_icon() const+{+ // NB: After the user chose a row, or typed over or deleted a completion, the icon already shows where Return goes.+ return has_pending_suggestions() && !m_display_text.is_empty() && !selection_is_explicit() && !m_user_rejected_completion;+}+Optional<String> Omnibox::completion_title() const{if (m_provenance != TextProvenance::InlineCompleted || !m_completion_suggestion.has_value())diff --git a/Libraries/LibWebView/Omnibox.h b/Libraries/LibWebView/Omnibox.hindex f272e9a6ead..4bac6116eb9 100644--- a/Libraries/LibWebView/Omnibox.h+++ b/Libraries/LibWebView/Omnibox.h@@ -116,6 +116,21 @@ public:// The title of the page the text on display is inline completed to, if it has one.Optional<String> completion_title() const;+ // While editing, the icon before the text says where Return would go: a search, or a page and its favicon.+ struct EditingIcon {+ enum class Kind {+ Search,+ Page,+ };++ Kind kind { Kind::Search };+ Optional<ByteBuffer const&> favicon_png;+ };+ EditingIcon editing_icon() const;+ // Each key press asks for new suggestions, and until they arrive, Return would go to the text as typed. The icon+ // stays as it is meanwhile, rather than flickering on each key, unless Return goes to the text as typed anyway.+ bool should_keep_editing_icon() const;+// Callbacks to the chrome:Function<void(Display const&)> on_display_change;Function<void()> on_suggestions_change;@@ -179,11 +194,23 @@ private:NonnullOwnPtr<OmniboxSuggestionProvider> m_provider;+ struct QueryClassification {+ String query;+ bool is_search { false };+ };+ mutable Optional<QueryClassification> m_query_classification;+bool m_is_editing { false };// The chrome temporarily handed input elsewhere (for example a context menu) without ending the- // session; suggestion deliveries are dropped and completions left alone until it resumes.+ // session; suggestion deliveries are held and completions left alone until it resumes.bool m_is_suspended { false };+ // The latest rows for the active query that arrived while suspended, shown on resuming.+ struct HeldDelivery {+ AutocompleteQueryID query_id;+ Vector<AutocompleteSuggestion> suggestions;+ };+ Optional<HeldDelivery> m_delivery_held_while_suspended;TextProvenance m_provenance { TextProvenance::UserText };@@ -213,14 +240,14 @@ private:// strings. The rows survive close_popup() so the arrow keys can bring a dismissed popup back.bool m_popup_visible { false };Optional<AutocompleteQueryID> m_popup_query_id;+ // The text the rows in the popup were made for.+ String m_popup_query;Vector<AutocompleteSuggestion> m_suggestions;Optional<Selection> m_selection;u64 m_next_query_id { 0 };Optional<AutocompleteQueryID> m_active_query_id;OmniboxDestinationKind m_destination_kind_for_last_commit { OmniboxDestinationKind::URL };- // The text the rows in the popup were made for.- String m_popup_query;};}diff --git a/Tests/LibWebView/TestOmnibox.cpp b/Tests/LibWebView/TestOmnibox.cppindex 67e12525536..aa0450a311c 100644--- a/Tests/LibWebView/TestOmnibox.cpp+++ b/Tests/LibWebView/TestOmnibox.cpp@@ -124,6 +124,8 @@ struct Harness {omnibox.on_display_change = [this](Omnibox::Display const& display) {display_text = display.text;selection_start = display.selection_start;+ // NB: The chrome redraws the editing icon whenever the text changes, even in the middle of an update.+ (void)omnibox.editing_icon();};omnibox.on_commit = [this](String text) {commits.append(move(text));@@ -1210,6 +1212,81 @@ TEST_CASE(deleting_from_a_previewed_row_does_not_highlight_rows_for_older_text)EXPECT_NE(harness.commits.last(), "ex"sv);}+TEST_CASE(a_completion_for_fewer_rows_than_the_chosen_row_does_not_read_past_them)+{+ Harness harness;+ harness.begin_editing();++ harness.press_key('t');+ harness.provider->deliver({ history_row("https://ta.example/"sv), history_row("https://tb.example/"sv), history_row("https://tc.example/"sv), history_row("https://td.example/"sv) });+ EXPECT(harness.omnibox.select_next_suggestion());+ EXPECT(harness.omnibox.select_next_suggestion());+ EXPECT(harness.omnibox.select_next_suggestion());+ EXPECT_EQ(harness.omnibox.selected_suggestion(), 3u);++ // The user types after the chosen row, and the new rows are fewer than the row that was chosen. Completing to the+ // top row redraws the editing icon before the selection for the new rows is decided.+ harness.press_key('x');+ auto completed_row = MUST(String::formatted("https://{}yz.example/", harness.display_text));+ harness.provider->deliver({ history_row(completed_row) });+ EXPECT(harness.omnibox.is_inline_completed());+ EXPECT_EQ(harness.omnibox.selected_suggestion(), 0u);+}++TEST_CASE(rows_held_while_suspended_show_on_resuming)+{+ Harness harness;+ harness.begin_editing();++ harness.press_key('t');+ harness.omnibox.set_suspended(true);+ harness.provider->deliver({ search_row("t"sv) });+ EXPECT(harness.omnibox.has_pending_suggestions());+ EXPECT(!harness.omnibox.is_popup_visible());++ // The rows show without asking for them again.+ auto queries_before_resuming = harness.provider->queries.size();+ harness.omnibox.set_suspended(false);+ EXPECT_EQ(harness.provider->queries.size(), queries_before_resuming);+ EXPECT(!harness.omnibox.has_pending_suggestions());+ EXPECT(harness.omnibox.is_popup_visible());+}++TEST_CASE(refreshed_rows_held_while_suspended_keep_the_chosen_row)+{+ Harness harness;+ harness.begin_editing();++ harness.press_key('t');+ harness.provider->deliver({ search_row("t"sv), non_inline_history_row("https://www.tango.example/"sv) });+ EXPECT(harness.omnibox.select_next_suggestion());+ auto previewed_text = harness.display_text;++ // The remote rows refresh the rows on display while a context menu is open.+ harness.omnibox.set_suspended(true);+ harness.provider->deliver({ search_row("t"sv), non_inline_history_row("https://www.tango.example/"sv), search_row("tea"sv) });++ auto queries_before_resuming = harness.provider->queries.size();+ harness.omnibox.set_suspended(false);+ EXPECT_EQ(harness.provider->queries.size(), queries_before_resuming);+ EXPECT_EQ(harness.omnibox.suggestions().size(), 3u);+ EXPECT(harness.omnibox.selection_is_explicit());+ EXPECT_EQ(harness.display_text, previewed_text);+}++TEST_CASE(no_rows_with_the_popup_closed_still_tell_the_chrome)+{+ Harness harness;+ harness.begin_editing();++ harness.press_key('t');+ auto repaints_before = harness.popup_repaints;+ harness.provider->deliver({});+ EXPECT(!harness.omnibox.has_pending_suggestions());+ EXPECT(!harness.omnibox.is_popup_visible());+ EXPECT_EQ(harness.popup_repaints, repaints_before + 1);+}+TEST_CASE(restarting_the_session_cancels_in_flight_queries){Harness harness;@@ -1466,6 +1543,7 @@ void walk(u64 seed, size_t step_count, WalkCoverage& coverage)// Return goes exactly where the field said it would.auto target = harness.omnibox.suggestion_for_return();auto expected = target.has_value() ? target->text : harness.omnibox.query();+ auto icon_says_search = harness.omnibox.editing_icon().kind == Omnibox::EditingIcon::Kind::Search;++(target.has_value() ? coverage.returns_to_suggestions : coverage.returns_to_typed_text);auto commit_count = harness.commits.size();harness.omnibox.return_pressed();@@ -1473,6 +1551,11 @@ void walk(u64 seed, size_t step_count, WalkCoverage& coverage)FAIL(MUST(String::formatted("Return did not go to '{}'{}", expected, harness.describe_context())));return;}+ // The icon said whether Return would search or go to a page.+ if (icon_says_search != (harness.commit_destination_kinds.last() == WebView::OmniboxDestinationKind::Search)) {+ FAIL(MUST(String::formatted("The icon did not say where Return went for '{}'{}", expected, harness.describe_context())));+ return;+ }restart();}harness.check_invariants();@@ -1617,6 +1700,12 @@ struct Scenario {}AutocompleteSuggestion const& top_row() const { return harness.omnibox.suggestions().first(); }+ bool icon_is_search() const { return harness.omnibox.editing_icon().kind == Omnibox::EditingIcon::Kind::Search; }+ bool icon_is_page_with_favicon() const+ {+ auto icon = harness.omnibox.editing_icon();+ return icon.kind == Omnibox::EditingIcon::Kind::Page && icon.favicon_png.has_value();+ }bool top_row_is_highlighted() const { return harness.omnibox.selected_suggestion() == 0u; }// Where Return would go, as text.@@ -1664,6 +1753,7 @@ ScenarioProfile reddit_profile()TEST_CASE(scenario_typing_a_visited_site_completes_it_with_its_favicon){Scenario scenario(reddit_profile());+ EXPECT(scenario.icon_is_search());scenario.type("red"sv);EXPECT_EQ(scenario.harness.display_text, "reddit.com"sv);@@ -1674,6 +1764,7 @@ TEST_CASE(scenario_typing_a_visited_site_completes_it_with_its_favicon)EXPECT_EQ(scenario.harness.omnibox.completion_title(), "Reddit - The heart of the internet"sv);EXPECT_EQ(scenario.rows_for("reddit.com"sv), 1u);EXPECT(!scenario.return_searches());+ EXPECT(scenario.icon_is_page_with_favicon());EXPECT(walk_page_address(scenario.return_destination()) == "reddit.com/"sv);}@@ -1688,6 +1779,7 @@ TEST_CASE(scenario_backspacing_a_completion_leads_with_the_search)EXPECT_EQ(scenario.top_row().text, "red"sv);EXPECT(scenario.top_row_is_highlighted());EXPECT(scenario.return_searches());+ EXPECT(scenario.icon_is_search());EXPECT_EQ(scenario.return_destination(), "red"sv);}@@ -1702,6 +1794,7 @@ TEST_CASE(scenario_a_page_matching_only_by_title_does_not_take_return)EXPECT_EQ(scenario.top_row().text, "eau de"sv);EXPECT(scenario.top_row_is_highlighted());EXPECT(scenario.return_searches());+ EXPECT(scenario.icon_is_search());EXPECT_EQ(scenario.rows_for("example.com/fragrance"sv), 1u);}@@ -1712,6 +1805,7 @@ TEST_CASE(scenario_a_remote_address_of_an_unvisited_site_is_a_search)EXPECT_EQ(scenario.top_row().text, "goog"sv);EXPECT(scenario.top_row_is_highlighted());+ EXPECT(scenario.icon_is_search());auto const& rows = scenario.harness.omnibox.suggestions();EXPECT(rows.contains([](auto const& row) { return row.text == "google.com"sv && row.source == AutocompleteSuggestionSource::Search; }));EXPECT_EQ(scenario.rows_for("google.com"sv), 0u);@@ -1727,6 +1821,7 @@ TEST_CASE(scenario_a_remote_address_merges_with_the_visited_page)EXPECT_EQ(scenario.rows_for("google.com"sv), 1u);EXPECT(scenario.top_row().favicon_png.has_value());EXPECT_EQ(scenario.harness.display_text, "google.com"sv);+ EXPECT(scenario.icon_is_page_with_favicon());}TEST_CASE(scenario_a_typed_address_goes_to_that_address)@@ -1738,6 +1833,7 @@ TEST_CASE(scenario_a_typed_address_goes_to_that_address)EXPECT_EQ(scenario.top_row().source, AutocompleteSuggestionSource::LiteralURL);EXPECT_EQ(scenario.rows_for("ladybird.org"sv), 1u);EXPECT(!scenario.return_searches());+ EXPECT(!scenario.icon_is_search());}TEST_CASE(scenario_without_a_search_engine_offers_to_choose_one)@@ -1749,4 +1845,40 @@ TEST_CASE(scenario_without_a_search_engine_offers_to_choose_one)EXPECT_EQ(scenario.top_row().source, AutocompleteSuggestionSource::ChooseSearchEngine);EXPECT(scenario.top_row_is_highlighted());+ EXPECT(scenario.icon_is_search());+}++TEST_CASE(scenario_the_icon_holds_while_typing_through_a_completion)+{+ Scenario scenario(reddit_profile());+ scenario.type("red"sv);+ EXPECT(scenario.icon_is_page_with_favicon());++ // The next key press keeps the completion, and its suggestions have yet to arrive.+ scenario.harness.press_key('d');+ EXPECT_EQ(scenario.harness.display_text, "reddit.com"sv);+ EXPECT(scenario.harness.omnibox.should_keep_editing_icon());+ scenario.deliver();+ EXPECT(!scenario.harness.omnibox.should_keep_editing_icon());+ EXPECT(scenario.icon_is_page_with_favicon());++ // Backspacing over the completion does not keep the page's icon while the search's suggestions are on their way.+ scenario.harness.press_backspace();+ EXPECT(!scenario.harness.omnibox.should_keep_editing_icon());+ EXPECT(scenario.icon_is_search());+}++TEST_CASE(scenario_backspacing_a_completion_without_a_search_engine_offers_to_choose_one)+{+ auto profile = reddit_profile();+ profile.search_engine = {};+ Scenario scenario(move(profile));+ scenario.type("red"sv);+ EXPECT_EQ(scenario.harness.display_text, "reddit.com"sv);++ scenario.backspace();+ EXPECT_EQ(scenario.harness.display_text, "red"sv);+ EXPECT_EQ(scenario.top_row().source, AutocompleteSuggestionSource::ChooseSearchEngine);+ EXPECT(scenario.top_row_is_highlighted());+ EXPECT_EQ(scenario.return_destination(), "about:settings#search"sv);}diff --git a/UI/Qt/Autocomplete.h b/UI/Qt/Autocomplete.hindex d96d3e27b1d..9e2b6990cf6 100644--- a/UI/Qt/Autocomplete.h+++ b/UI/Qt/Autocomplete.h@@ -45,6 +45,7 @@ public:void show_with_suggestions(Vector<WebView::AutocompleteSuggestion>, Optional<size_t> selected_suggestion_index);void set_selected_suggestion(Optional<size_t> suggestion_index);bool close();+ bool is_visible() const;signals:void suggestion_clicked(int suggestion_index);@@ -58,7 +59,6 @@ private:int list_height() const;void show_current_suggestions();void set_anchor_popup_open(bool);- bool is_visible() const;bool is_selectable_row(int row) const;QLineEdit* m_anchor { nullptr };diff --git a/UI/Qt/LocationEdit.cpp b/UI/Qt/LocationEdit.cppindex cbd7fcac8e8..8b17136214c 100644--- a/UI/Qt/LocationEdit.cpp+++ b/UI/Qt/LocationEdit.cpp@@ -461,6 +461,7 @@ LocationEdit::LocationEdit(QWidget* parent, WebView::IsPrivate is_private)m_omnibox.on_selection_change = [this] {m_autocomplete->set_selected_suggestion(m_omnibox.selected_suggestion());+ update_location_icon();};m_omnibox.on_commit = [this](String const& input) {@@ -598,6 +599,7 @@ void LocationEdit::update_completion_title()m_completion_title->adjustSize();}m_completion_title->setVisible(title.has_value());+ update_location_icon();update_text_margins();update_trailing_item_positions();}@@ -828,7 +830,6 @@ void LocationEdit::focusInEvent(QFocusEvent* event)if (auto parked = m_parked_editing_session; parked.has_value()) {m_parked_editing_session.clear();NativeTextEditingLineEdit::focusInEvent(event);- m_omnibox.set_suspended(false);// Restore the selection with the cursor at the end it was on.if (parked->selection_length > 0) {@@ -839,7 +840,11 @@ void LocationEdit::focusInEvent(QFocusEvent* event)} else {setCursorPosition(parked->cursor_position);}- if (m_omnibox.is_popup_visible())++ // NB: Resuming shows rows that arrived while parked, which may complete the text, so the parked selection is+ // restored first. Those rows may already have shown the popup.+ m_omnibox.set_suspended(false);+ if (m_omnibox.is_popup_visible() && !m_autocomplete->is_visible())m_autocomplete->show_with_suggestions(m_omnibox.suggestions(), m_omnibox.selected_suggestion());show_focus_ring();return;@@ -922,6 +927,7 @@ void LocationEdit::show_focus_ring()emit editing_location_changed();}update_trailing_action_visibility();+ update_location_icon();animate_focus_ring();}@@ -1148,6 +1154,8 @@ void LocationEdit::update_trailing_item_positions()void LocationEdit::search_engine_settings_changed(){+ // NB: The change cancels the suggestions on their way, so the editing icon cannot wait for them.+ m_editing_icon_kind = {};update_location_icon();}@@ -1199,6 +1207,8 @@ void LocationEdit::schedule_chrome_style_update()update_chrome_style();m_autocomplete->schedule_chrome_style_update();update_focus_ring(m_focus_ring_opacity);+ // NB: The editing icon's color follows the appearance.+ m_editing_icon_kind = {};update_location_icon();update_zoom_indicator();highlight_location();@@ -1207,13 +1217,44 @@ void LocationEdit::schedule_chrome_style_update()});}+// While the address is being edited, the icon says where Return would go. It is rebuilt only when that changes.+void LocationEdit::update_editing_icon()+{+ auto icon = m_omnibox.editing_icon();+ auto favicon_png = icon.favicon_png.has_value() ? icon.favicon_png->bytes() : ReadonlyBytes {};+ if (m_editing_icon_kind == icon.kind && favicon_png == m_editing_favicon_png.bytes())+ return;++ m_editing_icon_kind = icon.kind;+ m_editing_favicon_png = MUST(ByteBuffer::copy(favicon_png));++ auto muted = Theme::chrome(*this).muted;+ if (icon.kind == WebView::Omnibox::EditingIcon::Kind::Search) {+ m_leading_icon_button->setIcon(create_chrome_icon(ChromeIcon::Search, muted));+ return;+ }++ QIcon favicon;+ if (!favicon_png.is_empty())+ favicon = favicon_with_rounded_corners(icon_from_png(favicon_png, 16), 16);+ m_leading_icon_button->setIcon(favicon.isNull() ? create_chrome_icon(ChromeIcon::Globe, muted) : favicon);+}+// Before the address, the field shows a button for the site's information, or a warning when the connection is not-// secure. While the address is being edited, nothing comes before the text.+// secure. While the address is being edited, an icon for where it would go stands in the place of the site's button.void LocationEdit::update_location_icon(){if (!m_leading_icon_button)return;+ // OPTIMIZATION: This runs several times per key press. While the editing icon is up and set for the current+ // appearance, only the icon itself can change, so the button is not set up and laid out again.+ if (m_is_editing_location && m_shows_editing_icon && m_editing_icon_kind.has_value()) {+ if (!m_omnibox.should_keep_editing_icon())+ update_editing_icon();+ return;+ }+auto update_indicator_style = [this](bool not_secure) {if (m_leading_icon_button->property("notSecure").toBool() == not_secure)return;@@ -1232,6 +1273,8 @@ void LocationEdit::update_location_icon()};m_shows_site_settings_button = false;+ m_shows_editing_icon = false;+ m_leading_icon_button->setAttribute(Qt::WA_TransparentForMouseEvents, false);auto hide_indicator = [&] {update_indicator_style(false);@@ -1271,6 +1314,23 @@ void LocationEdit::update_location_icon()show_indicator(width);};+ if (m_is_editing_location) {+ update_indicator_style(false);+ m_leading_icon_button->setToolButtonStyle(Qt::ToolButtonIconOnly);+ m_leading_icon_button->setText({});+ // NB: The button showed something else until now, or the appearance changed, so the icon is set afresh.+ m_editing_icon_kind = {};+ update_editing_icon();+ m_leading_icon_button->setIconSize({ 16, 16 });+ m_leading_icon_button->setFixedSize(LOCATION_SITE_SETTINGS_BUTTON_WIDTH, LOCATION_PILL_HEIGHT);+ m_leading_icon_button->setToolTip({});+ // NB: The icon only shows where the text goes, so a click on it lands in the text.+ m_leading_icon_button->setAttribute(Qt::WA_TransparentForMouseEvents, true);+ show_indicator(LOCATION_SITE_SETTINGS_BUTTON_WIDTH);+ m_shows_editing_icon = true;+ return;+ }+auto is_showing_current_url_for_display = !hasFocus()&& m_url.has_value()&& text() == display_url();@@ -1436,6 +1496,8 @@ void LocationEdit::set_text_and_restart_editing(QString const& text)bool suspended = !hasFocus();m_omnibox.begin_editing(ak_string_from_qstring(text));m_omnibox.set_suspended(suspended);+ // NB: Setting the text redrew the editing icon for the session that was just replaced.+ update_location_icon();}void LocationEdit::set_url(Optional<URL::URL> url)diff --git a/UI/Qt/LocationEdit.h b/UI/Qt/LocationEdit.hindex 75eb71095bf..002d5aff5fb 100644--- a/UI/Qt/LocationEdit.h+++ b/UI/Qt/LocationEdit.h@@ -117,6 +117,7 @@ private:void update_trailing_item_positions();void update_chrome_style();void update_location_icon();+ void update_editing_icon();void update_zoom_indicator();void update_translate_button();void update_in_use_chip_icons();@@ -141,6 +142,7 @@ private:Autocomplete* m_autocomplete { nullptr };QToolButton* m_leading_icon_button { nullptr };bool m_shows_site_settings_button { false };+ bool m_shows_editing_icon { false };QPointer<QWidget> m_site_settings_popover;QVariantAnimation* m_site_settings_knob_animation { nullptr };qreal m_site_settings_knob_travel { 0 };@@ -155,6 +157,9 @@ private:InUseChip* m_location_in_use_chip { nullptr };InUseChip* m_microphone_in_use_chip { nullptr };QLabel* m_completion_title { nullptr };+ // The editing icon on the button, unless it has to be set afresh.+ Optional<WebView::Omnibox::EditingIcon::Kind> m_editing_icon_kind;+ ByteBuffer m_editing_favicon_png;QVariantAnimation* m_focus_ring_animation { nullptr };QGraphicsEffect* m_focus_ring_effect { nullptr };QAction* m_zoom_action { nullptr };