Truly independent web browser
UI/Qt: Move the crash report review's building blocks to ReportReview
Jelle Raaijmakers7339b268f427
diff --git a/Tests/UI/Qt/CMakeLists.txt b/Tests/UI/Qt/CMakeLists.txtindex 5a73ea7c72a..eb6c004cddb 100644--- a/Tests/UI/Qt/CMakeLists.txt+++ b/Tests/UI/Qt/CMakeLists.txt@@ -69,6 +69,7 @@ if (APPLE OR LINUX)target_sources(TestCrashReportReviewWidget PRIVATE"${LADYBIRD_SOURCE_DIR}/UI/Qt/ChromeStyle.cpp""${LADYBIRD_SOURCE_DIR}/UI/Qt/CrashReportReviewWidget.cpp"+ "${LADYBIRD_SOURCE_DIR}/UI/Qt/ReportReview.cpp""${LADYBIRD_SOURCE_DIR}/UI/Qt/StringUtils.cpp")deploy_qt_offscreen_platform_plugin(TestCrashReportReviewWidget)diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txtindex defbe55004d..fd48f9ce4ff 100644--- a/UI/Qt/CMakeLists.txt+++ b/UI/Qt/CMakeLists.txt@@ -49,6 +49,7 @@ target_sources(ladybird PRIVATEPerformanceMonitorWidget.cppPictureInPictureWindow.cppPopover.cpp+ ReportReview.cppSelectDropdown.cppStringUtils.cppTab.cppdiff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex 1002999b0df..48650a151f1 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -1075,7 +1075,7 @@ QDialog#LadybirdBookmarkDialog QPushButton:focus {{surface, recessed, hover, pressed, control_border, accent, text, selection, selection_text);}-QString crash_report_review_style_sheet(QPalette const& palette)+QString report_review_style_sheet(QPalette const& palette){auto recessed = style_sheet_color(chrome_surface_recessed(palette));auto control_border = style_sheet_color(chrome_control_border(palette));@@ -1086,8 +1086,8 @@ QString crash_report_review_style_sheet(QPalette const& palette)auto muted = style_sheet_color(chrome_muted_text(palette));return qformatted(R"(-QWidget#LadybirdCrashReportReview QLineEdit,-QWidget#LadybirdCrashReportReview QPlainTextEdit {{+QWidget#LadybirdReportReview QLineEdit,+QWidget#LadybirdReportReview QPlainTextEdit {{color: {3};background: {0};border: 1px solid {1};@@ -1096,25 +1096,25 @@ QWidget#LadybirdCrashReportReview QPlainTextEdit {{selection-color: {6};}}-QWidget#LadybirdCrashReportReview QLineEdit {{+QWidget#LadybirdReportReview QLineEdit {{min-height: 26px;padding: 2px 9px;}}-QWidget#LadybirdCrashReportReview QPlainTextEdit {{+QWidget#LadybirdReportReview QPlainTextEdit {{padding: 4px 5px;}}-QWidget#LadybirdCrashReportReview QLineEdit:focus,-QWidget#LadybirdCrashReportReview QPlainTextEdit:focus {{+QWidget#LadybirdReportReview QLineEdit:focus,+QWidget#LadybirdReportReview QPlainTextEdit:focus {{border-color: {2};}}-QWidget#LadybirdCrashReportReview QLineEdit:disabled {{+QWidget#LadybirdReportReview QLineEdit:disabled {{color: {4};}}-QWidget#LadybirdCrashReportReview QFrame#CrashReportDetails {{+QWidget#LadybirdReportReview QFrame#ReportDetails {{background: {0};border: 1px solid {1};border-radius: 8px;@@ -1124,7 +1124,7 @@ QWidget#LadybirdCrashReportReview QFrame#CrashReportDetails {{}// Placeholders hint at what to write, so they stay readable rather than taking the platform's faintest text color.-QColor crash_report_review_placeholder_text(QPalette const& palette)+QColor report_review_placeholder_text(QPalette const& palette){return mix(chrome_text(palette), chrome_surface_recessed(palette), 0.45);}diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 84d6104611e..07ada31b307 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -46,8 +46,8 @@ QString bookmarks_bar_style_sheet(QPalette const&, int corner_radius);QString find_in_page_style_sheet(QPalette const&);QString javascript_dialog_style_sheet(QPalette const&);QString bookmark_dialog_style_sheet(QPalette const&);-QString crash_report_review_style_sheet(QPalette const&);-QColor crash_report_review_placeholder_text(QPalette const&);+QString report_review_style_sheet(QPalette const&);+QColor report_review_placeholder_text(QPalette const&);QString devtools_banner_style_sheet(QPalette const&);QString tab_widget_style_sheet(QPalette const&);QString autocomplete_popup_style_sheet(QPalette const&);diff --git a/UI/Qt/CrashReportReviewWidget.cpp b/UI/Qt/CrashReportReviewWidget.cppindex 5fec1a0057f..2816aab7124 100644--- a/UI/Qt/CrashReportReviewWidget.cpp+++ b/UI/Qt/CrashReportReviewWidget.cpp@@ -4,15 +4,12 @@* SPDX-License-Identifier: BSD-2-Clause*/-#include <LibWebView/ReportDetail.h>-#include <UI/Qt/ChromeStyle.h>#include <UI/Qt/CrashReportReviewWidget.h>+#include <UI/Qt/ReportReview.h>#include <UI/Qt/StringUtils.h>-#include <QApplication>#include <QCheckBox>#include <QEvent>-#include <QFontDatabase>#include <QFormLayout>#include <QFrame>#include <QHBoxLayout>@@ -21,101 +18,18 @@#include <QPlainTextEdit>#include <QProgressBar>#include <QPushButton>-#include <QScrollArea>#include <QStyle>#include <QVBoxLayout>namespace Ladybird {-static constexpr int PANEL_PADDING = 16;-static constexpr int BUTTON_SPACING = 12;--static QLabel* create_label(QString const& text, QWidget* parent)-{- auto* label = new QLabel(text, parent);- label->setTextFormat(Qt::PlainText);- label->setWordWrap(true);- label->setTextInteractionFlags(Qt::TextSelectableByMouse);- return label;-}--static QLabel* create_heading(QString const& text, qreal scale, QWidget* parent)-{- auto* label = create_label(text, parent);- auto font = label->font();- font.setPointSizeF(font.pointSizeF() * scale);- font.setBold(true);- label->setFont(font);- return label;-}--// A button that shows or hides the content below it, which starts out hidden. It is drawn as plain text, flush with the-// text around it, as styles frame buttons on hover and press and indent them. A triangle in the same font shows whether-// the content is shown, as styles size arrows to the icon size. Keyboard focus shows in the accent color.-static QPushButton* create_disclosure(QString const& text, QWidget* content, QWidget* parent)-{- auto* button = new QPushButton(parent);- button->setAutoDefault(false);- button->setStyleSheet("QPushButton { border: none; background: transparent; padding: 0; margin: 0; text-align: left; }"- "QPushButton:focus { color: palette(highlight); text-decoration: underline; }");- // Styles may give buttons a font of their own, which only a size set on the button itself overrides.- auto font = QApplication::font("QLabel");- if (font.pointSizeF() > 0)- font.setPointSizeF(font.pointSizeF());- else- font.setPixelSize(font.pixelSize());- button->setFont(font);-- auto update_text = [button, text](bool expanded) {- // U+FE0E keeps the triangles in text presentation, where macOS would otherwise draw them as emoji.- button->setText(QStringLiteral("%1\uFE0E %2").arg(expanded ? QChar(0x25BC) : QChar(0x25B6), text));- };- update_text(false);- content->hide();- QObject::connect(button, &QPushButton::clicked, content, [content, update_text] {- auto expanded = content->isHidden();- update_text(expanded);- content->setVisible(expanded);- });- return button;-}--// Items within a group sit close together, and the groups themselves further apart.-static QVBoxLayout* create_group_layout(QWidget* group)-{- auto* layout = new QVBoxLayout(group);- layout->setContentsMargins(0, 0, 0, 0);- layout->setSpacing(CrashReportReviewWidget::item_spacing);- return layout;-}--static void clear_form(QFormLayout& form)-{- while (form.rowCount() > 0)- form.removeRow(0);-}--static void add_field(QFormLayout& form, WebView::ReportDetail const& field, QWidget* parent)-{- // Labels stay on one line, so each value starts level with its label however far it wraps.- auto* label = create_label(qstring_from_ak_string(field.label), parent);- label->setWordWrap(false);- auto* value = create_label(qstring_from_ak_string(field.value), parent);- if (field.is_code)- value->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));- form.addRow(label, value);-}--QLabel* CrashReportReviewWidget::create_title(QString const& text, QWidget* parent)-{- return create_heading(text, 1.5, parent);-}+using namespace ReportReview;CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parent, WebView::CrashReportStore& store): QWidget(parent), m_review(store){- setObjectName("LadybirdCrashReportReview");+ setObjectName("LadybirdReportReview");// Only the page on screen is laid out, so the widget is only as tall as the page it shows.auto* layout = new QVBoxLayout(this);@@ -124,7 +38,7 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parm_review_page = new QWidget(this);auto* review_layout = new QVBoxLayout(m_review_page);review_layout->setContentsMargins(0, 0, 0, 0);- review_layout->setSpacing(CrashReportReviewWidget::group_spacing);+ review_layout->setSpacing(group_spacing);auto* description = new QWidget(m_review_page);auto* description_layout = create_group_layout(description);@@ -161,17 +75,11 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parauto* contents_summary = create_label(tr("Includes technical crash details, your Ladybird version and platform."), contents);contents_summary->setForegroundRole(QPalette::PlaceholderText);contents_layout->addWidget(contents_summary);- m_details = new QFrame(contents);- m_details->setObjectName("CrashReportDetails");- auto* details_layout = create_group_layout(m_details);- details_layout->setContentsMargins(PANEL_PADDING, PANEL_PADDING, PANEL_PADDING, PANEL_PADDING);- m_fields = new QFormLayout;- m_fields->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);- m_fields->setLabelAlignment(Qt::AlignLeft | Qt::AlignTop);- m_fields->setHorizontalSpacing(CrashReportReviewWidget::group_spacing / 2);- m_fields->setVerticalSpacing(CrashReportReviewWidget::item_spacing);+ m_details = create_details_panel(contents);+ auto* details_layout = static_cast<QVBoxLayout*>(m_details->layout());+ m_fields = create_details_form();details_layout->addLayout(m_fields);- details_layout->addSpacing(CrashReportReviewWidget::item_spacing);+ details_layout->addSpacing(item_spacing);auto* show_report_button = new QPushButton(tr("Open full report (.txt)"), m_details);show_report_button->setAutoDefault(false);show_report_button->setObjectName("CrashReportShowReportButton");@@ -198,7 +106,7 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parauto* decline_button = new QPushButton(tr("Don’t send"), m_review_page);decline_button->setObjectName("CrashReportDeclineButton");auto* review_buttons = new QHBoxLayout;- review_buttons->setSpacing(BUTTON_SPACING);+ review_buttons->setSpacing(button_spacing);review_buttons->addWidget(send_button);review_buttons->addWidget(decline_button);review_buttons->addStretch();@@ -214,7 +122,7 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parm_status_page = new QWidget(this);auto* status_layout = new QVBoxLayout(m_status_page);status_layout->setContentsMargins(0, 0, 0, 0);- status_layout->setSpacing(CrashReportReviewWidget::group_spacing);+ status_layout->setSpacing(group_spacing);// The outcome is a section of the crash screen rather than a headline of its own.auto* outcome = new QWidget(m_status_page);@@ -240,7 +148,7 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parm_exit_button = new QPushButton(exit_text, m_status_page);m_exit_button->setObjectName("CrashReportExitButton");auto* status_buttons = new QHBoxLayout;- status_buttons->setSpacing(BUTTON_SPACING);+ status_buttons->setSpacing(button_spacing);status_buttons->addWidget(m_retry_button);status_buttons->addWidget(m_next_button);status_buttons->addWidget(m_exit_button);@@ -284,35 +192,11 @@ CrashReportReviewWidget::CrashReportReviewWidget(QString exit_text, QWidget* parupdate_chrome_style();}-// Tab moves through every control of the review and wraps around within it. The platform's own focus chain would skip-// buttons where the system limits Tab to text fields, as macOS does by default, and lead into the web view behind a-// tab's crash screen, which keeps Tab for the page.bool CrashReportReviewWidget::focusNextPrevChild(bool next){- Vector<QWidget*> controls;- for (auto* widget = nextInFocusChain(); widget != this; widget = widget->nextInFocusChain()) {- if (isAncestorOf(widget) && widget->isVisibleTo(this) && widget->isEnabled() && (widget->focusPolicy() & Qt::TabFocus))- controls.append(widget);- }- if (controls.is_empty())- return QWidget::focusNextPrevChild(next);-- auto current = controls.find_first_index(window()->focusWidget());- size_t index = 0;- if (current.has_value())- index = next ? (*current + 1) % controls.size() : (*current + controls.size() - 1) % controls.size();- else if (!next)- index = controls.size() - 1;-- auto* control = controls[index];- control->setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);- for (auto* ancestor = parentWidget(); ancestor; ancestor = ancestor->parentWidget()) {- if (auto* scroll_area = qobject_cast<QScrollArea*>(ancestor)) {- scroll_area->ensureWidgetVisible(control);- break;- }- }- return true;+ if (focus_next_control(*this, next))+ return true;+ return QWidget::focusNextPrevChild(next);}bool CrashReportReviewWidget::event(QEvent* event)@@ -329,13 +213,8 @@ void CrashReportReviewWidget::update_chrome_style()return;m_is_updating_chrome_style = true;- // Only the fields get a stronger placeholder color. The muted lines keep the color the crash screen uses for its own.- for (QWidget* field : { static_cast<QWidget*>(m_description_edit), static_cast<QWidget*>(m_website) }) {- auto field_palette = field->palette();- field_palette.setColor(QPalette::PlaceholderText, ChromeStyle::crash_report_review_placeholder_text(palette()));- field->setPalette(field_palette);- }- setStyleSheet(ChromeStyle::crash_report_review_style_sheet(palette()));+ QWidget* fields[] = { m_description_edit, m_website };+ apply_style(*this, fields);m_is_updating_chrome_style = false;}@@ -344,9 +223,7 @@ ErrorOr<void> CrashReportReviewWidget::open_report(Optional<ByteString> const& n{auto report = TRY(m_review.open(name));- clear_form(*m_fields);- for (auto const& field : report.fields)- add_field(*m_fields, field, m_details);+ set_details(*m_fields, report.fields, m_details);// Without a website to offer, the option has nothing to include.m_website_option->setVisible(website.has_value());@@ -408,36 +285,16 @@ void CrashReportReviewWidget::show_status(QString const& title, QString const& mvoid CrashReportReviewWidget::show_progress(WebView::ReportSubmission::Stage stage){- using Stage = WebView::ReportSubmission::Stage;-- auto percent = [&] {- switch (stage) {- case Stage::Preparing:- return 15;- case Stage::RequestingChallenge:- return 40;- case Stage::SolvingProof:- return 65;- case Stage::Sending:- return 85;- }- VERIFY_NOT_REACHED();- }();-// Leaving stays possible while the report is on its way, which carries on behind the screen that follows.- show_status(tr("Sending crash report"), stage == Stage::Sending ? tr("Sending crash report…") : tr("Preparing report…"),- { m_exit_button });- m_progress->setValue(percent);+ auto is_sending = stage == WebView::ReportSubmission::Stage::Sending;+ show_status(tr("Sending crash report"), is_sending ? tr("Sending crash report…") : tr("Preparing report…"), { m_exit_button });+ m_progress->setValue(progress_percent(stage));m_progress->show();}void CrashReportReviewWidget::show_retry(String const& reason, u32 retry_number, u32 maximum_retries, u32 delay_seconds){- m_status_message->setText(tr("%1 Trying again in %2 seconds (%3 of %4)…")- .arg(qstring_from_ak_string(reason))- .arg(delay_seconds)- .arg(retry_number)- .arg(maximum_retries));+ m_status_message->setText(retry_message(reason, retry_number, maximum_retries, delay_seconds));}void CrashReportReviewWidget::show_sent()diff --git a/UI/Qt/CrashReportReviewWidget.h b/UI/Qt/CrashReportReviewWidget.hindex 3fef032b8f2..8168be4a25c 100644--- a/UI/Qt/CrashReportReviewWidget.h+++ b/UI/Qt/CrashReportReviewWidget.h@@ -33,12 +33,6 @@ class CrashReportReviewWidget final : public QWidget {public:AK_ALLOC_WITH_KMALLOC;- // The spacing of items within a group and of the groups themselves, which the screen around the review shares.- static constexpr int item_spacing = 8;- static constexpr int group_spacing = 28;-- static QLabel* create_title(QString const& text, QWidget* parent);-// The exit button leaves the review, for example by reloading the crashed page.CrashReportReviewWidget(QString exit_text, QWidget* parent, WebView::CrashReportStore& = WebView::CrashReportStore::the());diff --git a/UI/Qt/ReportReview.cpp b/UI/Qt/ReportReview.cppnew file mode 100644index 00000000000..2d77cd1ad77--- /dev/null+++ b/UI/Qt/ReportReview.cpp@@ -0,0 +1,192 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <AK/Vector.h>+#include <UI/Qt/ChromeStyle.h>+#include <UI/Qt/ReportReview.h>+#include <UI/Qt/StringUtils.h>++#include <QApplication>+#include <QFontDatabase>+#include <QFormLayout>+#include <QFrame>+#include <QLabel>+#include <QPushButton>+#include <QScrollArea>+#include <QVBoxLayout>++namespace Ladybird::ReportReview {++QLabel* create_label(QString const& text, QWidget* parent)+{+ auto* label = new QLabel(text, parent);+ label->setTextFormat(Qt::PlainText);+ label->setWordWrap(true);+ label->setTextInteractionFlags(Qt::TextSelectableByMouse);+ return label;+}++QLabel* create_heading(QString const& text, qreal scale, QWidget* parent)+{+ auto* label = create_label(text, parent);+ auto font = label->font();+ font.setPointSizeF(font.pointSizeF() * scale);+ font.setBold(true);+ label->setFont(font);+ return label;+}++QLabel* create_title(QString const& text, QWidget* parent)+{+ return create_heading(text, 1.5, parent);+}++// A button that shows or hides the content below it, which starts out hidden. It is drawn as plain text, flush with the+// text around it, as styles frame buttons on hover and press and indent them. A triangle in the same font shows whether+// the content is shown, as styles size arrows to the icon size. Keyboard focus shows in the accent color.+QPushButton* create_disclosure(QString const& text, QWidget* content, QWidget* parent)+{+ auto* button = new QPushButton(parent);+ button->setAutoDefault(false);+ button->setStyleSheet("QPushButton { border: none; background: transparent; padding: 0; margin: 0; text-align: left; }"+ "QPushButton:focus { color: palette(highlight); text-decoration: underline; }");+ // Styles may give buttons a font of their own, which only a size set on the button itself overrides.+ auto font = QApplication::font("QLabel");+ if (font.pointSizeF() > 0)+ font.setPointSizeF(font.pointSizeF());+ else+ font.setPixelSize(font.pixelSize());+ button->setFont(font);++ auto update_text = [button, text](bool expanded) {+ // U+FE0E keeps the triangles in text presentation, where macOS would otherwise draw them as emoji.+ button->setText(QStringLiteral("%1︎ %2").arg(expanded ? QChar(0x25BC) : QChar(0x25B6), text));+ };+ update_text(false);+ content->hide();+ QObject::connect(button, &QPushButton::clicked, content, [content, update_text] {+ auto expanded = content->isHidden();+ update_text(expanded);+ content->setVisible(expanded);+ });+ return button;+}++// Items within a group sit close together, and the groups themselves further apart.+QVBoxLayout* create_group_layout(QWidget* group)+{+ auto* layout = new QVBoxLayout(group);+ layout->setContentsMargins(0, 0, 0, 0);+ layout->setSpacing(item_spacing);+ return layout;+}++QFrame* create_details_panel(QWidget* parent)+{+ auto* details = new QFrame(parent);+ details->setObjectName("ReportDetails");+ auto* layout = create_group_layout(details);+ layout->setContentsMargins(panel_padding, panel_padding, panel_padding, panel_padding);+ return details;+}++QFormLayout* create_details_form()+{+ auto* form = new QFormLayout;+ form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);+ form->setLabelAlignment(Qt::AlignLeft | Qt::AlignTop);+ form->setHorizontalSpacing(group_spacing / 2);+ form->setVerticalSpacing(item_spacing);+ return form;+}++void set_details(QFormLayout& form, ReadonlySpan<WebView::ReportDetail> details, QWidget* parent)+{+ while (form.rowCount() > 0)+ form.removeRow(0);++ for (auto const& detail : details) {+ // Labels stay on one line, so each value starts level with its label however far it wraps.+ auto* label = create_label(qstring_from_ak_string(detail.label), parent);+ label->setWordWrap(false);+ auto* value = create_label(qstring_from_ak_string(detail.value), parent);+ if (detail.is_code)+ value->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));+ form.addRow(label, value);+ }+}++// Only the fields get a stronger placeholder color. The muted lines keep the color the screen around the review uses+// for its own.+void apply_style(QWidget& review, ReadonlySpan<QWidget*> fields)+{+ for (auto* field : fields) {+ auto field_palette = field->palette();+ field_palette.setColor(QPalette::PlaceholderText, ChromeStyle::report_review_placeholder_text(review.palette()));+ field->setPalette(field_palette);+ }+ review.setStyleSheet(ChromeStyle::report_review_style_sheet(review.palette()));+}++// Tab moves through every control of the review and wraps around within it. The platform's own focus chain would skip+// buttons where the system limits Tab to text fields, as macOS does by default, and lead into the web view behind a+// tab's crash screen, which keeps Tab for the page.+bool focus_next_control(QWidget& review, bool next)+{+ Vector<QWidget*> controls;+ for (auto* widget = review.nextInFocusChain(); widget != &review; widget = widget->nextInFocusChain()) {+ if (review.isAncestorOf(widget) && widget->isVisibleTo(&review) && widget->isEnabled() && (widget->focusPolicy() & Qt::TabFocus))+ controls.append(widget);+ }+ if (controls.is_empty())+ return false;++ auto current = controls.find_first_index(review.window()->focusWidget());+ size_t index = 0;+ if (current.has_value())+ index = next ? (*current + 1) % controls.size() : (*current + controls.size() - 1) % controls.size();+ else if (!next)+ index = controls.size() - 1;++ auto* control = controls[index];+ control->setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);+ for (auto* ancestor = review.parentWidget(); ancestor; ancestor = ancestor->parentWidget()) {+ if (auto* scroll_area = qobject_cast<QScrollArea*>(ancestor)) {+ scroll_area->ensureWidgetVisible(control);+ break;+ }+ }+ return true;+}++// How far along a report is at each stage of sending it, which takes most of its time solving the proof of work.+int progress_percent(WebView::ReportSubmission::Stage stage)+{+ using Stage = WebView::ReportSubmission::Stage;++ switch (stage) {+ case Stage::Preparing:+ return 15;+ case Stage::RequestingChallenge:+ return 40;+ case Stage::SolvingProof:+ return 65;+ case Stage::Sending:+ return 85;+ }+ VERIFY_NOT_REACHED();+}++QString retry_message(String const& reason, u32 retry_number, u32 maximum_retries, u32 delay_seconds)+{+ return QObject::tr("%1 Trying again in %2 seconds (%3 of %4)…")+ .arg(qstring_from_ak_string(reason))+ .arg(delay_seconds)+ .arg(retry_number)+ .arg(maximum_retries);+}++}diff --git a/UI/Qt/ReportReview.h b/UI/Qt/ReportReview.hnew file mode 100644index 00000000000..163399de386--- /dev/null+++ b/UI/Qt/ReportReview.h@@ -0,0 +1,47 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <AK/Span.h>+#include <AK/String.h>+#include <LibWebView/ReportDetail.h>+#include <LibWebView/ReportSubmission.h>++#include <QString>++class QFormLayout;+class QFrame;+class QLabel;+class QPushButton;+class QVBoxLayout;+class QWidget;++namespace Ladybird::ReportReview {++// The spacing of items within a group and of the groups themselves, which the screen around a review shares.+static constexpr int item_spacing = 8;+static constexpr int group_spacing = 28;+static constexpr int panel_padding = 16;+static constexpr int button_spacing = 12;++QLabel* create_label(QString const& text, QWidget* parent);+QLabel* create_heading(QString const& text, qreal scale, QWidget* parent);+QLabel* create_title(QString const& text, QWidget* parent);+QPushButton* create_disclosure(QString const& text, QWidget* content, QWidget* parent);+QVBoxLayout* create_group_layout(QWidget* group);++QFrame* create_details_panel(QWidget* parent);+QFormLayout* create_details_form();+void set_details(QFormLayout&, ReadonlySpan<WebView::ReportDetail>, QWidget* parent);++void apply_style(QWidget& review, ReadonlySpan<QWidget*> fields);+bool focus_next_control(QWidget& review, bool next);++int progress_percent(WebView::ReportSubmission::Stage);+QString retry_message(String const& reason, u32 retry_number, u32 maximum_retries, u32 delay_seconds);++}diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cppindex fa34c1fb091..54cbd913ce9 100644--- a/UI/Qt/WebContentView.cpp+++ b/UI/Qt/WebContentView.cpp@@ -32,6 +32,7 @@#include <LibWebView/WebContentClient.h>#include <UI/Qt/Application.h>#include <UI/Qt/CrashReportReviewWidget.h>+#include <UI/Qt/ReportReview.h>#ifdef AK_OS_MACOS# include <UI/Qt/MacWindow.h>#endif@@ -1318,9 +1319,9 @@ void WebContentView::set_crash_overlay_visible(bool visible)auto* heading = new QWidget(header);auto* heading_layout = new QVBoxLayout(heading);heading_layout->setContentsMargins(0, 0, 0, 0);- heading_layout->setSpacing(CrashReportReviewWidget::item_spacing);+ heading_layout->setSpacing(ReportReview::item_spacing);- auto* title = CrashReportReviewWidget::create_title(tr("Ladybird flew off-course!"), heading);+ auto* title = ReportReview::create_title(tr("Ladybird flew off-course!"), heading);m_crash_overlay_url = new CrashOverlayUrlLabel(heading);@@ -1350,7 +1351,7 @@ void WebContentView::set_crash_overlay_visible(bool visible)auto* column_layout = new QVBoxLayout(column);column_layout->setContentsMargins(0, 0, 0, 0);- column_layout->setSpacing(CrashReportReviewWidget::group_spacing);+ column_layout->setSpacing(ReportReview::group_spacing);column_layout->addWidget(header);column_layout->addWidget(m_crash_overlay_reload_button, 0, Qt::AlignLeft);if (WebView::CrashReport::is_supported()) {