2006-05-02 15:05:25 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla SVG project.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is IBM Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "nsSVGGeometryFrame.h"
|
2006-05-16 15:55:01 +00:00
|
|
|
#include "nsSVGPaintServerFrame.h"
|
|
|
|
#include "nsContentUtils.h"
|
2006-11-27 17:30:57 +00:00
|
|
|
#include "gfxContext.h"
|
2006-05-02 15:05:25 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGGeometryFrame)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGGeometryFrameBase)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-07-17 01:40:28 -07:00
|
|
|
// nsIFrame methods
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-07-19 14:44:51 +00:00
|
|
|
void
|
|
|
|
nsSVGGeometryFrame::Destroy()
|
|
|
|
{
|
|
|
|
// Remove the properties before the frame goes away, since we need it for QI
|
|
|
|
RemovePaintServerProperties();
|
|
|
|
nsSVGGeometryFrameBase::Destroy();
|
|
|
|
}
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGGeometryFrame::InitSVG()
|
|
|
|
{
|
|
|
|
AddStateBits(mParent->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-08-23 18:16:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGGeometryFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
mContent = aContent;
|
|
|
|
NS_IF_ADDREF(mContent);
|
|
|
|
mParent = aParent;
|
|
|
|
|
|
|
|
if (mContent) {
|
|
|
|
mContent->SetMayHaveFrame(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
InitSVG();
|
|
|
|
DidSetStyleContext();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGGeometryFrame::DidSetStyleContext()
|
|
|
|
{
|
|
|
|
// One of the styles that might have been changed are the urls that
|
|
|
|
// point to gradients, etc. Drop our cached values to those
|
2006-07-19 14:44:51 +00:00
|
|
|
RemovePaintServerProperties();
|
2006-05-02 15:05:25 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-17 01:40:28 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGValueObserver methods:
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGGeometryFrame::WillModifySVGObservable(nsISVGValue* observable,
|
|
|
|
nsISVGValue::modificationType aModType)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGGeometryFrame::DidModifySVGObservable(nsISVGValue* observable,
|
|
|
|
nsISVGValue::modificationType aModType)
|
|
|
|
{
|
2006-05-27 18:48:09 +00:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_PSERVER_MASK))
|
|
|
|
return NS_OK;
|
|
|
|
|
2006-05-11 20:01:12 +00:00
|
|
|
nsIFrame *frame;
|
|
|
|
CallQueryInterface(observable, &frame);
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-11 20:01:12 +00:00
|
|
|
if (!frame)
|
2006-05-02 15:05:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2006-05-27 18:48:09 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_FILL_PSERVER) {
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIFrame *ps = static_cast<nsIFrame*>(GetProperty(nsGkAtoms::fill));
|
2006-05-27 18:48:09 +00:00
|
|
|
if (frame == ps) {
|
|
|
|
if (aModType == nsISVGValue::mod_die) {
|
|
|
|
DeleteProperty(nsGkAtoms::fill);
|
|
|
|
RemoveStateBits(NS_STATE_SVG_FILL_PSERVER);
|
|
|
|
}
|
|
|
|
UpdateGraphic();
|
|
|
|
}
|
2006-05-11 20:01:12 +00:00
|
|
|
}
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-27 18:48:09 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_STROKE_PSERVER) {
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIFrame *ps = static_cast<nsIFrame*>(GetProperty(nsGkAtoms::stroke));
|
2006-05-27 18:48:09 +00:00
|
|
|
if (frame == ps) {
|
|
|
|
if (aModType == nsISVGValue::mod_die) {
|
|
|
|
DeleteProperty(nsGkAtoms::stroke);
|
|
|
|
RemoveStateBits(NS_STATE_SVG_STROKE_PSERVER);
|
|
|
|
}
|
|
|
|
UpdateGraphic();
|
|
|
|
}
|
2006-05-02 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2007-07-17 01:40:28 -07:00
|
|
|
void
|
|
|
|
nsSVGGeometryFrame::RemovePaintServerProperties()
|
|
|
|
{
|
|
|
|
DeleteProperty(nsGkAtoms::fill);
|
|
|
|
DeleteProperty(nsGkAtoms::stroke);
|
|
|
|
RemoveStateBits(NS_STATE_SVG_PSERVER_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGPaintServerFrame *
|
|
|
|
nsSVGGeometryFrame::GetPaintServer(const nsStyleSVGPaint *aPaint)
|
|
|
|
{
|
|
|
|
if (aPaint->mType != eStyleSVGPaintType_Server)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsIURI *uri;
|
|
|
|
uri = aPaint->mPaint.mPaintServer;
|
|
|
|
if (!uri)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsIFrame *result;
|
|
|
|
if (NS_FAILED(nsSVGUtils::GetReferencedFrame(&result, uri, mContent,
|
|
|
|
PresContext()->PresShell())))
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsIAtom *type = result->GetType();
|
|
|
|
if (type != nsGkAtoms::svgLinearGradientFrame &&
|
|
|
|
type != nsGkAtoms::svgRadialGradientFrame &&
|
|
|
|
type != nsGkAtoms::svgPatternFrame)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
// Loop check for pattern
|
|
|
|
if (type == nsGkAtoms::svgPatternFrame &&
|
|
|
|
nsContentUtils::ContentIsDescendantOf(mContent, result->GetContent()))
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsSVGPaintServerFrame *server =
|
|
|
|
static_cast<nsSVGPaintServerFrame*>(result);
|
|
|
|
|
|
|
|
server->AddObserver(this);
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
float
|
|
|
|
nsSVGGeometryFrame::GetStrokeWidth()
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
nsSVGElement *ctx = static_cast<nsSVGElement*>
|
|
|
|
(GetType() == nsGkAtoms::svgGlyphFrame ?
|
2007-03-09 16:27:01 +00:00
|
|
|
mContent->GetParent() : mContent);
|
|
|
|
|
2006-07-19 14:46:50 +00:00
|
|
|
return
|
2007-03-30 14:11:41 -07:00
|
|
|
nsSVGUtils::CoordToFloat(PresContext(),
|
2007-03-09 16:27:01 +00:00
|
|
|
ctx,
|
|
|
|
GetStyleSVG()->mStrokeWidth);
|
2006-05-02 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2007-01-10 17:01:20 +00:00
|
|
|
nsSVGGeometryFrame::GetStrokeDashArray(gfxFloat **aDashes, PRUint32 *aCount)
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
|
|
|
*aDashes = nsnull;
|
|
|
|
*aCount = 0;
|
|
|
|
|
|
|
|
PRUint32 count = GetStyleSVG()->mStrokeDasharrayLength;
|
2007-01-10 17:01:20 +00:00
|
|
|
gfxFloat *dashes = nsnull;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
|
|
|
if (count) {
|
|
|
|
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-01-10 17:01:20 +00:00
|
|
|
gfxFloat totalLength = 0.0f;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2007-01-10 17:01:20 +00:00
|
|
|
dashes = new gfxFloat[count];
|
2006-05-02 15:05:25 +00:00
|
|
|
if (dashes) {
|
|
|
|
for (PRUint32 i = 0; i < count; i++) {
|
|
|
|
dashes[i] =
|
2007-03-09 16:27:01 +00:00
|
|
|
nsSVGUtils::CoordToFloat(presContext,
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsSVGElement*>(mContent),
|
2007-03-09 16:27:01 +00:00
|
|
|
dasharray[i]);
|
2006-05-02 15:05:25 +00:00
|
|
|
if (dashes[i] < 0.0f) {
|
|
|
|
delete [] dashes;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
totalLength += dashes[i];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (totalLength == 0.0f) {
|
|
|
|
delete [] dashes;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aDashes = dashes;
|
|
|
|
*aCount = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
nsSVGGeometryFrame::GetStrokeDashoffset()
|
|
|
|
{
|
|
|
|
return
|
2007-03-30 14:11:41 -07:00
|
|
|
nsSVGUtils::CoordToFloat(PresContext(),
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsSVGElement*>(mContent),
|
2006-05-02 15:05:25 +00:00
|
|
|
GetStyleSVG()->mStrokeDashoffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint16
|
|
|
|
nsSVGGeometryFrame::GetClipRule()
|
|
|
|
{
|
|
|
|
return GetStyleSVG()->mClipRule;
|
|
|
|
}
|
|
|
|
|
2006-05-27 18:48:09 +00:00
|
|
|
static void
|
|
|
|
PServerPropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
|
|
|
void *aPropertyValue, void *aData)
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIFrame *ps = static_cast<nsIFrame*>(aPropertyValue);
|
|
|
|
nsSVGUtils::RemoveObserver(static_cast<nsIFrame*>(aObject), ps);
|
2006-05-27 18:48:09 +00:00
|
|
|
}
|
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
PRBool
|
|
|
|
nsSVGGeometryFrame::HasStroke()
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
2006-05-27 18:48:09 +00:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_STROKE_PSERVER)) {
|
|
|
|
nsIFrame *ps = GetPaintServer(&GetStyleSVG()->mStroke);
|
|
|
|
if (ps) {
|
|
|
|
SetProperty(nsGkAtoms::stroke, ps, PServerPropertyDtor);
|
|
|
|
AddStateBits(NS_STATE_SVG_STROKE_PSERVER);
|
|
|
|
}
|
|
|
|
}
|
2006-05-02 15:05:25 +00:00
|
|
|
|
|
|
|
// cairo will stop rendering if stroke-width is less than or equal to zero
|
2006-05-16 15:55:01 +00:00
|
|
|
if (GetStrokeWidth() <= 0)
|
|
|
|
return PR_FALSE;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
if (GetStyleSVG()->mStroke.mType == eStyleSVGPaintType_Color ||
|
2006-11-17 10:12:12 +00:00
|
|
|
(GetStyleSVG()->mStroke.mType == eStyleSVGPaintType_Server &&
|
|
|
|
(GetStateBits() & NS_STATE_SVG_STROKE_PSERVER)))
|
2006-05-16 15:55:01 +00:00
|
|
|
return PR_TRUE;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
return PR_FALSE;
|
2006-05-02 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
PRBool
|
|
|
|
nsSVGGeometryFrame::HasFill()
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
2006-05-27 18:48:09 +00:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_FILL_PSERVER)) {
|
|
|
|
nsIFrame *ps = GetPaintServer(&GetStyleSVG()->mFill);
|
|
|
|
if (ps) {
|
|
|
|
SetProperty(nsGkAtoms::fill, ps, PServerPropertyDtor);
|
|
|
|
AddStateBits(NS_STATE_SVG_FILL_PSERVER);
|
|
|
|
}
|
|
|
|
}
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
if (GetStyleSVG()->mFill.mType == eStyleSVGPaintType_Color ||
|
2006-11-16 10:22:51 +00:00
|
|
|
GetStyleSVG()->mFill.mType == eStyleSVGPaintType_Server)
|
2006-05-16 15:55:01 +00:00
|
|
|
return PR_TRUE;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
return PR_FALSE;
|
2006-05-02 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsSVGGeometryFrame::IsClipChild()
|
|
|
|
{
|
2006-05-03 19:39:21 +00:00
|
|
|
nsIContent *node = mContent;
|
2006-05-02 15:05:25 +00:00
|
|
|
|
|
|
|
do {
|
2006-05-03 19:39:21 +00:00
|
|
|
// Return false if we find a non-svg ancestor. Non-SVG elements are not
|
|
|
|
// allowed inside an SVG clipPath element.
|
|
|
|
if (node->GetNameSpaceID() != kNameSpaceID_SVG) {
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-05-03 19:39:21 +00:00
|
|
|
if (node->NodeInfo()->Equals(nsGkAtoms::clipPath, kNameSpaceID_SVG)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2006-05-02 15:05:25 +00:00
|
|
|
node = node->GetParent();
|
|
|
|
} while (node);
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoColor(gfxContext *aContext, nscolor aRGB, float aOpacity)
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetColor(gfxRGBA(NS_GET_R(aRGB)/255.0,
|
|
|
|
NS_GET_G(aRGB)/255.0,
|
|
|
|
NS_GET_B(aRGB)/255.0,
|
|
|
|
NS_GET_A(aRGB)/255.0 * aOpacity));
|
2006-05-02 15:05:25 +00:00
|
|
|
}
|
|
|
|
|
2007-01-04 15:05:39 +00:00
|
|
|
float
|
|
|
|
nsSVGGeometryFrame::MaybeOptimizeOpacity(float aOpacity)
|
|
|
|
{
|
|
|
|
if (nsSVGUtils::CanOptimizeOpacity(this)) {
|
|
|
|
aOpacity *= GetStyleDisplay()->mOpacity;
|
|
|
|
}
|
|
|
|
return aOpacity;
|
|
|
|
}
|
|
|
|
|
2007-04-23 02:11:19 -07:00
|
|
|
PRBool
|
2006-11-27 17:30:57 +00:00
|
|
|
nsSVGGeometryFrame::SetupCairoFill(gfxContext *aContext,
|
2006-05-16 15:55:01 +00:00
|
|
|
void **aClosure)
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
|
|
|
if (GetStyleSVG()->mFillRule == NS_STYLE_FILL_RULE_EVENODD)
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
|
2006-05-02 15:05:25 +00:00
|
|
|
else
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetFillRule(gfxContext::FILL_RULE_WINDING);
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2007-01-04 15:05:39 +00:00
|
|
|
float opacity = MaybeOptimizeOpacity(GetStyleSVG()->mFillOpacity);
|
|
|
|
|
2006-05-27 18:48:09 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_FILL_PSERVER) {
|
2007-07-08 00:08:04 -07:00
|
|
|
nsSVGPaintServerFrame *ps = static_cast<nsSVGPaintServerFrame*>
|
|
|
|
(GetProperty(nsGkAtoms::fill));
|
2007-01-10 17:01:20 +00:00
|
|
|
return ps->SetupPaintServer(aContext, this, opacity, aClosure);
|
2006-11-16 10:22:51 +00:00
|
|
|
} else if (GetStyleSVG()->mFill.mType == eStyleSVGPaintType_Server) {
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoColor(aContext,
|
2007-01-09 11:02:17 +00:00
|
|
|
GetStyleSVG()->mFill.mFallbackColor,
|
|
|
|
opacity);
|
2006-05-27 18:48:09 +00:00
|
|
|
} else
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoColor(aContext,
|
2006-05-16 15:55:01 +00:00
|
|
|
GetStyleSVG()->mFill.mPaint.mColor,
|
2007-01-04 15:05:39 +00:00
|
|
|
opacity);
|
2006-05-16 15:55:01 +00:00
|
|
|
|
2007-04-23 02:11:19 -07:00
|
|
|
return PR_TRUE;
|
2006-05-16 15:55:01 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
void
|
2007-01-10 17:01:20 +00:00
|
|
|
nsSVGGeometryFrame::SetupCairoStrokeGeometry(gfxContext *aContext)
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineWidth(GetStrokeWidth());
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
switch (GetStyleSVG()->mStrokeLinecap) {
|
|
|
|
case NS_STYLE_STROKE_LINECAP_BUTT:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineCap(gfxContext::LINE_CAP_BUTT);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_STROKE_LINECAP_ROUND:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineCap(gfxContext::LINE_CAP_ROUND);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_STROKE_LINECAP_SQUARE:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineCap(gfxContext::LINE_CAP_SQUARE);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-10 17:01:20 +00:00
|
|
|
|
|
|
|
aContext->SetMiterLimit(GetStyleSVG()->mStrokeMiterlimit);
|
|
|
|
|
2006-05-02 15:05:25 +00:00
|
|
|
switch (GetStyleSVG()->mStrokeLinejoin) {
|
|
|
|
case NS_STYLE_STROKE_LINEJOIN_MITER:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineJoin(gfxContext::LINE_JOIN_MITER);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_STROKE_LINEJOIN_ROUND:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineJoin(gfxContext::LINE_JOIN_ROUND);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_STROKE_LINEJOIN_BEVEL:
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetLineJoin(gfxContext::LINE_JOIN_BEVEL);
|
2006-05-02 15:05:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-07 16:41:58 +00:00
|
|
|
void
|
2007-01-10 17:01:20 +00:00
|
|
|
nsSVGGeometryFrame::SetupCairoStrokeHitGeometry(gfxContext *aContext)
|
2006-05-02 15:05:25 +00:00
|
|
|
{
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoStrokeGeometry(aContext);
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2007-01-10 17:01:20 +00:00
|
|
|
gfxFloat *dashArray;
|
2006-05-02 15:05:25 +00:00
|
|
|
PRUint32 count;
|
|
|
|
GetStrokeDashArray(&dashArray, &count);
|
|
|
|
if (count > 0) {
|
2007-01-10 17:01:20 +00:00
|
|
|
aContext->SetDash(dashArray, count, GetStrokeDashoffset());
|
2006-05-02 15:05:25 +00:00
|
|
|
delete [] dashArray;
|
|
|
|
}
|
2006-08-07 16:41:58 +00:00
|
|
|
}
|
|
|
|
|
2007-04-23 02:11:19 -07:00
|
|
|
PRBool
|
2006-11-27 17:30:57 +00:00
|
|
|
nsSVGGeometryFrame::SetupCairoStroke(gfxContext *aContext,
|
2006-08-07 16:41:58 +00:00
|
|
|
void **aClosure)
|
|
|
|
{
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoStrokeHitGeometry(aContext);
|
2006-05-02 15:05:25 +00:00
|
|
|
|
2007-01-04 15:05:39 +00:00
|
|
|
float opacity = MaybeOptimizeOpacity(GetStyleSVG()->mStrokeOpacity);
|
|
|
|
|
2006-05-27 18:48:09 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_STROKE_PSERVER) {
|
2007-07-08 00:08:04 -07:00
|
|
|
nsSVGPaintServerFrame *ps = static_cast<nsSVGPaintServerFrame*>
|
|
|
|
(GetProperty(nsGkAtoms::stroke));
|
2007-01-10 17:01:20 +00:00
|
|
|
return ps->SetupPaintServer(aContext, this, opacity, aClosure);
|
2007-01-09 11:02:17 +00:00
|
|
|
} else if (GetStyleSVG()->mStroke.mType == eStyleSVGPaintType_Server) {
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoColor(aContext,
|
2007-01-09 11:02:17 +00:00
|
|
|
GetStyleSVG()->mStroke.mFallbackColor,
|
|
|
|
opacity);
|
2006-05-27 18:48:09 +00:00
|
|
|
} else
|
2007-01-10 17:01:20 +00:00
|
|
|
SetupCairoColor(aContext,
|
2006-05-16 15:55:01 +00:00
|
|
|
GetStyleSVG()->mStroke.mPaint.mColor,
|
2007-01-04 15:05:39 +00:00
|
|
|
opacity);
|
2006-05-16 15:55:01 +00:00
|
|
|
|
2007-04-23 02:11:19 -07:00
|
|
|
return PR_TRUE;
|
2006-05-16 15:55:01 +00:00
|
|
|
}
|