2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef NS_SVGCONTAINERFRAME_H
|
|
|
|
#define NS_SVGCONTAINERFRAME_H
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsContainerFrame.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsIFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsISVGChildFrame.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsQueryFrame.h"
|
|
|
|
#include "nsRect.h"
|
2012-05-27 18:30:54 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-20 05:15:55 -07:00
|
|
|
class nsFrameList;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIPresShell;
|
2012-03-02 00:28:59 -08:00
|
|
|
class nsRenderingContext;
|
2012-03-20 05:15:55 -07:00
|
|
|
class nsStyleContext;
|
|
|
|
|
|
|
|
struct nsPoint;
|
2013-09-06 19:15:49 -07:00
|
|
|
struct nsRect;
|
|
|
|
struct nsIntRect;
|
2012-03-02 00:28:59 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsContainerFrame nsSVGContainerFrameBase;
|
|
|
|
|
2012-03-10 11:28:24 -08: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 08:23:57 -08:00
|
|
|
*
|
|
|
|
* *** WARNING ***
|
|
|
|
*
|
|
|
|
* Do *not* blindly cast to SVG element types in this class's methods (see the
|
|
|
|
* warning comment for nsSVGDisplayContainerFrame below).
|
2012-03-10 11:28:24 -08:00
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsSVGContainerFrame : public nsSVGContainerFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
|
|
|
protected:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsSVGContainerFrame(nsStyleContext* aContext)
|
2012-05-16 21:05:09 -07:00
|
|
|
: nsSVGContainerFrameBase(aContext)
|
|
|
|
{
|
|
|
|
AddStateBits(NS_FRAME_SVG_LAYOUT);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-07 02:30:51 -07:00
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSVGContainerFrame)
|
2009-04-28 21:31:34 -07:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2009-04-28 21:31:34 -07:00
|
|
|
|
2007-12-03 20:40:52 -08:00
|
|
|
// Returns the transform to our gfxContext (to device pixels, not CSS px)
|
2014-09-08 04:28:50 -07:00
|
|
|
virtual gfxMatrix GetCanvasTM() {
|
2012-06-30 04:20:46 -07:00
|
|
|
return gfxMatrix();
|
|
|
|
}
|
2007-09-07 02:30:51 -07:00
|
|
|
|
2012-05-16 21:05:09 -07: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-29 22:50:17 -08:00
|
|
|
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const {
|
2012-05-16 21:05:09 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIFrame:
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
2014-05-28 12:36:58 -07:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
2014-05-28 12:36:58 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
2014-05-28 12:36:58 -07:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-01 08:01:49 -08:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-09-07 02:30:51 -07:00
|
|
|
{
|
2008-09-30 17:51:05 -07:00
|
|
|
return nsSVGContainerFrameBase::IsFrameOfType(
|
|
|
|
aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
|
2007-09-07 02:30:51 -07:00
|
|
|
}
|
2012-05-16 21:05:09 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
|
2012-07-20 09:41:29 -07:00
|
|
|
|
2013-02-01 08:01:49 -08:00
|
|
|
virtual bool UpdateOverflow() MOZ_OVERRIDE;
|
2013-07-29 16:47:30 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
2013-12-20 08:38:51 -08:00
|
|
|
* Traverses a frame tree, marking any SVGTextFrame frames as dirty
|
2013-07-29 16:47:30 -07:00
|
|
|
* and calling InvalidateRenderingObservers() on it.
|
|
|
|
*/
|
|
|
|
static void ReflowSVGNonDisplayText(nsIFrame* aContainer);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-03-10 11:28:24 -08:00
|
|
|
/**
|
|
|
|
* Frame class or base-class for SVG containers that can or do display their
|
|
|
|
* contents directly.
|
2012-11-22 08:23:57 -08: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 11:28:24 -08:00
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsSVGDisplayContainerFrame : public nsSVGContainerFrame,
|
|
|
|
public nsISVGChildFrame
|
|
|
|
{
|
2007-09-07 02:30:51 -07:00
|
|
|
protected:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsSVGDisplayContainerFrame(nsStyleContext* aContext)
|
2012-05-16 21:05:09 -07:00
|
|
|
: nsSVGContainerFrame(aContext)
|
|
|
|
{
|
|
|
|
AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-07 02:30:51 -07:00
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIFrame:
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2014-05-28 12:36:58 -07:00
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2012-07-20 11:12:29 -07:00
|
|
|
|
2013-12-29 22:50:17 -08:00
|
|
|
virtual bool IsSVGTransformed(Matrix *aOwnTransform = nullptr,
|
|
|
|
Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
|
2012-05-16 21:05:09 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsISVGChildFrame interface:
|
2014-02-19 14:34:31 -08:00
|
|
|
virtual nsresult PaintSVG(nsRenderingContext* aContext,
|
2014-08-29 12:42:07 -07:00
|
|
|
const gfxMatrix& aTransform,
|
|
|
|
const nsIntRect *aDirtyRect = nullptr) MOZ_OVERRIDE;
|
2014-08-07 00:09:31 -07:00
|
|
|
virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) MOZ_OVERRIDE;
|
2014-02-19 14:34:31 -08:00
|
|
|
virtual nsRect GetCoveredRegion() MOZ_OVERRIDE;
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void ReflowSVG() MOZ_OVERRIDE;
|
|
|
|
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
|
2013-12-29 22:50:17 -08:00
|
|
|
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
|
2012-09-14 09:10:08 -07:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2014-02-19 14:34:31 -08:00
|
|
|
virtual bool IsDisplayContainer() MOZ_OVERRIDE { return true; }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|