2007-03-22 10:30:00 -07: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 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 "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGTextFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
|
|
|
#include "nsIDOMSVGTextElement.h"
|
|
|
|
#include "nsIDOMSVGAnimatedLengthList.h"
|
2010-12-03 08:40:23 -08:00
|
|
|
#include "SVGAnimatedNumberList.h"
|
|
|
|
#include "SVGNumberList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsISVGGlyphFragmentLeaf.h"
|
|
|
|
#include "nsDOMError.h"
|
2010-07-16 14:42:12 -07:00
|
|
|
#include "SVGLengthList.h"
|
2010-12-03 08:40:23 -08:00
|
|
|
#include "nsSVGTextPositioningElement.h"
|
2010-07-16 14:42:12 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
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(nsSVGTextContainerFrame)
|
2009-05-29 03:15:40 -07:00
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGTextContainerFrame)
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGDisplayContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGTextContainerFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void
|
2008-04-08 05:51:19 -07:00
|
|
|
nsSVGTextContainerFrame::NotifyGlyphMetricsChange()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsSVGTextFrame *textFrame = GetTextFrame();
|
|
|
|
if (textFrame)
|
|
|
|
textFrame->NotifyGlyphMetricsChange();
|
|
|
|
}
|
|
|
|
|
2010-07-16 14:42:12 -07:00
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::GetXY(SVGUserUnitList *aX, SVGUserUnitList *aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-16 14:42:12 -07:00
|
|
|
static_cast<nsSVGElement*>(mContent)->
|
|
|
|
GetAnimatedLengthListValues(aX, aY, nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-16 14:42:12 -07:00
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::GetDxDy(SVGUserUnitList *aDx, SVGUserUnitList *aDy)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-16 14:42:12 -07:00
|
|
|
// SVGUserUnitList is lazy, so there's little overhead it getting the x
|
|
|
|
// and y lists even though we ignore them.
|
|
|
|
SVGUserUnitList xLengthList, yLengthList;
|
|
|
|
static_cast<nsSVGElement*>(mContent)->
|
|
|
|
GetAnimatedLengthListValues(&xLengthList, &yLengthList, aDx, aDy, nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
const SVGNumberList*
|
2010-03-30 03:21:19 -07:00
|
|
|
nsSVGTextContainerFrame::GetRotate()
|
|
|
|
{
|
2010-12-03 08:40:23 -08:00
|
|
|
SVGAnimatedNumberList *animList =
|
|
|
|
static_cast<nsSVGElement*>(mContent)->
|
|
|
|
GetAnimatedNumberList(nsGkAtoms::rotate);
|
|
|
|
return animList ? &animList->GetAnimValue() : nsnull;
|
2010-03-30 03:21:19 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
|
|
|
|
2007-08-03 01:39:12 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-08-03 01:39:12 -07:00
|
|
|
{
|
|
|
|
nsresult rv = nsSVGDisplayContainerFrame::InsertFrames(aListName,
|
|
|
|
aPrevFrame,
|
|
|
|
aFrameList);
|
|
|
|
|
2008-04-08 05:51:19 -07:00
|
|
|
NotifyGlyphMetricsChange();
|
2007-08-03 01:39:12 -07:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::RemoveFrame(nsIAtom *aListName, nsIFrame *aOldFrame)
|
|
|
|
{
|
|
|
|
nsSVGTextFrame *textFrame = GetTextFrame();
|
|
|
|
|
|
|
|
nsresult rv = nsSVGDisplayContainerFrame::RemoveFrame(aListName, aOldFrame);
|
|
|
|
|
|
|
|
if (textFrame)
|
|
|
|
textFrame->NotifyGlyphMetricsChange();
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval)
|
|
|
|
{
|
|
|
|
*_retval = nsnull;
|
|
|
|
|
|
|
|
if (charnum >= GetNumberOfChars()) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
if (!node) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 offset;
|
|
|
|
nsISVGGlyphFragmentLeaf *fragment = GetGlyphFragmentAtCharNum(node, charnum, &offset);
|
|
|
|
if (!fragment) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fragment->GetStartPositionOfChar(charnum - offset, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval)
|
|
|
|
{
|
|
|
|
*_retval = nsnull;
|
|
|
|
|
|
|
|
if (charnum >= GetNumberOfChars()) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
if (!node) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 offset;
|
|
|
|
nsISVGGlyphFragmentLeaf *fragment = GetGlyphFragmentAtCharNum(node, charnum, &offset);
|
|
|
|
if (!fragment) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fragment->GetEndPositionOfChar(charnum - offset, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval)
|
|
|
|
{
|
|
|
|
*_retval = nsnull;
|
|
|
|
|
|
|
|
if (charnum >= GetNumberOfChars()) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
if (!node) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 offset;
|
|
|
|
nsISVGGlyphFragmentLeaf *fragment = GetGlyphFragmentAtCharNum(node, charnum, &offset);
|
|
|
|
if (!fragment) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fragment->GetExtentOfChar(charnum - offset, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGTextContainerFrame::GetRotationOfChar(PRUint32 charnum, float *_retval)
|
|
|
|
{
|
|
|
|
*_retval = 0.0f;
|
|
|
|
|
|
|
|
if (charnum >= GetNumberOfChars()) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
if (!node) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 offset;
|
|
|
|
nsISVGGlyphFragmentLeaf *fragment = GetGlyphFragmentAtCharNum(node, charnum, &offset);
|
|
|
|
if (!fragment) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fragment->GetRotationOfChar(charnum - offset, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsSVGTextContainerFrame::GetNumberOfChars()
|
|
|
|
{
|
|
|
|
PRUint32 nchars = 0;
|
|
|
|
nsISVGGlyphFragmentNode* node;
|
|
|
|
node = GetFirstGlyphFragmentChildNode();
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
nchars += node->GetNumberOfChars();
|
|
|
|
node = GetNextGlyphFragmentChildNode(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nchars;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
nsSVGTextContainerFrame::GetComputedTextLength()
|
|
|
|
{
|
|
|
|
float length = 0.0f;
|
|
|
|
nsISVGGlyphFragmentNode* node = GetFirstGlyphFragmentChildNode();
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
length += node->GetComputedTextLength();
|
|
|
|
node = GetNextGlyphFragmentChildNode(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
2009-05-29 03:15:40 -07:00
|
|
|
nsSVGTextContainerFrame::GetSubStringLength(PRUint32 charnum, PRUint32 nchars)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
float length = 0.0f;
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
PRUint32 count = node->GetNumberOfChars();
|
|
|
|
if (count > charnum) {
|
2009-09-16 08:01:36 -07:00
|
|
|
PRUint32 fragmentChars = NS_MIN(nchars, count);
|
2007-03-22 10:30:00 -07:00
|
|
|
float fragmentLength = node->GetSubStringLength(charnum, fragmentChars);
|
|
|
|
length += fragmentLength;
|
|
|
|
nchars -= fragmentChars;
|
|
|
|
if (nchars == 0) break;
|
|
|
|
}
|
2009-09-16 08:01:36 -07:00
|
|
|
charnum -= NS_MIN(charnum, count);
|
2007-03-22 10:30:00 -07:00
|
|
|
node = GetNextGlyphFragmentChildNode(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsSVGTextContainerFrame::GetCharNumAtPosition(nsIDOMSVGPoint *point)
|
|
|
|
{
|
|
|
|
PRInt32 index = -1;
|
|
|
|
PRInt32 offset = 0;
|
|
|
|
nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
PRUint32 count = node->GetNumberOfChars();
|
|
|
|
if (count > 0) {
|
|
|
|
PRInt32 charnum = node->GetCharNumAtPosition(point);
|
|
|
|
if (charnum >= 0) {
|
|
|
|
index = charnum + offset;
|
|
|
|
}
|
|
|
|
offset += count;
|
|
|
|
// Keep going, multiple characters may match
|
|
|
|
// and we must return the last one
|
|
|
|
}
|
|
|
|
node = GetNextGlyphFragmentChildNode(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2009-05-29 03:15:40 -07:00
|
|
|
// Protected functions
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *
|
|
|
|
nsSVGTextContainerFrame::GetFirstGlyphFragmentChildNode()
|
|
|
|
{
|
|
|
|
nsISVGGlyphFragmentNode *retval = nsnull;
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
|
|
|
retval = do_QueryFrame(kid);
|
|
|
|
if (retval) break;
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentNode *
|
|
|
|
nsSVGTextContainerFrame::GetNextGlyphFragmentChildNode(nsISVGGlyphFragmentNode *node)
|
|
|
|
{
|
|
|
|
nsISVGGlyphFragmentNode *retval = nsnull;
|
|
|
|
nsIFrame *frame = do_QueryFrame(node);
|
|
|
|
NS_ASSERTION(frame, "interface not implemented");
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
while (frame) {
|
|
|
|
retval = do_QueryFrame(frame);
|
|
|
|
if (retval) break;
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::SetWhitespaceHandling()
|
|
|
|
{
|
|
|
|
// init children:
|
|
|
|
nsISVGGlyphFragmentNode* node = GetFirstGlyphFragmentChildNode();
|
|
|
|
nsISVGGlyphFragmentNode* next;
|
|
|
|
|
|
|
|
PRUint8 whitespaceHandling = COMPRESS_WHITESPACE | TRIM_LEADING_WHITESPACE;
|
|
|
|
|
|
|
|
for (nsIFrame *frame = this; frame != nsnull; frame = frame->GetParent()) {
|
|
|
|
nsIContent *content = frame->GetContent();
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
|
|
|
{&nsGkAtoms::preserve, &nsGkAtoms::_default, nsnull};
|
|
|
|
|
|
|
|
PRInt32 index = content->FindAttrValueIn(kNameSpaceID_XML,
|
|
|
|
nsGkAtoms::space,
|
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index == 0) {
|
|
|
|
whitespaceHandling = PRESERVE_WHITESPACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (index != nsIContent::ATTR_MISSING ||
|
|
|
|
(frame->GetStateBits() & NS_STATE_IS_OUTER_SVG))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
next = GetNextGlyphFragmentChildNode(node);
|
|
|
|
if (!next && (whitespaceHandling & COMPRESS_WHITESPACE)) {
|
|
|
|
whitespaceHandling |= TRIM_TRAILING_WHITESPACE;
|
|
|
|
}
|
|
|
|
node->SetWhitespaceHandling(whitespaceHandling);
|
|
|
|
node = next;
|
|
|
|
whitespaceHandling &= ~TRIM_LEADING_WHITESPACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2007-03-22 10:30:00 -07:00
|
|
|
// Private functions
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsISVGGlyphFragmentLeaf *
|
|
|
|
nsSVGTextContainerFrame::GetGlyphFragmentAtCharNum(nsISVGGlyphFragmentNode* node,
|
|
|
|
PRUint32 charnum,
|
|
|
|
PRUint32 *offset)
|
|
|
|
{
|
|
|
|
nsISVGGlyphFragmentLeaf *fragment = node->GetFirstGlyphFragment();
|
|
|
|
*offset = 0;
|
|
|
|
|
|
|
|
while (fragment) {
|
|
|
|
PRUint32 count = fragment->GetNumberOfChars();
|
|
|
|
if (count > charnum)
|
|
|
|
return fragment;
|
|
|
|
charnum -= count;
|
|
|
|
*offset += count;
|
|
|
|
fragment = fragment->GetNextGlyphFragment();
|
|
|
|
}
|
|
|
|
|
|
|
|
// not found
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGTextFrame *
|
|
|
|
nsSVGTextContainerFrame::GetTextFrame()
|
|
|
|
{
|
|
|
|
for (nsIFrame *frame = this; frame != nsnull; frame = frame->GetParent()) {
|
|
|
|
if (frame->GetType() == nsGkAtoms::svgTextFrame) {
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsSVGTextFrame*>(frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
2010-09-17 20:46:48 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::CopyPositionList(nsTArray<float> *parentList,
|
|
|
|
SVGUserUnitList *selfList,
|
|
|
|
nsTArray<float> &dstList,
|
|
|
|
PRUint32 aOffset)
|
|
|
|
{
|
|
|
|
dstList.Clear();
|
|
|
|
|
|
|
|
PRUint32 strLength = GetNumberOfChars();
|
|
|
|
PRUint32 parentCount = 0;
|
|
|
|
if (parentList && parentList->Length() > aOffset) {
|
|
|
|
parentCount = NS_MIN(parentList->Length() - aOffset, strLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 selfCount = NS_MIN(selfList->Length(), strLength);
|
|
|
|
|
|
|
|
PRUint32 count = NS_MAX(parentCount, selfCount);
|
|
|
|
|
|
|
|
if (!dstList.SetLength(count))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < selfCount; i++) {
|
|
|
|
dstList[i] = (*selfList)[i];
|
|
|
|
}
|
|
|
|
for (PRUint32 i = selfCount; i < parentCount; i++) {
|
|
|
|
dstList[i] = (*parentList)[aOffset + i];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::CopyRotateList(nsTArray<float> *parentList,
|
2010-12-03 08:40:23 -08:00
|
|
|
const SVGNumberList *selfList,
|
2010-09-17 20:46:48 -07:00
|
|
|
nsTArray<float> &dstList,
|
|
|
|
PRUint32 aOffset)
|
|
|
|
{
|
|
|
|
dstList.Clear();
|
|
|
|
|
|
|
|
PRUint32 strLength = GetNumberOfChars();
|
|
|
|
PRUint32 parentCount = 0;
|
|
|
|
if (parentList && parentList->Length() > aOffset) {
|
|
|
|
parentCount = NS_MIN(parentList->Length() - aOffset, strLength);
|
|
|
|
}
|
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
PRUint32 selfCount = NS_MIN(selfList ? selfList->Length() : 0, strLength);
|
2010-09-17 20:46:48 -07:00
|
|
|
PRUint32 count = NS_MAX(parentCount, selfCount);
|
2010-12-03 08:40:23 -08:00
|
|
|
|
2010-09-17 20:46:48 -07:00
|
|
|
if (count > 0) {
|
|
|
|
if (!dstList.SetLength(count))
|
|
|
|
return;
|
|
|
|
for (PRUint32 i = 0; i < selfCount; i++) {
|
2010-12-03 08:40:23 -08:00
|
|
|
dstList[i] = (*selfList)[i];
|
2010-09-17 20:46:48 -07:00
|
|
|
}
|
|
|
|
for (PRUint32 i = selfCount; i < parentCount; i++) {
|
|
|
|
dstList[i] = (*parentList)[aOffset + i];
|
|
|
|
}
|
|
|
|
} else if (parentList && !parentList->IsEmpty()) {
|
|
|
|
// rotate is applied to extra characters too
|
|
|
|
dstList.AppendElement((*parentList)[parentList->Length() - 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsSVGTextContainerFrame::BuildPositionList(PRUint32 aOffset,
|
|
|
|
PRUint32 aDepth)
|
|
|
|
{
|
|
|
|
nsSVGTextContainerFrame *parent = do_QueryFrame(mParent);
|
|
|
|
nsTArray<float> *parentX = nsnull, *parentY = nsnull;
|
|
|
|
nsTArray<float> *parentDx = nsnull, *parentDy = nsnull;
|
|
|
|
nsTArray<float> *parentRotate = nsnull;
|
|
|
|
if (parent) {
|
|
|
|
parentX = &(parent->mX);
|
|
|
|
parentY = &(parent->mY);
|
|
|
|
parentDx = &(parent->mDx);
|
|
|
|
parentDy = &(parent->mDy);
|
|
|
|
parentRotate = &(parent->mRotate);
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGUserUnitList x, y;
|
|
|
|
GetXY(&x, &y);
|
|
|
|
CopyPositionList(parentX, &x, mX, aOffset);
|
|
|
|
CopyPositionList(parentY, &y, mY, aOffset);
|
|
|
|
|
|
|
|
SVGUserUnitList dx, dy;
|
|
|
|
GetDxDy(&dx, &dy);
|
|
|
|
CopyPositionList(parentDx, &dx, mDx, aOffset);
|
|
|
|
CopyPositionList(parentDy, &dy, mDy, aOffset);
|
|
|
|
|
2010-12-03 08:40:23 -08:00
|
|
|
const SVGNumberList *rotate = GetRotate();
|
2010-09-17 20:46:48 -07:00
|
|
|
CopyRotateList(parentRotate, rotate, mRotate, aOffset);
|
|
|
|
|
|
|
|
PRUint32 startIndex = 0;
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
|
|
|
nsSVGTextContainerFrame *text = do_QueryFrame(kid);
|
|
|
|
nsISVGGlyphFragmentLeaf *leaf = do_QueryFrame(kid);
|
|
|
|
if (text) {
|
|
|
|
startIndex += text->BuildPositionList(startIndex, aDepth + 1);
|
|
|
|
} else if (leaf) {
|
|
|
|
leaf->SetStartIndex(startIndex);
|
|
|
|
startIndex += leaf->GetNumberOfChars();
|
|
|
|
}
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
return startIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::GetEffectiveXY(nsTArray<float> &aX,
|
|
|
|
nsTArray<float> &aY)
|
|
|
|
{
|
|
|
|
aX.AppendElements(mX);
|
|
|
|
aY.AppendElements(mY);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::GetEffectiveDxDy(nsTArray<float> &aDx,
|
|
|
|
nsTArray<float> &aDy)
|
|
|
|
{
|
|
|
|
aDx.AppendElements(mDx);
|
|
|
|
aDy.AppendElements(mDy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGTextContainerFrame::GetEffectiveRotate(nsTArray<float> &aRotate)
|
|
|
|
{
|
|
|
|
aRotate.AppendElements(mRotate);
|
|
|
|
}
|