зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1647871 - Remove AutoResizeReflowSquasher. r=kats
After the above, I don't think this is needed anymore, because we shouldn't be looking at the widget size from layout. It also shouldn't cause more reflows on desktop at least, because of the early out in ResizeReflowIgnoreOverride before calling SimpleResizeReflow(). Differential Revision: https://phabricator.services.mozilla.com/D80731
This commit is contained in:
Родитель
24e9f0cd8e
Коммит
2948ee6b8c
|
@ -32,7 +32,6 @@
|
|||
#include "ipc/nsGUIEventIPC.h"
|
||||
#include "js/JSON.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/AutoResizeReflowSquasher.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
|
@ -1167,33 +1166,17 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions(
|
|||
ScreenIntSize screenSize = GetInnerSize();
|
||||
ScreenIntRect screenRect = GetOuterRect();
|
||||
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// For some reason on geckoview-junit tests we get multiple reflows on the
|
||||
// top-level presShell, but with different sizes. This seems kinda wrong,
|
||||
// but for now let's just leave it as-is and not squash them, since handling
|
||||
// the multiple reflows in order might be important. Filed bug 1646261 to
|
||||
// investigate this more closely.
|
||||
#else
|
||||
AutoResizeReflowSquasher squasher(GetTopLevelPresShell());
|
||||
#endif
|
||||
// Make sure to set the size on the document viewer first. The
|
||||
// MobileViewportManager needs the content viewer size to be updated before
|
||||
// the reflow, otherwise it gets a stale size when it computes a new CSS
|
||||
// viewport.
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
nsIBaseWindow::eRepaint);
|
||||
|
||||
// Make sure to set the size on the document viewer and the widget before
|
||||
// triggering a reflow. We do this by capturing the reflows and making
|
||||
// that happen at the end of this scoped block, using the squasher.
|
||||
// The MobileViewportManager needs the content viewer size to be updated
|
||||
// before the reflow, otherwise it gets a stale size when it computes
|
||||
// a new CSS viewport. Similarly, the widget size needs to be updated before
|
||||
// the root scrollframe figures out which scrollbars are needed because
|
||||
// it might read the composition size from the widget.
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
nsIBaseWindow::eRepaint);
|
||||
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
||||
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
}
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
||||
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
RecvSafeAreaInsetsChanged(mPuppetWidget->GetSafeAreaInsets());
|
||||
|
||||
|
@ -3175,13 +3158,15 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
|
|||
ScreenIntSize screenSize = GetInnerSize();
|
||||
if (mHasValidInnerSize && oldScreenSize != screenSize) {
|
||||
ScreenIntRect screenRect = GetOuterRect();
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
||||
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
// See RecvUpdateDimensions for the order of these operations.
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
nsIBaseWindow::eRepaint);
|
||||
|
||||
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
||||
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AutoResizeReflowSquasher.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
StaticRefPtr<PresShell> AutoResizeReflowSquasher::sPresShell;
|
||||
bool AutoResizeReflowSquasher::sHasCapture = false;
|
||||
nscoord AutoResizeReflowSquasher::sWidth = 0;
|
||||
nscoord AutoResizeReflowSquasher::sHeight = 0;
|
||||
ResizeReflowOptions AutoResizeReflowSquasher::sOptions =
|
||||
ResizeReflowOptions::NoOption;
|
||||
|
||||
AutoResizeReflowSquasher::AutoResizeReflowSquasher(PresShell* aShell) {
|
||||
// Don't allow nested AutoResizeReflowSquashers. Note that aShell may
|
||||
// be null, in which case this AutoResizeReflowSquasher should behave as
|
||||
// though it was never created. In this scenario nested instances are
|
||||
// allowed.
|
||||
MOZ_ASSERT(!sPresShell);
|
||||
sPresShell = aShell;
|
||||
MOZ_ASSERT(!sHasCapture);
|
||||
}
|
||||
|
||||
AutoResizeReflowSquasher::~AutoResizeReflowSquasher() {
|
||||
RefPtr<PresShell> presShell = sPresShell;
|
||||
sPresShell = nullptr;
|
||||
if (sHasCapture) {
|
||||
presShell->ResizeReflow(sWidth, sHeight, sOptions);
|
||||
sHasCapture = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool AutoResizeReflowSquasher::CaptureResizeReflow(
|
||||
PresShell* aShell, nscoord aWidth, nscoord aHeight,
|
||||
ResizeReflowOptions aOptions) {
|
||||
if (!sPresShell) {
|
||||
return false;
|
||||
}
|
||||
if (sPresShell.get() != aShell) {
|
||||
return false;
|
||||
}
|
||||
if (!sHasCapture) {
|
||||
sHasCapture = true;
|
||||
sWidth = aWidth;
|
||||
sHeight = aHeight;
|
||||
sOptions = aOptions;
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(sWidth == aWidth);
|
||||
MOZ_ASSERT(sHeight == aHeight);
|
||||
MOZ_ASSERT(sOptions == aOptions);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -1,40 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_AutoResizeReflowSquasher_h_
|
||||
#define mozilla_AutoResizeReflowSquasher_h_
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/PresShellForwards.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// Put one of these on the stack to "capture" any calls to aShell->ResizeReflow
|
||||
// and have them execute when this class is destroyed.
|
||||
// This effectively "squashes" together multiple calls to ResizeReflow and
|
||||
// combines them into one call at the end of the scope that contains this
|
||||
// RAII class. Note that only calls to ResizeReflow on a particular shell are
|
||||
// captured, and they must all have the same arguments, otherwise an assertion
|
||||
// will be thrown.
|
||||
class MOZ_RAII AutoResizeReflowSquasher {
|
||||
public:
|
||||
explicit AutoResizeReflowSquasher(PresShell* aShell);
|
||||
MOZ_CAN_RUN_SCRIPT ~AutoResizeReflowSquasher();
|
||||
static bool CaptureResizeReflow(PresShell* aShell, nscoord aWidth,
|
||||
nscoord aHeight,
|
||||
ResizeReflowOptions aOptions);
|
||||
|
||||
private:
|
||||
static StaticRefPtr<PresShell> sPresShell;
|
||||
static bool sHasCapture;
|
||||
static nscoord sWidth;
|
||||
static nscoord sHeight;
|
||||
static ResizeReflowOptions sOptions;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_AutoResizeReflowSquasher_h_
|
|
@ -12,7 +12,6 @@
|
|||
#include "mozilla/dom/FontFaceSet.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AutoResizeReflowSquasher.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/ContentIterator.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
|
@ -1941,11 +1940,6 @@ void PresShell::sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell) {
|
|||
|
||||
nsresult PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight,
|
||||
ResizeReflowOptions aOptions) {
|
||||
if (AutoResizeReflowSquasher::CaptureResizeReflow(this, aWidth, aHeight,
|
||||
aOptions)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mZoomConstraintsClient) {
|
||||
// If we have a ZoomConstraintsClient and the available screen area
|
||||
// changed, then we might need to disable double-tap-to-zoom, so notify
|
||||
|
|
|
@ -72,7 +72,6 @@ EXPORTS += [
|
|||
EXPORTS.mozilla += [
|
||||
'AccessibleCaretEventHub.h',
|
||||
'ArenaObjectID.h',
|
||||
'AutoResizeReflowSquasher.h',
|
||||
'GeckoMVMContext.h',
|
||||
'GeometryUtils.h',
|
||||
'MediaEmulationData.h',
|
||||
|
@ -100,7 +99,6 @@ UNIFIED_SOURCES += [
|
|||
'AccessibleCaret.cpp',
|
||||
'AccessibleCaretEventHub.cpp',
|
||||
'AccessibleCaretManager.cpp',
|
||||
'AutoResizeReflowSquasher.cpp',
|
||||
'GeckoMVMContext.cpp',
|
||||
'GeometryUtils.cpp',
|
||||
'LayoutLogging.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче