Bug 865901 - make nsSVGTextFrame2::mPositioningDirty and mPositioningUsesPercentages SVG frame state bits. r=cam

This commit is contained in:
Robert Longson 2013-06-24 12:20:38 +01:00
Родитель da4a0e4de0
Коммит 00d1add813
5 изменённых файлов: 65 добавлений и 61 удалений

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

@ -238,14 +238,14 @@ nsSVGTextFrame::ReflowSVG()
"ReflowSVG mechanism not designed for this");
if (!nsSVGUtils::NeedsReflowSVG(this)) {
NS_ASSERTION(!mPositioningDirty, "How did this happen?");
NS_ASSERTION(!(mState & NS_STATE_SVG_POSITIONING_DIRTY), "How did this happen?");
return;
}
// UpdateGlyphPositioning may have been called under DOM calls and set
// mPositioningDirty to false. We may now have better positioning, though, so
// UpdateGlyphPositioning may have been called under DOM calls and cleared
// NS_STATE_SVG_POSITIONING_DIRTY. We may now have better positioning, though, so
// set it to true so that UpdateGlyphPositioning will do its work.
mPositioningDirty = true;
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
UpdateGlyphPositioning(false);
@ -326,7 +326,7 @@ nsSVGTextFrame::NotifyGlyphMetricsChange()
nsSVGEffects::InvalidateRenderingObservers(this);
nsSVGUtils::ScheduleReflowSVG(this);
mPositioningDirty = true;
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
}
void
@ -374,10 +374,10 @@ nsSVGTextFrame::SetWhitespaceHandling(nsSVGGlyphFrame *aFrame)
void
nsSVGTextFrame::UpdateGlyphPositioning(bool aForceGlobalTransform)
{
if (!mPositioningDirty)
if (!(mState & NS_STATE_SVG_POSITIONING_DIRTY))
return;
mPositioningDirty = false;
RemoveStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
nsISVGGlyphFragmentNode* node = GetFirstGlyphFragmentChildNode();
if (!node)

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

@ -26,9 +26,10 @@ class nsSVGTextFrame : public nsSVGTextFrameBase
friend nsIFrame*
NS_NewSVGTextFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
protected:
nsSVGTextFrame(nsStyleContext* aContext)
: nsSVGTextFrameBase(aContext),
mPositioningDirty(true) {}
nsSVGTextFrame(nsStyleContext* aContext) : nsSVGTextFrameBase(aContext)
{
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
}
public:
NS_DECL_FRAMEARENA_HELPERS
@ -101,8 +102,6 @@ private:
void SetWhitespaceHandling(nsSVGGlyphFrame *aFrame);
nsAutoPtr<gfxMatrix> mCanvasTM;
bool mPositioningDirty;
};
#endif

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

