mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1689156 - Bring the fast tab switch paint back r=mstange,mattwoodrow
In bug 1669239, we removed the magic paint which would occur during tab switches, and instead we requested a tick. However, this approach didn't work well because tick was a heavy operation which did not only paints but also many other stuff, such as running requestAnimationFrame handlers, so it made the tab switches slower under certain conditions. So here we reverts the changes we made in bug 1669239. Differential Revision: https://phabricator.services.mozilla.com/D107858
This commit is contained in:
parent
f612c014e0
commit
706997d444
@ -268,10 +268,10 @@ void PuppetWidget::Invalidate(const LayoutDeviceIntRect& aRect) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBrowserChild && !aRect.IsEmpty()) {
|
||||
if (RefPtr<nsRefreshDriver> refreshDriver = GetTopLevelRefreshDriver()) {
|
||||
refreshDriver->ScheduleViewManagerFlush();
|
||||
}
|
||||
if (mBrowserChild && !aRect.IsEmpty() && !mWidgetPaintTask.IsPending()) {
|
||||
mWidgetPaintTask = new WidgetPaintTask(this);
|
||||
nsCOMPtr<nsIRunnable> event(mWidgetPaintTask.get());
|
||||
SchedulerGroup::Dispatch(TaskCategory::Other, event.forget());
|
||||
}
|
||||
}
|
||||
|
||||
@ -963,11 +963,31 @@ void PuppetWidget::SetChild(PuppetWidget* aChild) {
|
||||
mChild = aChild;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::WidgetPaintTask::Run() {
|
||||
if (mWidget) {
|
||||
mWidget->Paint();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void PuppetWidget::Paint() {
|
||||
if (!GetCurrentWidgetListener()) return;
|
||||
|
||||
mWidgetPaintTask.Revoke();
|
||||
|
||||
RefPtr<PuppetWidget> strongThis(this);
|
||||
|
||||
GetCurrentWidgetListener()->WillPaintWindow(this);
|
||||
|
||||
if (GetCurrentWidgetListener()) {
|
||||
GetCurrentWidgetListener()->DidPaintWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void PuppetWidget::PaintNowIfNeeded() {
|
||||
if (IsVisible()) {
|
||||
if (RefPtr<nsRefreshDriver> refreshDriver = GetTopLevelRefreshDriver()) {
|
||||
refreshDriver->DoTick();
|
||||
}
|
||||
if (IsVisible() && mWidgetPaintTask.IsPending()) {
|
||||
Paint();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,6 +316,8 @@ class PuppetWidget : public nsBaseWidget,
|
||||
virtual void OnMemoryPressure(layers::MemoryPressureReason aWhy) override;
|
||||
|
||||
private:
|
||||
void Paint();
|
||||
|
||||
void SetChild(PuppetWidget* aChild);
|
||||
|
||||
nsresult RequestIMEToCommitComposition(bool aCancel);
|
||||
@ -340,6 +342,17 @@ class PuppetWidget : public nsBaseWidget,
|
||||
// IMEStateManager, the cache is valid.
|
||||
bool HaveValidInputContextCache() const;
|
||||
|
||||
class WidgetPaintTask : public Runnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
explicit WidgetPaintTask(PuppetWidget* widget)
|
||||
: Runnable("PuppetWidget::WidgetPaintTask"), mWidget(widget) {}
|
||||
void Revoke() { mWidget = nullptr; }
|
||||
|
||||
private:
|
||||
PuppetWidget* mWidget;
|
||||
};
|
||||
|
||||
nsRefreshDriver* GetTopLevelRefreshDriver() const;
|
||||
|
||||
// BrowserChild normally holds a strong reference to this PuppetWidget
|
||||
@ -352,6 +365,7 @@ class PuppetWidget : public nsBaseWidget,
|
||||
// The "widget" to which we delegate events if we don't have an
|
||||
// event handler.
|
||||
RefPtr<PuppetWidget> mChild;
|
||||
nsRevocableEventPtr<WidgetPaintTask> mWidgetPaintTask;
|
||||
RefPtr<layers::MemoryPressureObserver> mMemoryPressureObserver;
|
||||
// XXX/cjones: keeping this around until we teach LayerManager to do
|
||||
// retained-content-only transactions
|
||||
|
Loading…
Reference in New Issue
Block a user