Backout Bug 388547 due to Mac test orange

This commit is contained in:
Robert Longson 2009-10-11 14:03:06 +01:00
Родитель 1dbfbb3e36
Коммит 4e895fad8b
11 изменённых файлов: 124 добавлений и 304 удалений

Просмотреть файл

@ -41,9 +41,7 @@
#include "nsIDOMSVGTSpanElement.h"
#include "nsCOMPtr.h"
#include "nsSVGAnimatedLengthList.h"
#include "nsSVGAnimatedNumberList.h"
#include "nsSVGLengthList.h"
#include "nsSVGNumberList.h"
#include "nsSVGSVGElement.h"
#include "nsSVGTextContentElement.h"
#include "nsIFrame.h"
@ -93,7 +91,6 @@ protected:
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mY;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mdX;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mdY;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> mRotate;
};
@ -181,18 +178,6 @@ nsSVGTSpanElement::Init()
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: nsIDOMSVGTextPositioningElement::rotate, #IMPLIED attrib: rotate
{
nsCOMPtr<nsIDOMSVGNumberList> numberList;
rv = NS_NewSVGNumberList(getter_AddRefs(numberList));
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedNumberList(getter_AddRefs(mRotate),
numberList);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::rotate, mRotate);
NS_ENSURE_SUCCESS(rv,rv);
}
return rv;
}
@ -246,9 +231,8 @@ NS_IMETHODIMP nsSVGTSpanElement::GetDy(nsIDOMSVGAnimatedLengthList * *aDy)
/* readonly attribute nsIDOMSVGAnimatedNumberList rotate; */
NS_IMETHODIMP nsSVGTSpanElement::GetRotate(nsIDOMSVGAnimatedNumberList * *aRotate)
{
*aRotate = mRotate;
NS_IF_ADDREF(*aRotate);
return NS_OK;
NS_NOTYETIMPLEMENTED("nsSVGTSpanElement::GetRotate");
return NS_ERROR_NOT_IMPLEMENTED;
}
//----------------------------------------------------------------------

Просмотреть файл

@ -41,9 +41,7 @@
#include "nsIDOMSVGTextElement.h"
#include "nsCOMPtr.h"
#include "nsSVGAnimatedLengthList.h"
#include "nsSVGAnimatedNumberList.h"
#include "nsSVGLengthList.h"
#include "nsSVGNumberList.h"
#include "nsSVGSVGElement.h"
#include "nsSVGTextContentElement.h"
#include "nsIFrame.h"
@ -90,7 +88,6 @@ protected:
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mY;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mdX;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> mdY;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> mRotate;
};
@ -177,18 +174,6 @@ nsSVGTextElement::Init()
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: nsIDOMSVGTextPositioningElement::rotate, #IMPLIED attrib: rotate
{
nsCOMPtr<nsIDOMSVGNumberList> numberList;
rv = NS_NewSVGNumberList(getter_AddRefs(numberList));
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewSVGAnimatedNumberList(getter_AddRefs(mRotate),
numberList);
NS_ENSURE_SUCCESS(rv,rv);
rv = AddMappedSVGValue(nsGkAtoms::rotate, mRotate);
NS_ENSURE_SUCCESS(rv,rv);
}
return rv;
}
@ -242,9 +227,8 @@ NS_IMETHODIMP nsSVGTextElement::GetDy(nsIDOMSVGAnimatedLengthList * *aDy)
/* readonly attribute nsIDOMSVGAnimatedNumberList rotate; */
NS_IMETHODIMP nsSVGTextElement::GetRotate(nsIDOMSVGAnimatedNumberList * *aRotate)
{
*aRotate = mRotate;
NS_IF_ADDREF(*aRotate);
return NS_OK;
NS_NOTYETIMPLEMENTED("nsSVGTextElement::GetRotate");
return NS_ERROR_NOT_IMPLEMENTED;
}
//----------------------------------------------------------------------

Просмотреть файл

