Files
Fırat Kızılboğa 67a0d6eae6 Browser: Share Find in Page search term across tabs
This adds a global search term stored in BrowserWindow that is shared
across all tabs. When opening Find in Page (Ctrl+F), the widget now
uses the following priority logic:

1. If there's text selected on the page, use that
2. If the search box is empty, use the global search term
3. Otherwise, keep the existing text

To imitatates Chromium's logic, the global search term is updated
whenever the user types, navigates matches, or when a selection
populates the search box.
2026-01-21 22:38:20 -05:00

51 lines
1.3 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* Copyright (c) 2026, Fırat Kızılboğa <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibGUI/Button.h>
#include <LibGUI/CheckBox.h>
#include <LibGUI/Event.h>
#include <LibGUI/Label.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/Widget.h>
#include <LibWebView/OutOfProcessWebView.h>
namespace Browser {
class FindInPageWidget final
: public GUI::Widget {
C_OBJECT(FindInPageWidget);
public:
virtual ~FindInPageWidget() override = default;
void initialize(WebView::OutOfProcessWebView& web_view);
void show(String const& global_term);
Function<void(String const&)> on_search_text_change;
private:
FindInPageWidget();
virtual void keydown_event(GUI::KeyEvent&) override;
void find_text_changed();
void notify_search_text_changed();
void update_result_label(size_t current_match_index, Optional<size_t> const& total_match_count);
RefPtr<WebView::OutOfProcessWebView> m_web_content_view;
RefPtr<GUI::Button> m_close_button;
RefPtr<GUI::Button> m_previous_button;
RefPtr<GUI::Button> m_next_button;
RefPtr<GUI::TextBox> m_search_textbox;
RefPtr<GUI::CheckBox> m_match_case_checkbox;
RefPtr<GUI::Label> m_result_label;
};
}