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
|
|
|
|
|
|
|
#ifndef __NS_SVGMASKFRAME_H__
|
|
|
|
#define __NS_SVGMASKFRAME_H__
|
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-09-12 11:20:12 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2007-05-22 23:31:04 +04:00
|
|
|
#include "gfxPattern.h"
|
2009-04-29 08:31:34 +04:00
|
|
|
#include "gfxMatrix.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2006-11-27 20:30:57 +03:00
|
|
|
class gfxContext;
|
|
|
|
|
2016-04-18 10:30:09 +03:00
|
|
|
class nsSVGMaskFrame final : public nsSVGContainerFrame
|
2006-07-25 22:29:10 +04:00
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2014-09-12 11:20:12 +04:00
|
|
|
|
|
|
|
typedef mozilla::gfx::Matrix Matrix;
|
|
|
|
typedef mozilla::gfx::SourceSurface SourceSurface;
|
2017-05-18 23:03:41 +03:00
|
|
|
typedef mozilla::image::imgDrawingParams imgDrawingParams;
|
2014-09-12 11:20:12 +04:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGMaskFrame(nsStyleContext* aContext)
|
2017-05-26 13:11:11 +03:00
|
|
|
: nsSVGContainerFrame(aContext, kClassID)
|
2012-03-10 23:28:06 +04:00
|
|
|
, 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:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
|
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;
|
|
|
|
Matrix* maskTransform;
|
|
|
|
uint8_t 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,
|
2017-03-27 06:10:48 +03:00
|
|
|
Matrix* aMaskTransform, uint8_t aMaskMode,
|
2017-05-18 23:03:45 +03:00
|
|
|
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), maskTransform(aMaskTransform), maskMode(aMaskMode),
|
2017-05-18 23:03:45 +03:00
|
|
|
imgParams(aImgParams)
|
2016-11-16 07:59:52 +03:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2006-07-25 22:29:10 +04:00
|
|
|
// nsSVGMaskFrame 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.
|
|
|
|
*/
|
|
|
|
already_AddRefed<SourceSurface>
|
2016-11-16 07:59:52 +03:00
|
|
|
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,
|
2017-10-03 01:05:19 +03:00
|
|
|
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(NS_LITERAL_STRING("SVGMask"), 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
|
|
|
|
|
|
|
// nsSVGContainerFrame 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
|
|
|
|
|
|
|
#endif
|