Bug 1708422: part 9) Declare `mozInlineSpellChecker::ShouldSpellCheckNode` `static...
[gecko.git] / image / AutoRestoreSVGState.h
blob3a5708c63ac68ec83a301c460d9888ca9f81a982
1 /* -*- Mode: C++; tab-width: 2; 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 #ifndef mozilla_image_AutoRestoreSVGState_h
7 #define mozilla_image_AutoRestoreSVGState_h
9 #include "mozilla/Attributes.h"
10 #include "mozilla/AutoRestore.h"
11 #include "mozilla/SVGContextPaint.h"
12 #include "mozilla/dom/SVGSVGElement.h"
13 #include "SVGDrawingParameters.h"
14 #include "SVGDocumentWrapper.h"
16 namespace mozilla {
17 namespace image {
19 class MOZ_STACK_CLASS AutoRestoreSVGState final {
20 public:
21 AutoRestoreSVGState(const SVGDrawingParameters& aParams,
22 SVGDocumentWrapper* aSVGDocumentWrapper,
23 bool aContextPaint)
24 : mIsDrawing(aSVGDocumentWrapper->mIsDrawing)
25 // Apply any 'preserveAspectRatio' override (if specified) to the root
26 // element:
28 mPAR(aParams.svgContext, aSVGDocumentWrapper->GetRootSVGElem())
29 // Set the animation time:
31 mTime(aSVGDocumentWrapper->GetRootSVGElem(), aParams.animationTime) {
32 MOZ_ASSERT(!mIsDrawing.SavedValue());
33 MOZ_ASSERT(aSVGDocumentWrapper->GetDocument());
35 aSVGDocumentWrapper->mIsDrawing = true;
37 // Set context paint (if specified) on the document:
38 if (aContextPaint) {
39 MOZ_ASSERT(aParams.svgContext->GetContextPaint());
40 mContextPaint.emplace(*aParams.svgContext->GetContextPaint(),
41 *aSVGDocumentWrapper->GetDocument());
45 private:
46 AutoRestore<bool> mIsDrawing;
47 AutoPreserveAspectRatioOverride mPAR;
48 AutoSVGTimeSetRestore mTime;
49 Maybe<AutoSetRestoreSVGContextPaint> mContextPaint;
52 } // namespace image
53 } // namespace mozilla
55 #endif // mozilla_image_AutoRestoreSVGState_h