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 12:39:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2004-04-18 14:30:37 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
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 12:39:26 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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
|
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 12:39:26 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
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 12:39:26 +00:00
|
|
|
* Crocodile Clips Ltd..
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2004-04-18 14:30:37 +00:00
|
|
|
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
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 12:39:26 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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"),
|
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 12:39:26 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
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 12:39:26 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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 12:39:26 +00:00
|
|
|
|
|
|
|
#include "nsSVGPathGeometryFrame.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2004-12-09 03:16:15 +00:00
|
|
|
#include "nsSVGMarkerFrame.h"
|
2005-04-04 21:42:26 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2008-10-10 13:14:05 +00:00
|
|
|
#include "nsSVGEffects.h"
|
2006-04-20 15:24:51 +00:00
|
|
|
#include "nsSVGGraphicElement.h"
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
2006-06-20 17:01:09 +00:00
|
|
|
#include "nsSVGRect.h"
|
2006-06-21 15:42:28 +00:00
|
|
|
#include "nsSVGPathGeometryElement.h"
|
2006-11-27 17:30:57 +00:00
|
|
|
#include "gfxContext.h"
|
2010-08-20 19:29:01 +00:00
|
|
|
#include "gfxPlatform.h"
|
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 12:39:26 +00:00
|
|
|
|
2006-06-21 15:42:28 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGPathGeometryFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00: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 12:39:26 +00:00
|
|
|
//----------------------------------------------------------------------
|
2009-01-12 19:20:59 +00: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 12:39:26 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGPathGeometryFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGChildFrame)
|
|
|
|
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 12:39:26 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2006-06-20 17:01:09 +00: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 12:39:26 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsSVGPathGeometryFrame::AttributeChanged(PRInt32 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 12:39:26 +00:00
|
|
|
nsIAtom* aAttribute,
|
2005-04-19 03:48:10 +00:00
|
|
|
PRInt32 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 12:39:26 +00:00
|
|
|
{
|
2006-03-02 20:22:19 +00:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
2007-07-08 07:08:04 +00:00
|
|
|
(static_cast<nsSVGPathGeometryElement*>
|
2009-04-23 23:41:17 +00:00
|
|
|
(mContent)->AttributeDefinesGeometry(aAttribute) ||
|
2006-06-21 15:42:28 +00:00
|
|
|
aAttribute == nsGkAtoms::transform))
|
2008-04-08 12:51:19 +00:00
|
|
|
nsSVGUtils::UpdateGraphic(this);
|
2006-06-21 15:42:28 +00: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 12:39:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-13 22:03:28 +00:00
|
|
|
/* virtual */ void
|
2008-10-26 10:11:34 +00:00
|
|
|
nsSVGPathGeometryFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
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 12:39:26 +00:00
|
|
|
{
|
2008-10-26 10:11:34 +00:00
|
|
|
nsSVGPathGeometryFrameBase::DidSetStyleContext(aOldStyleContext);
|
2006-05-02 15:05:25 +00: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 12:39:26 +00:00
|
|
|
// XXX: we'd like to use the style_hint mechanism and the
|
|
|
|
// ContentStateChanged/AttributeChanged functions for style changes
|
|
|
|
// to get slightly finer granularity, but unfortunately the
|
|
|
|
// style_hints don't map very well onto svg. Here seems to be the
|
|
|
|
// best place to deal with style changes:
|
|
|
|
|
2008-04-08 12:51:19 +00:00
|
|
|
nsSVGUtils::UpdateGraphic(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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 19:56:08 +00:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGPathGeometryFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::svgPathGeometryFrame;
|
2005-04-01 19:56:08 +00:00
|
|
|
}
|
|
|
|
|
2006-04-06 13:02:53 +00: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 12:39:26 +00:00
|
|
|
NS_IMETHODIMP
|
2012-03-02 08:28:59 +00:00
|
|
|
nsSVGPathGeometryFrame::PaintSVG(nsRenderingContext *aContext,
|
2008-10-20 08:42:03 +00:00
|
|
|
const nsIntRect *aDirtyRect)
|
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 12:39:26 +00:00
|
|
|
{
|
2004-10-04 18:56:53 +00:00
|
|
|
if (!GetStyleVisibility()->IsVisible())
|
|
|
|
return NS_OK;
|
|
|
|
|
2005-01-25 03:55:03 +00:00
|
|
|
/* render */
|
2006-11-27 17:30:57 +00:00
|
|
|
Render(aContext);
|
2006-03-21 15:49:20 +00:00
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
|
2008-10-10 13:14:05 +00:00
|
|
|
MarkerProperties properties = GetMarkerProperties(this);
|
2006-03-21 15:49:20 +00:00
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
if (properties.MarkersExist()) {
|
2006-05-02 15:05:25 +00:00
|
|
|
float strokeWidth = GetStrokeWidth();
|
2006-03-21 15:49:20 +00:00
|
|
|
|
2006-06-21 19:35:59 +00:00
|
|
|
nsTArray<nsSVGMark> marks;
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsSVGPathGeometryElement*>
|
|
|
|
(mContent)->GetMarkPoints(&marks);
|
2006-03-21 15:49:20 +00:00
|
|
|
|
2006-06-21 19:35:59 +00:00
|
|
|
PRUint32 num = marks.Length();
|
2007-04-10 10:19:59 +00:00
|
|
|
|
|
|
|
if (num) {
|
2008-10-10 13:14:05 +00:00
|
|
|
nsSVGMarkerFrame *frame = properties.GetMarkerStartFrame();
|
2007-04-10 10:19:59 +00:00
|
|
|
if (frame)
|
|
|
|
frame->PaintMark(aContext, this, &marks[0], strokeWidth);
|
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
frame = properties.GetMarkerMidFrame();
|
2007-04-10 10:19:59 +00:00
|
|
|
if (frame) {
|
|
|
|
for (PRUint32 i = 1; i < num - 1; i++)
|
|
|
|
frame->PaintMark(aContext, this, &marks[i], strokeWidth);
|
|
|
|
}
|
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
frame = properties.GetMarkerEndFrame();
|
2007-04-10 10:19:59 +00:00
|
|
|
if (frame)
|
|
|
|
frame->PaintMark(aContext, this, &marks[num-1], strokeWidth);
|
|
|
|
}
|
2005-04-06 19:02:13 +00:00
|
|
|
}
|
2004-12-09 03:16:15 +00: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 12:39:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-25 09:23:54 +00: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 12:39:26 +00:00
|
|
|
{
|
2011-07-08 13:20:14 +00:00
|
|
|
PRUint16 fillRule, hitTestFlags;
|
2010-12-06 20:57:18 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
|
2011-07-08 13:20:14 +00:00
|
|
|
hitTestFlags = SVG_HIT_TEST_FILL;
|
2007-12-04 05:11:49 +00:00
|
|
|
fillRule = GetClipRule();
|
|
|
|
} else {
|
2011-07-08 13:20:14 +00:00
|
|
|
hitTestFlags = GetHitTestFlags();
|
2012-02-10 12:33:46 +00:00
|
|
|
// XXX once bug 614732 is fixed, aPoint won't need any conversion in order
|
|
|
|
// to compare it with mRect.
|
|
|
|
gfxMatrix canvasTM = GetCanvasTM();
|
|
|
|
if (canvasTM.IsSingular()) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
nsPoint point =
|
|
|
|
nsSVGUtils::TransformOuterSVGPointToChildFrame(aPoint, canvasTM, PresContext());
|
2011-07-08 13:20:14 +00:00
|
|
|
if (!hitTestFlags || ((hitTestFlags & SVG_HIT_TEST_CHECK_MRECT) &&
|
2012-02-10 12:33:46 +00:00
|
|
|
!mRect.Contains(point)))
|
2008-08-25 09:23:54 +00:00
|
|
|
return nsnull;
|
2007-12-04 05:11:49 +00:00
|
|
|
fillRule = GetStyleSVG()->mFillRule;
|
|
|
|
}
|
2006-06-09 18:08:33 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHit = false;
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2010-10-15 10:20:22 +00:00
|
|
|
nsRefPtr<gfxContext> context =
|
|
|
|
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2010-10-15 10:20:22 +00:00
|
|
|
GeneratePath(context);
|
2008-08-25 09:23:54 +00:00
|
|
|
gfxPoint userSpacePoint =
|
2010-10-15 10:20:22 +00:00
|
|
|
context->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
|
|
|
|
PresContext()->AppUnitsToGfxUnits(aPoint.y)));
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2006-08-07 16:41:58 +00:00
|
|
|
if (fillRule == NS_STYLE_FILL_RULE_EVENODD)
|
2010-10-15 10:20:22 +00:00
|
|
|
context->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
|
2006-08-07 16:41:58 +00:00
|
|
|
else
|
2010-10-15 10:20:22 +00:00
|
|
|
context->SetFillRule(gfxContext::FILL_RULE_WINDING);
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2011-07-08 13:20:14 +00:00
|
|
|
if (hitTestFlags & SVG_HIT_TEST_FILL)
|
2010-10-15 10:20:22 +00:00
|
|
|
isHit = context->PointInFill(userSpacePoint);
|
2011-07-08 13:20:14 +00:00
|
|
|
if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) {
|
2010-10-15 10:20:22 +00:00
|
|
|
SetupCairoStrokeHitGeometry(context);
|
|
|
|
isHit = context->PointInStroke(userSpacePoint);
|
2006-08-07 16:41:58 +00:00
|
|
|
}
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2008-08-25 09:23:54 +00:00
|
|
|
if (isHit && nsSVGUtils::HitTestClip(this, aPoint))
|
|
|
|
return this;
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2008-08-25 09:23:54 +00:00
|
|
|
return nsnull;
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 18:08:33 +00: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 12:39:26 +00:00
|
|
|
nsSVGPathGeometryFrame::GetCoveredRegion()
|
|
|
|
{
|
2012-02-10 12:33:49 +00:00
|
|
|
// See bug 614732 comment 32:
|
|
|
|
//return nsSVGUtils::TransformFrameRectToOuterSVG(mRect, GetCanvasTM(), PresContext());
|
|
|
|
return mCoveredRegion;
|
2006-06-09 18:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGPathGeometryFrame::UpdateCoveredRegion()
|
|
|
|
{
|
2012-02-10 12:33:46 +00:00
|
|
|
gfxRect extent = GetBBoxContribution(gfxMatrix(),
|
2011-09-30 09:25:37 +00:00
|
|
|
nsSVGUtils::eBBoxIncludeFill | nsSVGUtils::eBBoxIgnoreFillIfNone |
|
|
|
|
nsSVGUtils::eBBoxIncludeStroke | nsSVGUtils::eBBoxIgnoreStrokeIfNone |
|
|
|
|
nsSVGUtils::eBBoxIncludeMarkers);
|
2012-02-10 12:33:18 +00:00
|
|
|
mRect = nsLayoutUtils::RoundGfxRectToAppRect(extent,
|
2012-02-17 06:07:51 +00:00
|
|
|
PresContext()->AppUnitsPerCSSPixel());
|
2012-02-10 12:33:49 +00:00
|
|
|
|
|
|
|
// See bug 614732 comment 32.
|
|
|
|
mCoveredRegion = nsSVGUtils::TransformFrameRectToOuterSVG(
|
|
|
|
mRect, GetCanvasTM(), PresContext());
|
|
|
|
|
2006-06-09 18:08:33 +00:00
|
|
|
return NS_OK;
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGPathGeometryFrame::InitialUpdate()
|
|
|
|
{
|
2007-10-19 11:07:08 +00:00
|
|
|
NS_ASSERTION(GetStateBits() & NS_FRAME_FIRST_REFLOW,
|
|
|
|
"Yikes! We've been called already! Hopefully we weren't called "
|
|
|
|
"before our nsSVGOuterSVGFrame's initial Reflow()!!!");
|
|
|
|
|
2008-04-08 12:51:19 +00:00
|
|
|
nsSVGUtils::UpdateGraphic(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 12:39:26 +00:00
|
|
|
|
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 05:38:33 +00:00
|
|
|
NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW),
|
|
|
|
"We don't actually participate in reflow");
|
|
|
|
|
|
|
|
// Do unset the various reflow bits, though.
|
|
|
|
mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
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 12:39:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
void
|
|
|
|
nsSVGPathGeometryFrame::NotifySVGChanged(PRUint32 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 12:39:26 +00:00
|
|
|
{
|
2008-04-08 12:51:19 +00:00
|
|
|
if (!(aFlags & SUPPRESS_INVALIDATION)) {
|
|
|
|
nsSVGUtils::UpdateGraphic(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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 13:58:46 +00:00
|
|
|
void
|
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 12:39:26 +00:00
|
|
|
nsSVGPathGeometryFrame::NotifyRedrawSuspended()
|
|
|
|
{
|
2012-02-04 13:58:46 +00:00
|
|
|
AddStateBits(NS_STATE_SVG_REDRAW_SUSPENDED);
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 13:58:46 +00:00
|
|
|
void
|
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 12:39:26 +00:00
|
|
|
nsSVGPathGeometryFrame::NotifyRedrawUnsuspended()
|
|
|
|
{
|
2012-02-04 13:58:46 +00:00
|
|
|
RemoveStateBits(NS_STATE_SVG_REDRAW_SUSPENDED);
|
|
|
|
|
2006-05-24 18:18:27 +00:00
|
|
|
if (GetStateBits() & NS_STATE_SVG_DIRTY)
|
2008-04-08 12:51:19 +00:00
|
|
|
nsSVGUtils::UpdateGraphic(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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxRect
|
2011-09-30 09:25:37 +00:00
|
|
|
nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
|
|
|
|
PRUint32 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 12:39:26 +00:00
|
|
|
{
|
2009-04-29 04:31:34 +00:00
|
|
|
if (aToBBoxUserspace.IsSingular()) {
|
|
|
|
// XXX ReportToConsole
|
|
|
|
return gfxRect(0.0, 0.0, 0.0, 0.0);
|
|
|
|
}
|
2011-09-30 09:25:37 +00:00
|
|
|
|
2010-10-15 10:20:22 +00:00
|
|
|
nsRefPtr<gfxContext> context =
|
|
|
|
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
2011-09-30 09:25:37 +00:00
|
|
|
|
2010-10-15 10:20:22 +00:00
|
|
|
GeneratePath(context, &aToBBoxUserspace);
|
|
|
|
context->IdentityMatrix();
|
2011-09-30 09:25:37 +00:00
|
|
|
|
|
|
|
gfxRect bbox;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
gfxRect pathExtents = context->GetUserPathExtent();
|
|
|
|
|
|
|
|
// Account for fill:
|
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeFill) != 0 &&
|
|
|
|
((aFlags & nsSVGUtils::eBBoxIgnoreFillIfNone) == 0 ||
|
|
|
|
GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None)) {
|
|
|
|
bbox = pathExtents;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Account for stroke:
|
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeStroke) != 0 &&
|
|
|
|
((aFlags & nsSVGUtils::eBBoxIgnoreStrokeIfNone) == 0 || HasStroke())) {
|
|
|
|
// We can't use context->GetUserStrokeExtent() since it doesn't work for
|
|
|
|
// 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
|
|
|
|
// been set. Happily we can use context->GetUserStrokeExtent() to find
|
|
|
|
// the center point of the extents even though it gets the extents wrong.
|
|
|
|
SetupCairoStrokeGeometry(context);
|
|
|
|
pathExtents.MoveTo(context->GetUserStrokeExtent().Center());
|
|
|
|
pathExtents.SizeTo(0, 0);
|
|
|
|
}
|
|
|
|
bbox =
|
2012-02-10 12:33:39 +00:00
|
|
|
bbox.Union(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents,
|
|
|
|
this,
|
|
|
|
aToBBoxUserspace));
|
2011-09-30 09:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Account for markers:
|
|
|
|
if ((aFlags & nsSVGUtils::eBBoxIncludeMarkers) != 0 &&
|
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
|
|
|
|
|
|
|
|
float strokeWidth = GetStrokeWidth();
|
|
|
|
MarkerProperties properties = GetMarkerProperties(this);
|
|
|
|
|
|
|
|
if (properties.MarkersExist()) {
|
|
|
|
nsTArray<nsSVGMark> marks;
|
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->GetMarkPoints(&marks);
|
|
|
|
PRUint32 num = marks.Length();
|
|
|
|
|
|
|
|
if (num) {
|
|
|
|
nsSVGMarkerFrame *frame = properties.GetMarkerStartFrame();
|
|
|
|
if (frame) {
|
|
|
|
gfxRect mbbox =
|
|
|
|
frame->GetMarkBBoxContribution(aToBBoxUserspace, aFlags, this,
|
|
|
|
&marks[0], strokeWidth);
|
|
|
|
bbox.UnionRect(bbox, mbbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
frame = properties.GetMarkerMidFrame();
|
|
|
|
if (frame) {
|
|
|
|
for (PRUint32 i = 1; i < num - 1; i++) {
|
|
|
|
gfxRect mbbox =
|
|
|
|
frame->GetMarkBBoxContribution(aToBBoxUserspace, aFlags, this,
|
|
|
|
&marks[i], strokeWidth);
|
|
|
|
bbox.UnionRect(bbox, mbbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frame = properties.GetMarkerEndFrame();
|
|
|
|
if (frame) {
|
|
|
|
gfxRect mbbox =
|
|
|
|
frame->GetMarkBBoxContribution(aToBBoxUserspace, aFlags, this,
|
|
|
|
&marks[num-1], strokeWidth);
|
|
|
|
bbox.UnionRect(bbox, mbbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2006-05-02 15:05:25 +00:00
|
|
|
// nsSVGGeometryFrame 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 12:39:26 +00:00
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxMatrix
|
|
|
|
nsSVGPathGeometryFrame::GetCanvasTM()
|
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 12:39:26 +00:00
|
|
|
{
|
2009-04-29 04:31:34 +00:00
|
|
|
NS_ASSERTION(mParent, "null parent");
|
2004-08-05 09:01:13 +00:00
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
|
|
|
nsSVGGraphicElement *content = static_cast<nsSVGGraphicElement*>(mContent);
|
2006-04-20 15:24:51 +00:00
|
|
|
|
2012-02-17 08:12:47 +00:00
|
|
|
return content->PrependLocalTransformsTo(parent->GetCanvasTM());
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2006-06-20 17:01:09 +00: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 12:39:26 +00:00
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
nsSVGPathGeometryFrame::MarkerProperties
|
|
|
|
nsSVGPathGeometryFrame::GetMarkerProperties(nsSVGPathGeometryFrame *aFrame)
|
2007-07-24 09:05:37 +00:00
|
|
|
{
|
2008-10-10 13:14:05 +00:00
|
|
|
NS_ASSERTION(!aFrame->GetPrevContinuation(), "aFrame should be first continuation");
|
2007-07-24 09:05:37 +00:00
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
MarkerProperties result;
|
|
|
|
const nsStyleSVG *style = aFrame->GetStyleSVG();
|
2010-03-29 01:46:55 +00: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 13:14:05 +00:00
|
|
|
return result;
|
2007-07-24 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerStartFrame()
|
2007-07-24 09:05:37 +00:00
|
|
|
{
|
2008-10-10 13:14:05 +00:00
|
|
|
if (!mMarkerStart)
|
|
|
|
return nsnull;
|
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
|
|
|
(mMarkerStart->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nsnull));
|
2007-07-24 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 13:14:05 +00:00
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerMidFrame()
|
2007-07-24 09:05:37 +00:00
|
|
|
{
|
2008-10-10 13:14:05 +00:00
|
|
|
if (!mMarkerMid)
|
|
|
|
return nsnull;
|
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
|
|
|
(mMarkerMid->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nsnull));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGMarkerFrame *
|
|
|
|
nsSVGPathGeometryFrame::MarkerProperties::GetMarkerEndFrame()
|
|
|
|
{
|
|
|
|
if (!mMarkerEnd)
|
|
|
|
return nsnull;
|
|
|
|
return static_cast<nsSVGMarkerFrame *>
|
|
|
|
(mMarkerEnd->GetReferencedFrame(nsGkAtoms::svgMarkerFrame, nsnull));
|
2007-07-24 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 17:01:09 +00:00
|
|
|
void
|
2012-03-02 08:28:59 +00:00
|
|
|
nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext)
|
2006-06-20 17:01:09 +00:00
|
|
|
{
|
2012-03-02 08:28:59 +00:00
|
|
|
gfxContext *gfx = aContext->ThebesContext();
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2012-03-02 08:28:59 +00:00
|
|
|
PRUint16 renderMode = SVGAutoRenderState::GetRenderMode(aContext);
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2009-04-24 13:11:03 +00:00
|
|
|
switch (GetStyleSVG()->mShapeRendering) {
|
|
|
|
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 17:01:09 +00:00
|
|
|
|
2009-10-30 20:21:49 +00:00
|
|
|
/* save/restore the state so we don't screw up the xform */
|
|
|
|
gfx->Save();
|
|
|
|
|
|
|
|
GeneratePath(gfx);
|
|
|
|
|
2012-03-02 08:28:59 +00:00
|
|
|
if (renderMode != SVGAutoRenderState::NORMAL) {
|
2009-10-30 20:21:49 +00:00
|
|
|
gfx->Restore();
|
|
|
|
|
2006-06-20 17:01:09 +00:00
|
|
|
if (GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
|
2006-06-20 17:01:09 +00:00
|
|
|
else
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->SetFillRule(gfxContext::FILL_RULE_WINDING);
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2012-03-02 08:28:59 +00:00
|
|
|
if (renderMode == SVGAutoRenderState::CLIP_MASK) {
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
gfx->Fill();
|
|
|
|
gfx->NewPath();
|
2006-06-20 17:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
if (SetupCairoFill(gfx)) {
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->Fill();
|
2006-06-20 17:01:09 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
if (SetupCairoStroke(gfx)) {
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->Stroke();
|
2006-06-20 17:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->NewPath();
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2007-01-31 16:05:42 +00:00
|
|
|
gfx->Restore();
|
2006-06-20 17:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-04-29 04:31:34 +00:00
|
|
|
nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext,
|
|
|
|
const gfxMatrix *aOverrideTransform)
|
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 12:39:26 +00:00
|
|
|
{
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxMatrix matrix;
|
|
|
|
if (aOverrideTransform) {
|
|
|
|
matrix = *aOverrideTransform;
|
|
|
|
} else {
|
|
|
|
matrix = GetCanvasTM();
|
|
|
|
}
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2007-01-31 16:05:42 +00:00
|
|
|
if (matrix.IsSingular()) {
|
|
|
|
aContext->IdentityMatrix();
|
|
|
|
aContext->NewPath();
|
2006-06-20 17:01:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-31 16:05:42 +00:00
|
|
|
|
2007-03-27 12:43:59 +00:00
|
|
|
aContext->Multiply(matrix);
|
2006-06-20 17:01:09 +00:00
|
|
|
|
2011-04-20 09:16:02 +00:00
|
|
|
// Hack to let SVGPathData::ConstructPath know if we have square caps:
|
|
|
|
const nsStyleSVG* style = GetStyleSVG();
|
|
|
|
if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) {
|
|
|
|
aContext->SetLineCap(gfxContext::LINE_CAP_SQUARE);
|
|
|
|
}
|
|
|
|
|
2007-01-31 16:05:42 +00:00
|
|
|
aContext->NewPath();
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsSVGPathGeometryElement*>(mContent)->ConstructPath(aContext);
|
2006-06-20 17:01:09 +00:00
|
|
|
}
|