@ -122,7 +122,6 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == text-font-weight-01.svg text-font-weigh
== switch-01.svg pass.svg
== text-gradient-01.svg text-gradient-01-ref.svg
== text-in-link-01.svg text-in-link-01-ref.svg
== text-layout-01.svg text-layout-01-ref.svg
== text-scale-01.svg text-scale-01-ref.svg
== text-style-01a.svg text-style-01-ref.svg
== text-style-01b.svg text-style-01-ref.svg

Просмотреть файл

@ -58,12 +58,15 @@ public:
NS_IMETHOD_(float) GetAdvance(PRBool aForceGlobalTransform)=0;
NS_IMETHOD_(void) SetGlyphPosition(gfxPoint *aPosition, PRBool aForceGlobalTransform)=0;
NS_IMETHOD_(void) SetGlyphPosition(float x, float y, PRBool aForceGlobalTransform)=0;
NS_IMETHOD_(nsSVGTextPathFrame*) FindTextPathParent()=0;
NS_IMETHOD_(PRBool) IsStartOfChunk()=0; // == is new absolutely positioned chunk.
NS_IMETHOD_(void) GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y)=0;
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX()=0;
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY()=0;
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx()=0;
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy()=0;
NS_IMETHOD_(PRUint16) GetTextAnchor()=0;
NS_IMETHOD_(PRBool) IsAbsolutelyPositioned()=0;
};

Просмотреть файл

