2008-09-11 00:24:16 +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/. */
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Main header first:
|
2008-09-11 00:24:16 +00:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Keep others in (case-insensitive) order:
|
|
|
|
#include "gfxDrawable.h"
|
2013-03-03 00:31:48 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2016-02-08 22:08:09 +00:00
|
|
|
#include "nsCSSClipPathInstance.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsDisplayList.h"
|
2014-02-24 15:22:58 +00:00
|
|
|
#include "nsFilterInstance.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsSVGClipPathFrame.h"
|
2008-09-11 00:24:16 +00:00
|
|
|
#include "nsSVGEffects.h"
|
2012-07-20 18:12:29 +00:00
|
|
|
#include "nsSVGElement.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsSVGFilterPaintCallback.h"
|
2008-10-01 00:51:05 +00:00
|
|
|
#include "nsSVGMaskFrame.h"
|
2010-08-13 13:32:27 +00:00
|
|
|
#include "nsSVGPaintServerFrame.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2012-07-17 17:03:51 +00:00
|
|
|
#include "FrameLayerBuilder.h"
|
|
|
|
#include "BasicLayers.h"
|
2013-12-29 23:35:52 +00:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2016-01-28 05:29:00 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2016-08-23 04:09:32 +00:00
|
|
|
#include "mozilla/Unused.h"
|
2012-07-17 17:03:51 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layers;
|
2014-09-12 07:20:12 +00:00
|
|
|
using namespace mozilla::gfx;
|
2016-07-11 17:22:54 +00:00
|
|
|
using namespace mozilla::image;
|
2008-09-11 00:24:16 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
2012-06-21 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* This class is used to get the pre-effects visual overflow rect of a frame,
|
|
|
|
* or, in the case of a frame with continuations, to collect the union of the
|
|
|
|
* pre-effects visual overflow rects of all the continuations. The result is
|
|
|
|
* relative to the origin (top left corner of the border box) of the frame, or,
|
|
|
|
* if the frame has continuations, the origin of the _first_ continuation.
|
|
|
|
*/
|
|
|
|
class PreEffectsVisualOverflowCollector : public nsLayoutUtils::BoxCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* If the pre-effects visual overflow rect of the frame being examined
|
|
|
|
* happens to be known, it can be passed in as aCurrentFrame and its
|
|
|
|
* pre-effects visual overflow rect can be passed in as
|
|
|
|
* aCurrentFrameOverflowArea. This is just an optimization to save a
|
|
|
|
* frame property lookup - these arguments are optional.
|
|
|
|
*/
|
|
|
|
PreEffectsVisualOverflowCollector(nsIFrame* aFirstContinuation,
|
|
|
|
nsIFrame* aCurrentFrame,
|
|
|
|
const nsRect& aCurrentFrameOverflowArea)
|
|
|
|
: mFirstContinuation(aFirstContinuation)
|
|
|
|
, mCurrentFrame(aCurrentFrame)
|
|
|
|
, mCurrentFrameOverflowArea(aCurrentFrameOverflowArea)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mFirstContinuation->GetPrevContinuation(),
|
|
|
|
"We want the first continuation here");
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void AddBox(nsIFrame* aFrame) override {
|
2012-06-21 00:29:50 +00:00
|
|
|
nsRect overflow = (aFrame == mCurrentFrame) ?
|
|
|
|
mCurrentFrameOverflowArea : GetPreEffectsVisualOverflowRect(aFrame);
|
|
|
|
mResult.UnionRect(mResult, overflow + aFrame->GetOffsetTo(mFirstContinuation));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect GetResult() const {
|
|
|
|
return mResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static nsRect GetPreEffectsVisualOverflowRect(nsIFrame* aFrame) {
|
2016-06-21 20:17:11 +00:00
|
|
|
nsRect* r = aFrame->Properties().Get(nsIFrame::PreEffectsBBoxProperty());
|
2012-06-21 00:29:50 +00:00
|
|
|
if (r) {
|
|
|
|
return *r;
|
|
|
|
}
|
|
|
|
// Despite the fact that we're invoked for frames with SVG effects applied,
|
2014-02-07 01:45:33 +00:00
|
|
|
// we can actually get here. All continuations and IB split siblings of a
|
2012-06-21 00:29:50 +00:00
|
|
|
// frame with SVG effects applied will have the PreEffectsBBoxProperty
|
|
|
|
// property set on them. Therefore, the frames that are passed to us will
|
|
|
|
// always have that property set...well, with one exception. If the frames
|
|
|
|
// for an element with SVG effects applied have been subject to an "IB
|
|
|
|
// split", then the block frame(s) that caused the split will have been
|
|
|
|
// wrapped in anonymous, inline-block, nsBlockFrames of pseudo-type
|
2014-02-07 01:45:33 +00:00
|
|
|
// nsCSSAnonBoxes::mozAnonymousBlock. These "IB split sibling" anonymous
|
2012-06-21 00:29:50 +00:00
|
|
|
// blocks will have the PreEffectsBBoxProperty property set on them, but
|
|
|
|
// they will never be passed to us. Instead, we'll be passed the block
|
|
|
|
// children that they wrap, which don't have the PreEffectsBBoxProperty
|
|
|
|
// property set on them. This is actually okay. What we care about is
|
|
|
|
// collecting the _pre_ effects visual overflow rects of the frames to
|
|
|
|
// which the SVG effects have been applied. Since the IB split results in
|
|
|
|
// any overflow rect adjustments for transforms, effects, etc. taking
|
|
|
|
// place on the anonymous block wrappers, the wrapped children are left
|
|
|
|
// with their overflow rects unaffected. In other words, calling
|
|
|
|
// GetVisualOverflowRect() on the children will return their pre-effects
|
|
|
|
// visual overflow rects, just as we need.
|
|
|
|
//
|
|
|
|
// A couple of tests that demonstrate the IB split and cause us to get here
|
|
|
|
// are:
|
|
|
|
//
|
|
|
|
// * reftests/svg/svg-integration/clipPath-html-06.xhtml
|
|
|
|
// * reftests/svg/svg-integration/clipPath-html-06-extref.xhtml
|
|
|
|
//
|
|
|
|
// If we ever got passed a frame with the PreTransformOverflowAreasProperty
|
|
|
|
// property set, that would be bad, since then our GetVisualOverflowRect()
|
|
|
|
// call would give us the post-effects, and post-transform, overflow rect.
|
|
|
|
//
|
2013-02-16 05:38:33 +00:00
|
|
|
NS_ASSERTION(aFrame->GetParent()->StyleContext()->GetPseudo() ==
|
2012-06-21 00:29:50 +00:00
|
|
|
nsCSSAnonBoxes::mozAnonymousBlock,
|
|
|
|
"How did we getting here, then?");
|
|
|
|
NS_ASSERTION(!aFrame->Properties().Get(
|
|
|
|
aFrame->PreTransformOverflowAreasProperty()),
|
|
|
|
"GetVisualOverflowRect() won't return the pre-effects rect!");
|
|
|
|
return aFrame->GetVisualOverflowRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* mFirstContinuation;
|
|
|
|
nsIFrame* mCurrentFrame;
|
|
|
|
const nsRect& mCurrentFrameOverflowArea;
|
|
|
|
nsRect mResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the union of the pre-effects visual overflow rects of all of a frame's
|
|
|
|
* continuations, in "user space".
|
|
|
|
*/
|
|
|
|
static nsRect
|
|
|
|
GetPreEffectsVisualOverflowUnion(nsIFrame* aFirstContinuation,
|
|
|
|
nsIFrame* aCurrentFrame,
|
|
|
|
const nsRect& aCurrentFramePreEffectsOverflow,
|
|
|
|
const nsPoint& aFirstContinuationToUserSpace)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aFirstContinuation->GetPrevContinuation(),
|
|
|
|
"Need first continuation here");
|
|
|
|
PreEffectsVisualOverflowCollector collector(aFirstContinuation,
|
|
|
|
aCurrentFrame,
|
|
|
|
aCurrentFramePreEffectsOverflow);
|
|
|
|
// Compute union of all overflow areas relative to aFirstContinuation:
|
|
|
|
nsLayoutUtils::GetAllInFlowBoxes(aFirstContinuation, &collector);
|
|
|
|
// Return the result in user space:
|
|
|
|
return collector.GetResult() + aFirstContinuationToUserSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-09-11 00:24:16 +00:00
|
|
|
nsSVGIntegrationUtils::UsingEffectsForFrame(const nsIFrame* aFrame)
|
|
|
|
{
|
2012-07-20 18:12:29 +00:00
|
|
|
// Even when SVG display lists are disabled, returning true for SVG frames
|
|
|
|
// does not adversely affect any of our callers. Therefore we don't bother
|
|
|
|
// checking the SDL prefs here, since we don't know if we're being called for
|
|
|
|
// painting or hit-testing anyway.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleSVGReset *style = aFrame->StyleSVGReset();
|
2016-04-12 05:52:43 +00:00
|
|
|
return aFrame->StyleEffects()->HasFilters() ||
|
|
|
|
style->HasClipPath() ||
|
|
|
|
style->mMask.HasLayerWithImage();
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 05:56:11 +00:00
|
|
|
bool
|
|
|
|
nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(const nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSVGReset *style = aFrame->StyleSVGReset();
|
|
|
|
return style->HasClipPath() ||
|
2016-09-05 03:47:18 +00:00
|
|
|
style->mMask.HasLayerWithImage();
|
2016-08-16 05:56:11 +00:00
|
|
|
}
|
|
|
|
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
// For non-SVG frames, this gives the offset to the frame's "user space".
|
|
|
|
// For SVG frames, this returns a zero offset.
|
|
|
|
static nsPoint
|
|
|
|
GetOffsetToBoundingBox(nsIFrame* aFrame)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2012-07-20 18:12:29 +00:00
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
|
|
|
|
// Do NOT call GetAllInFlowRectsUnion for SVG - it will get the
|
|
|
|
// covered region relative to the nsSVGOuterSVGFrame, which is absolutely
|
|
|
|
// not what we want. SVG frames are always in user space, so they have
|
|
|
|
// no offset adjustment to make.
|
|
|
|
return nsPoint();
|
|
|
|
}
|
2012-06-19 15:28:04 +00:00
|
|
|
|
|
|
|
// The GetAllInFlowRectsUnion() call gets the union of the frame border-box
|
|
|
|
// rects over all continuations, relative to the origin (top-left of the
|
|
|
|
// border box) of its second argument (here, aFrame, the first continuation).
|
|
|
|
return -nsLayoutUtils::GetAllInFlowRectsUnion(aFrame, aFrame).TopLeft();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nsSize
|
|
|
|
nsSVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
|
|
|
"SVG frames should not get here");
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aNonSVGFrame);
|
2012-06-19 15:28:04 +00:00
|
|
|
return nsLayoutUtils::GetAllInFlowRectsUnion(firstFrame, firstFrame).Size();
|
|
|
|
}
|
|
|
|
|
2013-12-29 23:35:52 +00:00
|
|
|
/* static */ gfx::Size
|
2012-06-19 15:28:04 +00:00
|
|
|
nsSVGIntegrationUtils::GetSVGCoordContextForNonSVGFrame(nsIFrame* aNonSVGFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
|
|
|
"SVG frames should not get here");
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aNonSVGFrame);
|
2012-06-19 15:28:04 +00:00
|
|
|
nsRect r = nsLayoutUtils::GetAllInFlowRectsUnion(firstFrame, firstFrame);
|
|
|
|
nsPresContext* presContext = firstFrame->PresContext();
|
2013-12-29 23:35:52 +00:00
|
|
|
return gfx::Size(presContext->AppUnitsToFloatCSSPixels(r.width),
|
|
|
|
presContext->AppUnitsToFloatCSSPixels(r.height));
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2012-06-21 00:29:50 +00:00
|
|
|
gfxRect
|
|
|
|
nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame(nsIFrame* aNonSVGFrame)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2012-06-21 00:29:50 +00:00
|
|
|
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
|
|
|
"SVG frames should not get here");
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aNonSVGFrame);
|
2012-06-21 00:29:50 +00:00
|
|
|
// 'r' is in "user space":
|
2012-07-30 14:20:58 +00:00
|
|
|
nsRect r = GetPreEffectsVisualOverflowUnion(firstFrame, nullptr, nsRect(),
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
GetOffsetToBoundingBox(firstFrame));
|
2012-06-21 00:29:50 +00:00
|
|
|
return nsLayoutUtils::RectToGfxRect(r,
|
|
|
|
aNonSVGFrame->PresContext()->AppUnitsPerCSSPixel());
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 10:42:05 +00:00
|
|
|
// XXX Since we're called during reflow, this method is broken for frames with
|
|
|
|
// continuations. When we're called for a frame with continuations, we're
|
|
|
|
// called for each continuation in turn as it's reflowed. However, it isn't
|
|
|
|
// until the last continuation is reflowed that this method's
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
// GetOffsetToBoundingBox() and GetPreEffectsVisualOverflowUnion() calls will
|
2012-06-22 10:42:05 +00:00
|
|
|
// obtain valid border boxes for all the continuations. As a result, we'll
|
|
|
|
// end up returning bogus post-filter visual overflow rects for all the prior
|
|
|
|
// continuations. Unfortunately, by the time the last continuation is
|
|
|
|
// reflowed, it's too late to go back and set and propagate the overflow
|
|
|
|
// rects on the previous continuations.
|
|
|
|
//
|
|
|
|
// The reason that we need to pass an override bbox to
|
|
|
|
// GetPreEffectsVisualOverflowUnion rather than just letting it call into our
|
|
|
|
// GetSVGBBoxForNonSVGFrame method is because we get called by
|
2014-02-15 05:29:12 +00:00
|
|
|
// ComputeEffectsRect when it has been called with
|
2012-06-22 10:42:05 +00:00
|
|
|
// aStoreRectProperties set to false. In this case the pre-effects visual
|
|
|
|
// overflow rect that it has been passed may be different to that stored on
|
|
|
|
// aFrame, resulting in a different bbox.
|
|
|
|
//
|
|
|
|
// XXXjwatt The pre-effects visual overflow rect passed to
|
2014-02-15 05:29:12 +00:00
|
|
|
// ComputeEffectsRect won't include continuation overflows, so
|
2012-06-22 10:42:05 +00:00
|
|
|
// for frames with continuation the following filter analysis will likely end
|
|
|
|
// up being carried out with a bbox created as if the frame didn't have
|
|
|
|
// continuations.
|
|
|
|
//
|
|
|
|
// XXXjwatt Using aPreEffectsOverflowRect to create the bbox isn't really right
|
|
|
|
// for SVG frames, since for SVG frames the SVG spec defines the bbox to be
|
|
|
|
// something quite different to the pre-effects visual overflow rect. However,
|
|
|
|
// we're essentially calculating an invalidation area here, and using the
|
|
|
|
// pre-effects overflow rect will actually overestimate that area which, while
|
|
|
|
// being a bit wasteful, isn't otherwise a problem.
|
|
|
|
//
|
2008-09-11 00:24:16 +00:00
|
|
|
nsRect
|
2012-06-21 00:29:50 +00:00
|
|
|
nsSVGIntegrationUtils::
|
|
|
|
ComputePostEffectsVisualOverflowRect(nsIFrame* aFrame,
|
|
|
|
const nsRect& aPreEffectsOverflowRect)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2012-06-21 00:29:50 +00:00
|
|
|
NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT),
|
|
|
|
"Don't call this on SVG child frames");
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
|
2008-09-11 00:24:16 +00:00
|
|
|
nsSVGEffects::EffectProperties effectProperties =
|
|
|
|
nsSVGEffects::GetEffectProperties(firstFrame);
|
2014-02-24 15:22:58 +00:00
|
|
|
if (!effectProperties.HasValidFilter()) {
|
2012-06-21 00:29:50 +00:00
|
|
|
return aPreEffectsOverflowRect;
|
2014-02-24 15:22:58 +00:00
|
|
|
}
|
2012-06-21 00:29:50 +00:00
|
|
|
|
2012-06-22 10:42:05 +00:00
|
|
|
// Create an override bbox - see comment above:
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
nsPoint firstFrameToBoundingBox = GetOffsetToBoundingBox(firstFrame);
|
2012-06-23 03:01:36 +00:00
|
|
|
// overrideBBox is in "user space", in _CSS_ pixels:
|
2012-06-22 10:42:05 +00:00
|
|
|
// XXX Why are we rounding out to pixel boundaries? We don't do that in
|
|
|
|
// GetSVGBBoxForNonSVGFrame, and it doesn't appear to be necessary.
|
2012-06-23 03:01:36 +00:00
|
|
|
gfxRect overrideBBox =
|
|
|
|
nsLayoutUtils::RectToGfxRect(
|
|
|
|
GetPreEffectsVisualOverflowUnion(firstFrame, aFrame,
|
|
|
|
aPreEffectsOverflowRect,
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
firstFrameToBoundingBox),
|
2012-06-23 03:01:36 +00:00
|
|
|
aFrame->PresContext()->AppUnitsPerCSSPixel());
|
|
|
|
overrideBBox.RoundOut();
|
2012-06-21 00:29:50 +00:00
|
|
|
|
|
|
|
nsRect overflowRect =
|
2014-02-24 15:22:58 +00:00
|
|
|
nsFilterInstance::GetPostFilterBounds(firstFrame, &overrideBBox);
|
2012-06-21 00:29:50 +00:00
|
|
|
|
|
|
|
// Return overflowRect relative to aFrame, rather than "user space":
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
return overflowRect - (aFrame->GetOffsetTo(firstFrame) + firstFrameToBoundingBox);
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 08:25:17 +00:00
|
|
|
nsIntRegion
|
2012-06-21 00:29:50 +00:00
|
|
|
nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(nsIFrame* aFrame,
|
2012-11-28 04:06:07 +00:00
|
|
|
const nsPoint& aToReferenceFrame,
|
2014-04-24 08:25:17 +00:00
|
|
|
const nsIntRegion& aInvalidRegion)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2014-04-24 08:25:17 +00:00
|
|
|
if (aInvalidRegion.IsEmpty()) {
|
2013-09-06 09:30:27 +00:00
|
|
|
return nsIntRect();
|
|
|
|
}
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
// Don't bother calling GetEffectProperties; the filter property should
|
|
|
|
// already have been set up during reflow/ComputeFrameEffectsRect
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
|
2010-11-10 21:18:11 +00:00
|
|
|
nsSVGFilterProperty *prop = nsSVGEffects::GetFilterProperty(firstFrame);
|
2014-02-10 04:31:03 +00:00
|
|
|
if (!prop || !prop->IsInObserverLists()) {
|
2014-04-24 08:25:17 +00:00
|
|
|
return aInvalidRegion;
|
2010-11-10 05:50:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:33 +00:00
|
|
|
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
2014-02-24 15:22:58 +00:00
|
|
|
if (!prop || !prop->ReferencesValidResources()) {
|
2008-12-12 08:25:16 +00:00
|
|
|
// The frame is either not there or not currently available,
|
|
|
|
// perhaps because we're in the middle of tearing stuff down.
|
2012-11-28 04:06:07 +00:00
|
|
|
// Be conservative, return our visual overflow rect relative
|
|
|
|
// to the reference frame.
|
|
|
|
nsRect overflow = aFrame->GetVisualOverflowRect() + aToReferenceFrame;
|
2012-08-29 05:39:33 +00:00
|
|
|
return overflow.ToOutsidePixels(appUnitsPerDevPixel);
|
2008-12-12 08:25:16 +00:00
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2014-04-24 08:25:17 +00:00
|
|
|
// Convert aInvalidRegion into bounding box frame space in app units:
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
nsPoint toBoundingBox =
|
|
|
|
aFrame->GetOffsetTo(firstFrame) + GetOffsetToBoundingBox(firstFrame);
|
2012-11-28 04:06:07 +00:00
|
|
|
// The initial rect was relative to the reference frame, so we need to
|
|
|
|
// remove that offset to get a rect relative to the current frame.
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
toBoundingBox -= aToReferenceFrame;
|
2014-04-24 08:25:17 +00:00
|
|
|
nsRegion preEffectsRegion = aInvalidRegion.ToAppUnits(appUnitsPerDevPixel).MovedBy(toBoundingBox);
|
2012-06-19 15:28:04 +00:00
|
|
|
|
2012-11-28 04:06:07 +00:00
|
|
|
// Adjust the dirty area for effects, and shift it back to being relative to
|
|
|
|
// the reference frame.
|
2014-04-24 08:25:17 +00:00
|
|
|
nsRegion result = nsFilterInstance::GetPostFilterDirtyArea(firstFrame,
|
|
|
|
preEffectsRegion).MovedBy(-toBoundingBox);
|
2012-11-28 04:06:07 +00:00
|
|
|
// Return the result, in pixels relative to the reference frame.
|
2012-08-29 05:39:33 +00:00
|
|
|
return result.ToOutsidePixels(appUnitsPerDevPixel);
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRect
|
|
|
|
nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(nsIFrame* aFrame,
|
2012-06-19 15:28:04 +00:00
|
|
|
const nsRect& aDirtyRect)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
|
|
|
// Don't bother calling GetEffectProperties; the filter property should
|
|
|
|
// already have been set up during reflow/ComputeFrameEffectsRect
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
|
2014-02-24 15:22:58 +00:00
|
|
|
nsSVGFilterProperty *prop = nsSVGEffects::GetFilterProperty(firstFrame);
|
|
|
|
if (!prop || !prop->ReferencesValidResources()) {
|
2012-06-19 15:28:04 +00:00
|
|
|
return aDirtyRect;
|
2014-02-24 15:22:58 +00:00
|
|
|
}
|
2014-08-01 00:37:35 +00:00
|
|
|
|
2012-06-26 10:49:23 +00:00
|
|
|
// Convert aDirtyRect into "user space" in app units:
|
2012-06-19 15:28:04 +00:00
|
|
|
nsPoint toUserSpace =
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
aFrame->GetOffsetTo(firstFrame) + GetOffsetToBoundingBox(firstFrame);
|
2012-06-26 10:49:23 +00:00
|
|
|
nsRect postEffectsRect = aDirtyRect + toUserSpace;
|
2012-06-19 15:28:04 +00:00
|
|
|
|
2012-06-26 10:49:23 +00:00
|
|
|
// Return ther result, relative to aFrame, not in user space:
|
2014-04-24 08:25:17 +00:00
|
|
|
return nsFilterInstance::GetPreFilterNeededArea(firstFrame, postEffectsRect).GetBounds()
|
2014-02-24 15:22:58 +00:00
|
|
|
- toUserSpace;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-09-11 00:24:16 +00:00
|
|
|
nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, const nsPoint& aPt)
|
|
|
|
{
|
|
|
|
nsIFrame* firstFrame =
|
2014-02-07 01:45:31 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
|
2012-06-19 15:28:04 +00:00
|
|
|
// Convert aPt to user space:
|
2013-01-04 11:48:12 +00:00
|
|
|
nsPoint toUserSpace;
|
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
// XXXmstange Isn't this wrong for svg:use and innerSVG frames?
|
2013-01-04 11:48:12 +00:00
|
|
|
toUserSpace = aFrame->GetPosition();
|
|
|
|
} else {
|
|
|
|
toUserSpace =
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
aFrame->GetOffsetTo(firstFrame) + GetOffsetToBoundingBox(firstFrame);
|
2013-01-04 11:48:12 +00:00
|
|
|
}
|
2012-06-19 15:28:04 +00:00
|
|
|
nsPoint pt = aPt + toUserSpace;
|
2014-08-07 07:09:31 +00:00
|
|
|
gfxPoint userSpacePt =
|
|
|
|
gfxPoint(pt.x, pt.y) / aFrame->PresContext()->AppUnitsPerCSSPixel();
|
|
|
|
return nsSVGUtils::HitTestClip(firstFrame, userSpacePt);
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class RegularFramePaintCallback : public nsSVGFilterPaintCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RegularFramePaintCallback(nsDisplayListBuilder* aBuilder,
|
2012-07-17 17:03:51 +00:00
|
|
|
LayerManager* aManager,
|
2008-09-11 00:24:16 +00:00
|
|
|
const nsPoint& aOffset)
|
2012-07-17 17:03:51 +00:00
|
|
|
: mBuilder(aBuilder), mLayerManager(aManager),
|
2010-03-10 20:55:05 +00:00
|
|
|
mOffset(aOffset) {}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2016-07-14 04:47:06 +00:00
|
|
|
virtual DrawResult Paint(gfxContext& aContext, nsIFrame *aTarget,
|
|
|
|
const gfxMatrix& aTransform,
|
|
|
|
const nsIntRect* aDirtyRect) override
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2012-07-17 17:03:51 +00:00
|
|
|
BasicLayerManager* basic = static_cast<BasicLayerManager*>(mLayerManager);
|
2014-10-31 20:08:54 +00:00
|
|
|
basic->SetTarget(&aContext);
|
2014-09-11 06:48:09 +00:00
|
|
|
|
|
|
|
gfxPoint devPixelOffset =
|
|
|
|
nsLayoutUtils::PointToGfxPoint(-mOffset,
|
|
|
|
aTarget->PresContext()->AppUnitsPerDevPixel());
|
|
|
|
|
2014-10-31 20:08:54 +00:00
|
|
|
gfxContextMatrixAutoSaveRestore autoSR(&aContext);
|
|
|
|
aContext.SetMatrix(aContext.CurrentMatrix().Translate(devPixelOffset));
|
2014-09-11 06:48:09 +00:00
|
|
|
|
2014-09-26 17:06:08 +00:00
|
|
|
mLayerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, mBuilder);
|
2016-07-14 04:47:06 +00:00
|
|
|
return DrawResult::SUCCESS;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
2012-07-17 17:03:51 +00:00
|
|
|
LayerManager* mLayerManager;
|
2008-09-11 00:24:16 +00:00
|
|
|
nsPoint mOffset;
|
|
|
|
};
|
|
|
|
|
2016-08-15 15:49:21 +00:00
|
|
|
static IntRect
|
|
|
|
ComputeClipExtsInDeviceSpace(gfxContext& aCtx)
|
|
|
|
{
|
|
|
|
gfxContextMatrixAutoSaveRestore matRestore(&aCtx);
|
|
|
|
|
|
|
|
// Get the clip extents in device space.
|
|
|
|
aCtx.SetMatrix(gfxMatrix());
|
|
|
|
gfxRect clippedFrameSurfaceRect = aCtx.GetClipExtents();
|
|
|
|
clippedFrameSurfaceRect.RoundOut();
|
|
|
|
|
|
|
|
IntRect result;
|
|
|
|
ToRect(clippedFrameSurfaceRect).ToIntRect(&result);
|
|
|
|
return mozilla::gfx::Factory::CheckSurfaceSize(result.Size()) ? result
|
|
|
|
: IntRect();
|
|
|
|
}
|
|
|
|
|
2016-09-22 03:12:54 +00:00
|
|
|
typedef nsSVGIntegrationUtils::PaintFramesParams PaintFramesParams;
|
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
static IntRect
|
2016-09-22 03:12:54 +00:00
|
|
|
ComputeMaskGeometry(const PaintFramesParams& aParams,
|
2016-06-17 23:24:26 +00:00
|
|
|
const nsStyleSVGReset *svgReset,
|
|
|
|
const nsPoint& aOffsetToUserSpace,
|
|
|
|
const nsTArray<nsSVGMaskFrame *>& aMaskFrames)
|
|
|
|
{
|
|
|
|
gfxContext& ctx = aParams.ctx;
|
|
|
|
nsIFrame* frame = aParams.frame;
|
|
|
|
|
|
|
|
// Convert boaderArea and dirtyRect to user space.
|
|
|
|
int32_t appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
nsRect userSpaceBorderArea = aParams.borderArea - aOffsetToUserSpace;
|
|
|
|
nsRect userSpaceDirtyRect = aParams.dirtyRect - aOffsetToUserSpace;
|
|
|
|
|
|
|
|
// Union all mask layer rectangles in user space.
|
|
|
|
gfxRect maskInUserSpace;
|
|
|
|
for (size_t i = 0; i < aMaskFrames.Length() ; i++) {
|
|
|
|
nsSVGMaskFrame* maskFrame = aMaskFrames[i];
|
|
|
|
gfxRect currentMaskSurfaceRect;
|
|
|
|
|
|
|
|
if (maskFrame) {
|
|
|
|
currentMaskSurfaceRect = maskFrame->GetMaskArea(aParams.frame);
|
|
|
|
} else {
|
|
|
|
nsCSSRendering::ImageLayerClipState clipState;
|
|
|
|
nsCSSRendering::GetImageLayerClip(svgReset->mMask.mLayers[i],
|
|
|
|
frame,
|
|
|
|
*frame->StyleBorder(),
|
|
|
|
userSpaceBorderArea,
|
|
|
|
userSpaceDirtyRect,
|
|
|
|
false, /* aWillPaintBorder */
|
|
|
|
appUnitsPerDevPixel,
|
|
|
|
&clipState);
|
|
|
|
currentMaskSurfaceRect = clipState.mDirtyRectGfx;
|
|
|
|
}
|
|
|
|
|
|
|
|
maskInUserSpace = maskInUserSpace.Union(currentMaskSurfaceRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Save();
|
|
|
|
|
|
|
|
// Clip ctx by both frame's visual overflow rect and mask union.
|
|
|
|
gfxRect frameVisualOverflowRect =
|
|
|
|
nsLayoutUtils::RectToGfxRect(frame->GetVisualOverflowRectRelativeToSelf(),
|
|
|
|
appUnitsPerDevPixel);
|
|
|
|
ctx.Clip(frameVisualOverflowRect);
|
|
|
|
// maskInUserSpace might be empty if all mask references are not resolvable
|
|
|
|
// or the size of them are empty. We still need to create a transparent mask
|
|
|
|
// before bug 1276834 fixed, so don't clip ctx by an empty rectangle for for
|
|
|
|
// now.
|
|
|
|
if (!maskInUserSpace.IsEmpty()) {
|
|
|
|
ctx.Clip(maskInUserSpace);
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:49:21 +00:00
|
|
|
IntRect result = ComputeClipExtsInDeviceSpace(ctx);
|
2016-06-17 23:24:26 +00:00
|
|
|
ctx.Restore();
|
|
|
|
|
2016-08-15 15:49:21 +00:00
|
|
|
return result;
|
2016-06-17 23:24:26 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 17:22:54 +00:00
|
|
|
static DrawResult
|
2016-09-22 03:12:54 +00:00
|
|
|
GenerateMaskSurface(const PaintFramesParams& aParams,
|
2016-09-28 14:52:05 +00:00
|
|
|
float aOpacity, nsStyleContext* aSC,
|
2016-05-31 07:45:42 +00:00
|
|
|
const nsTArray<nsSVGMaskFrame *>& aMaskFrames,
|
2016-06-17 23:24:26 +00:00
|
|
|
const nsPoint& aOffsetToUserSpace,
|
|
|
|
Matrix& aOutMaskTransform,
|
2016-09-27 18:46:47 +00:00
|
|
|
RefPtr<SourceSurface>& aOutMaskSurface,
|
|
|
|
bool& aOpacityApplied)
|
2016-05-19 07:43:43 +00:00
|
|
|
{
|
|
|
|
const nsStyleSVGReset *svgReset = aSC->StyleSVGReset();
|
2016-05-31 07:45:42 +00:00
|
|
|
MOZ_ASSERT(aMaskFrames.Length() > 0);
|
2016-05-19 07:43:43 +00:00
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
gfxMatrix cssPxToDevPxMatrix =
|
|
|
|
nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aParams.frame);
|
2016-05-19 07:43:43 +00:00
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
gfxContext& ctx = aParams.ctx;
|
2016-05-19 07:44:19 +00:00
|
|
|
|
2016-05-31 07:45:42 +00:00
|
|
|
// There is only one SVG mask.
|
|
|
|
if (((aMaskFrames.Length() == 1) && aMaskFrames[0])) {
|
2016-09-27 18:46:47 +00:00
|
|
|
aOpacityApplied = true;
|
2016-05-19 07:44:19 +00:00
|
|
|
aOutMaskSurface =
|
2016-05-31 07:45:42 +00:00
|
|
|
aMaskFrames[0]->GetMaskForMaskedFrame(&ctx, aParams.frame,
|
2016-09-28 14:52:05 +00:00
|
|
|
cssPxToDevPxMatrix, aOpacity,
|
2016-05-31 07:45:42 +00:00
|
|
|
&aOutMaskTransform,
|
|
|
|
svgReset->mMask.mLayers[0].mMaskMode);
|
2016-07-11 17:22:54 +00:00
|
|
|
return DrawResult::SUCCESS;
|
2016-05-19 07:44:19 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
IntRect maskSurfaceRect = ComputeMaskGeometry(aParams, svgReset,
|
|
|
|
aOffsetToUserSpace,
|
|
|
|
aMaskFrames);
|
2016-05-31 07:45:42 +00:00
|
|
|
if (maskSurfaceRect.IsEmpty()) {
|
2016-07-11 17:22:54 +00:00
|
|
|
return DrawResult::SUCCESS;
|
2016-05-31 07:45:42 +00:00
|
|
|
}
|
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
// Mask composition result on CoreGraphic::A8 surface is not correct
|
|
|
|
// when mask-mode is not add(source over). Switch to skia when CG backend
|
|
|
|
// detected.
|
|
|
|
RefPtr<DrawTarget> maskDT =
|
2016-09-08 06:28:00 +00:00
|
|
|
(ctx.GetDrawTarget()->GetBackendType() == BackendType::COREGRAPHICS)
|
2016-05-19 07:44:07 +00:00
|
|
|
? Factory::CreateDrawTarget(BackendType::SKIA, maskSurfaceRect.Size(),
|
|
|
|
SurfaceFormat::A8)
|
|
|
|
: ctx.GetDrawTarget()->CreateSimilarDrawTarget(maskSurfaceRect.Size(),
|
|
|
|
SurfaceFormat::A8);
|
2016-06-07 01:17:48 +00:00
|
|
|
if (!maskDT || !maskDT->IsValid()) {
|
2016-07-11 17:22:54 +00:00
|
|
|
return DrawResult::TEMPORARY_ERROR;
|
2016-06-07 01:17:48 +00:00
|
|
|
}
|
2016-05-31 07:45:42 +00:00
|
|
|
|
2016-06-06 23:39:56 +00:00
|
|
|
RefPtr<gfxContext> maskContext = gfxContext::CreateOrNull(maskDT);
|
2016-06-07 01:17:48 +00:00
|
|
|
MOZ_ASSERT(maskContext);
|
2016-05-19 07:44:07 +00:00
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
nsPresContext* presContext = aParams.frame->PresContext();
|
|
|
|
gfxPoint devPixelOffsetToUserSpace =
|
|
|
|
nsLayoutUtils::PointToGfxPoint(aOffsetToUserSpace,
|
|
|
|
presContext->AppUnitsPerDevPixel());
|
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
// Set ctx's matrix on maskContext, offset by the maskSurfaceRect's position.
|
|
|
|
// This makes sure that we combine the masks in device space.
|
|
|
|
gfxMatrix maskSurfaceMatrix =
|
|
|
|
ctx.CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
|
|
|
|
maskContext->SetMatrix(maskSurfaceMatrix);
|
|
|
|
|
2016-09-27 18:46:47 +00:00
|
|
|
// Set aAppliedOpacity as true only if all mask layers are svg mask.
|
|
|
|
// In this case, we will apply opacity into the final mask surface, so the
|
|
|
|
// caller does not need to apply it again.
|
|
|
|
aOpacityApplied = true;
|
|
|
|
for (size_t i = 0; i < aMaskFrames.Length() ; i++) {
|
|
|
|
nsSVGMaskFrame *maskFrame = aMaskFrames[i];
|
|
|
|
if (!maskFrame) {
|
|
|
|
aOpacityApplied = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
// Multiple SVG masks interleave with image mask. Paint each layer onto
|
|
|
|
// maskDT one at a time.
|
2016-05-31 07:45:42 +00:00
|
|
|
for (int i = aMaskFrames.Length() - 1; i >= 0 ; i--) {
|
|
|
|
nsSVGMaskFrame *maskFrame = aMaskFrames[i];
|
2016-05-19 07:44:07 +00:00
|
|
|
|
2016-05-31 07:45:42 +00:00
|
|
|
CompositionOp compositionOp = (i == int(aMaskFrames.Length() - 1))
|
2016-05-26 08:07:43 +00:00
|
|
|
? CompositionOp::OP_OVER
|
|
|
|
: nsCSSRendering::GetGFXCompositeMode(svgReset->mMask.mLayers[i].mComposite);
|
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
// maskFrame != nullptr means we get a SVG mask.
|
|
|
|
// maskFrame == nullptr means we get an image mask.
|
|
|
|
if (maskFrame) {
|
|
|
|
Matrix svgMaskMatrix;
|
|
|
|
RefPtr<SourceSurface> svgMask =
|
|
|
|
maskFrame->GetMaskForMaskedFrame(maskContext, aParams.frame,
|
2016-09-27 18:46:47 +00:00
|
|
|
cssPxToDevPxMatrix,
|
|
|
|
aOpacityApplied ? aOpacity : 1.0,
|
2016-05-19 07:44:07 +00:00
|
|
|
&svgMaskMatrix,
|
|
|
|
svgReset->mMask.mLayers[i].mMaskMode);
|
|
|
|
if (svgMask) {
|
|
|
|
gfxContextMatrixAutoSaveRestore matRestore(maskContext);
|
|
|
|
|
|
|
|
maskContext->Multiply(ThebesMatrix(svgMaskMatrix));
|
|
|
|
Rect drawRect = IntRectToRect(IntRect(IntPoint(0, 0), svgMask->GetSize()));
|
2016-09-27 18:46:47 +00:00
|
|
|
maskDT->MaskSurface(ColorPattern(Color(0.0, 0.0, 0.0, 1.0)), svgMask,
|
|
|
|
drawRect.TopLeft(),
|
2016-09-08 06:28:00 +00:00
|
|
|
DrawOptions(1.0, compositionOp));
|
2016-05-19 07:44:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gfxContextMatrixAutoSaveRestore matRestore(maskContext);
|
|
|
|
|
2016-06-17 23:24:26 +00:00
|
|
|
maskContext->Multiply(gfxMatrix::Translation(-devPixelOffsetToUserSpace));
|
2016-05-19 07:44:07 +00:00
|
|
|
nsRenderingContext rc(maskContext);
|
|
|
|
nsCSSRendering::PaintBGParams params =
|
2016-06-17 23:24:26 +00:00
|
|
|
nsCSSRendering::PaintBGParams::ForSingleLayer(*presContext,
|
2016-05-19 07:44:07 +00:00
|
|
|
rc, aParams.dirtyRect,
|
|
|
|
aParams.borderArea,
|
|
|
|
aParams.frame,
|
|
|
|
aParams.builder->GetBackgroundPaintFlags() |
|
|
|
|
nsCSSRendering::PAINTBG_MASK_IMAGE,
|
|
|
|
i, compositionOp);
|
|
|
|
|
2016-07-11 17:22:54 +00:00
|
|
|
DrawResult result =
|
|
|
|
nsCSSRendering::PaintBackgroundWithSC(params, aSC,
|
|
|
|
*aParams.frame->StyleBorder());
|
|
|
|
if (result != DrawResult::SUCCESS) {
|
|
|
|
return result;
|
|
|
|
}
|
2016-05-19 07:43:43 +00:00
|
|
|
}
|
2016-05-19 07:44:07 +00:00
|
|
|
}
|
2016-05-19 07:43:43 +00:00
|
|
|
|
2016-05-19 07:44:07 +00:00
|
|
|
aOutMaskTransform = ToMatrix(maskSurfaceMatrix);
|
|
|
|
if (!aOutMaskTransform.Invert()) {
|
2016-07-11 17:22:54 +00:00
|
|
|
return DrawResult::SUCCESS;
|
2016-05-19 07:43:43 +00:00
|
|
|
}
|
2016-05-19 07:44:07 +00:00
|
|
|
|
|
|
|
aOutMaskSurface = maskDT->Snapshot();
|
2016-07-11 17:22:54 +00:00
|
|
|
return DrawResult::SUCCESS;
|
2016-05-19 07:43:43 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:57:45 +00:00
|
|
|
static float
|
2016-09-22 03:12:54 +00:00
|
|
|
ComputeOpacity(const PaintFramesParams& aParams)
|
2016-08-15 15:57:45 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = aParams.frame;
|
|
|
|
float opacity = frame->StyleEffects()->mOpacity;
|
|
|
|
|
|
|
|
if (opacity != 1.0f &&
|
2016-09-05 03:47:18 +00:00
|
|
|
(nsSVGUtils::CanOptimizeOpacity(frame) || !aParams.handleOpacity)) {
|
2016-08-15 15:57:45 +00:00
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return opacity;
|
|
|
|
}
|
|
|
|
|
2016-08-15 16:05:10 +00:00
|
|
|
static bool
|
2016-09-22 03:12:54 +00:00
|
|
|
ValidateSVGFrame(const PaintFramesParams& aParams, bool aHasSVGLayout,
|
|
|
|
DrawResult* aResult)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2016-05-19 07:43:32 +00:00
|
|
|
NS_ASSERTION(!(aParams.frame->GetStateBits() & NS_FRAME_SVG_LAYOUT) ||
|
2012-07-20 18:12:29 +00:00
|
|
|
(NS_SVGDisplayListPaintingEnabled() &&
|
2016-05-19 07:43:32 +00:00
|
|
|
!(aParams.frame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)),
|
2012-07-20 18:12:29 +00:00
|
|
|
"Should not use nsSVGIntegrationUtils on this SVG frame");
|
2009-01-12 19:20:59 +00:00
|
|
|
#endif
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2016-08-15 16:05:10 +00:00
|
|
|
nsIFrame* frame = aParams.frame;
|
|
|
|
const nsIContent* content = frame->GetContent();
|
|
|
|
if (aHasSVGLayout) {
|
|
|
|
nsISVGChildFrame *svgChildFrame = do_QueryFrame(frame);
|
|
|
|
if (!svgChildFrame || !frame->GetContent()->IsSVGElement()) {
|
|
|
|
NS_ASSERTION(false, "why?");
|
|
|
|
*aResult = DrawResult::BAD_ARGS;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!static_cast<const nsSVGElement*>(content)->HasValidDimensions()) {
|
|
|
|
// The SVG spec says not to draw _anything_
|
|
|
|
*aResult = DrawResult::SUCCESS;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-21 08:49:27 +00:00
|
|
|
/**
|
|
|
|
* Setup transform matrix of a gfx context by a specific frame. Depend on
|
|
|
|
* aClipCtx, this function may clip that context by the visual overflow area
|
|
|
|
* of aFrame.
|
|
|
|
*
|
|
|
|
* @param aFrame is the target frame.
|
|
|
|
* @param aOffsetToBoundingBox returns the offset between the reference frame
|
|
|
|
* and the bounding box of aFrame.
|
|
|
|
* @oaram aOffsetToUserSpace returns the offset between the reference frame and
|
|
|
|
* the user space coordinate of aFrame.
|
|
|
|
* @param aClipCtx indicate whether clip aParams.ctx by visual overflow rect of
|
|
|
|
* aFrame or not.
|
|
|
|
*/
|
2016-08-15 16:33:35 +00:00
|
|
|
static void
|
2016-09-21 08:49:27 +00:00
|
|
|
SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
|
|
|
|
nsPoint& aOffsetToBoundingBox, nsPoint& aOffsetToUserSpace,
|
|
|
|
bool aClipCtx)
|
2016-08-15 16:33:35 +00:00
|
|
|
{
|
2016-09-21 08:49:27 +00:00
|
|
|
aOffsetToBoundingBox = aParams.builder->ToReferenceFrame(aFrame) -
|
|
|
|
GetOffsetToBoundingBox(aFrame);
|
|
|
|
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
|
2016-08-15 16:33:35 +00:00
|
|
|
/* Snap the offset if the reference frame is not a SVG frame,
|
|
|
|
* since other frames will be snapped to pixel when rendering. */
|
|
|
|
aOffsetToBoundingBox = nsPoint(
|
2016-09-21 08:49:27 +00:00
|
|
|
aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(aOffsetToBoundingBox.x),
|
|
|
|
aFrame->PresContext()->RoundAppUnitsToNearestDevPixels(aOffsetToBoundingBox.y));
|
2016-08-15 16:33:35 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 15:16:35 +00:00
|
|
|
// After applying only "aOffsetToBoundingBox", aParams.ctx would have its
|
|
|
|
// origin at the top left corner of frame's bounding box (over all
|
|
|
|
// continuations).
|
2016-08-15 16:33:35 +00:00
|
|
|
// However, SVG painting needs the origin to be located at the origin of the
|
|
|
|
// SVG frame's "user space", i.e. the space in which, for example, the
|
|
|
|
// frame's BBox lives.
|
|
|
|
// SVG geometry frames and foreignObject frames apply their own offsets, so
|
|
|
|
// their position is relative to their user space. So for these frame types,
|
|
|
|
// if we want aCtx to be in user space, we first need to subtract the
|
|
|
|
// frame's position so that SVG painting can later add it again and the
|
|
|
|
// frame is painted in the right place.
|
|
|
|
|
2016-09-21 08:49:27 +00:00
|
|
|
gfxPoint toUserSpaceGfx = nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame);
|
|
|
|
nsPoint toUserSpace =
|
2016-08-15 16:33:35 +00:00
|
|
|
nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)),
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y)));
|
|
|
|
|
2016-09-21 08:49:27 +00:00
|
|
|
aOffsetToUserSpace = aOffsetToBoundingBox - toUserSpace;
|
2016-08-15 16:33:35 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2016-09-21 08:49:27 +00:00
|
|
|
bool hasSVGLayout = (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
|
2016-08-15 16:33:35 +00:00
|
|
|
NS_ASSERTION(hasSVGLayout || aOffsetToBoundingBox == aOffsetToUserSpace,
|
|
|
|
"For non-SVG frames there shouldn't be any additional offset");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gfxPoint devPixelOffsetToUserSpace =
|
|
|
|
nsLayoutUtils::PointToGfxPoint(aOffsetToUserSpace,
|
2016-09-21 08:49:27 +00:00
|
|
|
aFrame->PresContext()->AppUnitsPerDevPixel());
|
|
|
|
gfxContext& context = aParams.ctx;
|
|
|
|
context.SetMatrix(context.CurrentMatrix().Translate(devPixelOffsetToUserSpace));
|
|
|
|
|
|
|
|
if (aClipCtx) {
|
|
|
|
nsRect clipRect =
|
|
|
|
aParams.frame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
|
|
|
|
context.Clip(NSRectToSnappedRect(clipRect,
|
|
|
|
aFrame->PresContext()->AppUnitsPerDevPixel(),
|
|
|
|
*context.GetDrawTarget()));
|
|
|
|
}
|
2016-08-15 16:33:35 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 16:05:10 +00:00
|
|
|
DrawResult
|
2016-08-15 17:07:57 +00:00
|
|
|
nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
|
2016-08-15 16:05:10 +00:00
|
|
|
{
|
2016-09-05 04:46:56 +00:00
|
|
|
MOZ_ASSERT(UsingMaskOrClipPathForFrame(aParams.frame),
|
|
|
|
"Should not use this method when no mask or clipPath effect"
|
|
|
|
"on this frame");
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
/* SVG defines the following rendering model:
|
|
|
|
*
|
|
|
|
* 1. Render geometry
|
|
|
|
* 2. Apply filter
|
|
|
|
* 3. Apply clipping, masking, group opacity
|
|
|
|
*
|
2016-08-15 17:07:57 +00:00
|
|
|
* We handle #3 here and perform a couple of optimizations:
|
2008-09-11 00:24:16 +00:00
|
|
|
*
|
|
|
|
* + Use cairo's clipPath when representable natively (single object
|
|
|
|
* clip region).
|
|
|
|
*
|
|
|
|
* + Merge opacity and masking if both used together.
|
|
|
|
*/
|
2016-05-19 07:43:32 +00:00
|
|
|
nsIFrame* frame = aParams.frame;
|
2016-08-15 16:05:10 +00:00
|
|
|
DrawResult result = DrawResult::SUCCESS;
|
2016-05-19 07:43:32 +00:00
|
|
|
bool hasSVGLayout = (frame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
|
2016-08-15 16:05:10 +00:00
|
|
|
if (!ValidateSVGFrame(aParams, hasSVGLayout, &result)) {
|
|
|
|
return result;
|
2012-07-20 18:12:29 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:57:45 +00:00
|
|
|
float opacity = ComputeOpacity(aParams);
|
2016-07-29 05:58:15 +00:00
|
|
|
if (opacity == 0.0f) {
|
|
|
|
return DrawResult::SUCCESS;
|
|
|
|
}
|
2012-06-21 00:29:50 +00:00
|
|
|
|
2016-08-15 16:33:35 +00:00
|
|
|
gfxContext& context = aParams.ctx;
|
|
|
|
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(&context);
|
|
|
|
|
2012-06-21 00:29:50 +00:00
|
|
|
/* Properties are added lazily and may have been removed by a restyle,
|
|
|
|
so make sure all applicable ones are set again. */
|
|
|
|
nsIFrame* firstFrame =
|
2016-05-19 07:43:32 +00:00
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(frame);
|
2012-06-21 00:29:50 +00:00
|
|
|
nsSVGEffects::EffectProperties effectProperties =
|
|
|
|
nsSVGEffects::GetEffectProperties(firstFrame);
|
|
|
|
|
2014-02-24 15:22:58 +00:00
|
|
|
bool isOK = effectProperties.HasNoFilterOrHasValidFilter();
|
2008-10-01 00:51:05 +00:00
|
|
|
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(&isOK);
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2012-06-21 00:29:50 +00:00
|
|
|
bool isTrivialClip = clipPathFrame ? clipPathFrame->IsTrivial() : true;
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2016-05-19 07:43:32 +00:00
|
|
|
gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);
|
2016-01-28 05:29:00 +00:00
|
|
|
const nsStyleSVGReset *svgReset = firstFrame->StyleSVGReset();
|
2016-05-31 07:45:42 +00:00
|
|
|
nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
|
2016-08-18 03:24:28 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
|
2016-05-31 07:45:42 +00:00
|
|
|
// For a HTML doc:
|
|
|
|
// According to css-masking spec, always create a mask surface when we
|
|
|
|
// have any item in maskFrame even if all of those items are
|
|
|
|
// non-resolvable <mask-sources> or <images>, we still need to create a
|
|
|
|
// transparent black mask layer under this condition.
|
|
|
|
// For a SVG doc:
|
|
|
|
// SVG 1.1 say that if we fail to resolve a mask, we should draw the
|
|
|
|
// object unmasked.
|
2016-08-10 07:52:38 +00:00
|
|
|
bool shouldGenerateMaskLayer = hasSVGLayout
|
2016-05-31 07:45:42 +00:00
|
|
|
? maskFrames.Length() == 1 && maskFrames[0]
|
|
|
|
: maskFrames.Length() > 0;
|
2016-08-18 03:24:28 +00:00
|
|
|
#else
|
|
|
|
// Since we do not support image mask so far, we should treat any
|
|
|
|
// unresolvable mask as no mask. Otherwise, any object with a valid image
|
|
|
|
// mask, e.g. url("xxx.png"), will become invisible just because we can not
|
|
|
|
// handle image mask correctly. (See bug 1294171)
|
|
|
|
bool shouldGenerateMaskLayer = maskFrames.Length() == 1 && maskFrames[0];
|
|
|
|
#endif
|
2016-01-28 05:29:00 +00:00
|
|
|
|
2016-08-15 15:04:50 +00:00
|
|
|
bool shouldGenerateClipMaskLayer = clipPathFrame && !isTrivialClip;
|
|
|
|
bool shouldApplyClipPath = clipPathFrame && isTrivialClip;
|
|
|
|
bool shouldApplyBasicShape = !clipPathFrame && svgReset->HasClipPath();
|
|
|
|
MOZ_ASSERT_IF(shouldGenerateClipMaskLayer,
|
|
|
|
!shouldApplyClipPath && !shouldApplyBasicShape);
|
|
|
|
|
2016-09-21 08:49:27 +00:00
|
|
|
nsPoint offsetToBoundingBox;
|
|
|
|
nsPoint offsetToUserSpace;
|
|
|
|
|
2016-08-15 15:04:50 +00:00
|
|
|
bool shouldGenerateMask = (opacity != 1.0f || shouldGenerateClipMaskLayer ||
|
|
|
|
shouldGenerateMaskLayer);
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
/* Check if we need to do additional operations on this child's
|
|
|
|
* rendering, which necessitates rendering into another surface. */
|
2016-08-15 15:04:50 +00:00
|
|
|
if (shouldGenerateMask) {
|
2016-09-22 05:38:55 +00:00
|
|
|
gfxContextMatrixAutoSaveRestore matSR;
|
|
|
|
|
2016-01-28 05:29:00 +00:00
|
|
|
Matrix maskTransform;
|
|
|
|
RefPtr<SourceSurface> maskSurface;
|
2016-09-27 18:46:47 +00:00
|
|
|
bool opacityApplied = false;
|
2016-09-22 05:38:55 +00:00
|
|
|
|
2016-05-31 07:45:42 +00:00
|
|
|
if (shouldGenerateMaskLayer) {
|
2016-09-22 05:38:55 +00:00
|
|
|
matSR.SetContext(&context);
|
|
|
|
|
|
|
|
// For css-mask, we want to generate a mask for each continuation frame,
|
|
|
|
// so we setup context matrix by the position of the current frame,
|
|
|
|
// instead of the first continuation frame.
|
|
|
|
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
|
|
|
|
offsetToUserSpace, true);
|
2016-09-28 14:52:05 +00:00
|
|
|
result = GenerateMaskSurface(aParams, opacity,
|
2016-07-11 17:22:54 +00:00
|
|
|
firstFrame->StyleContext(),
|
|
|
|
maskFrames, offsetToUserSpace,
|
2016-09-27 18:46:47 +00:00
|
|
|
maskTransform, maskSurface, opacityApplied);
|
2016-09-22 05:38:55 +00:00
|
|
|
context.PopClip();
|
|
|
|
if (!maskSurface) {
|
|
|
|
// Entire surface is clipped out.
|
|
|
|
return result;
|
|
|
|
}
|
2016-01-28 05:29:00 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:04:50 +00:00
|
|
|
if (shouldGenerateClipMaskLayer) {
|
2016-09-22 05:38:55 +00:00
|
|
|
matSR.Restore();
|
|
|
|
matSR.SetContext(&context);
|
|
|
|
|
|
|
|
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
|
|
|
|
offsetToUserSpace, true);
|
2015-11-11 15:15:39 +00:00
|
|
|
Matrix clippedMaskTransform;
|
2016-07-14 04:47:06 +00:00
|
|
|
RefPtr<SourceSurface> clipMaskSurface =
|
|
|
|
clipPathFrame->GetClipMask(context, frame, cssPxToDevPxMatrix,
|
|
|
|
&clippedMaskTransform, maskSurface,
|
|
|
|
maskTransform, &result);
|
2016-09-22 05:38:55 +00:00
|
|
|
context.PopClip();
|
2015-11-11 15:15:39 +00:00
|
|
|
|
|
|
|
if (clipMaskSurface) {
|
|
|
|
maskSurface = clipMaskSurface;
|
|
|
|
maskTransform = clippedMaskTransform;
|
2016-09-22 08:29:03 +00:00
|
|
|
} else {
|
|
|
|
// Either entire surface is clipped out, or gfx buffer allocation
|
|
|
|
// failure in nsSVGClipPathFrame::GetClipMask.
|
|
|
|
return result;
|
2015-11-11 15:15:39 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-22 05:38:55 +00:00
|
|
|
|
|
|
|
// opacity != 1.0f.
|
|
|
|
if (!shouldGenerateClipMaskLayer && !shouldGenerateMaskLayer) {
|
|
|
|
MOZ_ASSERT(opacity != 1.0f);
|
|
|
|
|
|
|
|
matSR.SetContext(&context);
|
|
|
|
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
|
|
|
|
offsetToUserSpace, true);
|
|
|
|
}
|
2015-11-11 15:15:39 +00:00
|
|
|
|
2016-09-29 03:07:51 +00:00
|
|
|
context.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA,
|
2016-09-27 18:46:47 +00:00
|
|
|
opacityApplied ? 1.0 : opacity,
|
|
|
|
maskSurface, maskTransform);
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If this frame has only a trivial clipPath, set up cairo's clipping now so
|
|
|
|
* we can just do normal painting and get it clipped appropriately.
|
|
|
|
*/
|
2016-09-21 08:49:27 +00:00
|
|
|
if (shouldApplyClipPath || shouldApplyBasicShape) {
|
2016-05-19 07:43:32 +00:00
|
|
|
context.Save();
|
2016-09-21 08:49:27 +00:00
|
|
|
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
|
|
|
|
offsetToUserSpace, false);
|
|
|
|
|
|
|
|
MOZ_ASSERT(!shouldApplyClipPath || !shouldApplyBasicShape);
|
|
|
|
if (shouldApplyClipPath) {
|
|
|
|
clipPathFrame->ApplyClipPath(context, frame, cssPxToDevPxMatrix);
|
|
|
|
} else {
|
|
|
|
nsCSSClipPathInstance::ApplyBasicShapeClip(context, frame);
|
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Paint the child */
|
2016-09-29 03:07:51 +00:00
|
|
|
context.SetMatrix(matrixAutoSaveRestore.Matrix());
|
2016-08-15 17:07:57 +00:00
|
|
|
BasicLayerManager* basic = static_cast<BasicLayerManager*>(aParams.layerManager);
|
|
|
|
RefPtr<gfxContext> oldCtx = basic->GetTarget();
|
2016-09-29 03:07:51 +00:00
|
|
|
basic->SetTarget(&context);
|
2016-08-15 17:07:57 +00:00
|
|
|
aParams.layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
|
2016-09-18 15:16:35 +00:00
|
|
|
aParams.builder);
|
2016-08-15 17:07:57 +00:00
|
|
|
basic->SetTarget(oldCtx);
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2016-08-15 15:04:50 +00:00
|
|
|
if (shouldApplyClipPath || shouldApplyBasicShape) {
|
2016-05-19 07:43:32 +00:00
|
|
|
context.Restore();
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:04:50 +00:00
|
|
|
if (shouldGenerateMask) {
|
2016-09-29 03:07:51 +00:00
|
|
|
context.PopGroupAndBlend();
|
2016-09-22 05:38:55 +00:00
|
|
|
|
|
|
|
if (!shouldGenerateClipMaskLayer && !shouldGenerateMaskLayer) {
|
|
|
|
MOZ_ASSERT(opacity != 1.0f);
|
|
|
|
// Pop the clip push by SetupContextMatrix
|
|
|
|
context.PopClip();
|
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 17:22:54 +00:00
|
|
|
return result;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 16:59:35 +00:00
|
|
|
DrawResult
|
|
|
|
nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
|
|
|
|
{
|
2016-09-05 04:46:56 +00:00
|
|
|
MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask(),
|
|
|
|
"Filter effect is discarded while generating glyph mask.");
|
|
|
|
MOZ_ASSERT(aParams.frame->StyleEffects()->HasFilters(),
|
|
|
|
"Should not use this method when no filter effect on this frame");
|
2016-09-01 06:54:11 +00:00
|
|
|
|
2016-08-15 16:59:35 +00:00
|
|
|
nsIFrame* frame = aParams.frame;
|
|
|
|
DrawResult result = DrawResult::SUCCESS;
|
|
|
|
bool hasSVGLayout = (frame->GetStateBits() & NS_FRAME_SVG_LAYOUT);
|
|
|
|
if (!ValidateSVGFrame(aParams, hasSVGLayout, &result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
float opacity = ComputeOpacity(aParams);
|
|
|
|
if (opacity == 0.0f) {
|
|
|
|
return DrawResult::SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Properties are added lazily and may have been removed by a restyle,
|
|
|
|
so make sure all applicable ones are set again. */
|
|
|
|
nsIFrame* firstFrame =
|
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(frame);
|
|
|
|
nsSVGEffects::EffectProperties effectProperties =
|
|
|
|
nsSVGEffects::GetEffectProperties(firstFrame);
|
|
|
|
|
|
|
|
if (!effectProperties.HasValidFilter()) {
|
|
|
|
return DrawResult::NOT_READY;
|
|
|
|
}
|
|
|
|
|
2016-09-21 08:49:27 +00:00
|
|
|
gfxContext& context = aParams.ctx;
|
|
|
|
nsPoint offsetToBoundingBox;
|
|
|
|
nsPoint offsetToUserSpace;
|
|
|
|
|
2016-09-22 05:38:55 +00:00
|
|
|
gfxContextAutoSaveRestore autoSR(&context);
|
2016-09-21 08:49:27 +00:00
|
|
|
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
|
|
|
|
offsetToUserSpace, true);
|
2016-08-15 16:59:35 +00:00
|
|
|
|
2016-09-05 03:47:18 +00:00
|
|
|
if (opacity != 1.0f) {
|
2016-09-29 03:07:51 +00:00
|
|
|
context.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, opacity,
|
2016-09-05 03:47:18 +00:00
|
|
|
nullptr, Matrix());
|
|
|
|
}
|
|
|
|
|
2016-08-15 16:59:35 +00:00
|
|
|
/* Paint the child and apply filters */
|
2016-09-01 06:54:11 +00:00
|
|
|
RegularFramePaintCallback callback(aParams.builder, aParams.layerManager,
|
|
|
|
offsetToUserSpace);
|
|
|
|
nsRegion dirtyRegion = aParams.dirtyRect - offsetToBoundingBox;
|
|
|
|
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(frame);
|
2016-09-29 03:07:51 +00:00
|
|
|
nsFilterInstance::PaintFilteredFrame(frame, context.GetDrawTarget(),
|
2016-09-01 06:54:11 +00:00
|
|
|
tm, &callback, &dirtyRegion);
|
2016-08-15 16:59:35 +00:00
|
|
|
|
2016-09-05 03:47:18 +00:00
|
|
|
if (opacity != 1.0f) {
|
2016-09-29 03:07:51 +00:00
|
|
|
context.PopGroupAndBlend();
|
2016-08-15 16:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-07-23 08:35:59 +00:00
|
|
|
gfxMatrix
|
2012-06-21 00:29:50 +00:00
|
|
|
nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame)
|
2008-09-11 00:24:16 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel();
|
2008-09-11 00:24:16 +00:00
|
|
|
float devPxPerCSSPx =
|
|
|
|
1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);
|
2009-07-23 08:35:59 +00:00
|
|
|
|
|
|
|
return gfxMatrix(devPxPerCSSPx, 0.0,
|
|
|
|
0.0, devPxPerCSSPx,
|
|
|
|
0.0, 0.0);
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2010-08-13 13:32:27 +00:00
|
|
|
class PaintFrameCallback : public gfxDrawingCallback {
|
|
|
|
public:
|
|
|
|
PaintFrameCallback(nsIFrame* aFrame,
|
|
|
|
const nsSize aPaintServerSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize aRenderSize,
|
2013-08-01 20:42:34 +00:00
|
|
|
uint32_t aFlags)
|
2010-08-13 13:32:27 +00:00
|
|
|
: mFrame(aFrame)
|
|
|
|
, mPaintServerSize(aPaintServerSize)
|
|
|
|
, mRenderSize(aRenderSize)
|
2013-08-01 20:42:34 +00:00
|
|
|
, mFlags (aFlags)
|
2010-08-13 13:32:27 +00:00
|
|
|
{}
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool operator()(gfxContext* aContext,
|
2015-10-06 00:18:10 +00:00
|
|
|
const gfxRect& aFillRect,
|
2016-05-25 16:01:18 +00:00
|
|
|
const SamplingFilter aSamplingFilter,
|
2015-10-06 00:18:10 +00:00
|
|
|
const gfxMatrix& aTransform) override;
|
2010-08-13 13:32:27 +00:00
|
|
|
private:
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsSize mPaintServerSize;
|
2015-09-23 18:49:05 +00:00
|
|
|
IntSize mRenderSize;
|
2013-08-01 20:42:34 +00:00
|
|
|
uint32_t mFlags;
|
2010-08-13 13:32:27 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-08-13 13:32:27 +00:00
|
|
|
PaintFrameCallback::operator()(gfxContext* aContext,
|
|
|
|
const gfxRect& aFillRect,
|
2016-05-25 16:01:18 +00:00
|
|
|
const SamplingFilter aSamplingFilter,
|
2010-08-13 13:32:27 +00:00
|
|
|
const gfxMatrix& aTransform)
|
|
|
|
{
|
|
|
|
if (mFrame->GetStateBits() & NS_FRAME_DRAWING_AS_PAINTSERVER)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-08-13 13:32:27 +00:00
|
|
|
|
|
|
|
mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
|
|
|
|
|
|
|
|
aContext->Save();
|
|
|
|
|
|
|
|
// Clip to aFillRect so that we don't paint outside.
|
|
|
|
aContext->NewPath();
|
|
|
|
aContext->Rectangle(aFillRect);
|
|
|
|
aContext->Clip();
|
|
|
|
|
2014-07-11 07:06:39 +00:00
|
|
|
gfxMatrix invmatrix = aTransform;
|
|
|
|
if (!invmatrix.Invert()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aContext->Multiply(invmatrix);
|
2010-08-13 13:32:27 +00:00
|
|
|
|
|
|
|
// nsLayoutUtils::PaintFrame will anchor its painting at mFrame. But we want
|
|
|
|
// to have it anchored at the top left corner of the bounding box of all of
|
|
|
|
// mFrame's continuations. So we add a translation transform.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
Bug 997735 - Rename nsSVGIntegrationUtils::GetOffsetToUserSpace to GetOffsetToBoundingBox. r=roc
There are three spaces that nsSVGIntegrationUtils needs to convert between. I'll call them "frame space", "bounding box frame space" and "user space".
"Bounding box frame space" has its origin at the top left of the union of a frame's border boxes over all continuations.
For SVG frames, "frame space" and "bounding box frame space" are the same because SVG frames don't have multiple continuations.
For non-SVG frames, "bounding box frame space" and "user space" are the same.
However, for SVG frames, "bounding box frame space" and "user space" are different! For example, for a <rect x="100" y="100">, the point 0,0 in frame space is at the rect's top left corner, but the point 0,0 in user space is 100,100 pixels away from the rect's corner.
nsSVGIntegrationUtils::GetOffsetToUserSpace took the non-SVG viewpoint, but it's misleading for SVG frames.
2014-04-23 09:47:31 +00:00
|
|
|
nsPoint offset = GetOffsetToBoundingBox(mFrame);
|
2012-06-19 15:28:04 +00:00
|
|
|
gfxPoint devPxOffset = gfxPoint(offset.x, offset.y) / appUnitsPerDevPixel;
|
2014-09-10 13:26:12 +00:00
|
|
|
aContext->Multiply(gfxMatrix::Translation(devPxOffset));
|
2010-08-13 13:32:27 +00:00
|
|
|
|
|
|
|
gfxSize paintServerSize =
|
|
|
|
gfxSize(mPaintServerSize.width, mPaintServerSize.height) /
|
|
|
|
mFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
|
|
|
// nsLayoutUtils::PaintFrame wants to render with paintServerSize, but we
|
|
|
|
// want it to render with mRenderSize, so we need to set up a scale transform.
|
|
|
|
gfxFloat scaleX = mRenderSize.width / paintServerSize.width;
|
|
|
|
gfxFloat scaleY = mRenderSize.height / paintServerSize.height;
|
2014-09-10 13:26:12 +00:00
|
|
|
aContext->Multiply(gfxMatrix::Scaling(scaleX, scaleY));
|
2010-08-13 13:32:27 +00:00
|
|
|
|
|
|
|
// Draw.
|
2012-06-19 15:28:04 +00:00
|
|
|
nsRect dirty(-offset.x, -offset.y,
|
|
|
|
mPaintServerSize.width, mPaintServerSize.height);
|
2013-08-01 20:42:34 +00:00
|
|
|
|
2016-04-27 04:01:54 +00:00
|
|
|
using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags;
|
|
|
|
PaintFrameFlags flags = PaintFrameFlags::PAINT_IN_TRANSFORM;
|
2013-08-01 20:42:34 +00:00
|
|
|
if (mFlags & nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES) {
|
2016-04-27 04:01:54 +00:00
|
|
|
flags |= PaintFrameFlags::PAINT_SYNC_DECODE_IMAGES;
|
2013-08-01 20:42:34 +00:00
|
|
|
}
|
2014-10-31 20:08:49 +00:00
|
|
|
nsRenderingContext context(aContext);
|
|
|
|
nsLayoutUtils::PaintFrame(&context, mFrame,
|
2010-08-13 13:32:27 +00:00
|
|
|
dirty, NS_RGBA(0, 0, 0, 0),
|
2016-04-25 16:26:40 +00:00
|
|
|
nsDisplayListBuilderMode::PAINTING,
|
2013-08-01 20:42:34 +00:00
|
|
|
flags);
|
2010-08-13 13:32:27 +00:00
|
|
|
|
2015-09-24 22:26:34 +00:00
|
|
|
nsIFrame* currentFrame = mFrame;
|
|
|
|
while ((currentFrame = currentFrame->GetNextContinuation()) != nullptr) {
|
|
|
|
offset = currentFrame->GetOffsetToCrossDoc(mFrame);
|
|
|
|
devPxOffset = gfxPoint(offset.x, offset.y) / appUnitsPerDevPixel;
|
|
|
|
|
|
|
|
aContext->Save();
|
|
|
|
aContext->Multiply(gfxMatrix::Scaling(1/scaleX, 1/scaleY));
|
|
|
|
aContext->Multiply(gfxMatrix::Translation(devPxOffset));
|
|
|
|
aContext->Multiply(gfxMatrix::Scaling(scaleX, scaleY));
|
|
|
|
|
|
|
|
nsLayoutUtils::PaintFrame(&context, currentFrame,
|
|
|
|
dirty - offset, NS_RGBA(0, 0, 0, 0),
|
2016-04-25 16:26:40 +00:00
|
|
|
nsDisplayListBuilderMode::PAINTING,
|
2015-09-24 22:26:34 +00:00
|
|
|
flags);
|
|
|
|
|
|
|
|
aContext->Restore();
|
|
|
|
}
|
|
|
|
|
2010-08-13 13:32:27 +00:00
|
|
|
aContext->Restore();
|
|
|
|
|
|
|
|
mFrame->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-08-13 13:32:27 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 03:36:42 +00:00
|
|
|
/* static */ already_AddRefed<gfxDrawable>
|
|
|
|
nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame,
|
|
|
|
nsIFrame* aTarget,
|
|
|
|
const nsSize& aPaintServerSize,
|
2015-09-23 18:49:05 +00:00
|
|
|
const IntSize& aRenderSize,
|
2014-09-29 13:15:19 +00:00
|
|
|
const DrawTarget* aDrawTarget,
|
2014-01-31 03:36:42 +00:00
|
|
|
const gfxMatrix& aContextMatrix,
|
|
|
|
uint32_t aFlags)
|
2010-08-13 13:32:27 +00:00
|
|
|
{
|
|
|
|
// aPaintServerSize is the size that would be filled when using
|
|
|
|
// background-repeat:no-repeat and background-size:auto. For normal background
|
|
|
|
// images, this would be the intrinsic size of the image; for gradients and
|
|
|
|
// patterns this would be the whole target frame fill area.
|
|
|
|
// aRenderSize is what we will be actually filling after accounting for
|
|
|
|
// background-size.
|
|
|
|
if (aFrame->IsFrameOfType(nsIFrame::eSVGPaintServer)) {
|
|
|
|
// aFrame is either a pattern or a gradient. These fill the whole target
|
|
|
|
// frame by default, so aPaintServerSize is the whole target background fill
|
|
|
|
// area.
|
|
|
|
nsSVGPaintServerFrame* server =
|
|
|
|
static_cast<nsSVGPaintServerFrame*>(aFrame);
|
|
|
|
|
|
|
|
gfxRect overrideBounds(0, 0,
|
|
|
|
aPaintServerSize.width, aPaintServerSize.height);
|
|
|
|
overrideBounds.ScaleInverse(aFrame->PresContext()->AppUnitsPerDevPixel());
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxPattern> pattern =
|
2014-09-29 13:15:19 +00:00
|
|
|
server->GetPaintServerPattern(aTarget, aDrawTarget,
|
|
|
|
aContextMatrix, &nsStyleSVG::mFill, 1.0,
|
|
|
|
&overrideBounds);
|
2010-08-13 13:32:27 +00:00
|
|
|
|
2010-09-06 03:12:46 +00:00
|
|
|
if (!pattern)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-09-06 03:12:46 +00:00
|
|
|
|
2010-08-13 13:32:27 +00:00
|
|
|
// pattern is now set up to fill aPaintServerSize. But we want it to
|
|
|
|
// fill aRenderSize, so we need to add a scaling transform.
|
|
|
|
// We couldn't just have set overrideBounds to aRenderSize - it would have
|
|
|
|
// worked for gradients, but for patterns it would result in a different
|
|
|
|
// pattern size.
|
|
|
|
gfxFloat scaleX = overrideBounds.Width() / aRenderSize.width;
|
|
|
|
gfxFloat scaleY = overrideBounds.Height() / aRenderSize.height;
|
2014-07-11 07:07:07 +00:00
|
|
|
gfxMatrix scaleMatrix = gfxMatrix::Scaling(scaleX, scaleY);
|
|
|
|
pattern->SetMatrix(scaleMatrix * pattern->GetMatrix());
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxDrawable> drawable =
|
2010-08-13 13:32:27 +00:00
|
|
|
new gfxPatternDrawable(pattern, aRenderSize);
|
|
|
|
return drawable.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't want to paint into a surface as long as we don't need to, so we
|
|
|
|
// set up a drawing callback.
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxDrawingCallback> cb =
|
2013-08-01 20:42:34 +00:00
|
|
|
new PaintFrameCallback(aFrame, aPaintServerSize, aRenderSize, aFlags);
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxDrawable> drawable = new gfxCallbackDrawable(cb, aRenderSize);
|
2010-08-13 13:32:27 +00:00
|
|
|
return drawable.forget();
|
|
|
|
}
|