/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* 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/. *//* This class wraps an SVG document, for use by VectorImage objects. */#ifndef mozilla_image_SVGDocumentWrapper_h#define mozilla_image_SVGDocumentWrapper_h#include"mozilla/Attributes.h"#include"nsCOMPtr.h"#include"nsIStreamListener.h"#include"nsIObserver.h"#include"nsIContentViewer.h"#include"nsWeakReference.h"#include"nsSize.h"classnsIRequest;classnsILoadGroup;classnsIFrame;#define OBSERVER_SVC_CID "@mozilla.org/observer-service;1"namespacemozilla{classPresShell;namespacedom{classSVGSVGElement;classSVGDocument;}// namespace domnamespaceimage{classSVGDocumentWrapperfinal:publicnsIStreamListener,publicnsIObserver,nsSupportsWeakReference{public:SVGDocumentWrapper();NS_DECL_ISUPPORTSNS_DECL_NSISTREAMLISTENERNS_DECL_NSIREQUESTOBSERVERNS_DECL_NSIOBSERVERenumDimension{eWidth,eHeight};/** * Returns the wrapped document, or nullptr on failure. (No AddRef.) */mozilla::dom::SVGDocument*GetDocument();/** * Returns the root <svg> element for the wrapped document, or nullptr on * failure. */mozilla::dom::SVGSVGElement*GetRootSVGElem();/** * Returns the root nsIFrame* for the wrapped document, or nullptr on failure. * * @return the root nsIFrame* for the wrapped document, or nullptr on failure. */nsIFrame*GetRootLayoutFrame();/** * Returns the mozilla::PresShell for the wrapped document. */inlinemozilla::PresShell*GetPresShell(){returnmViewer->GetPresShell();}/** * Modifier to update the viewport dimensions of the wrapped document. This * method performs a synchronous "FlushType::Layout" on the wrapped document, * since a viewport-change affects layout. * * @param aViewportSize The new viewport dimensions. */voidUpdateViewportBounds(constnsIntSize&aViewportSize);/** * If an SVG image's helper document has a pending notification for an * override on the root node's "preserveAspectRatio" attribute, then this * method will flush that notification so that the image can paint correctly. * (First, though, it sets the mIgnoreInvalidation flag so that we won't * notify the image's observers and trigger unwanted repaint-requests.) */voidFlushImageTransformInvalidation();/** * Returns a bool indicating whether the document has any SMIL animations. * * @return true if the document has any SMIL animations. Else, false. */boolIsAnimated();/** * Indicates whether we should currently ignore rendering invalidations sent * from the wrapped SVG doc. * * @return true if we should ignore invalidations sent from this SVG doc. */boolShouldIgnoreInvalidation(){returnmIgnoreInvalidation;}/** * Methods to control animation. */voidStartAnimation();voidStopAnimation();voidResetAnimation();floatGetCurrentTimeAsFloat();voidSetCurrentTime(floataTime);voidTickRefreshDriver();/** * Force a layout flush of the underlying SVG document. */voidFlushLayout();private:~SVGDocumentWrapper();nsresultSetupViewer(nsIRequest*aRequest,nsIContentViewer**aViewer,nsILoadGroup**aLoadGroup);voidDestroyViewer();voidRegisterForXPCOMShutdown();voidUnregisterForXPCOMShutdown();nsCOMPtr<nsIContentViewer>mViewer;nsCOMPtr<nsILoadGroup>mLoadGroup;nsCOMPtr<nsIStreamListener>mListener;boolmIgnoreInvalidation;boolmRegisteredForXPCOMShutdown;};}// namespace image}// namespace mozilla#endif // mozilla_image_SVGDocumentWrapper_h