@@ -921,23 +921,8 @@ void nsView::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {
921
921
MOZ_ASSERT (this == mViewManager ->GetRootView (),
922
922
" Should be called for the root view" );
923
923
924
- PresShell* presShell = mViewManager ->GetPresShell ();
925
- if (!presShell) {
926
- return ;
927
- }
928
-
929
- dom::Document* document = presShell->GetDocument ();
930
- if (!document) {
931
- return ;
932
- }
933
-
934
- nsPIDOMWindowOuter* window = document->GetWindow ();
935
- if (!window) {
936
- return ;
937
- }
938
-
939
- nsContentUtils::CallOnAllRemoteChildren (
940
- window, [&aHeight](dom::BrowserParent* aBrowserParent) -> CallState {
924
+ CallOnAllRemoteChildren (
925
+ [aHeight](dom::BrowserParent* aBrowserParent) -> CallState {
941
926
aBrowserParent->DynamicToolbarMaxHeightChanged (aHeight);
942
927
return CallState::Continue;
943
928
});
@@ -948,30 +933,31 @@ void nsView::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) {
948
933
" Should be only called for the browser parent process" );
949
934
MOZ_ASSERT (this == mViewManager ->GetRootView (),
950
935
" Should be called for the root view" );
936
+ CallOnAllRemoteChildren (
937
+ [aOffset](dom::BrowserParent* aBrowserParent) -> CallState {
938
+ // Skip background tabs.
939
+ if (!aBrowserParent->GetDocShellIsActive ()) {
940
+ return CallState::Continue;
941
+ }
951
942
952
- PresShell* presShell = mViewManager ->GetPresShell ();
953
- if (!presShell) {
954
- return ;
955
- }
956
-
957
- dom::Document* document = presShell->GetDocument ();
958
- if (!document) {
959
- return ;
960
- }
961
-
962
- nsPIDOMWindowOuter* window = document->GetWindow ();
963
- if (!window) {
964
- return ;
965
- }
943
+ aBrowserParent->DynamicToolbarOffsetChanged (aOffset);
944
+ return CallState::Stop;
945
+ });
946
+ }
966
947
967
- nsContentUtils::CallOnAllRemoteChildren (
968
- window, [&aOffset](dom::BrowserParent* aBrowserParent) -> CallState {
948
+ void nsView::KeyboardHeightChanged (ScreenIntCoord aHeight) {
949
+ MOZ_ASSERT (XRE_IsParentProcess (),
950
+ " Should be only called for the browser parent process" );
951
+ MOZ_ASSERT (this == mViewManager ->GetRootView (),
952
+ " Should be called for the root view" );
953
+ CallOnAllRemoteChildren (
954
+ [aHeight](dom::BrowserParent* aBrowserParent) -> CallState {
969
955
// Skip background tabs.
970
956
if (!aBrowserParent->GetDocShellIsActive ()) {
971
957
return CallState::Continue;
972
958
}
973
959
974
- aBrowserParent->DynamicToolbarOffsetChanged (aOffset );
960
+ aBrowserParent->KeyboardHeightChanged (aHeight );
975
961
return CallState::Stop;
976
962
});
977
963
}
@@ -1092,6 +1078,24 @@ void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) {
1092
1078
// https://github.com/w3c/csswg-drafts/issues/4670
1093
1079
// Actually we don't set this value on sub document. This behaviour is
1094
1080
// same as Blink.
1081
+ CallOnAllRemoteChildren ([windowSafeAreaInsets](
1082
+ dom::BrowserParent* aBrowserParent) -> CallState {
1083
+ Unused << aBrowserParent->SendSafeAreaInsetsChanged (windowSafeAreaInsets);
1084
+ return CallState::Continue;
1085
+ });
1086
+ }
1087
+
1088
+ bool nsView::IsPrimaryFramePaintSuppressed () {
1089
+ return StaticPrefs::layout_show_previous_page () && mFrame &&
1090
+ mFrame ->PresShell ()->IsPaintingSuppressed ();
1091
+ }
1092
+
1093
+ void nsView::CallOnAllRemoteChildren (
1094
+ const std::function<CallState (dom::BrowserParent*)>& aCallback) {
1095
+ PresShell* presShell = mViewManager ->GetPresShell ();
1096
+ if (!presShell) {
1097
+ return ;
1098
+ }
1095
1099
1096
1100
dom::Document* document = presShell->GetDocument ();
1097
1101
if (!document) {
@@ -1103,16 +1107,5 @@ void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) {
1103
1107
return ;
1104
1108
}
1105
1109
1106
- nsContentUtils::CallOnAllRemoteChildren (
1107
- window,
1108
- [windowSafeAreaInsets](dom::BrowserParent* aBrowserParent) -> CallState {
1109
- Unused << aBrowserParent->SendSafeAreaInsetsChanged (
1110
- windowSafeAreaInsets);
1111
- return CallState::Continue;
1112
- });
1113
- }
1114
-
1115
- bool nsView::IsPrimaryFramePaintSuppressed () {
1116
- return StaticPrefs::layout_show_previous_page () && mFrame &&
1117
- mFrame ->PresShell ()->IsPaintingSuppressed ();
1110
+ nsContentUtils::CallOnAllRemoteChildren (window, aCallback);
1118
1111
}
0 commit comments