Bug 655877 - Part 35: Ensure SVG text is updated when attributes on text content children change. r=jwatt

This commit is contained in:
Cameron McCormack 2013-02-11 17:22:17 +11:00
parent 5f14660011
commit 085b8e6d1d
2 changed files with 51 additions and 13 deletions

View File

@ -2833,7 +2833,8 @@ nsSVGTextFrame2::MutationObserver::ContentAppended(nsIDocument *aDocument,
}
void
nsSVGTextFrame2::MutationObserver::ContentInserted(nsIDocument *aDocument,
nsSVGTextFrame2::MutationObserver::ContentInserted(
nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer)
@ -2842,7 +2843,8 @@ nsSVGTextFrame2::MutationObserver::ContentInserted(nsIDocument *aDocument,
}
void
nsSVGTextFrame2::MutationObserver::ContentRemoved(nsIDocument *aDocument,
nsSVGTextFrame2::MutationObserver::ContentRemoved(
nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer,
@ -2851,6 +2853,44 @@ nsSVGTextFrame2::MutationObserver::ContentRemoved(nsIDocument *aDocument,
mFrame->NotifyGlyphMetricsChange();
}
void
nsSVGTextFrame2::MutationObserver::AttributeChanged(
nsIDocument* aDocument,
mozilla::dom::Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
{
if (!aElement->IsSVG()) {
return;
}
// Attribute changes on this element are handled in
// nsSVGTextFrame2::AttributeChanged.
if (aElement == mFrame->GetContent()) {
return;
}
// Attributes changes on descendent elements.
if (aElement->Tag() == nsGkAtoms::textPath) {
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::startOffset) {
mFrame->NotifyGlyphMetricsChange();
} else if (aNameSpaceID == kNameSpaceID_XLink &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
nsIFrame* childElementFrame = aElement->GetPrimaryFrame();
childElementFrame->Properties().Delete(nsSVGEffects::HrefProperty());
mFrame->NotifyGlyphMetricsChange();
}
} else {
if (aNameSpaceID == kNameSpaceID_None &&
IsGlyphPositioningAttribute(aAttribute)) {
mFrame->NotifyGlyphMetricsChange();
}
}
}
NS_IMETHODIMP
nsSVGTextFrame2::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -178,9 +178,6 @@ public:
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType);
NS_IMETHOD AttributeChanged(int32_t aNamespaceID,
nsIAtom* aAttribute,
@ -317,6 +314,7 @@ private:
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
private:
nsSVGTextFrame2* mFrame;