Issue #2737 - Part 1: Base implementation of SVGGeometryElement.

Mostly mechanical changes to generalize path geometry for all SVG draw
elements. No user-exposed changes.
This commit is contained in:
Moonchild 2025-04-27 18:03:48 +02:00 committed by roytam1
commit fd4a224d1d
45 changed files with 368 additions and 319 deletions

View file

@ -134,7 +134,7 @@ NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell, nsStyleContext* aConte
nsIFrame*
NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
NS_NewSVGGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
@ -5482,13 +5482,13 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
SIMPLE_SVG_CREATE(svg, NS_NewSVGInnerSVGFrame),
SIMPLE_SVG_CREATE(g, NS_NewSVGGFrame),
SIMPLE_SVG_CREATE(svgSwitch, NS_NewSVGSwitchFrame),
SIMPLE_SVG_CREATE(polygon, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(polyline, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(circle, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(ellipse, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(line, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(rect, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(path, NS_NewSVGPathGeometryFrame),
SIMPLE_SVG_CREATE(polygon, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(polyline, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(circle, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(ellipse, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(line, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(rect, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(path, NS_NewSVGGeometryFrame),
SIMPLE_SVG_CREATE(defs, NS_NewSVGContainerFrame),
SIMPLE_SVG_CREATE(generic_, NS_NewSVGGenericContainerFrame),
{ &nsGkAtoms::foreignObject,

View file

@ -52,7 +52,7 @@ DECLARE_DISPLAY_ITEM_TYPE(SUBDOCUMENT)
DECLARE_DISPLAY_ITEM_TYPE(MASK)
DECLARE_DISPLAY_ITEM_TYPE(FILTER)
DECLARE_DISPLAY_ITEM_TYPE(SVG_OUTER_SVG)
DECLARE_DISPLAY_ITEM_TYPE(SVG_PATH_GEOMETRY)
DECLARE_DISPLAY_ITEM_TYPE(SVG_GEOMETRY)
DECLARE_DISPLAY_ITEM_TYPE(SVG_TEXT)
DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_BACKGROUND)
DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_SELECTION)

View file

@ -153,7 +153,7 @@ FRAME_ID(nsSVGMaskFrame)
FRAME_ID(nsSVGOuterSVGFrame)
FRAME_ID(nsSVGOuterSVGAnonChildFrame)
FRAME_ID(nsSVGPaintServerFrame)
FRAME_ID(nsSVGPathGeometryFrame)
FRAME_ID(SVGGeometryFrame)
FRAME_ID(nsSVGPatternFrame)
FRAME_ID(nsSVGRadialGradientFrame)
FRAME_ID(nsSVGStopFrame)

View file

@ -929,7 +929,7 @@ nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
if (!DefinitelyEqualURIs(mMarkerEnd, aNewData.mMarkerEnd) ||
!DefinitelyEqualURIs(mMarkerMid, aNewData.mMarkerMid) ||
!DefinitelyEqualURIs(mMarkerStart, aNewData.mMarkerStart)) {
// Markers currently contribute to nsSVGPathGeometryFrame::mRect,
// Markers currently contribute to SVGGeometryFrame::mRect,
// so we need a reflow as well as a repaint. No intrinsic sizes need
// to change, so nsChangeHint_NeedReflow is sufficient.
return nsChangeHint_UpdateEffects |
@ -950,7 +950,7 @@ nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
// stroke (in which case whether we have fill or not is significant to frame
// bounds) and whether we have fill or not just changed. In either case we
// need to reflow so the frame rect is updated.
// XXXperf this is a waste on non nsSVGPathGeometryFrames.
// XXXperf this is a waste on non SVGGeometryFrames.
hint |= nsChangeHint_NeedReflow |
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
}
@ -960,10 +960,10 @@ nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
}
}
// Stroke currently contributes to nsSVGPathGeometryFrame::mRect, so
// Stroke currently contributes to SVGGeometryFrame::mRect, so
// we need a reflow here. No intrinsic sizes need to change, so
// nsChangeHint_NeedReflow is sufficient.
// Note that stroke-dashoffset does not affect nsSVGPathGeometryFrame::mRect.
// Note that stroke-dashoffset does not affect SVGGeometryFrame::mRect.
// text-anchor changes also require a reflow since it changes frames' rects.
if (mStrokeWidth != aNewData.mStrokeWidth ||
mStrokeMiterlimit != aNewData.mStrokeMiterlimit ||
@ -1189,9 +1189,9 @@ nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aNewData) const
// XXXjwatt: why NS_STYLE_HINT_REFLOW? Isn't that excessive?
hint |= NS_STYLE_HINT_REFLOW;
} else if (mVectorEffect != aNewData.mVectorEffect) {
// Stroke currently affects nsSVGPathGeometryFrame::mRect, and
// Stroke currently affects SVGGeometryFrame::mRect, and
// vector-effect affect stroke. As a result we need to reflow if
// vector-effect changes in order to have nsSVGPathGeometryFrame::
// vector-effect changes in order to have SVGGeometryFrame::
// ReflowSVG called to update its mRect. No intrinsic sizes need
// to change so nsChangeHint_NeedReflow is sufficient.
hint |= nsChangeHint_NeedReflow |
@ -3962,8 +3962,8 @@ nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
}
if (mPointerEvents != aNewData.mPointerEvents) {
// nsSVGPathGeometryFrame's mRect depends on stroke _and_ on the value
// of pointer-events. See nsSVGPathGeometryFrame::ReflowSVG's use of
// SVGGeometryFrame's mRect depends on stroke _and_ on the value
// of pointer-events. See SVGGeometryFrame::ReflowSVG's use of
// GetHitTestFlags. (Only a reflow, no visual change.)
hint |= nsChangeHint_NeedReflow |
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085

View file

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Main header first:
#include "nsSVGPathGeometryFrame.h"
#include "SVGGeometryFrame.h"
// Keep others in (case-insensitive) order:
#include "gfx2DGlue.h"
@ -22,7 +22,7 @@
#include "nsSVGEffects.h"
#include "nsSVGIntegrationUtils.h"
#include "nsSVGMarkerFrame.h"
#include "nsSVGPathGeometryElement.h"
#include "SVGGeometryElement.h"
#include "nsSVGUtils.h"
#include "mozilla/ArrayUtils.h"
#include "SVGAnimatedTransformList.h"
@ -37,41 +37,41 @@ using namespace mozilla::image;
// Implementation
nsIFrame*
NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext)
NS_NewSVGGeometryFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext)
{
return new (aPresShell) nsSVGPathGeometryFrame(aContext);
return new (aPresShell) SVGGeometryFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsSVGPathGeometryFrame)
NS_IMPL_FRAMEARENA_HELPERS(SVGGeometryFrame)
//----------------------------------------------------------------------
// nsQueryFrame methods
NS_QUERYFRAME_HEAD(nsSVGPathGeometryFrame)
NS_QUERYFRAME_HEAD(SVGGeometryFrame)
NS_QUERYFRAME_ENTRY(nsISVGChildFrame)
NS_QUERYFRAME_ENTRY(nsSVGPathGeometryFrame)
NS_QUERYFRAME_ENTRY(SVGGeometryFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsFrame)
//----------------------------------------------------------------------
// Display list item:
class nsDisplaySVGPathGeometry : public nsDisplayItem {
class nsDisplaySVGGeometry : public nsDisplayItem {
public:
nsDisplaySVGPathGeometry(nsDisplayListBuilder* aBuilder,
nsSVGPathGeometryFrame* aFrame)
nsDisplaySVGGeometry(nsDisplayListBuilder* aBuilder,
SVGGeometryFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame)
{
MOZ_COUNT_CTOR(nsDisplaySVGPathGeometry);
MOZ_COUNT_CTOR(nsDisplaySVGGeometry);
MOZ_ASSERT(aFrame, "Must have a frame!");
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplaySVGPathGeometry() {
MOZ_COUNT_DTOR(nsDisplaySVGPathGeometry);
virtual ~nsDisplaySVGGeometry() {
MOZ_COUNT_DTOR(nsDisplaySVGGeometry);
}
#endif
NS_DISPLAY_DECL_NAME("nsDisplaySVGPathGeometry", TYPE_SVG_PATH_GEOMETRY)
NS_DISPLAY_DECL_NAME("nsDisplaySVGGeometry", TYPE_SVG_GEOMETRY)
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) override;
@ -89,10 +89,10 @@ public:
};
void
nsDisplaySVGPathGeometry::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
nsDisplaySVGGeometry::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
{
nsSVGPathGeometryFrame *frame = static_cast<nsSVGPathGeometryFrame*>(mFrame);
SVGGeometryFrame *frame = static_cast<SVGGeometryFrame*>(mFrame);
nsPoint pointRelativeToReferenceFrame = aRect.Center();
// ToReferenceFrame() includes frame->GetPosition(), our user space position.
nsPoint userSpacePtInAppUnits = pointRelativeToReferenceFrame -
@ -106,8 +106,8 @@ nsDisplaySVGPathGeometry::HitTest(nsDisplayListBuilder* aBuilder, const nsRect&
}
void
nsDisplaySVGPathGeometry::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
nsDisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
uint32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
@ -122,13 +122,13 @@ nsDisplaySVGPathGeometry::Paint(nsDisplayListBuilder* aBuilder,
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) *
gfxMatrix::Translation(devPixelOffset);
DrawResult result =
static_cast<nsSVGPathGeometryFrame*>(mFrame)->PaintSVG(*aCtx->ThebesContext(), tm);
static_cast<SVGGeometryFrame*>(mFrame)->PaintSVG(*aCtx->ThebesContext(), tm);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
void
nsDisplaySVGPathGeometry::ComputeInvalidationRegion(
nsDisplaySVGGeometry::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion)
@ -145,22 +145,24 @@ nsDisplaySVGPathGeometry::ComputeInvalidationRegion(
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
namespace mozilla {
//----------------------------------------------------------------------
// nsIFrame methods
void
nsSVGPathGeometryFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow)
SVGGeometryFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow)
{
AddStateBits(aParent->GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD);
nsFrame::Init(aContent, aParent, aPrevInFlow);
}
nsresult
nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
SVGGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
{
// We don't invalidate for transform changes (the layers code does that).
// Also note that SVGTransformableElement::GetAttributeChangeHint will
@ -168,7 +170,7 @@ nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
// and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
if (aNameSpaceID == kNameSpaceID_None &&
(static_cast<nsSVGPathGeometryElement*>
(static_cast<SVGGeometryElement*>
(mContent)->AttributeDefinesGeometry(aAttribute))) {
nsLayoutUtils::PostRestyleEvent(
mContent->AsElement(), nsRestyleHint(0),
@ -179,7 +181,7 @@ nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
}
/* virtual */ void
nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
SVGGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
{
nsFrame::DidSetStyleContext(aOldStyleContext);
@ -193,8 +195,8 @@ nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
InvalidateFrame();
}
nsSVGPathGeometryElement* element =
static_cast<nsSVGPathGeometryElement*>(mContent);
SVGGeometryElement* element =
static_cast<SVGGeometryElement*>(mContent);
auto oldStyleSVG = aOldStyleContext->PeekStyleSVG();
if (oldStyleSVG && !SVGContentUtils::ShapeTypeHasNoCorners(mContent)) {
@ -222,14 +224,14 @@ nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
}
nsIAtom *
nsSVGPathGeometryFrame::GetType() const
SVGGeometryFrame::GetType() const
{
return nsGkAtoms::svgPathGeometryFrame;
return nsGkAtoms::svgGeometryFrame;
}
bool
nsSVGPathGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
gfx::Matrix *aFromParentTransform) const
SVGGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
gfx::Matrix *aFromParentTransform) const
{
bool foundTransform = false;
@ -258,8 +260,8 @@ nsSVGPathGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
}
void
nsSVGPathGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
SVGGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
{
if (!static_cast<const nsSVGElement*>(mContent)->HasValidDimensions() ||
(!IsVisibleForPainting(aBuilder) && aBuilder->IsForPainting())) {
@ -267,16 +269,16 @@ nsSVGPathGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
DisplayOutline(aBuilder, aLists);
aLists.Content()->AppendNewToTop(
new (aBuilder) nsDisplaySVGPathGeometry(aBuilder, this));
new (aBuilder) nsDisplaySVGGeometry(aBuilder, this));
}
//----------------------------------------------------------------------
// nsISVGChildFrame methods
DrawResult
nsSVGPathGeometryFrame::PaintSVG(gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect* aDirtyRect)
SVGGeometryFrame::PaintSVG(gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect* aDirtyRect)
{
if (!StyleVisibility()->IsVisible())
return DrawResult::SUCCESS;
@ -322,7 +324,7 @@ nsSVGPathGeometryFrame::PaintSVG(gfxContext& aContext,
}
nsIFrame*
nsSVGPathGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint)
SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint)
{
FillRule fillRule;
uint16_t hitTestFlags;
@ -346,8 +348,8 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint)
bool isHit = false;
nsSVGPathGeometryElement* content =
static_cast<nsSVGPathGeometryElement*>(mContent);
SVGGeometryElement* content =
static_cast<SVGGeometryElement*>(mContent);
// Using ScreenReferenceDrawTarget() opens us to Moz2D backend specific hit-
// testing bugs. Maybe we should use a BackendType::CAIRO DT for hit-testing
@ -387,7 +389,7 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint)
}
nsRect
nsSVGPathGeometryFrame::GetCoveredRegion()
SVGGeometryFrame::GetCoveredRegion()
{
gfxMatrix canvasTM = GetCanvasTM();
if (canvasTM.PreservesAxisAlignedRectangles()) {
@ -409,7 +411,7 @@ nsSVGPathGeometryFrame::GetCoveredRegion()
}
void
nsSVGPathGeometryFrame::ReflowSVG()
SVGGeometryFrame::ReflowSVG()
{
NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this),
"This call is probably a wasteful mistake");
@ -463,7 +465,7 @@ nsSVGPathGeometryFrame::ReflowSVG()
}
void
nsSVGPathGeometryFrame::NotifySVGChanged(uint32_t aFlags)
SVGGeometryFrame::NotifySVGChanged(uint32_t aFlags)
{
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
"Invalidation logic may need adjusting");
@ -487,9 +489,9 @@ nsSVGPathGeometryFrame::NotifySVGChanged(uint32_t aFlags)
// of stroke-dashoffset since, although that can have a percentage value
// that is resolved against our coordinate context, it does not affect our
// mRect.
if (static_cast<nsSVGPathGeometryElement*>(mContent)->GeometryDependsOnCoordCtx() ||
if (static_cast<SVGGeometryElement*>(mContent)->GeometryDependsOnCoordCtx() ||
StyleSVG()->mStrokeWidth.HasPercent()) {
static_cast<nsSVGPathGeometryElement*>(mContent)->ClearAnyCachedPath();
static_cast<SVGGeometryElement*>(mContent)->ClearAnyCachedPath();
nsSVGUtils::ScheduleReflowSVG(this);
}
}
@ -502,8 +504,8 @@ nsSVGPathGeometryFrame::NotifySVGChanged(uint32_t aFlags)
}
SVGBBox
nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags)
SVGGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags)
{
SVGBBox bbox;
@ -512,8 +514,8 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
return bbox;
}
nsSVGPathGeometryElement* element =
static_cast<nsSVGPathGeometryElement*>(mContent);
SVGGeometryElement* element =
static_cast<SVGGeometryElement*>(mContent);
bool getFill = (aFlags & nsSVGUtils::eBBoxIncludeFillGeometry) ||
((aFlags & nsSVGUtils::eBBoxIncludeFill) &&
@ -629,7 +631,7 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
//
// Second, the way we account for non-scaling-stroke by transforming the
// path using the transform to the outer-<svg> element is not compatible
// with the way that nsSVGPathGeometryFrame::Reflow() inserts a scale
// with the way that SVGGeometryFrame::Reflow() inserts a scale
// into aToBBoxUserspace and then scales the bounds that we return.
SVGContentUtils::AutoStrokeOptions strokeOptions;
SVGContentUtils::GetStrokeOptions(&strokeOptions, element,
@ -666,14 +668,14 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
// Account for markers:
if ((aFlags & nsSVGUtils::eBBoxIncludeMarkers) != 0 &&
static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
static_cast<SVGGeometryElement*>(mContent)->IsMarkable()) {
float strokeWidth = nsSVGUtils::GetStrokeWidth(this);
MarkerProperties properties = GetMarkerProperties(this);
if (properties.MarkersExist()) {
nsTArray<nsSVGMark> marks;
static_cast<nsSVGPathGeometryElement*>(mContent)->GetMarkPoints(&marks);
static_cast<SVGGeometryElement*>(mContent)->GetMarkPoints(&marks);
uint32_t num = marks.Length();
// These are in the same order as the nsSVGMark::Type constants.
@ -703,10 +705,10 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
}
//----------------------------------------------------------------------
// nsSVGPathGeometryFrame methods:
// SVGGeometryFrame methods:
gfxMatrix
nsSVGPathGeometryFrame::GetCanvasTM()
SVGGeometryFrame::GetCanvasTM()
{
NS_ASSERTION(GetParent(), "null parent");
@ -716,8 +718,8 @@ nsSVGPathGeometryFrame::GetCanvasTM()
return content->PrependLocalTransformsTo(parent->GetCanvasTM());
}
nsSVGPathGeometryFrame::MarkerProperties
nsSVGPathGeometryFrame::GetMarkerProperties(nsSVGPathGeometryFrame *aFrame)
SVGGeometryFrame::MarkerProperties
SVGGeometryFrame::GetMarkerProperties(SVGGeometryFrame *aFrame)
{
NS_ASSERTION(!aFrame->GetPrevContinuation(), "aFrame should be first continuation");
@ -741,7 +743,7 @@ nsSVGPathGeometryFrame::GetMarkerProperties(nsSVGPathGeometryFrame *aFrame)
}
nsSVGMarkerFrame *
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerStartFrame()
SVGGeometryFrame::MarkerProperties::GetMarkerStartFrame()
{
if (!mMarkerStart)
return nullptr;
@ -750,7 +752,7 @@ nsSVGPathGeometryFrame::MarkerProperties::GetMarkerStartFrame()
}
nsSVGMarkerFrame *
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerMidFrame()
SVGGeometryFrame::MarkerProperties::GetMarkerMidFrame()
{
if (!mMarkerMid)
return nullptr;
@ -759,7 +761,7 @@ nsSVGPathGeometryFrame::MarkerProperties::GetMarkerMidFrame()
}
nsSVGMarkerFrame *
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerEndFrame()
SVGGeometryFrame::MarkerProperties::GetMarkerEndFrame()
{
if (!mMarkerEnd)
return nullptr;
@ -768,9 +770,9 @@ nsSVGPathGeometryFrame::MarkerProperties::GetMarkerEndFrame()
}
void
nsSVGPathGeometryFrame::Render(gfxContext* aContext,
uint32_t aRenderComponents,
const gfxMatrix& aNewTransform)
SVGGeometryFrame::Render(gfxContext* aContext,
uint32_t aRenderComponents,
const gfxMatrix& aNewTransform)
{
MOZ_ASSERT(!aNewTransform.IsSingular());
@ -780,8 +782,8 @@ nsSVGPathGeometryFrame::Render(gfxContext* aContext,
nsSVGUtils::ToFillRule((GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) ?
StyleSVG()->mClipRule : StyleSVG()->mFillRule);
nsSVGPathGeometryElement* element =
static_cast<nsSVGPathGeometryElement*>(mContent);
SVGGeometryElement* element =
static_cast<SVGGeometryElement*>(mContent);
AntialiasMode aaMode =
(StyleSVG()->mShapeRendering == NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED ||
@ -806,7 +808,7 @@ nsSVGPathGeometryFrame::Render(gfxContext* aContext,
return;
}
nsSVGPathGeometryElement::SimplePath simplePath;
SVGGeometryElement::SimplePath simplePath;
RefPtr<Path> path;
element->GetAsSimplePath(&simplePath);
@ -882,19 +884,19 @@ nsSVGPathGeometryFrame::Render(gfxContext* aContext,
}
void
nsSVGPathGeometryFrame::PaintMarkers(gfxContext& aContext,
const gfxMatrix& aTransform)
SVGGeometryFrame::PaintMarkers(gfxContext& aContext,
const gfxMatrix& aTransform)
{
SVGContextPaint* contextPaint = SVGContextPaint::GetContextPaint(mContent);
if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
if (static_cast<SVGGeometryElement*>(mContent)->IsMarkable()) {
MarkerProperties properties = GetMarkerProperties(this);
if (properties.MarkersExist()) {
float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint);
nsTArray<nsSVGMark> marks;
static_cast<nsSVGPathGeometryElement*>
static_cast<SVGGeometryElement*>
(mContent)->GetMarkPoints(&marks);
uint32_t num = marks.Length();
@ -921,7 +923,8 @@ nsSVGPathGeometryFrame::PaintMarkers(gfxContext& aContext,
}
uint16_t
nsSVGPathGeometryFrame::GetHitTestFlags()
SVGGeometryFrame::GetHitTestFlags()
{
return nsSVGUtils::GetGeometryHitTestFlags(this);
}
} // namespace mozilla

View file

@ -3,8 +3,8 @@
* 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/. */
#ifndef __NS_SVGPATHGEOMETRYFRAME_H__
#define __NS_SVGPATHGEOMETRYFRAME_H__
#ifndef __SVGGEOMETRYFRAME_H__
#define __SVGGEOMETRYFRAME_H__
#include "mozilla/Attributes.h"
#include "gfxMatrix.h"
@ -16,13 +16,14 @@
#include "nsSVGUtils.h"
namespace mozilla {
class SVGGeometryFrame;
namespace gfx {
class DrawTarget;
} // namespace gfx
} // namespace mozilla
class gfxContext;
class nsDisplaySVGPathGeometry;
class nsDisplaySVGGeometry;
class nsIAtom;
class nsIFrame;
class nsIPresShell;
@ -32,25 +33,30 @@ class nsSVGMarkerProperty;
struct nsRect;
class nsSVGPathGeometryFrame : public nsFrame
, public nsISVGChildFrame
nsIFrame*
NS_NewSVGGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
namespace mozilla {
class SVGGeometryFrame : public nsFrame
, public nsISVGChildFrame
{
typedef mozilla::gfx::DrawTarget DrawTarget;
friend nsIFrame*
NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
::NS_NewSVGGeometryFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
friend class nsDisplaySVGPathGeometry;
friend class ::nsDisplaySVGGeometry;
protected:
explicit nsSVGPathGeometryFrame(nsStyleContext* aContext)
explicit SVGGeometryFrame(nsStyleContext* aContext)
: nsFrame(aContext)
{
AddStateBits(NS_FRAME_SVG_LAYOUT | NS_FRAME_MAY_BE_TRANSFORMED);
}
public:
NS_DECL_QUERYFRAME_TARGET(nsSVGPathGeometryFrame)
NS_DECL_QUERYFRAME_TARGET(SVGGeometryFrame)
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
@ -73,7 +79,7 @@ public:
/**
* Get the "type" of the frame
*
* @see nsGkAtoms::svgPathGeometryFrame
* @see nsGkAtoms::svgGeometryFrame
*/
virtual nsIAtom* GetType() const override;
@ -83,14 +89,14 @@ public:
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override
{
return MakeFrameName(NS_LITERAL_STRING("SVGPathGeometry"), aResult);
return MakeFrameName(NS_LITERAL_STRING("SVGGeometry"), aResult);
}
#endif
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) override;
// nsSVGPathGeometryFrame methods
// SVGGeometryFrame methods
gfxMatrix GetCanvasTM();
protected:
// nsISVGChildFrame interface:
@ -140,7 +146,8 @@ private:
/**
* @param aFrame should be the first continuation
*/
static MarkerProperties GetMarkerProperties(nsSVGPathGeometryFrame *aFrame);
static MarkerProperties GetMarkerProperties(SVGGeometryFrame *aFrame);
};
} // namespace mozilla
#endif // __NS_SVGPATHGEOMETRYFRAME_H__
#endif // __SVGGEOMETRYFRAME_H__

View file

@ -40,7 +40,6 @@ UNIFIED_SOURCES += [
'nsSVGMarkerFrame.cpp',
'nsSVGMaskFrame.cpp',
'nsSVGOuterSVGFrame.cpp',
'nsSVGPathGeometryFrame.cpp',
'nsSVGPatternFrame.cpp',
'nsSVGStopFrame.cpp',
'nsSVGSwitchFrame.cpp',
@ -51,6 +50,7 @@ UNIFIED_SOURCES += [
'SVGFEImageFrame.cpp',
'SVGFELeafFrame.cpp',
'SVGFEUnstyledLeafFrame.cpp',
'SVGGeometryFrame.cpp',
'SVGTextFrame.cpp',
'SVGViewFrame.cpp',
]

View file

@ -11,8 +11,8 @@
#include "mozilla/dom/SVGClipPathElement.h"
#include "nsGkAtoms.h"
#include "nsSVGEffects.h"
#include "nsSVGPathGeometryElement.h"
#include "nsSVGPathGeometryFrame.h"
#include "SVGGeometryElement.h"
#include "SVGGeometryFrame.h"
#include "nsSVGUtils.h"
using namespace mozilla;
@ -54,10 +54,10 @@ nsSVGClipPathFrame::ApplyClipPath(gfxContext& aContext,
IsTrivial(&singleClipPathChild);
if (singleClipPathChild) {
nsSVGPathGeometryFrame* pathFrame = do_QueryFrame(singleClipPathChild);
SVGGeometryFrame* pathFrame = do_QueryFrame(singleClipPathChild);
if (pathFrame) {
nsSVGPathGeometryElement* pathElement =
static_cast<nsSVGPathGeometryElement*>(pathFrame->GetContent());
SVGGeometryElement* pathElement =
static_cast<SVGGeometryElement*>(pathFrame->GetContent());
gfxMatrix toChildsUserSpace = pathElement->
PrependLocalTransformsTo(GetClipPathTransform(aClippedFrame) * aMatrix,
eUserSpaceToParent);
@ -214,7 +214,7 @@ nsSVGClipPathFrame::GetClipMask(gfxContext& aReferenceContext,
}
// Our children have NS_STATE_SVG_CLIPPATH_CHILD set on them, and
// nsSVGPathGeometryFrame::Render checks for that state bit and paints
// SVGGeometryFrame::Render checks for that state bit and paints
// only the geometry (opaque black) if set.
DrawResult result = SVGFrame->PaintSVG(*ctx, toChildsUserSpace);
if (aResult) {
@ -394,7 +394,7 @@ nsSVGClipPathFrame::IsValid()
nsIAtom* grandKidType = grandKid->GetType();
if (grandKidType != nsGkAtoms::svgPathGeometryFrame &&
if (grandKidType != nsGkAtoms::svgGeometryFrame &&
grandKidType != nsGkAtoms::svgTextFrame) {
return false;
}
@ -402,7 +402,7 @@ nsSVGClipPathFrame::IsValid()
continue;
}
if (kidType != nsGkAtoms::svgPathGeometryFrame &&
if (kidType != nsGkAtoms::svgGeometryFrame &&
kidType != nsGkAtoms::svgTextFrame) {
return false;
}

View file

@ -12,11 +12,11 @@
#include "nsISupportsImpl.h"
#include "nsSVGClipPathFrame.h"
#include "nsSVGPaintServerFrame.h"
#include "nsSVGPathGeometryElement.h"
#include "nsSVGFilterFrame.h"
#include "nsSVGMaskFrame.h"
#include "nsIReflowCallback.h"
#include "nsCycleCollectionParticipant.h"
#include "SVGGeometryElement.h"
#include "SVGUseElement.h"
using namespace mozilla;
@ -523,8 +523,8 @@ nsSVGMarkerProperty*
nsSVGEffects::GetMarkerProperty(nsIURI* aURI, nsIFrame* aFrame,
const mozilla::FramePropertyDescriptor<nsSVGMarkerProperty>* aProperty)
{
MOZ_ASSERT(aFrame->GetType() == nsGkAtoms::svgPathGeometryFrame &&
static_cast<nsSVGPathGeometryElement*>(aFrame->GetContent())->IsMarkable(),
MOZ_ASSERT(aFrame->GetType() == nsGkAtoms::svgGeometryFrame &&
static_cast<SVGGeometryElement*>(aFrame->GetContent())->IsMarkable(),
"Bad frame");
return GetEffectProperty(aURI, aFrame, aProperty);
}
@ -700,8 +700,8 @@ nsSVGEffects::UpdateEffects(nsIFrame* aFrame)
// We can't do that in DoUpdate as the referenced frame may not be valid
GetOrCreateFilterProperty(aFrame);
if (aFrame->GetType() == nsGkAtoms::svgPathGeometryFrame &&
static_cast<nsSVGPathGeometryElement*>(aFrame->GetContent())->IsMarkable()) {
if (aFrame->GetType() == nsGkAtoms::svgGeometryFrame &&
static_cast<SVGGeometryElement*>(aFrame->GetContent())->IsMarkable()) {
// Set marker properties here to avoid reference loops
nsCOMPtr<nsIURI> markerURL =
GetMarkerURI(aFrame, &nsStyleSVG::mMarkerStart);

View file

@ -13,10 +13,10 @@
#include "nsLayoutUtils.h"
#include "imgINotificationObserver.h"
#include "nsSVGEffects.h"
#include "nsSVGPathGeometryFrame.h"
#include "mozilla/dom/SVGSVGElement.h"
#include "nsSVGUtils.h"
#include "SVGContentUtils.h"
#include "SVGGeometryFrame.h"
#include "SVGImageContext.h"
#include "mozilla/dom/SVGImageElement.h"
#include "nsContentUtils.h"
@ -46,7 +46,7 @@ private:
nsSVGImageFrame *mFrame;
};
class nsSVGImageFrame : public nsSVGPathGeometryFrame
class nsSVGImageFrame : public SVGGeometryFrame
, public nsIReflowCallback
{
friend nsIFrame*
@ -54,7 +54,7 @@ class nsSVGImageFrame : public nsSVGPathGeometryFrame
protected:
explicit nsSVGImageFrame(nsStyleContext* aContext)
: nsSVGPathGeometryFrame(aContext)
: SVGGeometryFrame(aContext)
, mReflowCallbackPosted(false)
{
EnableVisibilityTracking();
@ -72,7 +72,7 @@ public:
virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override;
virtual void ReflowSVG() override;
// nsSVGPathGeometryFrame methods:
// SVGGeometryFrame methods:
virtual uint16_t GetHitTestFlags() override;
// nsIFrame interface:
@ -154,7 +154,7 @@ nsSVGImageFrame::Init(nsIContent* aContent,
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::image),
"Content is not an SVG image!");
nsSVGPathGeometryFrame::Init(aContent, aParent, aPrevInFlow);
SVGGeometryFrame::Init(aContent, aParent, aPrevInFlow);
if (GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
// Non-display frames are likely to be patterns, masks or the like.
@ -246,8 +246,8 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
}
}
return nsSVGPathGeometryFrame::AttributeChanged(aNameSpaceID,
aAttribute, aModType);
return SVGGeometryFrame::AttributeChanged(aNameSpaceID,
aAttribute, aModType);
}
void
@ -256,13 +256,13 @@ nsSVGImageFrame::OnVisibilityChange(Visibility aNewVisibility,
{
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
if (!imageLoader) {
nsSVGPathGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
SVGGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
return;
}
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsSVGPathGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
SVGGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
}
gfx::Matrix
@ -505,7 +505,7 @@ nsSVGImageFrame::GetType() const
}
//----------------------------------------------------------------------
// nsSVGPathGeometryFrame methods:
// SVGGeometryFrame methods:
// Lie about our fill/stroke so that covered region and hit detection work properly

View file

@ -10,8 +10,8 @@
#include "gfxContext.h"
#include "nsSVGEffects.h"
#include "mozilla/dom/SVGMarkerElement.h"
#include "nsSVGPathGeometryElement.h"
#include "nsSVGPathGeometryFrame.h"
#include "SVGGeometryElement.h"
#include "SVGGeometryFrame.h"
using namespace mozilla::dom;
using namespace mozilla::gfx;
@ -73,7 +73,7 @@ nsSVGMarkerFrame::GetType() const
gfxMatrix
nsSVGMarkerFrame::GetCanvasTM()
{
NS_ASSERTION(mMarkedFrame, "null nsSVGPathGeometry frame");
NS_ASSERTION(mMarkedFrame, "null SVGGeometry frame");
if (mInUse2) {
// We're going to be bailing drawing the marker, so return an identity.
@ -105,7 +105,7 @@ GetAnonymousChildFrame(nsIFrame* aFrame)
nsresult
nsSVGMarkerFrame::PaintMark(gfxContext& aContext,
const gfxMatrix& aToMarkedFrameUserSpace,
nsSVGPathGeometryFrame *aMarkedFrame,
SVGGeometryFrame *aMarkedFrame,
nsSVGMark *aMark, float aStrokeWidth)
{
// If the flag is set when we get here, it means this marker frame
@ -166,7 +166,7 @@ nsSVGMarkerFrame::PaintMark(gfxContext& aContext,
SVGBBox
nsSVGMarkerFrame::GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags,
nsSVGPathGeometryFrame *aMarkedFrame,
SVGGeometryFrame *aMarkedFrame,
const nsSVGMark *aMark,
float aStrokeWidth)
{
@ -227,7 +227,7 @@ nsSVGMarkerFrame::SetParentCoordCtxProvider(SVGSVGElement *aContext)
nsSVGMarkerFrame::AutoMarkerReferencer::AutoMarkerReferencer(
nsSVGMarkerFrame *aFrame,
nsSVGPathGeometryFrame *aMarkedFrame
SVGGeometryFrame *aMarkedFrame
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: mFrame(aFrame)
{

View file

@ -16,9 +16,9 @@
#include "nsSVGUtils.h"
class gfxContext;
class nsSVGPathGeometryFrame;
namespace mozilla {
class SVGGeometryFrame;
namespace dom {
class SVGSVGElement;
} // namespace dom
@ -83,19 +83,19 @@ public:
// nsSVGMarkerFrame methods:
nsresult PaintMark(gfxContext& aContext,
const gfxMatrix& aToMarkedFrameUserSpace,
nsSVGPathGeometryFrame *aMarkedFrame,
SVGGeometryFrame *aMarkedFrame,
nsSVGMark *aMark,
float aStrokeWidth);
SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags,
nsSVGPathGeometryFrame *aMarkedFrame,
SVGGeometryFrame *aMarkedFrame,
const nsSVGMark *aMark,
float aStrokeWidth);
private:
// stuff needed for callback
nsSVGPathGeometryFrame *mMarkedFrame;
SVGGeometryFrame *mMarkedFrame;
float mStrokeWidth, mX, mY, mAutoAngle;
bool mIsStart; // whether the callback is for a marker-start marker
@ -111,7 +111,7 @@ private:
{
public:
AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
nsSVGPathGeometryFrame *aMarkedFrame
SVGGeometryFrame *aMarkedFrame
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~AutoMarkerReferencer();
private:

View file

@ -18,7 +18,7 @@
#include "nsISVGChildFrame.h"
#include "nsStyleContext.h"
#include "nsSVGEffects.h"
#include "nsSVGPathGeometryFrame.h"
#include "SVGGeometryFrame.h"
#include "mozilla/dom/SVGPatternElement.h"
#include "nsSVGUtils.h"
#include "nsSVGAnimatedTransformList.h"
@ -392,7 +392,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
if (aSource->IsFrameOfType(nsIFrame::eSVGGeometry)) {
// Set the geometrical parent of the pattern we are rendering
patternWithChildren->mSource = static_cast<nsSVGPathGeometryFrame*>(aSource);
patternWithChildren->mSource = static_cast<SVGGeometryFrame*>(aSource);
}
// Delay checking NS_FRAME_DRAWING_AS_PAINTSERVER bit until here so we can

View file

@ -15,11 +15,11 @@
class nsIFrame;
class nsSVGLength2;
class nsSVGPathGeometryFrame;
class nsSVGViewBox;
namespace mozilla {
class SVGAnimatedPreserveAspectRatio;
class SVGGeometryFrame;
class nsSVGAnimatedTransformList;
} // namespace mozilla
@ -142,7 +142,7 @@ private:
// this is a *temporary* reference to the frame of the element currently
// referencing our pattern. This must be temporary because different
// referencing frames will all reference this one frame
nsSVGPathGeometryFrame *mSource;
SVGGeometryFrame *mSource;
nsAutoPtr<gfxMatrix> mCTM;
protected:

View file

@ -46,8 +46,8 @@
#include "nsSVGOuterSVGFrame.h"
#include "mozilla/dom/SVGClipPathElement.h"
#include "mozilla/dom/SVGPathElement.h"
#include "nsSVGPathGeometryElement.h"
#include "nsSVGPathGeometryFrame.h"
#include "SVGGeometryElement.h"
#include "SVGGeometryFrame.h"
#include "nsSVGPaintServerFrame.h"
#include "mozilla/dom/SVGSVGElement.h"
#include "nsTextFrame.h"
@ -415,7 +415,7 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame)
return containerFrame->GetCanvasTM();
}
return static_cast<nsSVGPathGeometryFrame*>(aFrame)->GetCanvasTM();
return static_cast<SVGGeometryFrame*>(aFrame)->GetCanvasTM();
}
gfxMatrix
@ -1223,7 +1223,7 @@ nsSVGUtils::CanOptimizeOpacity(nsIFrame *aFrame)
}
nsIAtom *type = aFrame->GetType();
if (type != nsGkAtoms::svgImageFrame &&
type != nsGkAtoms::svgPathGeometryFrame) {
type != nsGkAtoms::svgGeometryFrame) {
return false;
}
if (aFrame->StyleEffects()->HasFilters()) {
@ -1329,7 +1329,7 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
/*static*/ gfxRect
nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGPathGeometryFrame* aFrame,
SVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix)
{
bool strokeMayHaveCorners =

View file

@ -39,7 +39,6 @@ class nsSVGElement;
class nsSVGEnum;
class nsSVGLength2;
class nsSVGOuterSVGFrame;
class nsSVGPathGeometryFrame;
class nsTextFrame;
struct nsStyleSVG;
@ -48,6 +47,7 @@ struct nsRect;
namespace mozilla {
class SVGContextPaint;
struct SVGContextPaintImpl;
class SVGGeometryFrame;
namespace dom {
class Element;
class UserSpaceMetrics;
@ -186,6 +186,7 @@ public:
typedef mozilla::gfx::Size Size;
typedef mozilla::SVGContextPaint SVGContextPaint;
typedef mozilla::SVGContextPaintImpl SVGContextPaintImpl;
typedef mozilla::SVGGeometryFrame SVGGeometryFrame;
typedef mozilla::image::DrawResult DrawResult;
static void Init();
@ -482,7 +483,7 @@ public:
nsTextFrame* aFrame,
const gfxMatrix& aMatrix);
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGPathGeometryFrame* aFrame,
SVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix);
/**