2006-06-15 23:10:28 +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/. */
|
2006-06-15 23:10:28 +04:00
|
|
|
|
|
|
|
#ifndef __NS_SVGOUTERSVGFRAME_H__
|
|
|
|
#define __NS_SVGOUTERSVGFRAME_H__
|
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsISVGSVGFrame.h"
|
|
|
|
#include "nsSVGContainerFrame.h"
|
2013-08-24 02:16:38 +04:00
|
|
|
#include "nsRegion.h"
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2014-10-31 23:08:54 +03:00
|
|
|
class gfxContext;
|
2012-07-17 21:03:51 +04:00
|
|
|
class nsSVGForeignObjectFrame;
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsSVGOuterSVGFrame class
|
|
|
|
|
|
|
|
typedef nsSVGDisplayContainerFrame nsSVGOuterSVGFrameBase;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsSVGOuterSVGFrame final : public nsSVGOuterSVGFrameBase,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsISVGSVGFrame
|
2006-06-15 23:10:28 +04:00
|
|
|
{
|
2014-05-25 02:20:40 +04:00
|
|
|
friend nsContainerFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2006-06-15 23:10:28 +04:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGOuterSVGFrame(nsStyleContext* aContext);
|
2006-06-15 23:10:28 +04:00
|
|
|
|
|
|
|
public:
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-11-20 12:10:18 +03:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
~nsSVGOuterSVGFrame() {
|
2013-09-02 12:41:57 +04:00
|
|
|
NS_ASSERTION(!mForeignObjectHash || mForeignObjectHash->Count() == 0,
|
2012-07-17 21:03:51 +04:00
|
|
|
"foreignObject(s) still registered!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
// nsIFrame:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
|
2007-11-18 15:09:03 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual mozilla::IntrinsicSize GetIntrinsicSize() override;
|
|
|
|
virtual nsSize GetIntrinsicRatio() override;
|
2007-11-18 15:09:03 +03:00
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
virtual mozilla::LogicalSize
|
|
|
|
ComputeSize(nsRenderingContext *aRenderingContext,
|
|
|
|
mozilla::WritingMode aWritingMode,
|
|
|
|
const mozilla::LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin,
|
|
|
|
const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding,
|
2015-03-21 19:28:04 +03:00
|
|
|
ComputeSizeFlags aFlags) override;
|
2007-06-12 22:27:09 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
2014-05-13 02:47:41 +04:00
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
virtual void DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDidReflowStatus aStatus) override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool UpdateOverflow() override;
|
2013-05-24 17:51:50 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2007-08-30 21:01:37 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsSplittableType GetSplittableType() const override;
|
2008-02-22 13:50:32 +03:00
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 03:06:41 +03:00
|
|
|
* @see nsGkAtoms::svgOuterSVGFrame
|
2006-06-15 23:10:28 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
2006-06-15 23:10:28 +04:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGOuterSVG"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2007-03-09 19:27:01 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() override {
|
2012-07-09 05:04:56 +04:00
|
|
|
// Any children must be added to our single anonymous inner frame kid.
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetFirstPrincipalChild() &&
|
|
|
|
GetFirstPrincipalChild()->GetType() ==
|
|
|
|
nsGkAtoms::svgOuterSVGAnonChildFrame,
|
|
|
|
"Where is our anonymous child?");
|
2012-07-09 05:04:56 +04:00
|
|
|
return GetFirstPrincipalChild()->GetContentInsertionFrame();
|
|
|
|
}
|
|
|
|
|
2013-12-30 10:50:17 +04:00
|
|
|
virtual bool IsSVGTransformed(Matrix *aOwnTransform,
|
2015-03-21 19:28:04 +03:00
|
|
|
Matrix *aFromParentTransform) const override {
|
2013-05-05 11:20:25 +04:00
|
|
|
// Our anonymous wrapper performs the transforms. We simply
|
|
|
|
// return whether we are transformed here but don't apply the transforms
|
|
|
|
// themselves.
|
2013-05-06 10:33:20 +04:00
|
|
|
return GetFirstPrincipalChild()->IsSVGTransformed();
|
2012-05-17 08:05:09 +04:00
|
|
|
}
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
// nsISVGSVGFrame interface:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2012-07-09 05:04:56 +04:00
|
|
|
// nsISVGChildFrame methods:
|
2014-10-31 23:08:54 +03:00
|
|
|
virtual nsresult PaintSVG(gfxContext& aContext,
|
2014-08-29 23:42:07 +04:00
|
|
|
const gfxMatrix& aTransform,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsIntRect* aDirtyRect = nullptr) override;
|
2013-12-30 10:50:07 +04:00
|
|
|
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFlags) override;
|
2012-07-09 05:04:56 +04:00
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
/* Methods to allow descendant nsSVGForeignObjectFrame frames to register and
|
|
|
|
* unregister themselves with their nearest nsSVGOuterSVGFrame ancestor. This
|
|
|
|
* is temporary until display list based invalidation is impleented for SVG.
|
|
|
|
* Maintaining a list of our foreignObject descendants allows us to search
|
|
|
|
* them for areas that need to be invalidated, without having to also search
|
|
|
|
* the SVG frame tree for foreignObjects. This is important so that bug 539356
|
|
|
|
* does not slow down SVG in general (only foreignObjects, until bug 614732 is
|
|
|
|
* fixed).
|
|
|
|
*/
|
|
|
|
void RegisterForeignObject(nsSVGForeignObjectFrame* aFrame);
|
|
|
|
void UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const override {
|
2012-07-09 05:04:56 +04:00
|
|
|
// Our anonymous wrapper child must claim our children-only transforms as
|
|
|
|
// its own so that our real children (the frames it wraps) are transformed
|
|
|
|
// by them, and we must pretend we don't have any children-only transforms
|
|
|
|
// so that our anonymous child is _not_ transformed by them.
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-17 08:05:09 +04:00
|
|
|
|
2012-03-19 12:34:19 +04:00
|
|
|
/**
|
|
|
|
* Return true only if the height is unspecified (defaulting to 100%) or else
|
|
|
|
* the height is explicitly set to a percentage value no greater than 100%.
|
|
|
|
*/
|
|
|
|
bool VerticalScrollbarNotNeeded() const;
|
|
|
|
|
2012-07-22 04:01:44 +04:00
|
|
|
bool IsCallingReflowSVG() const {
|
|
|
|
return mCallingReflowSVG;
|
2012-03-20 16:15:53 +04:00
|
|
|
}
|
|
|
|
|
2012-08-29 09:39:33 +04:00
|
|
|
void InvalidateSVG(const nsRegion& aRegion)
|
|
|
|
{
|
|
|
|
if (!aRegion.IsEmpty()) {
|
|
|
|
mInvalidRegion.Or(mInvalidRegion, aRegion);
|
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearInvalidRegion() { mInvalidRegion.SetEmpty(); }
|
|
|
|
|
|
|
|
const nsRegion& GetInvalidRegion() {
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect rect;
|
|
|
|
if (!IsInvalid(rect)) {
|
2012-08-29 09:39:33 +04:00
|
|
|
mInvalidRegion.SetEmpty();
|
|
|
|
}
|
|
|
|
return mInvalidRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRegion FindInvalidatedForeignObjectFrameChildren(nsIFrame* aFrame);
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
protected:
|
|
|
|
|
2012-07-22 04:01:44 +04:00
|
|
|
bool mCallingReflowSVG;
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2007-11-18 15:09:03 +03:00
|
|
|
/* Returns true if our content is the document element and our document is
|
|
|
|
* embedded in an HTML 'object', 'embed' or 'applet' element. Set
|
|
|
|
* aEmbeddingFrame to obtain the nsIFrame for the embedding HTML element.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
bool IsRootOfReplacedElementSubDoc(nsIFrame **aEmbeddingFrame = nullptr);
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2010-09-09 00:40:39 +04:00
|
|
|
/* Returns true if our content is the document element and our document is
|
|
|
|
* being used as an image.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRootOfImage();
|
2010-09-09 00:40:39 +04:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
// This is temporary until display list based invalidation is implemented for
|
|
|
|
// SVG.
|
|
|
|
// A hash-set containing our nsSVGForeignObjectFrame descendants. Note we use
|
|
|
|
// a hash-set to avoid the O(N^2) behavior we'd get tearing down an SVG frame
|
|
|
|
// subtree if we were to use a list (see bug 381285 comment 20).
|
2013-09-02 12:41:57 +04:00
|
|
|
nsAutoPtr<nsTHashtable<nsPtrHashKey<nsSVGForeignObjectFrame> > > mForeignObjectHash;
|
2012-07-17 21:03:51 +04:00
|
|
|
|
2011-09-26 01:04:32 +04:00
|
|
|
nsAutoPtr<gfxMatrix> mCanvasTM;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2012-08-29 09:39:33 +04:00
|
|
|
nsRegion mInvalidRegion;
|
|
|
|
|
2007-12-04 07:40:52 +03:00
|
|
|
float mFullZoom;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mViewportInitialized;
|
|
|
|
bool mIsRootContent;
|
2006-06-15 23:10:28 +04:00
|
|
|
};
|
|
|
|
|
2012-07-09 05:04:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsSVGOuterSVGAnonChildFrame class
|
|
|
|
|
|
|
|
typedef nsSVGDisplayContainerFrame nsSVGOuterSVGAnonChildFrameBase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsSVGOuterSVGFrames have a single direct child that is an instance of this
|
|
|
|
* class, and which is used to wrap their real child frames. Such anonymous
|
|
|
|
* wrapper frames created from this class exist because SVG frames need their
|
|
|
|
* GetPosition() offset to be their offset relative to "user space" (in app
|
|
|
|
* units) so that they can play nicely with nsDisplayTransform. This is fine
|
|
|
|
* for all SVG frames except for direct children of an nsSVGOuterSVGFrame,
|
|
|
|
* since an nsSVGOuterSVGFrame can have CSS border and padding (unlike other
|
|
|
|
* SVG frames). The direct children can't include the offsets due to any such
|
|
|
|
* border/padding in their mRects since that would break nsDisplayTransform,
|
|
|
|
* but not including these offsets would break other parts of the Mozilla code
|
|
|
|
* that assume a frame's mRect contains its border-box-to-parent-border-box
|
|
|
|
* offset, in particular nsIFrame::GetOffsetTo and the functions that depend on
|
|
|
|
* it. Wrapping an nsSVGOuterSVGFrame's children in an instance of this class
|
|
|
|
* with its GetPosition() set to its nsSVGOuterSVGFrame's border/padding offset
|
|
|
|
* keeps both nsDisplayTransform and nsIFrame::GetOffsetTo happy.
|
|
|
|
*
|
|
|
|
* The reason that this class inherit from nsSVGDisplayContainerFrame rather
|
|
|
|
* than simply from nsContainerFrame is so that we can avoid having special
|
|
|
|
* handling for these inner wrappers in multiple parts of the SVG code. For
|
|
|
|
* example, the implementations of IsSVGTransformed and GetCanvasTM assume
|
|
|
|
* nsSVGContainerFrame instances all the way up to the nsSVGOuterSVGFrame.
|
|
|
|
*/
|
|
|
|
class nsSVGOuterSVGAnonChildFrame
|
|
|
|
: public nsSVGOuterSVGAnonChildFrameBase
|
|
|
|
{
|
2014-05-25 02:20:40 +04:00
|
|
|
friend nsContainerFrame*
|
2012-07-09 05:04:56 +04:00
|
|
|
NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGOuterSVGAnonChildFrame(nsStyleContext* aContext)
|
2012-07-09 05:04:56 +04:00
|
|
|
: nsSVGOuterSVGAnonChildFrameBase(aContext)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2014-01-06 03:31:14 +04:00
|
|
|
#endif
|
2012-07-09 05:04:56 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2012-07-09 05:04:56 +04:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGOuterSVGAnonChild"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgOuterSVGAnonChildFrame
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2012-07-09 05:04:56 +04:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override {
|
2012-07-09 05:04:56 +04:00
|
|
|
// GetCanvasTM returns the transform from an SVG frame to the frame's
|
|
|
|
// nsSVGOuterSVGFrame's content box, so we do not include any x/y offset
|
|
|
|
// set on us for any CSS border or padding on our nsSVGOuterSVGFrame.
|
2014-09-08 15:28:50 +04:00
|
|
|
return static_cast<nsSVGOuterSVGFrame*>(GetParent())->GetCanvasTM();
|
2012-07-09 05:04:56 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const override;
|
2012-07-09 05:04:56 +04:00
|
|
|
};
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
#endif
|