@ -3261,7 +3261,8 @@ nsSVGTextFrame2::NotifySVGChanged(uint32_t aFlags)
bool needGlyphMetricsUpdate = false;
bool needNewCanvasTM = false;
if ((aFlags & COORD_CONTEXT_CHANGED) && mPositioningMayUsePercentages) {
if ((aFlags & COORD_CONTEXT_CHANGED) &&
(mState & NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES)) {
needGlyphMetricsUpdate = true;
}
@ -3533,7 +3534,7 @@ nsSVGTextFrame2::ReflowSVG()
"ReflowSVG mechanism not designed for this");
if (!nsSVGUtils::NeedsReflowSVG(this)) {
NS_ASSERTION(!mPositioningDirty, "How did this happen?");
NS_ASSERTION(!(mState & NS_STATE_SVG_POSITIONING_DIRTY), "How did this happen?");
return;
}
@ -4144,7 +4145,7 @@ nsSVGTextFrame2::ResolvePositions(nsIContent* aContent,
}
uint32_t count = GetTextContentLength(aContent);
bool& percentages = mPositioningMayUsePercentages;
bool percentages = false;
// New text anchoring chunks start at each character assigned a position
// with x="" or y="", or if we forced one with aForceStartOfChunk due to
@ -4212,6 +4213,10 @@ nsSVGTextFrame2::ResolvePositions(nsIContent* aContent,
j++;
}
}
if (percentages) {
AddStateBits(NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES);
}
}
// Recurse to children.
@ -4235,7 +4240,7 @@ bool
nsSVGTextFrame2::ResolvePositions(nsTArray<gfxPoint>& aDeltas)
{
NS_ASSERTION(mPositions.IsEmpty(), "expected mPositions to be empty");
mPositioningMayUsePercentages = false;
RemoveStateBits(NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES);
CharIterator it(this, CharIterator::eOriginal);
if (it.AtEnd()) {
@ -4669,7 +4674,7 @@ void
nsSVGTextFrame2::DoGlyphPositioning()
{
mPositions.Clear();
mPositioningDirty = false;
RemoveStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
// Determine the positions of each character in app units.
nsTArray<nsPoint> charPositions;
@ -4820,7 +4825,7 @@ nsSVGTextFrame2::ScheduleReflowSVG()
void
nsSVGTextFrame2::NotifyGlyphMetricsChange()
{
mPositioningDirty = true;
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
nsSVGEffects::InvalidateRenderingObservers(this);
ScheduleReflowSVG();
}
@ -4833,7 +4838,7 @@ nsSVGTextFrame2::UpdateGlyphPositioning()
return;
}
if (mPositioningDirty) {
if (mState & NS_STATE_SVG_POSITIONING_DIRTY) {
MOZ_ASSERT(!NS_SUBTREE_DIRTY(kid), "should have already reflowed the kid");
DoGlyphPositioning();
}
@ -4869,7 +4874,7 @@ nsSVGTextFrame2::DoReflow()
{
// Since we are going to reflow the anonymous block frame, we will
// need to update mPositions.
mPositioningDirty = true;
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
if (mState & NS_STATE_SVG_NONDISPLAY_CHILD) {
// Normally, these dirty flags would be cleared in ReflowSVG(), but that

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

@ -188,10 +188,9 @@ protected:
nsSVGTextFrame2(nsStyleContext* aContext)
: nsSVGTextFrame2Base(aContext),
mFontSizeScaleFactor(1.0f),
mGetCanvasTMForFlag(FOR_OUTERSVG_TM),
mPositioningDirty(true),
mPositioningMayUsePercentages(false)
mGetCanvasTMForFlag(FOR_OUTERSVG_TM)
{
AddStateBits(NS_STATE_SVG_POSITIONING_DIRTY);
}
public:
@ -650,42 +649,6 @@ private:
* having a current mMarkedFrame.
*/
uint32_t mGetCanvasTMForFlag;
/**
* The NS_FRAME_IS_DIRTY and NS_FRAME_HAS_DIRTY_CHILDREN bits indicate
* that our anonymous block child needs to be reflowed, and that mPositions
* will likely need to be updated as a consequence. These are set, for
* example, when the font-family changes. Sometimes we only need to
* update mPositions though. For example if the x/y attributes change.
* mPositioningDirty is used to indicate this latter "things are dirty" case
* to allow us to avoid reflowing the anonymous block when it is not
* necessary.
*/
bool mPositioningDirty;
/**
* Whether the values from x/y/dx/dy attributes have any percentage values
* that are used in determining the positions of glyphs. The value will
* be true even if a positioning value is overridden by a descendant element's
* attribute with a non-percentage length. For example,
* mPositioningMayUsePercentages would be true for:
*
* <text x="10%"><tspan x="0">abc</tspan></text>
*
* Percentage values beyond the number of addressable characters, however, do
* not influence mPositioningMayUsePercentages. For example,
* mPositioningMayUsePercentages would be false for:
*
* <text x="10 20 30 40%">abc</text>
*
* mPositioningMayUsePercentages is used to determine whether to recompute
* mPositions when the viewport size changes. So although the first example
* above shows that mPositioningMayUsePercentages can be true even if a viewport
* size change will not affect mPositions, determining a completley accurate
* value for mPositioningMayUsePercentages would require extra work that is
* probably not worth it.
*/
bool mPositioningMayUsePercentages;
};
#endif

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

@ -64,10 +64,47 @@ class Element;
#define NS_STATE_IS_OUTER_SVG NS_FRAME_STATE_BIT(20)
/* are we the child of a non-display container? */
#define NS_STATE_SVG_NONDISPLAY_CHILD NS_FRAME_STATE_BIT(22)
#define NS_STATE_SVG_NONDISPLAY_CHILD NS_FRAME_STATE_BIT(21)
// If this bit is set, we are a <clipPath> element or descendant.
#define NS_STATE_SVG_CLIPPATH_CHILD NS_FRAME_STATE_BIT(23)
#define NS_STATE_SVG_CLIPPATH_CHILD NS_FRAME_STATE_BIT(22)
/**
* For text, the NS_FRAME_IS_DIRTY and NS_FRAME_HAS_DIRTY_CHILDREN bits indicate
* that our anonymous block child needs to be reflowed, and that mPositions
* will likely need to be updated as a consequence. These are set, for
* example, when the font-family changes. Sometimes we only need to
* update mPositions though. For example if the x/y attributes change.
* mPositioningDirty is used to indicate this latter "things are dirty" case
* to allow us to avoid reflowing the anonymous block when it is not
* necessary.
*/
#define NS_STATE_SVG_POSITIONING_DIRTY NS_FRAME_STATE_BIT(23)
/**
* For text, whether the values from x/y/dx/dy attributes have any percentage values
* that are used in determining the positions of glyphs. The value will
* be true even if a positioning value is overridden by a descendant element's
* attribute with a non-percentage length. For example,
* NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES would be set for:
*
* <text x="10%"><tspan x="0">abc</tspan></text>
*
* Percentage values beyond the number of addressable characters, however, do
* not influence NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES. For example,
* NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES would be false for:
*
* <text x="10 20 30 40%">abc</text>
*
* NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES is used to determine whether
* to recompute mPositions when the viewport size changes. So although the
* first example above shows that NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES
* can be true even if a viewport size change will not affect mPositions,
* determining a completley accurate value for
* NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES would require extra work that is
* probably not worth it.
*/
#define NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES NS_FRAME_STATE_BIT(24)
/**
* Byte offsets of channels in a native packed gfxColor or cairo image surface.