2017-10-27 17:33:53 +00: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 11:12:37 +00: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/. */
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
#ifndef NS_SVGCONTAINERFRAME_H
|
|
|
|
#define NS_SVGCONTAINERFRAME_H
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2004-06-23 18:14:04 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsIFrame.h"
|
2017-02-09 18:24:31 +00:00
|
|
|
#include "nsSVGDisplayableFrame.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsQueryFrame.h"
|
|
|
|
#include "nsRect.h"
|
2012-05-28 01:30:54 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2014-10-31 20:08:54 +00:00
|
|
|
class gfxContext;
|
2012-03-20 12:15:55 +00:00
|
|
|
class nsFrameList;
|
|
|
|
class nsIContent;
|
|
|
|
|
2013-09-07 02:15:49 +00:00
|
|
|
struct nsRect;
|
2012-03-02 08:28:59 +00:00
|
|
|
|
2019-04-16 07:24:49 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-03-10 19:28:24 +00:00
|
|
|
/**
|
|
|
|
* Base class for SVG container frames. Frame sub-classes that do not
|
|
|
|
* display their contents directly (such as the frames for <marker> or
|
|
|
|
* <pattern>) just inherit this class. Frame sub-classes that do or can
|
|
|
|
* display their contents directly (such as the frames for inner-<svg> or
|
|
|
|
* <g>) inherit our nsDisplayContainerFrame sub-class.
|
2012-11-22 16:23:57 +00:00
|
|
|
*
|
|
|
|
* *** WARNING ***
|
|
|
|
*
|
|
|
|
* Do *not* blindly cast to SVG element types in this class's methods (see the
|
2017-07-06 12:00:35 +00:00
|
|
|
* warning comment for nsSVGDisplayContainerFrame below).
|
2012-03-10 19:28:24 +00:00
|
|
|
*/
|
2016-04-18 06:56:50 +00:00
|
|
|
class nsSVGContainerFrame : public nsContainerFrame {
|
2019-04-16 07:24:49 +00:00
|
|
|
friend nsIFrame* NS_NewSVGContainerFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aStyle);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2004-06-23 18:14:04 +00:00
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
nsSVGContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
|
|
|
ClassID aID)
|
|
|
|
: nsContainerFrame(aStyle, aPresContext, aID) {
|
2012-05-17 04:05:09 +00:00
|
|
|
AddStateBits(NS_FRAME_SVG_LAYOUT);
|
|
|
|
}
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-04-29 04:31:34 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGContainerFrame)
|
2009-04-29 04:31:34 +00:00
|
|
|
|
2007-12-04 04:40:52 +00:00
|
|
|
// Returns the transform to our gfxContext (to device pixels, not CSS px)
|
2014-09-08 11:28:50 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM() { return gfxMatrix(); }
|
2007-09-07 09:30:51 +00:00
|
|
|
|
2012-05-17 04:05:09 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the frame's content has a transform that applies only to
|
|
|
|
* its children, and not to the frame itself. For example, an implicit
|
|
|
|
* transform introduced by a 'viewBox' attribute, or an explicit transform
|
|
|
|
* due to a root-<svg> having its currentScale/currentTransform properties
|
|
|
|
* set. If aTransform is non-null, then it will be set to the transform.
|
|
|
|
*/
|
2013-12-30 06:50:17 +00:00
|
|
|
virtual bool HasChildrenOnlyTransform(Matrix* aTransform) const {
|
2012-05-17 04:05:09 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
// nsIFrame:
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2018-08-07 22:02:07 +00:00
|
|
|
if (aFlags & eSupportsContainLayoutAndPaint) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-18 06:56:50 +00:00
|
|
|
return nsContainerFrame::IsFrameOfType(
|
2008-10-01 00:51:05 +00:00
|
|
|
aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
|
2007-09-07 09:30:51 +00:00
|
|
|
}
|
2012-05-17 04:05:09 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override {}
|
2012-07-20 16:41:29 +00:00
|
|
|
|
2016-05-04 00:27:43 +00:00
|
|
|
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override;
|
2013-07-29 23:47:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
2013-12-20 16:38:51 +00:00
|
|
|
* Traverses a frame tree, marking any SVGTextFrame frames as dirty
|
2013-07-29 23:47:30 +00:00
|
|
|
* and calling InvalidateRenderingObservers() on it.
|
|
|
|
*/
|
|
|
|
static void ReflowSVGNonDisplayText(nsIFrame* aContainer);
|
2006-06-01 15:31:15 +00:00
|
|
|
};
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2012-03-10 19:28:24 +00:00
|
|
|
/**
|
|
|
|
* Frame class or base-class for SVG containers that can or do display their
|
|
|
|
* contents directly.
|
2012-11-22 16:23:57 +00:00
|
|
|
*
|
|
|
|
* *** WARNING ***
|
|
|
|
*
|
|
|
|
* This class's methods can *not* assume that mContent points to an instance of
|
|
|
|
* an SVG element class since this class is inherited by
|
|
|
|
* nsSVGGenericContainerFrame which is used for unrecognized elements in the
|
|
|
|
* SVG namespace. Do *not* blindly cast to SVG element types.
|
2012-03-10 19:28:24 +00:00
|
|
|
*/
|
2006-06-01 15:31:15 +00:00
|
|
|
class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,
|
2017-02-09 18:24:31 +00:00
|
|
|
public nsSVGDisplayableFrame {
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
nsSVGDisplayContainerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
|
|
|
nsIFrame::ClassID aID)
|
|
|
|
: nsSVGContainerFrame(aStyle, aPresContext, aID) {
|
2012-05-17 04:05:09 +00:00
|
|
|
AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
|
|
|
|
}
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
|
|
|
|
NS_DECL_ABSTRACT_FRAME(nsSVGDisplayContainerFrame)
|
2006-06-28 15:23:40 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
// nsIFrame:
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2012-07-20 18:12:29 +00:00
|
|
|
|
2013-12-30 06:50:17 +00:00
|
|
|
virtual bool IsSVGTransformed(
|
|
|
|
Matrix* aOwnTransform = nullptr,
|
2015-03-21 16:28:04 +00:00
|
|
|
Matrix* aFromParentTransform = nullptr) const override;
|
2012-05-17 04:05:09 +00:00
|
|
|
|
2017-02-09 18:24:31 +00:00
|
|
|
// nsSVGDisplayableFrame interface:
|
2017-05-18 20:03:41 +00:00
|
|
|
virtual void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
|
|
|
|
imgDrawingParams& aImgParams,
|
|
|
|
const nsIntRect* aDirtyRect = nullptr) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override;
|
|
|
|
virtual void ReflowSVG() override;
|
|
|
|
virtual void NotifySVGChanged(uint32_t aFlags) override;
|
2013-12-30 06:50:17 +00:00
|
|
|
virtual SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
|
|
|
virtual bool IsDisplayContainer() override { return true; }
|
2017-09-05 09:26:46 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Cached canvasTM value.
|
|
|
|
*/
|
|
|
|
nsAutoPtr<gfxMatrix> mCanvasTM;
|
2004-06-23 18:14:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|