Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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/. */
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Main header first:
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
#include "nsSVGPathGeometryFrame.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Keep others in (case-insensitive) order:
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxPlatform.h"
|
2012-09-06 08:58:46 +04:00
|
|
|
#include "gfxSVGGlyphs.h"
|
2012-07-20 22:12:29 +04:00
|
|
|
#include "nsDisplayList.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2008-10-10 17:14:05 +04:00
|
|
|
#include "nsSVGEffects.h"
|
2012-06-30 15:20:46 +04:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsSVGMarkerFrame.h"
|
2006-06-21 19:42:28 +04:00
|
|
|
#include "nsSVGPathGeometryElement.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2014-01-30 22:26:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2012-05-17 08:05:09 +04:00
|
|
|
#include "SVGAnimatedTransformList.h"
|
2013-01-03 10:17:03 +04:00
|
|
|
#include "SVGGraphicsElement.h"
|
2012-05-17 08:05:09 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-12-31 01:42:32 +04:00
|
|
|
using namespace mozilla::gfx;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2006-06-21 19:42:28 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGPathGeometryFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGPathGeometryFrame)
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
2009-01-12 22:20:59 +03:00
|
|
|
// nsQueryFrame methods
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGPathGeometryFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGChildFrame)
|
2013-01-04 08:26:00 +04:00
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGPathGeometryFrame)
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGPathGeometryFrameBase)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2012-07-20 22:12:29 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Display list item:
|
|
|
|
|
|
|
|
class nsDisplaySVGPathGeometry : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
nsDisplaySVGPathGeometry(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsSVGPathGeometryFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplaySVGPathGeometry);
|
|
|
|
NS_ABORT_IF_FALSE(aFrame, "Must have a frame!");
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySVGPathGeometry() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplaySVGPathGeometry);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplaySVGPathGeometry", TYPE_SVG_PATH_GEOMETRY)
|
|
|
|
|
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext* aCtx);
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplaySVGPathGeometry::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
|
|
{
|
|
|
|
nsSVGPathGeometryFrame *frame = static_cast<nsSVGPathGeometryFrame*>(mFrame);
|
|
|
|
nsPoint pointRelativeToReferenceFrame = aRect.Center();
|
|
|
|
// ToReferenceFrame() includes frame->GetPosition(), our user space position.
|
|
|
|
nsPoint userSpacePt = pointRelativeToReferenceFrame -
|
|
|
|
(ToReferenceFrame() - frame->GetPosition());
|
|
|
|
if (frame->GetFrameForPoint(userSpacePt)) {
|
|
|
|
aOutFrames->AppendElement(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplaySVGPathGeometry::Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext* aCtx)
|
|
|
|
{
|
|
|
|
// ToReferenceFrame includes our mRect offset, but painting takes
|
|
|
|
// account of that too. To avoid double counting, we subtract that
|
|
|
|
// here.
|
|
|
|
nsPoint offset = ToReferenceFrame() - mFrame->GetPosition();
|
|
|
|
|
|
|
|
aCtx->PushState();
|
|
|
|
aCtx->Translate(offset);
|
2012-07-30 18:20:58 +04:00
|
|
|
static_cast<nsSVGPathGeometryFrame*>(mFrame)->PaintSVG(aCtx, nullptr);
|
2012-07-20 22:12:29 +04:00
|
|
|
aCtx->PopState();
|
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2014-01-04 12:29:02 +04:00
|
|
|
void
|
|
|
|
nsSVGPathGeometryFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
AddStateBits(aParent->GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD);
|
|
|
|
nsSVGPathGeometryFrameBase::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGPathGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2013-05-23 11:04:21 +04:00
|
|
|
// We don't invalidate for transform changes (the layers code does that).
|
|
|
|
// Also note that SVGTransformableElement::GetAttributeChangeHint will
|
|
|
|
// return nsChangeHint_UpdateOverflow for "transform" attribute changes
|
|
|
|
// and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
|
|
|
|
|
2006-03-02 23:22:19 +03:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
2007-07-08 11:08:04 +04:00
|
|
|
(static_cast<nsSVGPathGeometryElement*>
|
2013-04-25 13:18:42 +04:00
|
|
|
(mContent)->AttributeDefinesGeometry(aAttribute))) {
|
|
|
|
nsSVGEffects::InvalidateRenderingObservers(this);
|
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
2012-11-28 13:42:13 +04:00
|
|
|
}
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-14 13:51:00 +04:00
|
|
|
/* virtual */ void
|
|
|
|
nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
|
|
|
nsSVGPathGeometryFrameBase::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
|
|
|
if (aOldStyleContext) {
|
|
|
|
float oldOpacity = aOldStyleContext->PeekStyleDisplay()->mOpacity;
|
|
|
|
float newOpacity = StyleDisplay()->mOpacity;
|
|
|
|
if (newOpacity != oldOpacity &&
|
|
|
|
nsSVGUtils::CanOptimizeOpacity(this)) {
|
|
|
|
// nsIFrame::BuildDisplayListForStackingContext() is not going to create an
|
|
|
|
// nsDisplayOpacity display list item, so DLBI won't invalidate for us.
|
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-01 23:56:08 +04:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGPathGeometryFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::svgPathGeometryFrame;
|
2005-04-01 23:56:08 +04:00
|
|
|
}
|
|
|
|
|
2012-05-17 08:05:09 +04:00
|
|
|
bool
|
2013-12-30 03:35:53 +04:00
|
|
|
nsSVGPathGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
|
|
|
|
gfx::Matrix *aFromParentTransform) const
|
2012-05-17 08:05:09 +04:00
|
|
|
{
|
|
|
|
bool foundTransform = false;
|
|
|
|
|
|
|
|
// Check if our parent has children-only transforms:
|
|
|
|
nsIFrame *parent = GetParent();
|
|
|
|
if (parent &&
|
|
|
|
parent->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer)) {
|
|
|
|
foundTransform = static_cast<nsSVGContainerFrame*>(parent)->
|
|
|
|
HasChildrenOnlyTransform(aFromParentTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList* transformList =
|
2013-04-14 11:17:36 +04:00
|
|
|
content->GetAnimatedTransformList();
|
|
|
|
if ((transformList && transformList->HasTransform()) ||
|
2012-07-09 21:41:12 +04:00
|
|
|
content->GetAnimateMotionTransform()) {
|
2012-05-17 08:05:09 +04:00
|
|
|
if (aOwnTransform) {
|
2013-12-30 03:35:53 +04:00
|
|
|
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
|
|
|
|
nsSVGElement::eUserSpaceToParent));
|
2012-05-17 08:05:09 +04:00
|
|
|
}
|
|
|
|
foundTransform = true;
|
|
|
|
}
|
|
|
|
return foundTransform;
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2012-07-20 22:12:29 +04:00
|
|
|
nsSVGPathGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!static_cast<const nsSVGElement*>(mContent)->HasValidDimensions()) {
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplaySVGPathGeometry(aBuilder, this));
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
|
|
|
|
2006-04-06 17:02:53 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
NS_IMETHODIMP
|
2012-03-02 12:28:59 +04:00
|
|
|
nsSVGPathGeometryFrame::PaintSVG(nsRenderingContext *aContext,
|
2013-09-11 11:27:45 +04:00
|
|
|
const nsIntRect *aDirtyRect,
|
|
|
|
nsIFrame* aTransformRoot)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
if (!StyleVisibility()->IsVisible())
|
2004-10-04 22:56:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
uint32_t paintOrder = StyleSVG()->mPaintOrder;
|
2013-01-13 03:27:53 +04:00
|
|
|
if (paintOrder == NS_STYLE_PAINT_ORDER_NORMAL) {
|
2013-09-11 11:27:45 +04:00
|
|
|
Render(aContext, eRenderFill | eRenderStroke, aTransformRoot);
|
2013-01-13 03:27:53 +04:00
|
|
|
PaintMarkers(aContext);
|
|
|
|
} else {
|
|
|
|
while (paintOrder) {
|
|
|
|
uint32_t component =
|
|
|
|
paintOrder & ((1 << NS_STYLE_PAINT_ORDER_BITWIDTH) - 1);
|
|
|
|
switch (component) {
|
|
|
|
case NS_STYLE_PAINT_ORDER_FILL:
|
2013-09-11 11:27:45 +04:00
|
|
|
Render(aContext, eRenderFill, aTransformRoot);
|
2013-01-13 03:27:53 +04:00
|
|
|
break;
|
|
|
|
case NS_STYLE_PAINT_ORDER_STROKE:
|
2013-09-11 11:27:45 +04:00
|
|
|
Render(aContext, eRenderStroke, aTransformRoot);
|
2013-01-13 03:27:53 +04:00
|
|
|
break;
|
|
|
|
case NS_STYLE_PAINT_ORDER_MARKERS:
|
|
|
|
PaintMarkers(aContext);
|
|
|
|
break;
|
2007-04-10 14:19:59 +04:00
|
|
|
}
|
2013-01-13 03:27:53 +04:00
|
|
|
paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH;
|
2005-04-06 23:02:13 +04:00
|
|
|
}
|
2004-12-09 06:16:15 +03:00
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-25 13:23:54 +04:00
|
|
|
NS_IMETHODIMP_(nsIFrame*)
|
|
|
|
nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2012-06-30 15:20:46 +04:00
|
|
|
gfxMatrix canvasTM = GetCanvasTM(FOR_HIT_TESTING);
|
2012-07-20 22:12:29 +04:00
|
|
|
if (canvasTM.IsSingular()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t fillRule, hitTestFlags;
|
2010-12-06 23:57:18 +03:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
|
2011-07-08 17:20:14 +04:00
|
|
|
hitTestFlags = SVG_HIT_TEST_FILL;
|
2014-01-04 12:29:02 +04:00
|
|
|
fillRule = StyleSVG()->mClipRule;
|
2007-12-04 08:11:49 +03:00
|
|
|
} else {
|
2011-07-08 17:20:14 +04:00
|
|
|
hitTestFlags = GetHitTestFlags();
|
2012-02-10 16:33:46 +04:00
|
|
|
// XXX once bug 614732 is fixed, aPoint won't need any conversion in order
|
|
|
|
// to compare it with mRect.
|
|
|
|
nsPoint point =
|
|
|
|
nsSVGUtils::TransformOuterSVGPointToChildFrame(aPoint, canvasTM, PresContext());
|
2011-07-08 17:20:14 +04:00
|
|
|
if (!hitTestFlags || ((hitTestFlags & SVG_HIT_TEST_CHECK_MRECT) &&
|
2012-02-10 16:33:46 +04:00
|
|
|
!mRect.Contains(point)))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2013-02-17 01:51:02 +04:00
|
|
|
fillRule = StyleSVG()->mFillRule;
|
2007-12-04 08:11:49 +03:00
|
|
|
}
|
2006-06-09 22:08:33 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHit = false;
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2013-12-06 13:59:36 +04:00
|
|
|
nsRefPtr<gfxContext> tmpCtx =
|
|
|
|
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2013-12-31 01:42:32 +04:00
|
|
|
GeneratePath(tmpCtx, ToMatrix(canvasTM));
|
2008-08-25 13:23:54 +04:00
|
|
|
gfxPoint userSpacePoint =
|
2012-06-15 07:02:29 +04:00
|
|
|
tmpCtx->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
|
|
|
|
PresContext()->AppUnitsToGfxUnits(aPoint.y)));
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2006-08-07 20:41:58 +04:00
|
|
|
if (fillRule == NS_STYLE_FILL_RULE_EVENODD)
|
2012-06-15 07:02:29 +04:00
|
|
|
tmpCtx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
|
2006-08-07 20:41:58 +04:00
|
|
|
else
|
2012-06-15 07:02:29 +04:00
|
|
|
tmpCtx->SetFillRule(gfxContext::FILL_RULE_WINDING);
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2011-07-08 17:20:14 +04:00
|
|
|
if (hitTestFlags & SVG_HIT_TEST_FILL)
|
2012-06-15 07:02:29 +04:00
|
|
|
isHit = tmpCtx->PointInFill(userSpacePoint);
|
2011-07-08 17:20:14 +04:00
|
|
|
if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) {
|
2013-06-25 10:05:32 +04:00
|
|
|
nsSVGUtils::SetupCairoStrokeGeometry(this, tmpCtx);
|
2013-06-26 16:31:06 +04:00
|
|
|
// tmpCtx's matrix may have transformed by SetupCairoStrokeGeometry
|
|
|
|
// if there is a non-scaling stroke. We need to transform userSpacePoint
|
|
|
|
// so that everything is using the same co-ordinate system.
|
|
|
|
userSpacePoint =
|
|
|
|
nsSVGUtils::GetStrokeTransform(this).Invert().Transform(userSpacePoint);
|
2012-06-15 07:02:29 +04:00
|
|
|
isHit = tmpCtx->PointInStroke(userSpacePoint);
|
2006-08-07 20:41:58 +04:00
|
|
|
}
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2008-08-25 13:23:54 +04:00
|
|
|
if (isHit && nsSVGUtils::HitTestClip(this, aPoint))
|
|
|
|
return this;
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2006-06-09 22:08:33 +04:00
|
|
|
NS_IMETHODIMP_(nsRect)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
nsSVGPathGeometryFrame::GetCoveredRegion()
|
|
|
|
{
|
2012-07-23 15:00:40 +04:00
|
|
|
return nsSVGUtils::TransformFrameRectToOuterSVG(
|
|
|
|
mRect, GetCanvasTM(FOR_OUTERSVG_TM), PresContext());
|
2006-06-09 22:08:33 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
void
|
2012-07-22 04:01:44 +04:00
|
|
|
nsSVGPathGeometryFrame::ReflowSVG()
|
2006-06-09 22:08:33 +04:00
|
|
|
{
|
2012-07-22 04:01:44 +04:00
|
|
|
NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this),
|
|
|
|
"This call is probably a wasteful mistake");
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2013-07-12 11:13:07 +04:00
|
|
|
NS_ABORT_IF_FALSE(!(GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
2012-07-22 04:01:44 +04:00
|
|
|
"ReflowSVG mechanism not designed for this");
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2012-07-22 04:01:44 +04:00
|
|
|
if (!nsSVGUtils::NeedsReflowSVG(this)) {
|
2012-03-20 16:15:53 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags = nsSVGUtils::eBBoxIncludeFill |
|
2012-07-09 15:55:16 +04:00
|
|
|
nsSVGUtils::eBBoxIncludeStroke |
|
|
|
|
nsSVGUtils::eBBoxIncludeMarkers;
|
2012-07-11 15:25:27 +04:00
|
|
|
// Our "visual" overflow rect needs to be valid for building display lists
|
|
|
|
// for hit testing, which means that for certain values of 'pointer-events'
|
|
|
|
// it needs to include the geometry of the fill or stroke even when the fill/
|
|
|
|
// stroke don't actually render (e.g. when stroke="none" or
|
|
|
|
// stroke-opacity="0"). GetHitTestFlags() accounts for 'pointer-events'.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t hitTestFlags = GetHitTestFlags();
|
2012-07-11 15:25:27 +04:00
|
|
|
if ((hitTestFlags & SVG_HIT_TEST_FILL)) {
|
|
|
|
flags |= nsSVGUtils::eBBoxIncludeFillGeometry;
|
|
|
|
}
|
|
|
|
if ((hitTestFlags & SVG_HIT_TEST_STROKE)) {
|
|
|
|
flags |= nsSVGUtils::eBBoxIncludeStrokeGeometry;
|
2012-07-09 15:55:16 +04:00
|
|
|
}
|
2012-12-20 17:49:54 +04:00
|
|
|
|
|
|
|
// We'd like to just pass the identity matrix to GetBBoxContribution, but if
|
|
|
|
// this frame's user space size is _very_ large/small then the extents we
|
|
|
|
// obtain below might have overflowed or otherwise be broken. This would
|
|
|
|
// cause us to end up with a broken mRect and visual overflow rect and break
|
|
|
|
// painting of this frame. This is particularly noticeable if the transforms
|
|
|
|
// between us and our nsSVGOuterSVGFrame scale this frame to a reasonable
|
|
|
|
// size. To avoid this we sadly have to do extra work to account for the
|
|
|
|
// transforms between us and our nsSVGOuterSVGFrame, even though the
|
|
|
|
// overwhelming number of SVGs will never have this problem.
|
|
|
|
// XXX Will Azure eventually save us from having to do this?
|
|
|
|
gfxSize scaleFactors = GetCanvasTM(FOR_OUTERSVG_TM).ScaleFactors(true);
|
|
|
|
bool applyScaling = fabs(scaleFactors.width) >= 1e-6 &&
|
|
|
|
fabs(scaleFactors.height) >= 1e-6;
|
2013-12-30 10:50:07 +04:00
|
|
|
gfx::Matrix scaling;
|
2012-12-20 17:49:54 +04:00
|
|
|
if (applyScaling) {
|
|
|
|
scaling.Scale(scaleFactors.width, scaleFactors.height);
|
|
|
|
}
|
2013-11-01 15:04:01 +04:00
|
|
|
gfxRect extent = GetBBoxContribution(scaling, flags).ToThebesRect();
|
2012-12-20 17:49:54 +04:00
|
|
|
if (applyScaling) {
|
|
|
|
extent.Scale(1 / scaleFactors.width, 1 / scaleFactors.height);
|
|
|
|
}
|
2012-02-10 16:33:18 +04:00
|
|
|
mRect = nsLayoutUtils::RoundGfxRectToAppRect(extent,
|
2012-02-17 10:07:51 +04:00
|
|
|
PresContext()->AppUnitsPerCSSPixel());
|
2012-02-10 16:33:49 +04:00
|
|
|
|
2012-05-17 08:05:09 +04:00
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// Make sure we have our filter property (if any) before calling
|
|
|
|
// FinishAndStoreOverflow (subsequent filter changes are handled off
|
|
|
|
// nsChangeHint_UpdateEffects):
|
|
|
|
nsSVGEffects::UpdateEffects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect overflow = nsRect(nsPoint(0,0), mRect.Size());
|
|
|
|
nsOverflowAreas overflowAreas(overflow, overflow);
|
|
|
|
FinishAndStoreOverflow(overflowAreas, mRect.Size());
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2012-11-28 14:34:58 +04:00
|
|
|
// Invalidate, but only if this is not our first reflow (since if it is our
|
|
|
|
// first reflow then we haven't had our first paint yet).
|
|
|
|
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
|
|
|
InvalidateFrame();
|
2012-03-20 16:15:53 +04:00
|
|
|
}
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGPathGeometryFrame::NotifySVGChanged(uint32_t aFlags)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2012-03-11 19:53:36 +04:00
|
|
|
NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
|
|
|
|
2013-05-08 21:13:11 +04:00
|
|
|
// Changes to our ancestors may affect how we render when we are rendered as
|
|
|
|
// part of our ancestor (specifically, if our coordinate context changes size
|
|
|
|
// and we have percentage lengths defining our geometry, then we need to be
|
|
|
|
// reflowed). However, ancestor changes cannot affect how we render when we
|
|
|
|
// are rendered as part of any rendering observers that we may have.
|
|
|
|
// Therefore no need to notify rendering observers here.
|
|
|
|
|
2013-05-23 18:30:14 +04:00
|
|
|
// Don't try to be too smart trying to avoid the ScheduleReflowSVG calls
|
|
|
|
// for the stroke properties examined below. Checking HasStroke() is not
|
|
|
|
// enough, since what we care about is whether we include the stroke in our
|
|
|
|
// overflow rects or not, and we sometimes deliberately include stroke
|
|
|
|
// when it's not visible. See the complexities of GetBBoxContribution.
|
|
|
|
|
|
|
|
if (aFlags & COORD_CONTEXT_CHANGED) {
|
|
|
|
// Stroke currently contributes to our mRect, which is why we have to take
|
|
|
|
// account of stroke-width here. Note that we do not need to take account
|
|
|
|
// 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() ||
|
|
|
|
StyleSVG()->mStrokeWidth.HasPercent()) {
|
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
|
|
|
}
|
2013-05-08 21:13:11 +04:00
|
|
|
}
|
2013-05-23 18:30:14 +04:00
|
|
|
|
|
|
|
if ((aFlags & TRANSFORM_CHANGED) &&
|
|
|
|
StyleSVGReset()->mVectorEffect ==
|
|
|
|
NS_STYLE_VECTOR_EFFECT_NON_SCALING_STROKE) {
|
|
|
|
// Stroke currently contributes to our mRect, and our stroke depends on
|
|
|
|
// the transform to our outer-<svg> if |vector-effect:non-scaling-stroke|.
|
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
|
|
|
}
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2012-04-16 12:23:48 +04:00
|
|
|
SVGBBox
|
2013-12-30 10:50:07 +04:00
|
|
|
nsSVGPathGeometryFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2012-04-16 12:23:48 +04:00
|
|
|
SVGBBox bbox;
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
if (aToBBoxUserspace.IsSingular()) {
|
|
|
|
// XXX ReportToConsole
|
2012-04-16 12:23:48 +04:00
|
|
|
return bbox;
|
2009-04-29 08:31:34 +04:00
|
|
|
}
|
2011-09-30 13:25:37 +04:00
|
|
|
|
2013-12-06 13:59:36 +04:00
|
|
|
nsRefPtr<gfxContext> tmpCtx =
|
|
|
|
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
2011-09-30 13:25:37 +04:00
|
|
|
|
2013-12-31 01:42:32 +04:00
|
|
|
GeneratePath(tmpCtx, aToBBoxUserspace);
|
2012-06-15 07:02:29 +04:00
|
|
|
tmpCtx->IdentityMatrix();
|
2011-09-30 13:25:37 +04:00
|
|
|
|
|
|
|
// Be careful when replacing the following logic to get the fill and stroke
|
|
|
|
// extents independently (instead of computing the stroke extents from the
|
|
|
|
// path extents). You may think that you can just use the stroke extents if
|
|
|
|
// there is both a fill and a stroke. In reality it's necessary to calculate
|
|
|
|
// both the fill and stroke extents, and take the union of the two. There are
|
|
|
|
// two reasons for this:
|
|
|
|
//
|
|
|
|
// # Due to stroke dashing, in certain cases the fill extents could actually
|
|
|
|
// extend outside the stroke extents.
|
|
|
|
// # If the stroke is very thin, cairo won't paint any stroke, and so the
|
|
|
|
// stroke bounds that it will return will be empty.
|
|
|
|
|
2012-06-15 07:02:29 +04:00
|
|
|
gfxRect pathExtents = tmpCtx->GetUserPathExtent();
|
2011-09-30 13:25:37 +04:00
|
|
|
|
|
|
|
// Account for fill:
|
2012-07-11 15:25:27 +04:00
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeFillGeometry) ||
|
|
|
|
((aFlags & nsSVGUtils::eBBoxIncludeFill) &&
|
2013-02-17 01:51:02 +04:00
|
|
|
StyleSVG()->mFill.mType != eStyleSVGPaintType_None)) {
|
2011-09-30 13:25:37 +04:00
|
|
|
bbox = pathExtents;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Account for stroke:
|
2012-07-11 15:25:27 +04:00
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeStrokeGeometry) ||
|
2012-08-10 15:13:43 +04:00
|
|
|
((aFlags & nsSVGUtils::eBBoxIncludeStroke) &&
|
|
|
|
nsSVGUtils::HasStroke(this))) {
|
2012-06-15 07:02:29 +04:00
|
|
|
// We can't use tmpCtx->GetUserStrokeExtent() since it doesn't work for
|
2011-09-30 13:25:37 +04:00
|
|
|
// device space extents. Instead we approximate the stroke extents from
|
|
|
|
// pathExtents using PathExtentsToMaxStrokeExtents.
|
|
|
|
if (pathExtents.Width() <= 0 && pathExtents.Height() <= 0) {
|
|
|
|
// We have a zero length path, but it may still have non-empty stroke
|
|
|
|
// bounds depending on the value of stroke-linecap. We need to fix up
|
|
|
|
// pathExtents before it can be used with PathExtentsToMaxStrokeExtents
|
|
|
|
// though, because if pathExtents is empty, its position will not have
|
2012-06-15 07:02:29 +04:00
|
|
|
// been set. Happily we can use tmpCtx->GetUserStrokeExtent() to find
|
2011-09-30 13:25:37 +04:00
|
|
|
// the center point of the extents even though it gets the extents wrong.
|
2013-06-25 10:05:31 +04:00
|
|
|
nsSVGUtils::SetupCairoStrokeBBoxGeometry(this, tmpCtx);
|
2012-06-15 07:02:29 +04:00
|
|
|
pathExtents.MoveTo(tmpCtx->GetUserStrokeExtent().Center());
|
2011-09-30 13:25:37 +04:00
|
|
|
pathExtents.SizeTo(0, 0);
|
|
|
|
}
|
2012-04-16 12:23:48 +04:00
|
|
|
bbox.UnionEdges(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents,
|
|
|
|
this,
|
2013-12-30 10:50:07 +04:00
|
|
|
ThebesMatrix(aToBBoxUserspace)));
|
2011-09-30 13:25:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Account for markers:
|
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeMarkers) != 0 &&
|
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
|
|
|
|
|
2012-08-10 15:13:43 +04:00
|
|
|
float strokeWidth = nsSVGUtils::GetStrokeWidth(this);
|
2011-09-30 13:25:37 +04:00
|
|
|
MarkerProperties properties = GetMarkerProperties(this);
|
|
|
|
|
|
|
|
if (properties.MarkersExist()) {
|
|
|
|
nsTArray<nsSVGMark> marks;
|
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->GetMarkPoints(&marks);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t num = marks.Length();
|
2011-09-30 13:25:37 +04:00
|
|
|
|
2013-07-12 10:39:38 +04:00
|
|
|
// These are in the same order as the nsSVGMark::Type constants.
|
|
|
|
nsSVGMarkerFrame* markerFrames[] = {
|
|
|
|
properties.GetMarkerStartFrame(),
|
|
|
|
properties.GetMarkerMidFrame(),
|
|
|
|
properties.GetMarkerEndFrame(),
|
|
|
|
};
|
2014-01-30 22:26:54 +04:00
|
|
|
PR_STATIC_ASSERT(MOZ_ARRAY_LENGTH(markerFrames) == nsSVGMark::eTypeCount);
|
2013-07-12 10:39:38 +04:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < num; i++) {
|
|
|
|
nsSVGMark& mark = marks[i];
|
|
|
|
nsSVGMarkerFrame* frame = markerFrames[mark.type];
|
2011-09-30 13:25:37 +04:00
|
|
|
if (frame) {
|
2012-04-16 12:23:48 +04:00
|
|
|
SVGBBox mbbox =
|
2011-09-30 13:25:37 +04:00
|
|
|
frame->GetMarkBBoxContribution(aToBBoxUserspace, aFlags, this,
|
2013-07-12 10:39:38 +04:00
|
|
|
&marks[i], strokeWidth);
|
2012-04-16 12:23:48 +04:00
|
|
|
bbox.UnionEdges(mbbox);
|
2011-09-30 13:25:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bbox;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2014-01-04 12:29:02 +04:00
|
|
|
// nsSVGPathGeometryFrame methods:
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
gfxMatrix
|
2013-09-11 11:27:45 +04:00
|
|
|
nsSVGPathGeometryFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2013-09-11 11:27:45 +04:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) {
|
2012-06-30 15:20:46 +04:00
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
NS_ASSERTION(mParent, "null parent");
|
2004-08-05 13:01:13 +04:00
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
2013-01-03 10:17:03 +04:00
|
|
|
dom::SVGGraphicsElement *content = static_cast<dom::SVGGraphicsElement*>(mContent);
|
2006-04-20 19:24:51 +04:00
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
return content->PrependLocalTransformsTo(
|
|
|
|
this == aTransformRoot ? gfxMatrix() :
|
|
|
|
parent->GetCanvasTM(aFor, aTransformRoot));
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2008-10-10 17:14:05 +04:00
|
|
|
nsSVGPathGeometryFrame::MarkerProperties
|
|
|
|
nsSVGPathGeometryFrame::GetMarkerProperties(nsSVGPathGeometryFrame *aFrame)
|
2007-07-24 13:05:37 +04:00
|
|
|
{
|
2008-10-10 17:14:05 +04:00
|
|
|
NS_ASSERTION(!aFrame->GetPrevContinuation(), "aFrame should be first continuation");
|
2007-07-24 13:05:37 +04:00
|
|
|
|
2008-10-10 17:14:05 +04:00
|
|
|
MarkerProperties result;
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleSVG *style = aFrame->StyleSVG();
|
2010-03-29 05:46:55 +04:00
|
|
|
result.mMarkerStart =
|
|
|
|
nsSVGEffects::GetMarkerProperty(style->mMarkerStart, aFrame,
|
|
|
|
nsSVGEffects::MarkerBeginProperty());
|
|
|
|
result.mMarkerMid =
|
|
|
|
nsSVGEffects::GetMarkerProperty(style->mMarkerMid, aFrame,
|
|
|
|
nsSVGEffects::MarkerMiddleProperty());
|
|
|
|
result.mMarkerEnd =
|
|
|
|
nsSVGEffects::GetMarkerProperty(style->mMarkerEnd, aFrame,
|
|
|
|
nsSVGEffects::MarkerEndProperty());
|
2008-10-10 17:14:05 +04:00
|
|
|
return result;
|
2007-07-24 13:05:37 +04:00
|
|
|
}
|
|
|
|
|
2008-10-10 17:14:05 +04:00
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerStartFrame()
|
2007-07-24 13:05:37 +04:00
|
|
|
{
|
2008-10-10 17:14:05 +04:00
|
|
|
if (!mMarkerStart)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-10-10 17:14:05 +04:00
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
2012-07-30 18:20:58 +04:00
|
|
|
(mMarkerStart->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nullptr));
|
2007-07-24 13:05:37 +04:00
|
|
|
}
|
|
|
|
|
2008-10-10 17:14:05 +04:00
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerMidFrame()
|
2007-07-24 13:05:37 +04:00
|
|
|
{
|
2008-10-10 17:14:05 +04:00
|
|
|
if (!mMarkerMid)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-10-10 17:14:05 +04:00
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
2012-07-30 18:20:58 +04:00
|
|
|
(mMarkerMid->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nullptr));
|
2008-10-10 17:14:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerEndFrame()
|
|
|
|
{
|
|
|
|
if (!mMarkerEnd)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-10-10 17:14:05 +04:00
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
2012-07-30 18:20:58 +04:00
|
|
|
(mMarkerEnd->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nullptr));
|
2007-07-24 13:05:37 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:01:09 +04:00
|
|
|
void
|
2013-01-13 03:27:53 +04:00
|
|
|
nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
|
2013-09-11 11:27:45 +04:00
|
|
|
uint32_t aRenderComponents,
|
|
|
|
nsIFrame* aTransformRoot)
|
2006-06-20 21:01:09 +04:00
|
|
|
{
|
2012-03-02 12:28:59 +04:00
|
|
|
gfxContext *gfx = aContext->ThebesContext();
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t renderMode = SVGAutoRenderState::GetRenderMode(aContext);
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
switch (StyleSVG()->mShapeRendering) {
|
2009-04-24 17:11:03 +04:00
|
|
|
case NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED:
|
|
|
|
case NS_STYLE_SHAPE_RENDERING_CRISPEDGES:
|
|
|
|
gfx->SetAntialiasMode(gfxContext::MODE_ALIASED);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gfx->SetAntialiasMode(gfxContext::MODE_COVERAGE);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2012-03-02 12:28:59 +04:00
|
|
|
if (renderMode != SVGAutoRenderState::NORMAL) {
|
2012-06-15 13:06:34 +04:00
|
|
|
NS_ABORT_IF_FALSE(renderMode == SVGAutoRenderState::CLIP ||
|
|
|
|
renderMode == SVGAutoRenderState::CLIP_MASK,
|
|
|
|
"Unknown render mode");
|
2013-10-23 01:45:51 +04:00
|
|
|
|
|
|
|
// In the case that |renderMode == SVGAutoRenderState::CLIP| then we don't
|
|
|
|
// use the path we generate here until further up the call stack when
|
|
|
|
// nsSVGClipPathFrame::Clip calls gfxContext::Clip. That's a problem for
|
|
|
|
// Moz2D which emits paths in user space (unlike cairo which emits paths in
|
|
|
|
// device space). gfxContext has hacks to deal with code changing the
|
|
|
|
// transform then using the current path when it is backed by Moz2D, but
|
|
|
|
// Moz2D itself does not since that would fundamentally go against its API.
|
|
|
|
// Therefore we do not want to Save()/Restore() the gfxContext here in the
|
|
|
|
// SVGAutoRenderState::CLIP case since that would block us from killing off
|
|
|
|
// gfxContext and using Moz2D directly. Not bothering to Save()/Restore()
|
|
|
|
// is actually okay, since we know that doesn't matter in the
|
|
|
|
// SVGAutoRenderState::CLIP case (at least for the current implementation).
|
|
|
|
gfxContextMatrixAutoSaveRestore autoSaveRestore;
|
|
|
|
if (renderMode != SVGAutoRenderState::CLIP) {
|
|
|
|
autoSaveRestore.SetContext(gfx);
|
|
|
|
}
|
|
|
|
|
2013-12-31 01:42:32 +04:00
|
|
|
GeneratePath(gfx, ToMatrix(GetCanvasTM(FOR_PAINTING, aTransformRoot)));
|
2013-10-23 01:45:51 +04:00
|
|
|
|
|
|
|
// We used to call gfx->Restore() here, since for the
|
|
|
|
// SVGAutoRenderState::CLIP case it is important to leave the fill rule
|
|
|
|
// that we set below untouched so that the value is still set when return
|
|
|
|
// to gfxContext::Clip() further up the call stack. Since we no longer
|
|
|
|
// call gfx->Save() in the SVGAutoRenderState::CLIP case we don't need to
|
|
|
|
// worry that autoSaveRestore will delay the Restore() call for the
|
|
|
|
// CLIP_MASK case until we exit this function.
|
|
|
|
|
|
|
|
gfxContext::FillRule oldFillRull = gfx->CurrentFillRule();
|
2009-10-30 23:21:49 +03:00
|
|
|
|
2014-01-04 12:29:02 +04:00
|
|
|
if (StyleSVG()->mClipRule == NS_STYLE_FILL_RULE_EVENODD)
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
|
2006-06-20 21:01:09 +04:00
|
|
|
else
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->SetFillRule(gfxContext::FILL_RULE_WINDING);
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2012-03-02 12:28:59 +04:00
|
|
|
if (renderMode == SVGAutoRenderState::CLIP_MASK) {
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
gfx->Fill();
|
2013-10-23 01:45:51 +04:00
|
|
|
gfx->SetFillRule(oldFillRull); // restore, but only for CLIP_MASK
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->NewPath();
|
2006-06-20 21:01:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-23 01:45:51 +04:00
|
|
|
gfxContextAutoSaveRestore autoSaveRestore(gfx);
|
|
|
|
|
2013-12-31 01:42:32 +04:00
|
|
|
GeneratePath(gfx, ToMatrix(GetCanvasTM(FOR_PAINTING, aTransformRoot)));
|
2013-10-23 01:45:51 +04:00
|
|
|
|
2013-05-16 06:35:12 +04:00
|
|
|
gfxTextContextPaint *contextPaint =
|
|
|
|
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
|
2012-09-06 08:58:46 +04:00
|
|
|
|
2013-01-13 03:27:53 +04:00
|
|
|
if ((aRenderComponents & eRenderFill) &&
|
2013-05-16 06:35:12 +04:00
|
|
|
nsSVGUtils::SetupCairoFillPaint(this, gfx, contextPaint)) {
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->Fill();
|
2006-06-20 21:01:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-13 03:27:53 +04:00
|
|
|
if ((aRenderComponents & eRenderStroke) &&
|
2013-05-16 06:35:12 +04:00
|
|
|
nsSVGUtils::SetupCairoStroke(this, gfx, contextPaint)) {
|
2013-01-12 02:08:37 +04:00
|
|
|
gfx->Stroke();
|
2006-06-20 21:01:09 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:05:42 +03:00
|
|
|
gfx->NewPath();
|
2006-06-20 21:01:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-04-29 08:31:34 +04:00
|
|
|
nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext,
|
2013-12-31 01:42:32 +04:00
|
|
|
const Matrix &aTransform)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2012-06-25 00:12:40 +04:00
|
|
|
if (aTransform.IsSingular()) {
|
2007-01-31 19:05:42 +03:00
|
|
|
aContext->IdentityMatrix();
|
|
|
|
aContext->NewPath();
|
2006-06-20 21:01:09 +04:00
|
|
|
return;
|
|
|
|
}
|
2007-01-31 19:05:42 +03:00
|
|
|
|
2013-12-31 01:42:32 +04:00
|
|
|
aContext->MultiplyAndNudgeToIntegers(ThebesMatrix(aTransform));
|
2006-06-20 21:01:09 +04:00
|
|
|
|
2011-04-20 13:16:02 +04:00
|
|
|
// Hack to let SVGPathData::ConstructPath know if we have square caps:
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleSVG* style = StyleSVG();
|
2011-04-20 13:16:02 +04:00
|
|
|
if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) {
|
|
|
|
aContext->SetLineCap(gfxContext::LINE_CAP_SQUARE);
|
|
|
|
}
|
|
|
|
|
2007-01-31 19:05:42 +03:00
|
|
|
aContext->NewPath();
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->ConstructPath(aContext);
|
2006-06-20 21:01:09 +04:00
|
|
|
}
|
2013-01-13 03:27:53 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGPathGeometryFrame::PaintMarkers(nsRenderingContext* aContext)
|
|
|
|
{
|
2013-05-16 06:35:12 +04:00
|
|
|
gfxTextContextPaint *contextPaint =
|
|
|
|
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
|
2013-01-13 03:27:53 +04:00
|
|
|
|
|
|
|
if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
|
|
|
|
MarkerProperties properties = GetMarkerProperties(this);
|
|
|
|
|
|
|
|
if (properties.MarkersExist()) {
|
2013-05-16 06:35:12 +04:00
|
|
|
float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint);
|
2013-01-13 03:27:53 +04:00
|
|
|
|
|
|
|
nsTArray<nsSVGMark> marks;
|
|
|
|
static_cast<nsSVGPathGeometryElement*>
|
|
|
|
(mContent)->GetMarkPoints(&marks);
|
|
|
|
|
|
|
|
uint32_t num = marks.Length();
|
|
|
|
if (num) {
|
2013-07-12 10:39:38 +04:00
|
|
|
// These are in the same order as the nsSVGMark::Type constants.
|
|
|
|
nsSVGMarkerFrame* markerFrames[] = {
|
|
|
|
properties.GetMarkerStartFrame(),
|
|
|
|
properties.GetMarkerMidFrame(),
|
|
|
|
properties.GetMarkerEndFrame(),
|
|
|
|
};
|
2014-01-30 22:26:54 +04:00
|
|
|
PR_STATIC_ASSERT(MOZ_ARRAY_LENGTH(markerFrames) == nsSVGMark::eTypeCount);
|
2013-07-12 10:39:38 +04:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < num; i++) {
|
|
|
|
nsSVGMark& mark = marks[i];
|
|
|
|
nsSVGMarkerFrame* frame = markerFrames[mark.type];
|
|
|
|
if (frame) {
|
|
|
|
frame->PaintMark(aContext, this, &mark, strokeWidth);
|
|
|
|
}
|
2013-01-13 03:27:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-04 12:29:02 +04:00
|
|
|
|
|
|
|
uint16_t
|
|
|
|
nsSVGPathGeometryFrame::GetHitTestFlags()
|
|
|
|
{
|
|
|
|
return nsSVGUtils::GetGeometryHitTestFlags(this);
|
|
|
|
}
|