From 59c534dddeecefb64bdb198443d38efe52d3691a Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Fri, 24 Jun 2016 16:02:44 +0800 Subject: [PATCH] Bug 1135329 - Reflow requests for nondisplay SVGTextFrame while its glyph is updated; r=heycam MozReview-Commit-ID: 6QiRwx0FYKT --HG-- extra : transplant_source : U%96%3D%AD%80-%E8%86X%1C%17%A3%F9%29%88H%DB%7Ds%A0 --- layout/generic/nsTextFrame.cpp | 24 ++++++++++++++++++------ layout/svg/SVGTextFrame.h | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 5e02a326e377..c5c4acd9ed5c 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -542,12 +542,24 @@ GlyphObserver::NotifyGlyphsChanged() break; } f->InvalidateFrame(); - // Theoretically we could just update overflow areas, perhaps using - // OverflowChangedTracker, but that would do a bunch of work eagerly that - // we should probably do lazily here since there could be a lot - // of text frames affected and we'd like to coalesce the work. So that's - // not easy to do well. - shell->FrameNeedsReflow(f, nsIPresShell::eResize, NS_FRAME_IS_DIRTY); + + // If this is a non-display text frame within SVG , we need + // to reflow the SVGTextFrame. (This is similar to reflowing the + // SVGTextFrame in response to style changes, in + // SVGTextFrame::DidSetStyleContext.) + if (f->IsSVGText() && f->GetStateBits() & NS_FRAME_IS_NONDISPLAY) { + auto svgTextFrame = static_cast( + nsLayoutUtils::GetClosestFrameOfType(f, + nsGkAtoms::svgTextFrame)); + svgTextFrame->ScheduleReflowSVGNonDisplayText(); + } else { + // Theoretically we could just update overflow areas, perhaps using + // OverflowChangedTracker, but that would do a bunch of work eagerly that + // we should probably do lazily here since there could be a lot + // of text frames affected and we'd like to coalesce the work. So that's + // not easy to do well. + shell->FrameNeedsReflow(f, nsIPresShell::eResize, NS_FRAME_IS_DIRTY); + } } } diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h index 27290142c1ca..68237a4aaca7 100644 --- a/layout/svg/SVGTextFrame.h +++ b/layout/svg/SVGTextFrame.h @@ -399,8 +399,8 @@ public: * it. * * The only case where we have to do this is in response to a style change on - * a non-display ; the only caller of ScheduleReflowSVGNonDisplayText - * currently is SVGTextFrame::DidSetStyleContext. + * a non-display . It is done in response to glyphs changes on + * non-display (i.e., animated SVG-in-OpenType glyphs). */ void ScheduleReflowSVGNonDisplayText();