@ -660,193 +660,82 @@ nsSVGGlyphFrame::GetCharacterData(nsAString & aCharacterData)
return !characterData.IsEmpty();
}
static PRUint32
GetNumberOfLengthListItems(nsIDOMSVGLengthList *aList)
{
PRUint32 items = 0;
if (aList) {
aList->GetNumberOfItems(&items);
}
return items;
}
static PRUint32
GetNumberOfNumberListItems(nsIDOMSVGNumberList *aList)
{
PRUint32 items = 0;
if (aList) {
aList->GetNumberOfItems(&items);
}
return items;
}
static float
GetLengthListValue(nsIDOMSVGLengthList *aList, PRUint32 aIndex)
{
if (!aList) {
return 0.0f;
}
nsCOMPtr<nsIDOMSVGLength> length;
nsresult rv = aList->GetItem(aIndex, getter_AddRefs(length));
float value = 0.0f;
if (NS_SUCCEEDED(rv)) {
length->GetValue(&value);
}
return value;
}
static float
GetNumberListValue(nsIDOMSVGNumberList *aList, PRUint32 aIndex)
{
if (!aList) {
return 0.0f;
}
nsCOMPtr<nsIDOMSVGNumber> number;
nsresult rv = aList->GetItem(aIndex, getter_AddRefs(number));
float value = 0.0f;
if (NS_SUCCEEDED(rv)) {
number->GetValue(&value);
}
return value;
}
PRBool
nsSVGGlyphFrame::GetCharacterPositions(nsTArray<CharacterPosition>* aCharacterPositions,
float aMetricsScale)
{
PRUint32 strLength = mTextRun->GetLength();
NS_ASSERTION(strLength > 0, "no text");
const gfxFloat radPerDeg = M_PI / 180.0;
nsCOMPtr<nsIDOMSVGLengthList> dxList = GetDx();
nsCOMPtr<nsIDOMSVGLengthList> dyList = GetDy();
nsCOMPtr<nsIDOMSVGNumberList> rotateList = GetRotate();
gfxPoint pos = mPosition;
NS_ASSERTION(mTextRun->GetLength() > 0, "no text");
nsSVGTextPathFrame *textPath = FindTextPathParent();
if (textPath) {
nsRefPtr<gfxFlattenedPath> data = textPath->GetFlattenedPath();
// textPath frame, but invalid target
if (!data)
return PR_FALSE;
if (!aCharacterPositions->SetLength(strLength))
return PR_FALSE;
gfxFloat pathScale = textPath->GetPathScale();
CharacterPosition *cp = aCharacterPositions->Elements();
gfxFloat length = data->GetLength();
for (PRUint32 i = 0; i < strLength; i++) {
gfxFloat halfAdvance =
mTextRun->GetAdvanceWidth(i, 1, nsnull)*aMetricsScale / 2.0;
pos.x += GetLengthListValue(dxList, i) * pathScale;
pos.y += GetLengthListValue(dyList, i) * pathScale;
// check that we're within the path boundaries
cp[i].draw = (pos.x + halfAdvance >= 0.0 &&
pos.x + halfAdvance <= length);
if (cp[i].draw) {
// add y (normal)
// add rotation
// move point back along tangent
gfxPoint pt = data->FindPoint(gfxPoint(pos.x + halfAdvance, pos.y),
&(cp[i].angle));
cp[i].pos =
pt - gfxPoint(cos(cp[i].angle), sin(cp[i].angle)) * halfAdvance;
cp[i].angle += GetNumberListValue(rotateList, i) * radPerDeg;
}
pos.x += 2 * halfAdvance;
}
/* we're an ordinary fragment - return */
/* XXX: we might want to use this for individual x/y/dx/dy adjustment */
if (!textPath)
return PR_TRUE;
}
nsCOMPtr<nsIDOMSVGLengthList> xList = GetX();
nsCOMPtr<nsIDOMSVGLengthList> yList = GetY();
nsRefPtr<gfxFlattenedPath> data = textPath->GetFlattenedPath();
PRUint32 xListCount = GetNumberOfLengthListItems(xList);
PRUint32 yListCount = GetNumberOfLengthListItems(yList);
/* textPath frame, but invalid target */
if (!data)
return PR_FALSE;
if (xListCount <= 1 &&
yListCount <= 1 &&
GetNumberOfLengthListItems(yList) == 0 &&
GetNumberOfLengthListItems(dyList) == 0 &&
GetNumberOfNumberListItems(rotateList) == 0) {
// simple text without individual positioning
return PR_TRUE;
}
gfxFloat length = data->GetLength();
PRUint32 strLength = mTextRun->GetLength();
if (!aCharacterPositions->SetLength(strLength))
return PR_FALSE;
CharacterPosition *cp = aCharacterPositions->Elements();
PRUint16 anchor = GetTextAnchor();
for (PRUint32 k = 0; k < strLength; k++)
cp[k].draw = PR_FALSE;
gfxFloat x = mPosition.x;
for (PRUint32 i = 0; i < strLength; i++) {
cp[i].draw = PR_TRUE;
gfxFloat halfAdvance =
mTextRun->GetAdvanceWidth(i, 1, nsnull)*aMetricsScale / 2.0;
gfxFloat advance = mTextRun->GetAdvanceWidth(i, 1, nsnull)*aMetricsScale;
if (xListCount > 1 && i < xListCount) {
pos.x = GetLengthListValue(xList, i);
// apply text-anchor to character
if (anchor == NS_STYLE_TEXT_ANCHOR_MIDDLE)
pos.x -= advance/2.0;
else if (anchor == NS_STYLE_TEXT_ANCHOR_END)
pos.x -= advance;
/* have we run off the end of the path? */
if (x + halfAdvance > length)
break;
/* check that we've advanced to the start of the path */
if (x + halfAdvance >= 0.0) {
cp[i].draw = PR_TRUE;
// add y (normal)
// add rotation
// move point back along tangent
gfxPoint pt = data->FindPoint(gfxPoint(x + halfAdvance, mPosition.y),
&(cp[i].angle));
cp[i].pos =
pt - gfxPoint(cos(cp[i].angle), sin(cp[i].angle)) * halfAdvance;
}
if (yListCount > 1 && i < yListCount) {
pos.y = GetLengthListValue(yList, i);
}
pos.x += GetLengthListValue(dxList, i);
pos.y += GetLengthListValue(dyList, i);
cp[i].pos = pos;
pos.x += advance;
cp[i].angle = GetNumberListValue(rotateList, i) * radPerDeg;
x += 2 * halfAdvance;
}
return PR_TRUE;
}
float
nsSVGGlyphFrame::GetSubStringAdvance(PRUint32 aCharnum,
PRUint32 aFragmentChars,
float aMetricsScale)
nsSVGGlyphFrame::GetSubStringAdvance(PRUint32 charnum,
PRUint32 fragmentChars)
{
if (aFragmentChars == 0)
if (fragmentChars == 0)
return 0.0f;
gfxFloat advance =
mTextRun->GetAdvanceWidth(aCharnum, aFragmentChars, nsnull) * aMetricsScale;
nsCOMPtr<nsIDOMSVGLengthList> dxlist = GetDx();
PRUint32 dxcount = GetNumberOfLengthListItems(dxlist);
if (dxcount) {
gfxFloat pathScale = 1.0;
nsSVGTextPathFrame *textPath = FindTextPathParent();
if (textPath)
pathScale = textPath->GetPathScale();
if (dxcount > aFragmentChars)
dxcount = aFragmentChars;
for (PRUint32 i = aCharnum; i < dxcount; i++) {
advance += GetLengthListValue(dxlist, i) * pathScale;
}
}
gfxFloat advance = mTextRun->GetAdvanceWidth(charnum, fragmentChars, nsnull);
return float(advance);
}
gfxFloat
nsSVGGlyphFrame::GetBaselineOffset(float aMetricsScale)
nsSVGGlyphFrame::GetBaselineOffset(PRBool aForceGlobalTransform)
{
float drawScale, metricsScale;
if (!EnsureTextRun(&drawScale, &metricsScale, aForceGlobalTransform))
return 0.0;
gfxTextRun::Metrics metrics =
mTextRun->MeasureText(0, mTextRun->GetLength(),
gfxFont::LOOSE_INK_EXTENTS, nsnull, nsnull);
@ -884,7 +773,7 @@ nsSVGGlyphFrame::GetBaselineOffset(float aMetricsScale)
NS_WARNING("We don't know about this type of dominant-baseline");
return 0.0;
}
return baselineAppUnits * aMetricsScale;
return baselineAppUnits * metricsScale;
}
//----------------------------------------------------------------------
@ -1025,40 +914,9 @@ nsSVGGlyphFrame::GetHighlight(PRUint32 *charnum, PRUint32 *nchars,
// nsISVGGlyphFragmentLeaf interface:
NS_IMETHODIMP_(void)
nsSVGGlyphFrame::SetGlyphPosition(gfxPoint *aPosition, PRBool aForceGlobalTransform)
nsSVGGlyphFrame::SetGlyphPosition(float x, float y, PRBool aForceGlobalTransform)
{
float drawScale, metricsScale;
if (!EnsureTextRun(&drawScale, &metricsScale, aForceGlobalTransform))
return;
mPosition.MoveTo(aPosition->x, aPosition->y - GetBaselineOffset(metricsScale));
PRUint32 strLength = mTextRun->GetLength();
aPosition->x +=
mTextRun->GetAdvanceWidth(0, strLength, nsnull) * metricsScale;
gfxFloat pathScale = 1.0;
nsSVGTextPathFrame *textPath = FindTextPathParent();
if (textPath)
pathScale = textPath->GetPathScale();
nsCOMPtr<nsIDOMSVGLengthList> dxList = GetDx();
nsCOMPtr<nsIDOMSVGLengthList> dyList = GetDy();
PRUint32 dxcount = GetNumberOfLengthListItems(dxList);
if (dxcount > strLength)
dxcount = strLength;
for (PRUint32 i = 0; i < dxcount; i++) {
aPosition->x += GetLengthListValue(dxList, i) * pathScale;
}
PRUint32 dycount = GetNumberOfLengthListItems(dyList);
if (dycount > strLength)
dycount = strLength;
for (PRUint32 i = 0; i < dycount; i++) {
aPosition->y += GetLengthListValue(dyList, i) * pathScale;
}
mPosition.MoveTo(x, y - GetBaselineOffset(aForceGlobalTransform));
nsSVGUtils::UpdateGraphic(this);
}
@ -1145,7 +1003,8 @@ nsSVGGlyphFrame::GetAdvance(PRBool aForceGlobalTransform)
if (!EnsureTextRun(&drawScale, &metricsScale, aForceGlobalTransform))
return 0.0f;
return GetSubStringAdvance(0, mTextRun->GetLength(), metricsScale);
float advanceAppUnits = GetSubStringAdvance(0, mTextRun->GetLength());
return advanceAppUnits * metricsScale;
}
NS_IMETHODIMP_(nsSVGTextPathFrame*)
@ -1174,6 +1033,11 @@ nsSVGGlyphFrame::IsStartOfChunk()
return PR_FALSE;
}
NS_IMETHODIMP_(void)
nsSVGGlyphFrame::GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y)
{
}
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGGlyphFrame::GetX()
{
@ -1194,7 +1058,7 @@ nsSVGGlyphFrame::GetY()
return nsnull;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGGlyphFrame::GetDx()
{
nsSVGTextContainerFrame *containerFrame;
@ -1204,7 +1068,7 @@ nsSVGGlyphFrame::GetDx()
return nsnull;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGGlyphFrame::GetDy()
{
nsSVGTextContainerFrame *containerFrame;
@ -1214,16 +1078,6 @@ nsSVGGlyphFrame::GetDy()
return nsnull;
}
already_AddRefed<nsIDOMSVGNumberList>
nsSVGGlyphFrame::GetRotate()
{
nsSVGTextContainerFrame *containerFrame;
containerFrame = static_cast<nsSVGTextContainerFrame *>(mParent);
if (containerFrame)
return containerFrame->GetRotate();
return nsnull;
}
NS_IMETHODIMP_(PRUint16)
nsSVGGlyphFrame::GetTextAnchor()
{
@ -1288,7 +1142,8 @@ nsSVGGlyphFrame::GetSubStringLength(PRUint32 charnum, PRUint32 fragmentChars)
if (!EnsureTextRun(&drawScale, &metricsScale, PR_FALSE))
return 0.0f;
return GetSubStringAdvance(charnum, fragmentChars, metricsScale);
float advanceAppUnits = GetSubStringAdvance(charnum, fragmentChars);
return advanceAppUnits * metricsScale;
}
PRInt32

Просмотреть файл

@ -145,12 +145,15 @@ public:
*/
NS_IMETHOD_(float) GetAdvance(PRBool aForceGlobalTransform);
NS_IMETHOD_(void) SetGlyphPosition(gfxPoint *aPosition, PRBool aForceGlobalTransform);
NS_IMETHOD_(void) SetGlyphPosition(float x, float y, PRBool aForceGlobalTransform);
NS_IMETHOD_(nsSVGTextPathFrame*) FindTextPathParent();
NS_IMETHOD_(PRBool) IsStartOfChunk(); // == is new absolutely positioned chunk.
NS_IMETHOD_(void) GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y);
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy();
NS_IMETHOD_(PRUint16) GetTextAnchor();
NS_IMETHOD_(PRBool) IsAbsolutelyPositioned();
@ -203,19 +206,14 @@ protected:
void SetupGlobalTransform(gfxContext *aContext);
nsresult GetHighlight(PRUint32 *charnum, PRUint32 *nchars,
nscolor *foreground, nscolor *background);
float GetSubStringAdvance(PRUint32 aCharnum, PRUint32 aFragmentChars,
float aMetricsScale);
gfxFloat GetBaselineOffset(float aMetricsScale);
float GetSubStringAdvance(PRUint32 charnum, PRUint32 fragmentChars);
gfxFloat GetBaselineOffset(PRBool aForceGlobalTransform);
const nsTextFragment* GetFragment() const
{
return !(GetStateBits() & NS_STATE_SVG_PRINTING) ?
mContent->GetText() : nsLayoutUtils::GetTextFragmentForPrinting(this);
}
already_AddRefed<nsIDOMSVGLengthList> GetDx();
already_AddRefed<nsIDOMSVGLengthList> GetDy();
already_AddRefed<nsIDOMSVGNumberList> GetRotate();
// Used to support GetBBoxContribution by making GetConvasTM use this as the
// parent transform instead of the real CanvasTM.
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCanvasTM;

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsSVGOuterSVGFrame.h"
#include "nsIDOMSVGTextElement.h"
#include "nsIDOMSVGAnimatedLengthList.h"
#include "nsIDOMSVGAnimatedNumberList.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsDOMError.h"
@ -61,7 +60,7 @@ nsSVGTextContainerFrame::NotifyGlyphMetricsChange()
textFrame->NotifyGlyphMetricsChange();
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextContainerFrame::GetX()
{
nsCOMPtr<nsIDOMSVGTextPositioningElement> tpElement =
@ -70,6 +69,9 @@ nsSVGTextContainerFrame::GetX()
if (!tpElement)
return nsnull;
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::x))
return nsnull;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> animLengthList;
tpElement->GetX(getter_AddRefs(animLengthList));
nsIDOMSVGLengthList *retval;
@ -77,7 +79,7 @@ nsSVGTextContainerFrame::GetX()
return retval;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextContainerFrame::GetY()
{
nsCOMPtr<nsIDOMSVGTextPositioningElement> tpElement =
@ -86,6 +88,9 @@ nsSVGTextContainerFrame::GetY()
if (!tpElement)
return nsnull;
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::y))
return nsnull;
nsCOMPtr<nsIDOMSVGAnimatedLengthList> animLengthList;
tpElement->GetY(getter_AddRefs(animLengthList));
nsIDOMSVGLengthList *retval;
@ -93,7 +98,7 @@ nsSVGTextContainerFrame::GetY()
return retval;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextContainerFrame::GetDx()
{
nsCOMPtr<nsIDOMSVGTextPositioningElement> tpElement =
@ -109,7 +114,7 @@ nsSVGTextContainerFrame::GetDx()
return retval;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextContainerFrame::GetDy()
{
nsCOMPtr<nsIDOMSVGTextPositioningElement> tpElement =
@ -125,22 +130,6 @@ nsSVGTextContainerFrame::GetDy()
return retval;
}
already_AddRefed<nsIDOMSVGNumberList>
nsSVGTextContainerFrame::GetRotate()
{
nsCOMPtr<nsIDOMSVGTextPositioningElement> tpElement =
do_QueryInterface(mContent);
if (!tpElement)
return nsnull;
nsCOMPtr<nsIDOMSVGAnimatedNumberList> animNumberList;
tpElement->GetRotate(getter_AddRefs(animNumberList));
nsIDOMSVGNumberList *retval;
animNumberList->GetAnimVal(&retval);
return retval;
}
//----------------------------------------------------------------------
// nsIFrame methods

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsSVGContainerFrame.h"
#include "nsIDOMSVGLengthList.h"
#include "nsIDOMSVGNumberList.h"
class nsISVGGlyphFragmentNode;
class nsISVGGlyphFragmentLeaf;
@ -53,11 +52,10 @@ public:
nsSVGDisplayContainerFrame(aContext) {}
void NotifyGlyphMetricsChange();
virtual already_AddRefed<nsIDOMSVGLengthList> GetX();
virtual already_AddRefed<nsIDOMSVGLengthList> GetY();
virtual already_AddRefed<nsIDOMSVGLengthList> GetDx();
virtual already_AddRefed<nsIDOMSVGLengthList> GetDy();
virtual already_AddRefed<nsIDOMSVGNumberList> GetRotate();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy();
public:
NS_DECL_QUERYFRAME_TARGET(nsSVGTextContainerFrame)

Просмотреть файл

@ -292,19 +292,21 @@ nsSVGTextFrame::NotifyGlyphMetricsChange()
}
static void
GetSingleValue(nsIDOMSVGLengthList *list, gfxFloat *val)
GetSingleValue(nsIDOMSVGLengthList *list, float *val)
{
if (!list)
return;
PRUint32 count = 0;
list->GetNumberOfItems(&count);
#ifdef DEBUG
if (count > 1)
NS_WARNING("multiple lengths for x/y attributes on <text> elements not implemented yet!");
#endif
if (count) {
nsCOMPtr<nsIDOMSVGLength> length;
list->GetItem(0, getter_AddRefs(length));
float value;
length->GetValue(&value);
*val = value;
length->GetValue(val);
}
}
@ -328,26 +330,26 @@ nsSVGTextFrame::UpdateGlyphPositioning(PRBool aForceGlobalTransform)
return;
}
gfxPoint ctp(0.0, 0.0);
float x = 0, y = 0;
{
nsCOMPtr<nsIDOMSVGLengthList> list = GetX();
GetSingleValue(list, &ctp.x);
GetSingleValue(list, &x);
}
{
nsCOMPtr<nsIDOMSVGLengthList> list = GetY();
GetSingleValue(list, &ctp.y);
GetSingleValue(list, &y);
}
// loop over chunks
while (firstFragment) {
{
nsCOMPtr<nsIDOMSVGLengthList> list = firstFragment->GetX();
GetSingleValue(list, &ctp.x);
GetSingleValue(list, &x);
}
{
nsCOMPtr<nsIDOMSVGLengthList> list = firstFragment->GetY();
GetSingleValue(list, &ctp.y);
GetSingleValue(list, &y);
}
// check for startOffset on textPath
@ -357,7 +359,7 @@ nsSVGTextFrame::UpdateGlyphPositioning(PRBool aForceGlobalTransform)
// invalid text path, give up
return;
}
ctp.x = textPath->GetStartOffset();
x = textPath->GetStartOffset();
}
// determine x offset based on text_anchor:
@ -370,7 +372,10 @@ nsSVGTextFrame::UpdateGlyphPositioning(PRBool aForceGlobalTransform)
fragment = firstFragment;
while (fragment) {
chunkLength += fragment->GetAdvance(aForceGlobalTransform);
float dx = 0.0f;
nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDx();
GetSingleValue(list, &dx);
chunkLength += dx + fragment->GetAdvance(aForceGlobalTransform);
fragment = fragment->GetNextGlyphFragment();
if (fragment && fragment->IsAbsolutelyPositioned())
break;
@ -378,16 +383,29 @@ nsSVGTextFrame::UpdateGlyphPositioning(PRBool aForceGlobalTransform)
}
if (anchor == NS_STYLE_TEXT_ANCHOR_MIDDLE)
ctp.x -= chunkLength/2.0f;
x -= chunkLength/2.0f;
else if (anchor == NS_STYLE_TEXT_ANCHOR_END)
ctp.x -= chunkLength;
x -= chunkLength;
// set position of each fragment in this chunk:
fragment = firstFragment;
while (fragment) {
fragment->SetGlyphPosition(&ctp, aForceGlobalTransform);
float dx = 0.0f, dy = 0.0f;
{
nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDx();
GetSingleValue(list, &dx);
}
{
nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDy();
GetSingleValue(list, &dy);
}
fragment->SetGlyphPosition(x + dx, y + dy, aForceGlobalTransform);
x += dx + fragment->GetAdvance(aForceGlobalTransform);
y += dy;
fragment = fragment->GetNextGlyphFragment();
if (fragment && fragment->IsAbsolutelyPositioned())
break;

Просмотреть файл

@ -84,36 +84,30 @@ nsSVGTextPathFrame::GetType() const
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextPathFrame::GetX()
{
return nsnull;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextPathFrame::GetY()
{
return nsnull;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextPathFrame::GetDx()
{
return nsnull;
}
already_AddRefed<nsIDOMSVGLengthList>
NS_IMETHODIMP_(already_AddRefed<nsIDOMSVGLengthList>)
nsSVGTextPathFrame::GetDy()
{
return nsnull;
}
already_AddRefed<nsIDOMSVGNumberList>
nsSVGTextPathFrame::GetRotate()
{
return nsnull;
}
//----------------------------------------------------------------------
// nsSVGTextPathFrame methods:

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsSVGTSpanFrame.h"
#include "nsSVGLengthList.h"
#include "nsSVGNumberList.h"
typedef nsSVGTSpanFrame nsSVGTextPathFrameBase;
@ -85,11 +84,10 @@ public:
gfxFloat GetPathScale();
protected:
virtual already_AddRefed<nsIDOMSVGLengthList> GetX();
virtual already_AddRefed<nsIDOMSVGLengthList> GetY();
virtual already_AddRefed<nsIDOMSVGLengthList> GetDx();
virtual already_AddRefed<nsIDOMSVGLengthList> GetDy();
virtual already_AddRefed<nsIDOMSVGNumberList> GetRotate();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy();
private:
already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIFrame *path);