From 2870a18b00706f80f6ece3a40f3ce3e3e645a3f7 Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Tue, 5 Aug 2008 14:07:03 +0100 Subject: [PATCH] bug 445687 - Should not be able to nest text r+sr=roc --- layout/base/nsCSSFrameConstructor.cpp | 9 ++++++++- layout/reftests/svg/invalid-text-01.svg | 15 +++++++++++++++ layout/reftests/svg/reftest.list | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 layout/reftests/svg/invalid-text-01.svg diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index a41a563a3305..933c572e40cb 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7144,7 +7144,14 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState, newFrame = NS_NewSVGAFrame(mPresShell, aContent, aStyleContext); } else if (aTag == nsGkAtoms::text) { - newFrame = NS_NewSVGTextFrame(mPresShell, aContent, aStyleContext); + nsIFrame *ancestorFrame = SVG_GetFirstNonAAncestorFrame(aParentFrame); + if (ancestorFrame) { + nsISVGTextContentMetrics* metrics; + CallQueryInterface(ancestorFrame, &metrics); + // Text cannot be nested + if (!metrics) + newFrame = NS_NewSVGTextFrame(mPresShell, aContent, aStyleContext); + } } else if (aTag == nsGkAtoms::tspan) { nsIFrame *ancestorFrame = SVG_GetFirstNonAAncestorFrame(aParentFrame); diff --git a/layout/reftests/svg/invalid-text-01.svg b/layout/reftests/svg/invalid-text-01.svg new file mode 100644 index 000000000000..4773b6fbe3a7 --- /dev/null +++ b/layout/reftests/svg/invalid-text-01.svg @@ -0,0 +1,15 @@ + + + + Testcase for invalid text + + + + + + Should not see this + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index 861cf4c8901a..dce81701e186 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -46,6 +46,7 @@ include moz-only/reftest.list fails == inline-in-xul-basic-01.xul pass.svg == image-scaling-01.svg pass.svg == image-scaling-02.svg pass.svg +== invalid-text-01.svg pass.svg == linearGradient-basic-01.svg pass.svg == linearGradient-basic-02.svg pass.svg == nested-viewBox-01.svg pass.svg