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

@ -2824,33 +2824,73 @@ nsSVGTextFrame2::GetType() const
NS_IMPL_ISUPPORTS1(nsSVGTextFrame2::MutationObserver, nsIMutationObserver)
void
nsSVGTextFrame2::MutationObserver::ContentAppended(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aFirstNewContent,
nsSVGTextFrame2::MutationObserver::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aFirstNewContent,
int32_t aNewIndexInContainer)
{
mFrame->NotifyGlyphMetricsChange();
}
void
nsSVGTextFrame2::MutationObserver::ContentInserted(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
nsSVGTextFrame2::MutationObserver::ContentInserted(
nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer)
{
mFrame->NotifyGlyphMetricsChange();
}
void
nsSVGTextFrame2::MutationObserver::ContentRemoved(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
nsSVGTextFrame2::MutationObserver::ContentRemoved(
nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer,
nsIContent *aPreviousSibling)
nsIContent* aPreviousSibling)
{
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;