2010-09-09 00:40:39 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
/* This class wraps an SVG document, for use by VectorImage objects. */
|
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#ifndef mozilla_image_SVGDocumentWrapper_h
|
|
|
|
#define mozilla_image_SVGDocumentWrapper_h
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2012-01-03 00:23:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2010-09-09 00:40:39 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIObserver.h"
|
2011-10-15 11:33:26 +04:00
|
|
|
#include "nsIContentViewer.h"
|
2010-11-08 20:45:18 +03:00
|
|
|
#include "nsWeakReference.h"
|
2015-03-29 17:59:08 +03:00
|
|
|
#include "nsSize.h"
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
class nsIRequest;
|
|
|
|
class nsILoadGroup;
|
|
|
|
class nsIFrame;
|
|
|
|
|
|
|
|
#define OBSERVER_SVC_CID "@mozilla.org/observer-service;1"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2019-04-16 05:47:26 +03:00
|
|
|
class PresShell;
|
2013-01-10 03:02:45 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGSVGElement;
|
2018-04-21 19:48:29 +03:00
|
|
|
class SVGDocument;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-01-10 03:02:45 +04:00
|
|
|
|
2012-01-06 20:02:27 +04:00
|
|
|
namespace image {
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGDocumentWrapper final : public nsIStreamListener,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver,
|
|
|
|
nsSupportsWeakReference {
|
2010-09-09 00:40:39 +04:00
|
|
|
public:
|
2017-07-25 15:33:56 +03:00
|
|
|
SVGDocumentWrapper();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
enum Dimension { eWidth, eHeight };
|
|
|
|
|
2013-02-14 06:04:08 +04:00
|
|
|
/**
|
|
|
|
* Returns the wrapped document, or nullptr on failure. (No AddRef.)
|
|
|
|
*/
|
2018-04-21 19:48:29 +03:00
|
|
|
mozilla::dom::SVGDocument* GetDocument();
|
2013-02-14 06:04:08 +04:00
|
|
|
|
2010-09-09 00:40:39 +04:00
|
|
|
/**
|
2012-07-30 18:20:58 +04:00
|
|
|
* Returns the root <svg> element for the wrapped document, or nullptr on
|
2010-09-09 00:40:39 +04:00
|
|
|
* failure.
|
|
|
|
*/
|
2013-01-10 03:02:45 +04:00
|
|
|
mozilla::dom::SVGSVGElement* GetRootSVGElem();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
/**
|
2012-07-30 18:20:58 +04:00
|
|
|
* Returns the root nsIFrame* for the wrapped document, or nullptr on failure.
|
2010-09-09 00:40:39 +04:00
|
|
|
*
|
2012-07-30 18:20:58 +04:00
|
|
|
* @return the root nsIFrame* for the wrapped document, or nullptr on failure.
|
2010-09-09 00:40:39 +04:00
|
|
|
*/
|
|
|
|
nsIFrame* GetRootLayoutFrame();
|
|
|
|
|
|
|
|
/**
|
2019-04-16 05:47:26 +03:00
|
|
|
* Returns the mozilla::PresShell for the wrapped document.
|
2010-09-09 00:40:39 +04:00
|
|
|
*/
|
2019-04-16 05:47:26 +03:00
|
|
|
inline mozilla::PresShell* GetPresShell() { return mViewer->GetPresShell(); }
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifier to update the viewport dimensions of the wrapped document. This
|
2017-01-05 10:31:56 +03:00
|
|
|
* method performs a synchronous "FlushType::Layout" on the wrapped document,
|
2010-09-09 00:40:39 +04:00
|
|
|
* since a viewport-change affects layout.
|
|
|
|
*
|
|
|
|
* @param aViewportSize The new viewport dimensions.
|
|
|
|
*/
|
|
|
|
void UpdateViewportBounds(const nsIntSize& aViewportSize);
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
/**
|
|
|
|
* 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.)
|
|
|
|
*/
|
2011-02-09 23:13:18 +03:00
|
|
|
void FlushImageTransformInvalidation();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
/**
|
2011-09-29 10:19:26 +04:00
|
|
|
* Returns a bool indicating whether the document has any SMIL animations.
|
2010-09-09 00:40:39 +04:00
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if the document has any SMIL animations. Else, false.
|
2010-09-09 00:40:39 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAnimated();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2010-09-09 00:40:40 +04:00
|
|
|
/**
|
|
|
|
* Indicates whether we should currently ignore rendering invalidations sent
|
|
|
|
* from the wrapped SVG doc.
|
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @return true if we should ignore invalidations sent from this SVG doc.
|
2010-09-09 00:40:40 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ShouldIgnoreInvalidation() { return mIgnoreInvalidation; }
|
2010-09-09 00:40:40 +04:00
|
|
|
|
2010-09-09 00:40:39 +04:00
|
|
|
/**
|
|
|
|
* Methods to control animation.
|
|
|
|
*/
|
|
|
|
void StartAnimation();
|
|
|
|
void StopAnimation();
|
|
|
|
void ResetAnimation();
|
2018-12-21 08:37:58 +03:00
|
|
|
float GetCurrentTimeAsFloat();
|
2013-03-11 05:43:37 +04:00
|
|
|
void SetCurrentTime(float aTime);
|
2014-05-01 20:31:54 +04:00
|
|
|
void TickRefreshDriver();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2013-02-14 06:04:08 +04:00
|
|
|
/**
|
|
|
|
* Force a layout flush of the underlying SVG document.
|
|
|
|
*/
|
|
|
|
void FlushLayout();
|
|
|
|
|
2010-09-09 00:40:39 +04:00
|
|
|
private:
|
2014-06-23 22:49:08 +04:00
|
|
|
~SVGDocumentWrapper();
|
|
|
|
|
2015-03-04 15:18:00 +03:00
|
|
|
nsresult SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer,
|
2010-09-09 00:40:39 +04:00
|
|
|
nsILoadGroup** aLoadGroup);
|
|
|
|
void DestroyViewer();
|
|
|
|
void RegisterForXPCOMShutdown();
|
2010-11-08 20:45:18 +03:00
|
|
|
void UnregisterForXPCOMShutdown();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2011-10-15 11:33:26 +04:00
|
|
|
nsCOMPtr<nsIContentViewer> mViewer;
|
2010-09-09 00:40:39 +04:00
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
|
|
|
nsCOMPtr<nsIStreamListener> mListener;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIgnoreInvalidation;
|
|
|
|
bool mRegisteredForXPCOMShutdown;
|
2010-09-09 00:40:39 +04:00
|
|
|
};
|
|
|
|
|
2012-01-06 20:02:27 +04:00
|
|
|
} // namespace image
|
2010-09-09 00:40:39 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#endif // mozilla_image_SVGDocumentWrapper_h
|