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 nsIPresShell;
|
|
|
|
class nsIRequest;
|
|
|
|
class nsILoadGroup;
|
|
|
|
class nsIFrame;
|
|
|
|
|
|
|
|
#define OBSERVER_SVC_CID "@mozilla.org/observer-service;1"
|
|
|
|
|
2013-11-19 10:03:36 +04:00
|
|
|
// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK
|
|
|
|
#undef GetCurrentTime
|
2010-09-09 00:40:39 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-01-10 03:02:45 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGSVGElement;
|
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:
|
|
|
|
SVGDocumentWrapper();
|
|
|
|
|
|
|
|
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.)
|
|
|
|
*/
|
|
|
|
nsIDocument* GetDocument();
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns (by reference) the nsIPresShell for the wrapped document.
|
|
|
|
*
|
|
|
|
* @param[out] aPresShell On success, this will be populated with a pointer
|
|
|
|
* to the wrapped document's nsIPresShell.
|
|
|
|
*
|
|
|
|
* @return NS_OK on success, or an error code on failure.
|
|
|
|
*/
|
|
|
|
inline nsresult GetPresShell(nsIPresShell** aPresShell)
|
|
|
|
{ return mViewer->GetPresShell(aPresShell); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifier to update the viewport dimensions of the wrapped document. This
|
|
|
|
* method performs a synchronous "Flush_Layout" on the wrapped document,
|
|
|
|
* 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();
|
2013-03-11 05:43:37 +04:00
|
|
|
float GetCurrentTime();
|
|
|
|
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,
|
2011-10-15 11:33:26 +04:00
|
|
|
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
|