Skip to content

Truly independent web browser

UI/Qt: Remove the tab hover previews for now

Andreas Klingf89275ec7c7d
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index 9db81df815d..a55bb9847aa 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -54,7 +54,6 @@
#include <QEasingCurve>
#include <QEvent>
#include <QFontMetrics>
-#include <QFrame>
#include <QGraphicsDropShadowEffect>
#include <QGraphicsOpacityEffect>
#include <QGraphicsPixmapItem>
@@ -71,7 +70,6 @@
#include <QPainter>
#include <QPainterPath>
#include <QPixmap>
-#include <QScreen>
#include <QStaticText>
#include <QStyle>
#include <QStyleOptionButton>
@@ -216,12 +214,6 @@ static constexpr qreal HORIZONTAL_TAB_SEPARATOR_WIDTH = 1;
static constexpr qreal HORIZONTAL_TAB_SEPARATOR_HEIGHT = 16;
static constexpr int TAB_CONTENT_HORIZONTAL_INSET = 8;
static constexpr int VERTICAL_TABS_HOVER_COLLAPSE_POLL_INTERVAL_MS = 250;
-static constexpr int TAB_PREVIEW_HOVER_DELAY_MS = 350;
-static constexpr int TAB_PREVIEW_THUMBNAIL_WIDTH = 320;
-static constexpr int TAB_PREVIEW_THUMBNAIL_HEIGHT = 180;
-// NB: The shadow falls downward, so it needs less room above the card.
-static constexpr QMargins TAB_PREVIEW_SHADOW_MARGINS { 60, 36, 60, 90 };
-static constexpr int TAB_PREVIEW_CARD_GAP = 6;
// A tab's close button is a smaller square than its speaker button, and both draw their icons at the same size. The
// close button takes clicks from the whole height of its tab, in a slot a little wider than its square.
static constexpr int TAB_CLOSE_BUTTON_SIZE = 18;
@@ -653,170 +645,6 @@ private:
QSize m_size;
};
-class TabPreviewThumbnail final : public QWidget {
-public:
- AK_ALLOC_WITH_KMALLOC;
-
- explicit TabPreviewThumbnail(QWidget* parent)
- : QWidget(parent)
- {
- setFixedSize(TAB_PREVIEW_THUMBNAIL_WIDTH, TAB_PREVIEW_THUMBNAIL_HEIGHT);
- }
-
- void set_colors(QColor background, QColor border)
- {
- m_background = background;
- m_border = border;
- update();
- }
-
- void set_pixmap(QPixmap pixmap)
- {
- m_pixmap = AK::move(pixmap);
- update();
- }
-
-private:
- virtual void paintEvent(QPaintEvent*) override
- {
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
-
- auto outer_rect = rect();
- outer_rect.adjust(0, 0, -1, -1);
-
- QPainterPath outer_path;
- outer_path.addRoundedRect(outer_rect, 7, 7);
- painter.fillPath(outer_path, m_background);
-
- if (!m_pixmap.isNull()) {
- auto image_rect = rect().adjusted(1, 1, -1, -1);
- QPainterPath image_path;
- image_path.addRoundedRect(image_rect, 6, 6);
-
- painter.save();
- painter.setClipPath(image_path);
-
- auto x = image_rect.x() + (image_rect.width() - m_pixmap.width()) / 2;
- auto y = image_rect.y() + (image_rect.height() - m_pixmap.height()) / 2;
- painter.drawPixmap(x, y, m_pixmap);
- painter.restore();
- }
-
- painter.setPen(m_border);
- painter.drawPath(outer_path);
- }
-
- QColor m_background;
- QColor m_border;
- QPixmap m_pixmap;
-};
-
-class TabPreviewPopup final : public QWidget {
-public:
- AK_ALLOC_WITH_KMALLOC;
-
- explicit TabPreviewPopup(QWidget* parent)
- // NB: The preview only shows, and the room around it for its shadow lies over the tabs, so it lets the mouse
- // through. On X11, Qt adds the stays-on-top hint to a tooltip itself, takes that for a change of flags, and
- // recreates the window as it is first shown, and the new window takes the mouse again. Asking for the hint
- // here keeps the window from being recreated.
- : QWidget(parent, Qt::ToolTip | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowTransparentForInput | Qt::WindowStaysOnTopHint)
- {
- setAttribute(Qt::WA_TranslucentBackground);
- setAttribute(Qt::WA_ShowWithoutActivating);
- setAttribute(Qt::WA_TransparentForMouseEvents);
-
- // NB: KDE's widget styles have the window system cast a shadow around any tooltip window. The card casts its own
- // within this window, so that would be a second shadow around the room left for the first.
- setProperty("_KDE_NET_WM_SKIP_SHADOW", true);
-
- auto* outer_layout = new QVBoxLayout(this);
- outer_layout->setContentsMargins(TAB_PREVIEW_SHADOW_MARGINS);
- outer_layout->setSpacing(0);
-
- m_card = new QFrame(this);
- m_card->setObjectName("LadybirdTabPreviewCard");
-
- cast_popover_shadow(*m_card);
-
- auto* card_layout = new QVBoxLayout(m_card);
- card_layout->setContentsMargins(10, 10, 10, 10);
- card_layout->setSpacing(8);
-
- m_thumbnail = new TabPreviewThumbnail(m_card);
-
- m_title_label = new QLabel(m_card);
- m_title_label->setObjectName("LadybirdTabPreviewTitle");
- m_title_label->setFixedWidth(TAB_PREVIEW_THUMBNAIL_WIDTH);
- m_title_label->setTextFormat(Qt::PlainText);
-
- m_url_label = new QLabel(m_card);
- m_url_label->setObjectName("LadybirdTabPreviewURL");
- m_url_label->setFixedWidth(TAB_PREVIEW_THUMBNAIL_WIDTH);
- m_url_label->setTextFormat(Qt::PlainText);
-
- card_layout->addWidget(m_thumbnail);
- card_layout->addWidget(m_title_label);
- card_layout->addWidget(m_url_label);
- outer_layout->addWidget(m_card);
- }
-
- void set_preview(QPalette const& palette, QString title, QString url, Optional<QPixmap const&> thumbnail)
- {
- update_chrome_style(palette);
-
- if (title.trimmed().isEmpty())
- title = "Untitled";
-
- QFontMetrics title_metrics(m_title_label->font());
- QFontMetrics url_metrics(m_url_label->font());
-
- m_thumbnail->setVisible(thumbnail.has_value());
- if (thumbnail.has_value())
- m_thumbnail->set_pixmap(*thumbnail);
- m_title_label->setText(title_metrics.elidedText(title, Qt::ElideRight, TAB_PREVIEW_THUMBNAIL_WIDTH));
- m_url_label->setText(url_metrics.elidedText(url, Qt::ElideMiddle, TAB_PREVIEW_THUMBNAIL_WIDTH));
- adjustSize();
- }
-
-private:
- void update_chrome_style(QPalette const& palette)
- {
- auto card_background = ChromeStyle::style_sheet_color(ChromeStyle::chrome_surface(palette));
- auto thumbnail_background = ChromeStyle::chrome_surface_recessed(palette);
- auto border_color = ChromeStyle::chrome_control_border(palette);
- auto border = ChromeStyle::style_sheet_color(border_color);
- auto text = ChromeStyle::style_sheet_color(ChromeStyle::chrome_text(palette));
- auto muted_text = ChromeStyle::style_sheet_color(ChromeStyle::chrome_muted_text(palette));
-
- m_thumbnail->set_colors(thumbnail_background, border_color);
-
- setStyleSheet(qformatted(R"(
-QFrame#LadybirdTabPreviewCard {{
- background: {};
- border: 1px solid {};
- border-radius: 10px;
-}}
-
-QLabel#LadybirdTabPreviewTitle {{
- color: {};
- font-weight: 600;
-}}
-
-QLabel#LadybirdTabPreviewURL {{
- color: {};
-}}
-)",
- card_background, border, text, muted_text));
- }
-
- QFrame* m_card { nullptr };
- TabPreviewThumbnail* m_thumbnail { nullptr };
- QLabel* m_title_label { nullptr };
- QLabel* m_url_label { nullptr };
-};
-
class TabDragCancellationFilter final : public QObject {
public:
AK_ALLOC_WITH_KMALLOC;
@@ -900,24 +728,6 @@ TabBar::TabBar(TabWidget* tab_widget)
refresh_tab_layout();
});
- m_tab_preview_timer = new QTimer(this);
- m_tab_preview_timer->setInterval(TAB_PREVIEW_HOVER_DELAY_MS);
- m_tab_preview_timer->setSingleShot(true);
- connect(m_tab_preview_timer, &QTimer::timeout, this, &TabBar::show_tab_preview);
-
- m_tab_preview_popup = new TabPreviewPopup(this);
-
- // While the preview shows, the pointer's moves over the tab bar and out of it are followed by where it is.
- m_tab_preview_pointer_timer = new QTimer(this);
- m_tab_preview_pointer_timer->setInterval(50);
- connect(m_tab_preview_pointer_timer, &QTimer::timeout, this, [this] {
- auto position = mapFromGlobal(QCursor::pos());
- if (rect().contains(position))
- set_hovered_tab_index(tab_index_at(position));
- else
- pointer_left();
- });
-
m_loading_ring_animation = new QVariantAnimation(this);
m_loading_ring_animation->setDuration(ChromeStyle::LOADING_RING_PERIOD_MS);
m_loading_ring_animation->setStartValue(0.0);
@@ -1025,7 +835,6 @@ TabBar::TabBar(TabWidget* tab_widget)
});
connect(this, &QTabBar::currentChanged, this, [this](int index) {
- hide_tab_preview();
// NB: The selected horizontal tab has a larger minimum width (see tabSizeHint()).
if (tab_layout() == TabLayout::Horizontal)
refresh_tab_layout();
@@ -1085,7 +894,6 @@ void TabBar::set_vertical_tabs_position(WebView::VerticalTabsPosition position)
m_vertical_tabs_position = position;
if (m_tab_layout != TabLayout::Horizontal)
setShape(vertical_tabs_are_on_right() ? QTabBar::RoundedEast : QTabBar::RoundedWest);
- hide_tab_preview();
refresh_tab_layout();
}
@@ -1221,7 +1029,6 @@ int TabBar::horizontal_tab_share() const
void TabBar::resizeEvent(QResizeEvent* event)
{
- hide_tab_preview();
QTabBar::resizeEvent(event);
set_scroll_offset(m_scroll_offset);
ensure_tab_visible(currentIndex());
@@ -1247,21 +1054,6 @@ void TabBar::tabLayoutChange()
update_layout_animation();
set_scroll_offset(m_scroll_offset);
update_tab_button_geometry();
-
- if (m_tab_preview_index < 0)
- return;
-
- // NB: Title and favicon updates also change the tab layout. Keep the preview open if it still belongs
- // to the tab under the pointer, but dismiss it if tabs moved or were removed.
- auto hovered_tab = tab_index_at(mapFromGlobal(QCursor::pos()));
- if (hovered_tab != m_tab_preview_index || !m_tab_widget
- || (m_previewed_tab && m_tab_widget->tab(hovered_tab) != m_previewed_tab)) {
- hide_tab_preview();
- return;
- }
-
- if (m_previewed_tab)
- show_tab_preview();
}
bool TabBar::event(QEvent* event)
@@ -1270,15 +1062,6 @@ bool TabBar::event(QEvent* event)
if (event->type() == QEvent::WindowActivate || event->type() == QEvent::WindowDeactivate)
update();
- // The preview stays above every other window, and no Leave arrives when another application takes the front, so
- // it goes away with the window's activation.
- if (event->type() == QEvent::WindowDeactivate)
- hide_tab_preview();
-
- // The pointer may still rest on the tab whose preview went away, so a preview of it is due again.
- if (event->type() == QEvent::WindowActivate && m_hovered_tab_index >= 0 && rect().contains(mapFromGlobal(QCursor::pos())))
- schedule_tab_preview(m_hovered_tab_index);
-
// The ring stops turning while the tab bar is hidden, so it has to start again for tabs still loading when it is shown.
if (event->type() == QEvent::Show)
update_loading_ring_animation();
@@ -1294,15 +1077,11 @@ Optional<ToolTipContent> TabBar::tooltip_at(QPoint position) const
auto* tab = m_tab_widget ? m_tab_widget->tab(hovered_tab) : nullptr;
- // A tab that shows a preview doesn't need a tooltip as well.
- if (tab && hovered_tab != currentIndex() && (!tab->is_loaded() || tab->view().tab_preview_pixmap({ TAB_PREVIEW_THUMBNAIL_WIDTH, TAB_PREVIEW_THUMBNAIL_HEIGHT }).has_value()))
- return ToolTipContent {};
-
- // The selected tab shows no preview, so a title too long for it shows in full, with the site, in a tooltip.
- if (tab && hovered_tab == currentIndex() && m_tabs_with_cut_titles.contains(tab)) {
+ // A title too long for its tab shows in full, with the site, in a tooltip.
+ if (tab && m_tabs_with_cut_titles.contains(tab)) {
auto text = tabText(hovered_tab);
// A URL without a host (about:blank, e.g.) has no site to show.
- if (auto url = tab->view().url(); url.host().has_value() && !url.serialized_host().is_empty())
+ if (auto url = tab->url(); url.host().has_value() && !url.serialized_host().is_empty())
text = qformatted("{}\n{}", ak_string_from_qstring(text), url.serialized_host());
return ToolTipContent { .text = AK::move(text), .rect = visual_tab_rect(hovered_tab) };
}
@@ -1530,6 +1309,10 @@ void TabBar::paintEvent(QPaintEvent*)
};
if (is_collapsed_vertical || is_pinned_tile) {
+ // A tab that shows only an icon has its title cut entirely.
+ if (auto* tab = m_tab_widget ? m_tab_widget->tab(index) : nullptr; tab && !tabText(index).isEmpty())
+ tabs_with_cut_titles.set(tab);
+
// The speaker and the microphone take the favicon's place on a pinned tile.
if (is_pinned_tile && (tabButton(index, QTabBar::LeftSide) || microphone_indicator(index)))
continue;
@@ -1569,6 +1352,9 @@ void TabBar::paintEvent(QPaintEvent*)
}
if (!is_vertical && contents_rect.width() < HORIZONTAL_TAB_MIN_CONTENT_WIDTH_FOR_TITLE) {
+ // A tab too narrow for its title has it cut entirely.
+ if (auto* tab = m_tab_widget ? m_tab_widget->tab(index) : nullptr; tab && !tabText(index).isEmpty())
+ tabs_with_cut_titles.set(tab);
// NB: A tab too narrow for its favicon next to its mute button shows the mute button alone, rather than
// drawing the favicon over it.
if (contents_rect.width() < TAB_ICON_SIZE)
@@ -1734,7 +1520,6 @@ void TabBar::dragEnterEvent(QDragEnterEvent* event)
void TabBar::dragLeaveEvent(QDragLeaveEvent* event)
{
- hide_tab_preview();
hide_drop_preview();
QTabBar::dragLeaveEvent(event);
}
@@ -1754,7 +1539,6 @@ void TabBar::dragMoveEvent(QDragMoveEvent* event)
void TabBar::dropEvent(QDropEvent* event)
{
- hide_tab_preview();
if (!m_tab_widget || !target_can_accept_tab_drop(*m_tab_widget, *event)) {
hide_drop_preview();
event->ignore();
@@ -1796,7 +1580,6 @@ bool TabBar::eventFilter(QObject* watched, QEvent* event)
void TabBar::mousePressEvent(QMouseEvent* event)
{
- hide_tab_preview();
auto pressed_tab = tab_index_at(event->pos());
m_pressed_tab = (m_tab_widget && pressed_tab >= 0) ? m_tab_widget->tab(pressed_tab) : nullptr;
@@ -1860,26 +1643,12 @@ void TabBar::enterEvent(QEnterEvent* event)
}
void TabBar::leaveEvent(QEvent* event)
-{
- // NB: The tab preview's window reaches over the tabs, to make room for its shadow. Though it lets the mouse through,
- // the pointer leaves the tab bar for it while it is still over the tab bar, so where the pointer is is watched
- // instead while the preview shows.
- if (m_tab_preview_popup && m_tab_preview_popup->isVisible() && rect().contains(mapFromGlobal(QCursor::pos()))) {
- QTabBar::leaveEvent(event);
- return;
- }
-
- pointer_left();
- QTabBar::leaveEvent(event);
-}
-
-void TabBar::pointer_left()
{
if (m_locked_tab_width.has_value())
m_tab_width_unlock_timer->start();
- hide_tab_preview();
set_hovered_tab_index(-1);
+ QTabBar::leaveEvent(event);
}
void TabBar::mouseReleaseEvent(QMouseEvent* event)
@@ -2451,8 +2220,6 @@ QPixmap TabBar::render_tab_drag_pixmap(int index) const
void TabBar::start_tab_drag(int index)
{
- hide_tab_preview();
-
if (!m_tab_widget || !m_tab_widget->tab(index))
return;
@@ -2771,157 +2538,6 @@ TabMicrophoneIndicator* TabBar::microphone_indicator(int index) const
return m_microphone_indicators.get(tab).value_or(nullptr);
}
-void TabBar::schedule_tab_preview(int index)
-{
- if (!m_tab_preview_timer || !m_tab_preview_popup)
- return;
-
- // An inactive window shows no preview: it would float over the application in front.
- if (!m_tab_widget || index < 0 || index == currentIndex() || index >= count() || m_pressed_tab || !isActiveWindow()) {
- hide_tab_preview();
- return;
- }
-
- if (m_tab_preview_index == index && m_tab_preview_popup->isVisible())
- return;
-
- hide_tab_preview();
- m_tab_preview_index = index;
- hide_tooltip();
- m_tab_preview_timer->start();
-}
-
-void TabBar::show_tab_preview()
-{
- if (!m_tab_widget || !m_tab_preview_popup)
- return;
-
- auto index = m_tab_preview_index;
- if (index < 0 || index != m_hovered_tab_index || index == currentIndex() || index >= count() || !isActiveWindow()) {
- hide_tab_preview();
- return;
- }
-
- auto* tab = m_tab_widget->tab(index);
- if (!tab) {
- hide_tab_preview();
- return;
- }
-
- // A tab that hasn't loaded has no page to show, so its preview is its title and URL.
- if (!tab->is_loaded()) {
- m_tab_preview_popup->set_preview(palette(), tab->title(), qstring_from_ak_string(tab->url().serialize()), {});
- show_tab_preview_popup(index);
- return;
- }
-
- if (m_previewed_tab != tab) {
- stop_following_previewed_tab_frames();
- m_previewed_tab = tab;
- m_tab_preview_paint_connection = connect(&tab->view(), &WebContentView::ready_to_paint, this, &TabBar::show_tab_preview);
- m_tab_preview_change_connection = connect(&tab->view(), &WebContentView::tab_preview_changed, this, &TabBar::show_tab_preview);
- tab->view().add_frame_notification_interest();
- // NB: Background tabs may never have painted. Allow rendering while their preview is requested,
- // without selecting the tab or showing its widget.
- tab->view().set_system_visibility_state(Web::HTML::VisibilityState::Visible);
- }
-
- auto thumbnail = tab->view().tab_preview_pixmap({ TAB_PREVIEW_THUMBNAIL_WIDTH, TAB_PREVIEW_THUMBNAIL_HEIGHT });
- if (!thumbnail.has_value())
- return;
-
- m_tab_preview_popup->set_preview(palette(), tab->title(), qstring_from_ak_string(tab->view().url().serialize()), *thumbnail);
- show_tab_preview_popup(index);
-}
-
-void TabBar::show_tab_preview_popup(int index)
-{
- auto was_visible = m_tab_preview_popup->isVisible();
- m_tab_preview_popup->move(tab_preview_position_for(index, m_tab_preview_popup->sizeHint()));
- m_tab_preview_popup->show();
- // Raising a window on macOS also brings the application to the front, so the preview is raised only as it opens, and
- // never again as it follows the frames of the tab it shows.
- if (!was_visible)
- m_tab_preview_popup->raise();
- m_tab_preview_pointer_timer->start();
-}
-
-void TabBar::stop_following_previewed_tab_frames()
-{
- disconnect(m_tab_preview_paint_connection);
- disconnect(m_tab_preview_change_connection);
- if (m_previewed_tab)
- m_previewed_tab->view().remove_frame_notification_interest();
-}
-
-void TabBar::hide_tab_preview()
-{
- stop_following_previewed_tab_frames();
- if (m_previewed_tab) {
- m_previewed_tab->view().set_system_visibility_state(m_previewed_tab->view().isVisible() ? Web::HTML::VisibilityState::Visible : Web::HTML::VisibilityState::Hidden);
- m_previewed_tab = nullptr;
- }
-
- if (m_tab_preview_timer)
- m_tab_preview_timer->stop();
- if (m_tab_preview_pointer_timer)
- m_tab_preview_pointer_timer->stop();
-
- m_tab_preview_index = -1;
-
- if (m_tab_preview_popup)
- m_tab_preview_popup->hide();
-}
-
-QPoint TabBar::tab_preview_position_for(int index, QSize const& popup_size) const
-{
- auto tab_rect = visual_tab_rect(index);
- auto screen = QGuiApplication::screenAt(mapToGlobal(tab_rect.center()));
- if (!screen)
- screen = window()->screen();
- if (!screen)
- screen = QGuiApplication::primaryScreen();
- auto available_geometry = screen ? screen->availableGeometry() : QRect {};
-
- QPoint position;
- if (tab_layout() == TabLayout::Horizontal) {
- position = mapToGlobal(QPoint {
- tab_rect.center().x() - popup_size.width() / 2,
- tab_rect.bottom() + TAB_PREVIEW_CARD_GAP - TAB_PREVIEW_SHADOW_MARGINS.top(),
- });
-
- if (position.y() + popup_size.height() > available_geometry.bottom())
- position.setY(mapToGlobal(QPoint { 0, tab_rect.top() }).y() - popup_size.height() - TAB_PREVIEW_CARD_GAP + TAB_PREVIEW_SHADOW_MARGINS.bottom());
- } else {
- auto place_popup_to_right = !vertical_tabs_are_on_right();
- // The popup sits beside the tab bar rather than the tab, so it never covers the other pinned tiles in a row.
- auto bar_rect = rect();
- position = mapToGlobal(QPoint {
- place_popup_to_right
- ? bar_rect.right() + TAB_PREVIEW_CARD_GAP - TAB_PREVIEW_SHADOW_MARGINS.left()
- : bar_rect.left() - popup_size.width() - TAB_PREVIEW_CARD_GAP + TAB_PREVIEW_SHADOW_MARGINS.right(),
- tab_rect.center().y() - popup_size.height() / 2,
- });
-
- if (place_popup_to_right && position.x() + popup_size.width() > available_geometry.right())
- position.setX(mapToGlobal(QPoint { bar_rect.left(), 0 }).x() - popup_size.width() - TAB_PREVIEW_CARD_GAP + TAB_PREVIEW_SHADOW_MARGINS.right());
- else if (!place_popup_to_right && position.x() < available_geometry.left())
- position.setX(mapToGlobal(QPoint { bar_rect.right(), 0 }).x() + TAB_PREVIEW_CARD_GAP - TAB_PREVIEW_SHADOW_MARGINS.left());
- }
-
- auto minimum_x = available_geometry.left() + TAB_PREVIEW_CARD_GAP - TAB_PREVIEW_SHADOW_MARGINS.left();
- auto maximum_x = available_geometry.right() - popup_size.width() - TAB_PREVIEW_CARD_GAP + TAB_PREVIEW_SHADOW_MARGINS.right();
- if (minimum_x <= maximum_x)
- position.setX(clamp(position.x(), minimum_x, maximum_x));
-
- auto minimum_y = available_geometry.top() + TAB_PREVIEW_CARD_GAP - TAB_PREVIEW_SHADOW_MARGINS.top();
- auto maximum_y = available_geometry.bottom() - popup_size.height() - TAB_PREVIEW_CARD_GAP + TAB_PREVIEW_SHADOW_MARGINS.bottom();
- if (minimum_y <= maximum_y)
- position.setY(clamp(position.y(), minimum_y, maximum_y));
-
- return position;
-}
-
// The width of the tabs, which the bar reaches past on the page's side, where the selected tab joins the page's frame.
int TabBar::vertical_bar_width() const
{
@@ -3140,7 +2756,6 @@ void TabBar::set_hovered_tab_index(int index)
update_tab_button_geometry();
// A tab's hover fill fades in, but disappears at once when the pointer leaves.
start_hover_animation(index, 1.0);
- schedule_tab_preview(index);
update();
}
diff --git a/UI/Qt/TabBar.h b/UI/Qt/TabBar.h
index 8cb51b7b09f..a5261902f16 100644
--- a/UI/Qt/TabBar.h
+++ b/UI/Qt/TabBar.h
@@ -59,7 +59,6 @@ class LadybirdButton;
class SandboxOffBar;
class TabMicrophoneIndicator;
-class TabPreviewPopup;
class TabWidget;
class WindowControlsReveal;
@@ -176,7 +175,6 @@ private:
bool start_window_move();
void start_tab_drag(int index);
QPoint tab_drag_hot_spot() const;
- void pointer_left();
void start_strip_drag(int index);
void update_strip_drag(QPoint position);
void end_strip_drag();
@@ -186,12 +184,6 @@ private:
void update_layout_animation();
QRect animated_tab_rect(int index, QRect const& target) const;
HorizontalTabEndRoom horizontal_tab_end_room(int index) const;
- void schedule_tab_preview(int index);
- void show_tab_preview();
- void show_tab_preview_popup(int index);
- void hide_tab_preview();
- void stop_following_previewed_tab_frames();
- QPoint tab_preview_position_for(int index, QSize const& popup_size) const;
// Where the pinned tabs sit in vertical tabs: a grid of tiles when expanded, one icon column when collapsed, and a
// separator below. Its height is 0 when there's no pinned tab.
@@ -296,13 +288,6 @@ private:
// Where the card a dragged tab is drawn as sits in the tab.
QPoint m_tab_drag_card_offset;
QObject* m_strip_drag_cancellation_filter { nullptr };
- QTimer* m_tab_preview_timer { nullptr };
- QTimer* m_tab_preview_pointer_timer { nullptr };
- TabPreviewPopup* m_tab_preview_popup { nullptr };
- int m_tab_preview_index { -1 };
- QPointer<Tab> m_previewed_tab;
- QMetaObject::Connection m_tab_preview_paint_connection;
- QMetaObject::Connection m_tab_preview_change_connection;
};
class TabWidget final : public QWidget {
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index a8f001ce172..bbe89a12f31 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -308,7 +308,6 @@ WebContentView::WebContentView(QWidget* window, Optional<u64> hub_view_id, WebCo
#endif
on_ready_to_paint = [this]() {
- m_tab_preview_is_stale = true;
if (m_screenshot_selection_overlay)
m_screenshot_selection_overlay->page_did_paint();
@@ -320,7 +319,6 @@ WebContentView::WebContentView(QWidget* window, Optional<u64> hub_view_id, WebCo
schedule_repaint();
#endif
}
- emit ready_to_paint();
};
on_cursor_change = [this](auto cursor) {
@@ -1276,20 +1274,14 @@ bool WebContentView::holds_displayed_frame() const
return paintable.has_value() && paintable->shared_image_buffer;
}
-void WebContentView::take_visible_snapshot(Optional<QSize> maximum_size, Function<void(QImage)> on_snapshot)
+void WebContentView::take_visible_snapshot(Function<void(QImage)> on_snapshot)
{
if (holds_displayed_frame() || !current_paintable().has_value()) {
- auto snapshot = visible_snapshot();
- if (maximum_size.has_value() && !snapshot.isNull() && (snapshot.width() > maximum_size->width() || snapshot.height() > maximum_size->height()))
- snapshot = snapshot.scaled(*maximum_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- on_snapshot(AK::move(snapshot));
+ on_snapshot(visible_snapshot());
return;
}
- Optional<Gfx::IntSize> maximum_bitmap_size;
- if (maximum_size.has_value())
- maximum_bitmap_size = Gfx::IntSize { maximum_size->width(), maximum_size->height() };
- take_frame_snapshot(maximum_bitmap_size, [self = QPointer { this }, on_snapshot = AK::move(on_snapshot)](Optional<Gfx::ShareableBitmap> snapshot) {
+ take_frame_snapshot({}, [self = QPointer { this }, on_snapshot = AK::move(on_snapshot)](Optional<Gfx::ShareableBitmap> snapshot) {
if (!self)
return;
auto const* bitmap = snapshot.has_value() && snapshot->is_valid() ? snapshot->bitmap() : nullptr;
@@ -1315,49 +1307,6 @@ void WebContentView::remove_frame_notification_interest()
set_wants_frame_notifications(false);
}
-// One request at a time, and only once a frame was presented since the last, as a page that animates presents a frame
-// each refresh.
-void WebContentView::refresh_tab_preview(QSize const& maximum_size)
-{
- if (m_tab_preview_request_in_flight || (!m_tab_preview_is_stale && m_tab_preview_maximum_size == maximum_size))
- return;
- m_tab_preview_request_in_flight = true;
- m_tab_preview_is_stale = false;
- take_visible_snapshot(maximum_size, [this, maximum_size](QImage snapshot) {
- m_tab_preview_request_in_flight = false;
- m_tab_preview_maximum_size = maximum_size;
- m_tab_preview = snapshot.isNull() ? QPixmap {} : QPixmap::fromImage(snapshot);
- emit tab_preview_changed();
- });
-}
-
-Optional<QPixmap> WebContentView::tab_preview_pixmap(QSize const& maximum_size)
-{
- if (maximum_size.isEmpty())
- return {};
-
- if (!holds_displayed_frame() && current_paintable().has_value()) {
- refresh_tab_preview(maximum_size);
- if (m_tab_preview.isNull())
- return {};
- return m_tab_preview;
- }
-
- auto snapshot = visible_snapshot();
- if (snapshot.isNull())
- return {};
-
- auto preview_size = snapshot.size().scaled(maximum_size, Qt::KeepAspectRatio);
- if (preview_size.isEmpty())
- return {};
-
- auto preview = QPixmap::fromImage(snapshot).scaled(preview_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- if (preview.isNull())
- return {};
-
- return preview;
-}
-
namespace {
static constexpr int PAGE_OVERLAY_MAXIMUM_WIDTH = 640;
@@ -1659,7 +1608,7 @@ void WebContentView::select_web_compat_report_screenshot(Function<void(QImage)>
if (m_screenshot_selection_overlay)
return;
- take_visible_snapshot({}, [this, on_selected = AK::move(on_selected), on_close = AK::move(on_close)](QImage frame) mutable {
+ take_visible_snapshot([this, on_selected = AK::move(on_selected), on_close = AK::move(on_close)](QImage frame) mutable {
if (frame.isNull() || m_screenshot_selection_overlay) {
if (on_close)
on_close();
@@ -1755,7 +1704,7 @@ ScreenshotSelectionOverlay& WebContentView::select_screenshot(QImage const& fram
if (on_close)
on_close();
};
- overlay->on_request_page_frame = [this](Function<void(QImage)> on_frame) { take_visible_snapshot({}, AK::move(on_frame)); };
+ overlay->on_request_page_frame = [this](Function<void(QImage)> on_frame) { take_visible_snapshot(AK::move(on_frame)); };
overlay->on_page_visibility_change = [this] { schedule_repaint(); };
return *overlay;
}
@@ -1767,7 +1716,7 @@ void WebContentView::start_screenshot()
if (m_screenshot_selection_overlay)
return;
- take_visible_snapshot({}, [this](QImage frame) {
+ take_visible_snapshot([this](QImage frame) {
if (m_screenshot_selection_overlay)
return;
if (frame.isNull()) {
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index fe7d3cef8da..a455c9fe210 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -199,9 +199,6 @@ public:
Dark,
};
void update_palette(PaletteMode = PaletteMode::Default);
- // A preview of a page that the Compositor shows itself comes from it, so it can lag a frame behind the page.
- Optional<QPixmap> tab_preview_pixmap(QSize const& maximum_size);
-
// Frames that the Compositor shows itself are only announced while something here wants to hear of them.
void add_frame_notification_interest();
void remove_frame_notification_interest();
@@ -217,8 +214,6 @@ public:
void set_follows_mouse_while_inactive(bool follows) { m_follows_mouse_while_inactive = follows; }
signals:
- void ready_to_paint();
- void tab_preview_changed();
void crash_overlay_changed();
void image_overlay_unavailable();
void urls_dropped(QList<QUrl> const&);
@@ -255,9 +250,8 @@ private:
RefPtr<Gfx::Bitmap const> cpu_bitmap_to_paint(Paintable const&) const;
QImage visible_snapshot() const;
// What the view shows, which the Compositor takes where the view does not hold the frame itself.
- void take_visible_snapshot(Optional<QSize> maximum_size, Function<void(QImage)>);
+ void take_visible_snapshot(Function<void(QImage)>);
bool holds_displayed_frame() const;
- void refresh_tab_preview(QSize const& maximum_size);
void update_viewport_size();
void update_cursor(Gfx::Cursor cursor);
@@ -351,10 +345,6 @@ private:
QPointer<ScreenshotSelectionOverlay> m_screenshot_selection_overlay;
size_t m_frame_notification_interest { 0 };
- QPixmap m_tab_preview;
- QSize m_tab_preview_maximum_size;
- bool m_tab_preview_is_stale { true };
- bool m_tab_preview_request_in_flight { false };
QPointer<ScreenshotViewer> m_screenshot_viewer;
struct FloatingSurface {
QPointer<QWidget> surface;