mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 20:42:49 +00:00
Bug 1586986 - Deliver 'fixed-bottom' offset to the top of the pres context on the foreground tab. r=geckoview-reviewers,tnikkel,snorp
The dynamic toolbar transition doesn't affect on background tabs since to switch tabs the dynamic toolbar should be restored to its original state (i.e., completely visible state). Differential Revision: https://phabricator.services.mozilla.com/D52336 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6aae1c4aaa
commit
9b165804d8
@ -1349,6 +1349,21 @@ mozilla::ipc::IPCResult BrowserChild::RecvDynamicToolbarMaxHeightChanged(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserChild::RecvDynamicToolbarOffsetChanged(
|
||||
const ScreenIntCoord& aOffset) {
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
RefPtr<Document> document = GetTopLevelDocument();
|
||||
if (!document) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (nsPresContext* presContext = document->GetPresContext()) {
|
||||
presContext->UpdateDynamicToolbarOffset(aOffset);
|
||||
}
|
||||
#endif
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserChild::RecvSuppressDisplayport(
|
||||
const bool& aEnabled) {
|
||||
if (RefPtr<PresShell> presShell = GetTopLevelPresShell()) {
|
||||
|
@ -293,6 +293,9 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
|
||||
mozilla::ipc::IPCResult RecvDynamicToolbarMaxHeightChanged(
|
||||
const mozilla::ScreenIntCoord& aHeight);
|
||||
|
||||
mozilla::ipc::IPCResult RecvDynamicToolbarOffsetChanged(
|
||||
const mozilla::ScreenIntCoord& aOffset);
|
||||
|
||||
mozilla::ipc::IPCResult RecvActivate();
|
||||
|
||||
mozilla::ipc::IPCResult RecvDeactivate();
|
||||
|
@ -1097,6 +1097,12 @@ void BrowserParent::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {
|
||||
Unused << SendDynamicToolbarMaxHeightChanged(aHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserParent::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) {
|
||||
if (!mIsDestroyed) {
|
||||
Unused << SendDynamicToolbarOffsetChanged(aOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BrowserParent::HandleAccessKey(const WidgetKeyboardEvent& aEvent,
|
||||
|
@ -535,6 +535,7 @@ class BrowserParent final : public PBrowserParent,
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
void DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight);
|
||||
void DynamicToolbarOffsetChanged(ScreenIntCoord aOffset);
|
||||
#endif
|
||||
|
||||
void Activate();
|
||||
|
@ -753,6 +753,8 @@ child:
|
||||
|
||||
async DynamicToolbarMaxHeightChanged(ScreenIntCoord height);
|
||||
|
||||
async DynamicToolbarOffsetChanged(ScreenIntCoord height);
|
||||
|
||||
async ParentActivated(bool aActivated);
|
||||
|
||||
async SetKeyboardIndicators(UIStateChangeType showFocusRings);
|
||||
|
@ -10418,6 +10418,10 @@ static void SetPluginIsActive(nsISupports* aSupports, void* aClosure) {
|
||||
nsresult PresShell::SetIsActive(bool aIsActive) {
|
||||
MOZ_ASSERT(mDocument, "should only be called with a document");
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
const bool changed = mIsActive != aIsActive;
|
||||
#endif
|
||||
|
||||
mIsActive = aIsActive;
|
||||
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
@ -10439,6 +10443,17 @@ nsresult PresShell::SetIsActive(bool aIsActive) {
|
||||
}
|
||||
}
|
||||
#endif // #ifdef ACCESSIBILITY
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
if (changed && !aIsActive && presContext &&
|
||||
presContext->IsRootContentDocumentCrossProcess()) {
|
||||
if (BrowserChild* browserChild = BrowserChild::GetFrom(this)) {
|
||||
// Reset the dynamic toolbar offset state.
|
||||
presContext->UpdateDynamicToolbarOffset(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2535,6 +2535,19 @@ void nsPresContext::AdjustSizeForViewportUnits() {
|
||||
NSIntPixelsToAppUnits(mDynamicToolbarMaxHeight, mCurAppUnitsPerDevPixel);
|
||||
}
|
||||
|
||||
void nsPresContext::UpdateDynamicToolbarOffset(ScreenIntCoord aOffset) {
|
||||
MOZ_ASSERT(IsRootContentDocumentCrossProcess());
|
||||
if (!mPresShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasDynamicToolbar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(-mDynamicToolbarMaxHeight <= aOffset && aOffset <= 0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void nsPresContext::ValidatePresShellAndDocumentReleation() const {
|
||||
|
@ -392,6 +392,11 @@ class nsPresContext : public nsISupports,
|
||||
return mDynamicToolbarMaxHeight > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* |aOffset| must be offset from the bottom edge of the ICB and it's negative.
|
||||
*/
|
||||
void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset);
|
||||
|
||||
/**
|
||||
* Return true if this presentation context is a paginated
|
||||
* context.
|
||||
|
@ -222,7 +222,7 @@ public class GeckoSession implements Parcelable {
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "current")
|
||||
public native void setMaxToolbarHeight(int height);
|
||||
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "current")
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
|
||||
public native void setFixedBottomOffset(int offset);
|
||||
|
||||
@WrapForJNI(calledFrom = "ui", dispatchTo = "current")
|
||||
|
@ -999,6 +999,43 @@ void nsView::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {
|
||||
nsContentUtils::CallOnAllRemoteChildren(
|
||||
window, NotifyDynamicToolbarMaxHeightChanged, &aHeight);
|
||||
}
|
||||
|
||||
static bool NotifyDynamicToolbarOffsetChanged(
|
||||
dom::BrowserParent* aBrowserParent, void* aArg) {
|
||||
// Skip background tabs.
|
||||
if (!aBrowserParent->GetDocShellIsActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ScreenIntCoord* offset = static_cast<ScreenIntCoord*>(aArg);
|
||||
aBrowserParent->DynamicToolbarOffsetChanged(*offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
void nsView::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess(),
|
||||
"Should be only called for the browser parent process");
|
||||
MOZ_ASSERT(this == mViewManager->GetRootView(),
|
||||
"Should be called for the root view");
|
||||
|
||||
PresShell* presShell = mViewManager->GetPresShell();
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
dom::Document* document = presShell->GetDocument();
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPIDOMWindowOuter* window = document->GetWindow();
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsContentUtils::CallOnAllRemoteChildren(
|
||||
window, NotifyDynamicToolbarOffsetChanged, &aOffset);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool nsView::RequestWindowClose(nsIWidget* aWidget) {
|
||||
|
@ -452,6 +452,8 @@ class nsView final : public nsIWidgetListener {
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
virtual void DynamicToolbarMaxHeightChanged(
|
||||
mozilla::ScreenIntCoord aHeight) override;
|
||||
virtual void DynamicToolbarOffsetChanged(
|
||||
mozilla::ScreenIntCoord aOffset) override;
|
||||
#endif
|
||||
virtual bool RequestWindowClose(nsIWidget* aWidget) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
|
@ -1090,11 +1090,18 @@ class nsWindow::LayerViewSupport final
|
||||
}
|
||||
|
||||
void SetFixedBottomOffset(int32_t aOffset) {
|
||||
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
|
||||
if (mWindow) {
|
||||
mWindow->UpdateDynamicToolbarOffset(ScreenIntCoord(aOffset));
|
||||
}
|
||||
|
||||
if (RefPtr<UiCompositorControllerChild> child =
|
||||
GetUiCompositorControllerChild()) {
|
||||
child->SetFixedBottomOffset(aOffset);
|
||||
if (RefPtr<nsThread> uiThread = GetAndroidUiThread()) {
|
||||
uiThread->Dispatch(NS_NewRunnableFunction(
|
||||
"LayerViewSupport::SetFixedBottomOffset", [this, offset = aOffset] {
|
||||
if (RefPtr<UiCompositorControllerChild> child =
|
||||
GetUiCompositorControllerChild()) {
|
||||
child->SetFixedBottomOffset(offset);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2326,6 +2333,16 @@ void nsWindow::UpdateDynamicToolbarMaxHeight(ScreenIntCoord aHeight) {
|
||||
}
|
||||
}
|
||||
|
||||
void nsWindow::UpdateDynamicToolbarOffset(ScreenIntCoord aOffset) {
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->DynamicToolbarOffsetChanged(aOffset);
|
||||
}
|
||||
|
||||
if (mAttachedWidgetListener) {
|
||||
mAttachedWidgetListener->DynamicToolbarOffsetChanged(aOffset);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
|
||||
aValue);
|
||||
|
@ -330,6 +330,8 @@ class nsWindow final : public nsBaseWidget {
|
||||
nsresult SetPrefersReducedMotionOverrideForTest(bool aValue) override;
|
||||
nsresult ResetPrefersReducedMotionOverrideForTest() override;
|
||||
|
||||
void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset);
|
||||
|
||||
protected:
|
||||
void BringToFront();
|
||||
nsWindow* FindTopLevel();
|
||||
|
@ -38,6 +38,7 @@ void nsIWidgetListener::UIResolutionChanged() {}
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
void nsIWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {
|
||||
}
|
||||
void nsIWidgetListener::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) {}
|
||||
#endif
|
||||
|
||||
void nsIWidgetListener::FullscreenWillChange(bool aInFullscreen) {}
|
||||
|
@ -87,6 +87,7 @@ class nsIWidgetListener {
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
virtual void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight);
|
||||
virtual void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user