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/. */
|
2006-01-20 17:00:43 +00:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMASKFRAME_H__
|
|
|
|
#define __NS_SVGMASKFRAME_H__
|
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-09-12 07:20:12 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2007-05-22 19:31:04 +00:00
|
|
|
#include "gfxPattern.h"
|
2009-04-29 04:31:34 +00:00
|
|
|
#include "gfxMatrix.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2006-11-27 17:30:57 +00:00
|
|
|
class gfxContext;
|
|
|
|
|
2016-04-18 07:30:09 +00:00
|
|
|
class nsSVGMaskFrame final : public nsSVGContainerFrame {
|
2018-03-22 18:20:41 +00:00
|
|
|
friend nsIFrame* NS_NewSVGMaskFrame(nsIPresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
2014-09-12 07:20:12 +00:00
|
|
|
|
|
|
|
typedef mozilla::gfx::Matrix Matrix;
|
|
|
|
typedef mozilla::gfx::SourceSurface SourceSurface;
|
2017-05-18 20:03:41 +00:00
|
|
|
typedef mozilla::image::imgDrawingParams imgDrawingParams;
|
2014-09-12 07:20:12 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
explicit nsSVGMaskFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
|
|
|
: nsSVGContainerFrame(aStyle, aPresContext, kClassID), mInUse(false) {
|
2013-07-12 07:13:07 +00:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 19:28:06 +00:00
|
|
|
}
|
2006-07-25 18:29:10 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2016-11-16 04:59:52 +00:00
|
|
|
struct MaskParams {
|
|
|
|
gfxContext* ctx;
|
|
|
|
nsIFrame* maskedFrame;
|
|
|
|
const gfxMatrix& toUserSpace;
|
|
|
|
float opacity;
|
|
|
|
Matrix* maskTransform;
|
2019-02-19 16:54:52 +00:00
|
|
|
mozilla::StyleMaskMode maskMode;
|
2017-05-18 20:03:45 +00:00
|
|
|
imgDrawingParams& imgParams;
|
2016-11-16 04:59:52 +00:00
|
|
|
|
|
|
|
explicit MaskParams(gfxContext* aCtx, nsIFrame* aMaskedFrame,
|
|
|
|
const gfxMatrix& aToUserSpace, float aOpacity,
|
2019-02-19 16:54:52 +00:00
|
|
|
Matrix* aMaskTransform, mozilla::StyleMaskMode aMaskMode,
|
2017-05-18 20:03:45 +00:00
|
|
|
imgDrawingParams& aImgParams)
|
2016-11-16 04:59:52 +00:00
|
|
|
: ctx(aCtx),
|
|
|
|
maskedFrame(aMaskedFrame),
|
|
|
|
toUserSpace(aToUserSpace),
|
2017-03-27 03:10:48 +00:00
|
|
|
opacity(aOpacity),
|
|
|
|
maskTransform(aMaskTransform),
|
|
|
|
maskMode(aMaskMode),
|
2017-05-18 20:03:45 +00:00
|
|
|
imgParams(aImgParams) {}
|
2016-11-16 04:59:52 +00:00
|
|
|
};
|
|
|
|
|
2006-07-25 18:29:10 +00:00
|
|
|
// nsSVGMaskFrame method:
|
2017-05-18 20:03:45 +00: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 04:59:52 +00:00
|
|
|
already_AddRefed<SourceSurface> GetMaskForMaskedFrame(MaskParams& aParams);
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
gfxRect GetMaskArea(nsIFrame* aMaskedFrame);
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t aModType) override;
|
2011-09-19 12:59:52 +00:00
|
|
|
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
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;
|
2009-01-19 18:31:34 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2006-07-25 18:29:10 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
private:
|
2014-08-18 09:35:26 +00: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 11:01:41 +00:00
|
|
|
// recursion prevention flag
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInUse;
|
2006-07-25 18:29:10 +00:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-07-25 18:29:10 +00:00
|
|
|
};
|
2006-01-20 17:00:43 +00:00
|
|
|
|
|
|
|
#endif
|