2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-26 04:58:59 -07:00
|
|
|
// Main header first:
|
|
|
|
#include "nsSVGTSpanFrame.h"
|
|
|
|
|
|
|
|
// Keep others in (case-insensitive) order:
|
2012-06-30 04:20:46 -07:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGTSpanFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGTSpanFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGTSpanFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::svgTSpanFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2009-01-12 11:20:59 -08:00
|
|
|
// nsQueryFrame methods
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGTSpanFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentNode)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGTSpanFrameBase)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
|
|
|
|
2009-01-19 10:31:34 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTSpanFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aParent, "null parent");
|
|
|
|
|
|
|
|
// Some of our subclasses have an aContent that's not a <svg:tspan> or are
|
|
|
|
// allowed to be constructed even when there is no nsISVGTextContentMetrics
|
|
|
|
// ancestor. For example, nsSVGAFrame inherits from us but may have nothing
|
|
|
|
// to do with text.
|
|
|
|
if (GetType() == nsGkAtoms::svgTSpanFrame) {
|
|
|
|
nsIFrame* ancestorFrame = nsSVGUtils::GetFirstNonAAncestorFrame(aParent);
|
|
|
|
NS_ASSERTION(ancestorFrame, "Must have ancestor");
|
|
|
|
|
2009-05-29 03:15:40 -07:00
|
|
|
nsSVGTextContainerFrame *metrics = do_QueryFrame(ancestorFrame);
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_ASSERTION(metrics,
|
|
|
|
"trying to construct an SVGTSpanFrame for an invalid "
|
|
|
|
"container");
|
|
|
|
|
2013-01-07 19:22:41 -08:00
|
|
|
NS_ASSERTION(aContent->IsSVG() && (aContent->Tag() == nsGkAtoms::altGlyph ||
|
|
|
|
aContent->Tag() == nsGkAtoms::tspan),
|
|
|
|
"Content is not an SVG tspan or altGlyph");
|
2009-01-19 10:31:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsSVGTSpanFrameBase::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGTSpanFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
(aAttribute == nsGkAtoms::x ||
|
|
|
|
aAttribute == nsGkAtoms::y ||
|
|
|
|
aAttribute == nsGkAtoms::dx ||
|
2010-10-17 09:27:49 -07:00
|
|
|
aAttribute == nsGkAtoms::dy ||
|
|
|
|
aAttribute == nsGkAtoms::rotate)) {
|
2012-11-28 01:42:13 -08:00
|
|
|
nsSVGUtils::InvalidateBounds(this, false);
|
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
2008-04-08 05:51:19 -07:00
|
|
|
NotifyGlyphMetricsChange();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGContainerFrame methods:
|
|
|
|
|
2009-04-28 21:31:34 -07:00
|
|
|
gfxMatrix
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGTSpanFrame::GetCanvasTM(uint32_t aFor)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-06-30 04:20:46 -07:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
|
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(mParent, "null parent");
|
2012-06-30 04:20:46 -07:00
|
|
|
return static_cast<nsSVGContainerFrame*>(mParent)->GetCanvasTM(aFor);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGGlyphFragmentNode methods:
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGTSpanFrame::GetNumberOfChars()
|
|
|
|
{
|
|
|
|
return nsSVGTSpanFrameBase::GetNumberOfChars();
|
|
|
|
}
|
|
|
|
|
2009-05-29 03:15:40 -07:00
|
|
|
float
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGTSpanFrame::GetComputedTextLength()
|
|
|
|
{
|
|
|
|
return nsSVGTSpanFrameBase::GetComputedTextLength();
|
|
|
|
}
|
|
|
|
|
2009-05-29 03:15:40 -07:00
|
|
|
float
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGTSpanFrame::GetSubStringLength(uint32_t charnum, uint32_t nchars)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-05-29 03:15:40 -07:00
|
|
|
return nsSVGTSpanFrameBase::GetSubStringLength(charnum, nchars);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2013-01-06 06:14:43 -08:00
|
|
|
nsSVGTSpanFrame::GetCharNumAtPosition(mozilla::nsISVGPoint *point)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsSVGTSpanFrameBase::GetCharNumAtPosition(point);
|
|
|
|
}
|
|
|
|
|
2011-05-07 10:08:41 -07:00
|
|
|
NS_IMETHODIMP_(nsSVGGlyphFrame *)
|
|
|
|
nsSVGTSpanFrame::GetFirstGlyphFrame()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// try children first:
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsISVGGlyphFragmentNode *node = do_QueryFrame(kid);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (node)
|
2011-05-07 10:08:41 -07:00
|
|
|
return node->GetFirstGlyphFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// nope. try siblings:
|
2011-05-07 10:08:41 -07:00
|
|
|
return GetNextGlyphFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-07 10:08:41 -07:00
|
|
|
NS_IMETHODIMP_(nsSVGGlyphFrame *)
|
|
|
|
nsSVGTSpanFrame::GetNextGlyphFrame()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-18 04:09:36 -07:00
|
|
|
nsIFrame* sibling = GetNextSibling();
|
2007-03-22 10:30:00 -07:00
|
|
|
while (sibling) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsISVGGlyphFragmentNode *node = do_QueryFrame(sibling);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (node)
|
2011-05-07 10:08:41 -07:00
|
|
|
return node->GetFirstGlyphFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
sibling = sibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// no more siblings. go back up the tree.
|
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
NS_ASSERTION(GetParent(), "null parent");
|
|
|
|
nsISVGGlyphFragmentNode *node = do_QueryFrame(GetParent());
|
2012-07-30 07:20:58 -07:00
|
|
|
return node ? node->GetNextGlyphFrame() : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
2011-09-28 23:19:26 -07:00
|
|
|
nsSVGTSpanFrame::SetWhitespaceCompression(bool)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-05-03 00:45:30 -07:00
|
|
|
nsSVGTSpanFrameBase::SetWhitespaceCompression();
|
2010-12-16 02:57:35 -08:00
|
|
|
}
|