2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef LAYOUT_SVG_SVGOUTERSVGFRAME_H_
|
|
|
|
#define LAYOUT_SVG_SVGOUTERSVGFRAME_H_
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2020-07-12 19:38:26 +03:00
|
|
|
#include "mozilla/ISVGSVGFrame.h"
|
2020-07-09 04:33:33 +03:00
|
|
|
#include "mozilla/SVGContainerFrame.h"
|
2020-02-01 12:40:36 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2013-08-24 02:16:38 +04:00
|
|
|
#include "nsRegion.h"
|
2021-03-24 20:56:46 +03:00
|
|
|
#include "nsTHashSet.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
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
2020-09-21 05:09:57 +03:00
|
|
|
class AutoSVGViewHandler;
|
2020-06-25 23:42:49 +03:00
|
|
|
class SVGForeignObjectFrame;
|
2020-09-21 05:09:57 +03:00
|
|
|
class SVGFragmentIdentifier;
|
2019-04-16 10:24:49 +03:00
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
nsContainerFrame* NS_NewSVGOuterSVGFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
|
|
|
nsContainerFrame* NS_NewSVGOuterSVGAnonChildFrame(
|
|
|
|
mozilla::PresShell* aPresShell, mozilla::ComputedStyle* aStyle);
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGOuterSVGFrame class
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGOuterSVGFrame final : public SVGDisplayContainerFrame,
|
2020-07-09 21:34:54 +03:00
|
|
|
public ISVGSVGFrame {
|
2020-07-15 13:37:55 +03:00
|
|
|
using imgDrawingParams = image::imgDrawingParams;
|
2017-05-18 23:03:41 +03:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
friend nsContainerFrame* ::NS_NewSVGOuterSVGFrame(
|
2019-04-16 10:24:49 +03:00
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
|
2020-09-21 05:09:57 +03:00
|
|
|
friend class AutoSVGViewHandler;
|
|
|
|
friend class SVGFragmentIdentifier;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-06-15 23:10:28 +04:00
|
|
|
protected:
|
2020-07-09 04:33:33 +03:00
|
|
|
explicit SVGOuterSVGFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
|
2006-06-15 23:10:28 +04:00
|
|
|
|
|
|
|
public:
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2020-07-09 04:33:33 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGOuterSVGFrame)
|
2007-11-20 12:10:18 +03:00
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
#ifdef DEBUG
|
2020-07-09 04:33:33 +03:00
|
|
|
~SVGOuterSVGFrame() {
|
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:
|
2017-06-09 22:14:53 +03:00
|
|
|
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
2007-11-18 15:09:03 +03:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
virtual IntrinsicSize GetIntrinsicSize() override;
|
2020-09-30 01:32:40 +03:00
|
|
|
AspectRatio GetIntrinsicRatio() const override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-01-26 05:47:40 +03:00
|
|
|
SizeComputationResult ComputeSize(
|
|
|
|
gfxContext* aRenderingContext, WritingMode aWritingMode,
|
|
|
|
const LogicalSize& aCBSize, nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin, const LogicalSize& aBorderPadding,
|
|
|
|
const mozilla::StyleSizeOverrides& aSizeOverrides,
|
|
|
|
ComputeSizeFlags aFlags) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
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,
|
2017-12-14 18:21:49 +03:00
|
|
|
const ReflowInput* aReflowInput) override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2020-11-18 03:08:12 +03:00
|
|
|
void UnionChildOverflow(mozilla::OverflowAreas& aOverflowAreas) override;
|
2013-05-24 17:51:50 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
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
|
|
|
|
2018-08-08 01:02:07 +03:00
|
|
|
bool IsFrameOfType(uint32_t aFlags) const override {
|
2020-07-09 04:33:33 +03:00
|
|
|
return SVGDisplayContainerFrame::IsFrameOfType(
|
2019-04-22 20:01:10 +03:00
|
|
|
aFlags &
|
|
|
|
~(eSupportsContainLayoutAndPaint | eReplaced | eReplacedSizing));
|
2018-08-08 01:02:07 +03: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(u"SVGOuterSVG"_ns, aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-21 05:09:57 +03:00
|
|
|
void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
|
|
|
|
|
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* 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.
|
2016-01-29 17:42:14 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
PrincipalChildList().FirstChild() &&
|
2017-04-30 18:30:08 +03:00
|
|
|
PrincipalChildList().FirstChild()->IsSVGOuterSVGAnonChildFrame(),
|
2015-02-10 01:34:50 +03:00
|
|
|
"Where is our anonymous child?");
|
2016-01-29 17:42:14 +03:00
|
|
|
return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
|
2012-07-09 05:04:56 +04:00
|
|
|
}
|
|
|
|
|
2017-03-13 17:05:38 +03:00
|
|
|
bool IsSVGTransformed(Matrix* aOwnTransform,
|
|
|
|
Matrix* aFromParentTransform) const override;
|
2012-05-17 08:05:09 +04:00
|
|
|
|
2017-06-16 12:22:33 +03:00
|
|
|
// Return our anonymous box child.
|
|
|
|
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
|
2017-03-15 21:00:44 +03:00
|
|
|
|
2020-07-09 21:34:54 +03:00
|
|
|
// ISVGSVGFrame interface:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2020-07-09 21:34:54 +03:00
|
|
|
// ISVGDisplayableFrame methods:
|
2017-05-18 23:03:41 +03:00
|
|
|
virtual void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
|
|
|
|
imgDrawingParams& aImgParams,
|
|
|
|
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
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-06-15 23:10:28 +04:00
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
/* Methods to allow descendant SVGForeignObjectFrame frames to register and
|
2020-07-09 04:33:33 +03:00
|
|
|
* unregister themselves with their nearest SVGOuterSVGFrame ancestor. This
|
2012-07-17 21:03:51 +04:00
|
|
|
* 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).
|
|
|
|
*/
|
2020-07-09 04:33:33 +03:00
|
|
|
void RegisterForeignObject(SVGForeignObjectFrame* aFrame);
|
|
|
|
void UnregisterForeignObject(SVGForeignObjectFrame* aFrame);
|
2012-07-17 21:03:51 +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
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2012-08-29 09:39:33 +04:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2020-09-21 05:09:57 +03:00
|
|
|
void MaybeSendIntrinsicSizeAndRatioToEmbedder();
|
|
|
|
void MaybeSendIntrinsicSizeAndRatioToEmbedder(Maybe<IntrinsicSize>,
|
|
|
|
Maybe<AspectRatio>);
|
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
// This is temporary until display list based invalidation is implemented for
|
|
|
|
// SVG.
|
2020-06-25 23:42:49 +03:00
|
|
|
// A hash-set containing our SVGForeignObjectFrame descendants. Note we use
|
2012-07-17 21:03:51 +04:00
|
|
|
// 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).
|
2021-03-24 20:56:46 +03:00
|
|
|
UniquePtr<nsTHashSet<SVGForeignObjectFrame*>> mForeignObjectHash;
|
2012-07-17 21:03:51 +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;
|
2020-09-21 05:09:57 +03:00
|
|
|
bool mIsInObjectOrEmbed;
|
|
|
|
bool mIsInIframe;
|
2006-06-15 23:10:28 +04:00
|
|
|
};
|
|
|
|
|
2012-07-09 05:04:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGOuterSVGAnonChildFrame class
|
2012-07-09 05:04:56 +04:00
|
|
|
|
|
|
|
/**
|
2020-07-09 04:33:33 +03:00
|
|
|
* SVGOuterSVGFrames have a single direct child that is an instance of this
|
2012-07-09 05:04:56 +04:00
|
|
|
* 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
|
2020-07-09 04:33:33 +03:00
|
|
|
* for all SVG frames except for direct children of an SVGOuterSVGFrame,
|
|
|
|
* since an SVGOuterSVGFrame can have CSS border and padding (unlike other
|
2012-07-09 05:04:56 +04:00
|
|
|
* 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
|
2020-07-09 04:33:33 +03:00
|
|
|
* it. Wrapping an SVGOuterSVGFrame's children in an instance of this class
|
|
|
|
* with its GetPosition() set to its SVGOuterSVGFrame's border/padding offset
|
2012-07-09 05:04:56 +04:00
|
|
|
* keeps both nsDisplayTransform and nsIFrame::GetOffsetTo happy.
|
|
|
|
*
|
2020-07-09 04:33:33 +03:00
|
|
|
* The reason that this class inherit from SVGDisplayContainerFrame rather
|
2012-07-09 05:04:56 +04:00
|
|
|
* 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
|
2020-07-09 04:33:33 +03:00
|
|
|
* SVGContainerFrame instances all the way up to the SVGOuterSVGFrame.
|
2012-07-09 05:04:56 +04:00
|
|
|
*/
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGOuterSVGAnonChildFrame final : public SVGDisplayContainerFrame {
|
|
|
|
friend nsContainerFrame* ::NS_NewSVGOuterSVGAnonChildFrame(
|
2019-04-16 10:24:49 +03:00
|
|
|
mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
|
2012-07-09 05:04:56 +04:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
explicit SVGOuterSVGAnonChildFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext)
|
|
|
|
: SVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
|
2012-07-09 05:04:56 +04:00
|
|
|
|
|
|
|
public:
|
2020-07-09 04:33:33 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGOuterSVGAnonChildFrame)
|
2012-07-09 05:04:56 +04:00
|
|
|
|
|
|
|
#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
|
|
|
|
2018-05-23 04:41:32 +03:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) override;
|
|
|
|
|
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(u"SVGOuterSVGAnonChild"_ns, aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-13 17:05:38 +03:00
|
|
|
bool IsSVGTransformed(Matrix* aOwnTransform,
|
2017-03-15 19:59:34 +03:00
|
|
|
Matrix* aFromParentTransform) const override;
|
2017-03-13 17:05:38 +03:00
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGContainerFrame 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
|
2020-07-09 04:33:33 +03:00
|
|
|
// SVGOuterSVGFrame's content box, so we do not include any x/y offset
|
|
|
|
// set on us for any CSS border or padding on our SVGOuterSVGFrame.
|
|
|
|
return static_cast<SVGOuterSVGFrame*>(GetParent())->GetCanvasTM();
|
2012-07-09 05:04:56 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // LAYOUT_SVG_SVGOUTERSVGFRAME_H_
|