performance improvements

This commit is contained in:
Fabian Freund
2026-07-31 05:14:27 +02:00
parent c2c7cc0729
commit bdfc851681
36 changed files with 1988 additions and 608 deletions
@@ -23,15 +23,20 @@ import 'package:nullability/nullability.dart';
import 'package:weblibre/data/models/web_page_info.dart';
import 'package:weblibre/domain/entities/equatable_image.dart';
import 'package:weblibre/features/geckoview/domain/entities/browser_icon.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/find_result.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/history.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/readerable.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/security.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/translation.dart';
import 'package:weblibre/features/geckoview/features/tabs/data/entities/tab_mode.dart';
part 'tab.g.dart';
/// Per-tab state the browser chrome and tab ordering depend on.
///
/// Deliberately narrow: the whole `Map<String, TabState>` is watched by the
/// providers feeding the always-visible quick tab switcher and the grouped tab
/// list, so any field added here rebuilds every visible chip whenever it
/// changes on *any* tab. High-churn fields (load progress, thumbnails, session
/// history, find-in-page results, translation) live in per-tab notifiers in
/// `providers/tab_detail_state.dart` instead.
@CopyWith(constructor: '_')
class TabState extends WebPageInfo {
static final defaultUrl = Uri.parse('about:blank');
@@ -59,10 +64,6 @@ class TabState extends WebPageInfo {
),
);
final EquatableImage? thumbnail;
final int progress;
final TabMode tabMode;
String? get isolationContextId => tabMode.isolationContextId;
@@ -70,13 +71,8 @@ class TabState extends WebPageInfo {
final bool isLoading;
final bool showToolbarAsExpanded;
bool get isFinishedLoading => !isLoading && progress == 100;
final SecurityState securityInfoState;
final HistoryState historyState;
final ReaderableState readerableState;
final FindResultState findResultState;
final TranslationState translationState;
TabState({
required this.id,
@@ -85,17 +81,12 @@ class TabState extends WebPageInfo {
required super.url,
required String title,
required this.icon,
required this.thumbnail,
required this.progress,
this.tabMode = TabMode.regular,
required this.isFullScreen,
required this.isLoading,
required this.showToolbarAsExpanded,
required this.securityInfoState,
required this.historyState,
required this.readerableState,
required this.findResultState,
required this.translationState,
}) : super(title: title.trim());
TabState._({
@@ -105,17 +96,12 @@ class TabState extends WebPageInfo {
required super.url,
required super.title,
required this.icon,
required this.thumbnail,
required this.progress,
required this.tabMode,
required this.isFullScreen,
required this.isLoading,
required this.showToolbarAsExpanded,
required this.securityInfoState,
required this.historyState,
required this.readerableState,
required this.findResultState,
required this.translationState,
});
factory TabState.$default(String tabId) => TabState(
@@ -125,16 +111,11 @@ class TabState extends WebPageInfo {
url: defaultUrl,
title: "",
icon: null,
thumbnail: null,
progress: 0,
isFullScreen: false,
isLoading: false,
showToolbarAsExpanded: false,
securityInfoState: SecurityState.$default(),
historyState: HistoryState.$default(),
readerableState: ReaderableState.$default(),
findResultState: FindResultState.$default(),
translationState: TranslationState.$default(),
);
@override
@@ -144,16 +125,11 @@ class TabState extends WebPageInfo {
parentId,
contextId,
icon,
thumbnail,
progress,
tabMode,
isFullScreen,
isLoading,
showToolbarAsExpanded,
securityInfoState,
historyState,
readerableState,
findResultState,
translationState,
];
}
@@ -17,10 +17,6 @@ abstract class _$TabStateCWProxy {
TabState icon(EquatableImage? icon);
TabState thumbnail(EquatableImage? thumbnail);
TabState progress(int progress);
TabState tabMode(TabMode tabMode);
TabState isFullScreen(bool isFullScreen);
@@ -31,14 +27,8 @@ abstract class _$TabStateCWProxy {
TabState securityInfoState(SecurityState securityInfoState);
TabState historyState(HistoryState historyState);
TabState readerableState(ReaderableState readerableState);
TabState findResultState(FindResultState findResultState);
TabState translationState(TranslationState translationState);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `TabState(...).copyWith.fieldName(value)`.
///
@@ -52,17 +42,12 @@ abstract class _$TabStateCWProxy {
Uri url,
String? title,
EquatableImage? icon,
EquatableImage? thumbnail,
int progress,
TabMode tabMode,
bool isFullScreen,
bool isLoading,
bool showToolbarAsExpanded,
SecurityState securityInfoState,
HistoryState historyState,
ReaderableState readerableState,
FindResultState findResultState,
TranslationState translationState,
});
}
@@ -88,12 +73,6 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
@override
TabState icon(EquatableImage? icon) => call(icon: icon);
@override
TabState thumbnail(EquatableImage? thumbnail) => call(thumbnail: thumbnail);
@override
TabState progress(int progress) => call(progress: progress);
@override
TabState tabMode(TabMode tabMode) => call(tabMode: tabMode);
@@ -111,22 +90,10 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
TabState securityInfoState(SecurityState securityInfoState) =>
call(securityInfoState: securityInfoState);
@override
TabState historyState(HistoryState historyState) =>
call(historyState: historyState);
@override
TabState readerableState(ReaderableState readerableState) =>
call(readerableState: readerableState);
@override
TabState findResultState(FindResultState findResultState) =>
call(findResultState: findResultState);
@override
TabState translationState(TranslationState translationState) =>
call(translationState: translationState);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `TabState(...).copyWith.fieldName(value)`.
@@ -141,17 +108,12 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
Object? url = const $CopyWithPlaceholder(),
Object? title = const $CopyWithPlaceholder(),
Object? icon = const $CopyWithPlaceholder(),
Object? thumbnail = const $CopyWithPlaceholder(),
Object? progress = const $CopyWithPlaceholder(),
Object? tabMode = const $CopyWithPlaceholder(),
Object? isFullScreen = const $CopyWithPlaceholder(),
Object? isLoading = const $CopyWithPlaceholder(),
Object? showToolbarAsExpanded = const $CopyWithPlaceholder(),
Object? securityInfoState = const $CopyWithPlaceholder(),
Object? historyState = const $CopyWithPlaceholder(),
Object? readerableState = const $CopyWithPlaceholder(),
Object? findResultState = const $CopyWithPlaceholder(),
Object? translationState = const $CopyWithPlaceholder(),
}) {
return TabState._(
id: _value.id,
@@ -175,14 +137,6 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
? _value.icon
// ignore: cast_nullable_to_non_nullable
: icon as EquatableImage?,
thumbnail: thumbnail == const $CopyWithPlaceholder()
? _value.thumbnail
// ignore: cast_nullable_to_non_nullable
: thumbnail as EquatableImage?,
progress: progress == const $CopyWithPlaceholder() || progress == null
? _value.progress
// ignore: cast_nullable_to_non_nullable
: progress as int,
tabMode: tabMode == const $CopyWithPlaceholder() || tabMode == null
? _value.tabMode
// ignore: cast_nullable_to_non_nullable
@@ -208,29 +162,12 @@ class _$TabStateCWProxyImpl implements _$TabStateCWProxy {
? _value.securityInfoState
// ignore: cast_nullable_to_non_nullable
: securityInfoState as SecurityState,
historyState:
historyState == const $CopyWithPlaceholder() || historyState == null
? _value.historyState
// ignore: cast_nullable_to_non_nullable
: historyState as HistoryState,
readerableState:
readerableState == const $CopyWithPlaceholder() ||
readerableState == null
? _value.readerableState
// ignore: cast_nullable_to_non_nullable
: readerableState as ReaderableState,
findResultState:
findResultState == const $CopyWithPlaceholder() ||
findResultState == null
? _value.findResultState
// ignore: cast_nullable_to_non_nullable
: findResultState as FindResultState,
translationState:
translationState == const $CopyWithPlaceholder() ||
translationState == null
? _value.translationState
// ignore: cast_nullable_to_non_nullable
: translationState as TranslationState,
);
}
}