Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / nsICanvasRenderingContextInternal.cpp
blob8442ed326b80b68ed84d9b49746178f9a9e1aace
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsICanvasRenderingContextInternal.h"
8 #include "mozilla/dom/Document.h"
9 #include "mozilla/PresShell.h"
10 #include "nsRefreshDriver.h"
12 nsICanvasRenderingContextInternal::nsICanvasRenderingContextInternal()
13 : mSharedPtrPtr(
14 std::make_shared<nsICanvasRenderingContextInternal*>(this)) {}
16 nsICanvasRenderingContextInternal::~nsICanvasRenderingContextInternal() =
17 default;
19 mozilla::PresShell* nsICanvasRenderingContextInternal::GetPresShell() {
20 if (mCanvasElement) {
21 return mCanvasElement->OwnerDoc()->GetPresShell();
23 return nullptr;
26 void nsICanvasRenderingContextInternal::RemovePostRefreshObserver() {
27 if (mRefreshDriver) {
28 mRefreshDriver->RemovePostRefreshObserver(this);
29 mRefreshDriver = nullptr;
33 void nsICanvasRenderingContextInternal::AddPostRefreshObserverIfNecessary() {
34 if (!GetPresShell() || !GetPresShell()->GetPresContext() ||
35 !GetPresShell()->GetPresContext()->RefreshDriver()) {
36 return;
38 mRefreshDriver = GetPresShell()->GetPresContext()->RefreshDriver();
39 mRefreshDriver->AddPostRefreshObserver(this);