1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsRefreshDriver.h"
8 #include "BrowserChild.h"
9 #include "CoalescedInputData.h"
10 #include "mozilla/PresShell.h"
12 using namespace mozilla
;
13 using namespace mozilla::dom
;
15 void CoalescedInputFlusher::StartObserver() {
16 nsRefreshDriver
* refreshDriver
= GetRefreshDriver();
17 if (mRefreshDriver
&& mRefreshDriver
== refreshDriver
) {
18 // Nothing to do if we already added an observer and it's same refresh
24 mRefreshDriver
= refreshDriver
;
25 mRefreshDriver
->AddRefreshObserver(this, FlushType::Event
,
26 "Coalesced input move flusher");
30 CoalescedInputFlusher::CoalescedInputFlusher(BrowserChild
* aBrowserChild
)
31 : mBrowserChild(aBrowserChild
) {}
33 void CoalescedInputFlusher::RemoveObserver() {
35 mRefreshDriver
->RemoveRefreshObserver(this, FlushType::Event
);
36 mRefreshDriver
= nullptr;
40 CoalescedInputFlusher::~CoalescedInputFlusher() = default;
42 nsRefreshDriver
* CoalescedInputFlusher::GetRefreshDriver() {
43 if (PresShell
* presShell
= mBrowserChild
->GetTopLevelPresShell()) {
44 return presShell
->GetRefreshDriver();