2004-06-23 18:14:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxRect.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"
|
2004-06-23 18:14:04 +00:00
|
|
|
#include "nsISVGChildFrame.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
|
|
|
|
2012-03-20 12:15:55 +00:00
|
|
|
class nsFrameList;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIPresShell;
|
2012-03-02 08:28:59 +00:00
|
|
|
class nsRenderingContext;
|
2012-03-20 12:15:55 +00:00
|
|
|
class nsStyleContext;
|
|
|
|
|
|
|
|
struct nsPoint;
|
2012-03-02 08:28:59 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
typedef nsContainerFrame nsSVGContainerFrameBase;
|
2004-06-23 18:14:04 +00:00
|
|
|
|
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
|
|
|
|
* warning comment for nsSVGDisplayContainerFrame below).
|
2012-03-10 19:28:24 +00:00
|
|
|
*/
|
2006-06-01 15:31:15 +00:00
|
|
|
class nsSVGContainerFrame : public nsSVGContainerFrameBase
|
2004-06-23 18:14:04 +00:00
|
|
|
{
|
2006-06-01 15:31:15 +00:00
|
|
|
friend nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2004-06-23 18:14:04 +00:00
|
|
|
protected:
|
2012-05-17 04:05:09 +00:00
|
|
|
nsSVGContainerFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGContainerFrameBase(aContext)
|
|
|
|
{
|
|
|
|
AddStateBits(NS_FRAME_SVG_LAYOUT);
|
|
|
|
}
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSVGContainerFrame)
|
2009-04-29 04:31:34 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
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)
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor) {
|
2012-06-30 11:20:46 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
// nsIFrame:
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
2006-06-01 15:31:15 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2006-06-01 15:31:15 +00:00
|
|
|
nsIFrame* aOldFrame);
|
2006-03-02 20:22:19 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const
|
2007-09-07 09:30:51 +00:00
|
|
|
{
|
2008-10-01 00:51:05 +00:00
|
|
|
return nsSVGContainerFrameBase::IsFrameOfType(
|
|
|
|
aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
|
2007-09-07 09:30:51 +00:00
|
|
|
}
|
2012-05-17 04:05:09 +00:00
|
|
|
|
2012-07-20 16:41:29 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-17 04:05:09 +00:00
|
|
|
virtual bool UpdateOverflow();
|
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,
|
|
|
|
public nsISVGChildFrame
|
|
|
|
{
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2012-05-17 04:05:09 +00:00
|
|
|
nsSVGDisplayContainerFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGContainerFrame(aContext)
|
|
|
|
{
|
|
|
|
AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
|
|
|
|
}
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSVGDisplayContainerFrame)
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2006-06-28 15:23:40 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
// nsIFrame:
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
2006-06-01 15:31:15 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
2007-08-30 17:01:37 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
2004-06-23 18:14:04 +00:00
|
|
|
|
2012-07-20 18:12:29 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2012-09-14 16:10:08 +00:00
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2012-07-20 18:12:29 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform = nullptr,
|
|
|
|
gfxMatrix *aFromParentTransform = nullptr) const;
|
2012-05-17 04:05:09 +00:00
|
|
|
|
2004-06-23 18:14:04 +00:00
|
|
|
// nsISVGChildFrame interface:
|
2012-03-02 08:28:59 +00:00
|
|
|
NS_IMETHOD PaintSVG(nsRenderingContext* aContext,
|
2008-10-20 08:42:03 +00:00
|
|
|
const nsIntRect *aDirtyRect);
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
|
|
|
|
virtual void ReflowSVG() MOZ_OVERRIDE;
|
|
|
|
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
|
2012-04-16 08:23:48 +00:00
|
|
|
virtual SVGBBox GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
|
2012-09-14 16:10:08 +00:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE { return true; }
|
2004-06-23 18:14:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|