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-01-20 20:00:43 +03:00
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef LAYOUT_SVG_SVGMASKFRAME_H_
|
|
|
|
#define LAYOUT_SVG_SVGMASKFRAME_H_
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2020-07-09 04:33:33 +03:00
|
|
|
#include "mozilla/SVGContainerFrame.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2007-05-22 23:31:04 +04:00
|
|
|
#include "gfxPattern.h"
|
2009-04-29 08:31:34 +04:00
|
|
|
#include "gfxMatrix.h"
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2006-11-27 20:30:57 +03:00
|
|
|
class gfxContext;
|
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
nsIFrame* NS_NewSVGMaskFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
2014-09-12 11:20:12 +04:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGMaskFrame final : public SVGContainerFrame {
|
2020-06-27 08:39:42 +03:00
|
|
|
friend nsIFrame* ::NS_NewSVGMaskFrame(mozilla::PresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using Matrix = gfx::Matrix;
|
|
|
|
using SourceSurface = gfx::SourceSurface;
|
|
|
|
using imgDrawingParams = image::imgDrawingParams;
|
2014-09-12 11:20:12 +04:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
protected:
|
2020-06-27 08:39:42 +03:00
|
|
|
explicit SVGMaskFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
2020-07-09 04:33:33 +03:00
|
|
|
: SVGContainerFrame(aStyle, aPresContext, kClassID), mInUse(false) {
|
2013-07-12 11:13:07 +04:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 23:28:06 +04:00
|
|
|
}
|
2006-07-25 22:29:10 +04:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
public:
|
2020-06-27 08:39:42 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGMaskFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2016-11-16 07:59:52 +03:00
|
|
|
struct MaskParams {
|
|
|
|
gfxContext* ctx;
|
|
|
|
nsIFrame* maskedFrame;
|
|
|
|
const gfxMatrix& toUserSpace;
|
|
|
|
float opacity;
|
2020-06-27 08:39:42 +03:00
|
|
|
StyleMaskMode maskMode;
|
2017-05-18 23:03:45 +03:00
|
|
|
imgDrawingParams& imgParams;
|
2016-11-16 07:59:52 +03:00
|
|
|
|
|
|
|
explicit MaskParams(gfxContext* aCtx, nsIFrame* aMaskedFrame,
|
|
|
|
const gfxMatrix& aToUserSpace, float aOpacity,
|
2020-06-27 08:39:42 +03:00
|
|
|
StyleMaskMode aMaskMode, imgDrawingParams& aImgParams)
|
2016-11-16 07:59:52 +03:00
|
|
|
: ctx(aCtx),
|
|
|
|
maskedFrame(aMaskedFrame),
|
|
|
|
toUserSpace(aToUserSpace),
|
2017-03-27 06:10:48 +03:00
|
|
|
opacity(aOpacity),
|
|
|
|
maskMode(aMaskMode),
|
2017-05-18 23:03:45 +03:00
|
|
|
imgParams(aImgParams) {}
|
2016-11-16 07:59:52 +03:00
|
|
|
};
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
// SVGMaskFrame method:
|
2017-05-18 23:03:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a mask surface for the target frame.
|
|
|
|
*
|
|
|
|
* The return surface can be null, it's the caller's responsibility to
|
|
|
|
* null-check before dereferencing.
|
|
|
|
*/
|
2016-11-16 07:59:52 +03:00
|
|
|
already_AddRefed<SourceSurface> GetMaskForMaskedFrame(MaskParams& aParams);
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2016-06-18 02:24:26 +03:00
|
|
|
gfxRect GetMaskArea(nsIFrame* aMaskedFrame);
|
|
|
|
|
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;
|
2011-09-19 16:59:52 +04:00
|
|
|
|
2009-01-19 21:31:34 +03: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;
|
2009-01-19 21:31:34 +03:00
|
|
|
#endif
|
|
|
|
|
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 {}
|
2012-07-20 20:41:29 +04: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-07-25 22:29:10 +04:00
|
|
|
return MakeFrameName(u"SVGMask"_ns, aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
private:
|
2014-08-18 13:35:26 +04:00
|
|
|
/**
|
|
|
|
* If the mask element transforms its children due to
|
|
|
|
* maskContentUnits="objectBoundingBox" being set on it, this function
|
|
|
|
* returns the resulting transform.
|
|
|
|
*/
|
|
|
|
gfxMatrix GetMaskTransform(nsIFrame* aMaskedFrame);
|
|
|
|
|
|
|
|
gfxMatrix mMatrixForChildren;
|
2007-06-21 15:01:41 +04:00
|
|
|
// recursion prevention flag
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInUse;
|
2006-07-25 22:29:10 +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-07-25 22:29:10 +04:00
|
|
|
};
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // LAYOUT_SVG_SVGMASKFRAME_H_
|