Bug 889736, part 3 - Remove nsSVGTSpanFrame. r=heycam

This commit is contained in:
Jonathan Watt 2013-11-18 14:29:52 +00:00
parent 5dc11fc229
commit 769a3a3091
9 changed files with 18 additions and 252 deletions

View File

@ -1863,7 +1863,6 @@ GK_ATOM(svgRadialGradientFrame, "SVGRadialGradientFrame")
GK_ATOM(svgStopFrame, "SVGStopFrame")
GK_ATOM(svgSwitchFrame, "SVGSwitchFrame")
GK_ATOM(svgTextFrame2, "SVGTextFrame2")
GK_ATOM(svgTSpanFrame, "SVGTSpanFrame")
GK_ATOM(svgUseFrame, "SVGUseFrame")
GK_ATOM(svgViewFrame, "SVGViewFrame")
GK_ATOM(HTMLVideoFrame, "VideoFrame")

View File

@ -126,8 +126,6 @@ NS_NewSVGSwitchFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGTextFrame2(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGUseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
@ -3147,13 +3145,11 @@ nsCSSFrameConstructor::FindTextData(nsIFrame* aParentFrame)
nsIFrame *ancestorFrame =
nsSVGUtils::GetFirstNonAAncestorFrame(aParentFrame);
if (ancestorFrame) {
if (NS_SVGTextCSSFramesEnabled()) {
static const FrameConstructionData sSVGTextData =
FCDATA_DECL(FCDATA_IS_LINE_PARTICIPANT | FCDATA_IS_SVG_TEXT,
NS_NewTextFrame);
if (ancestorFrame->IsSVGText()) {
return &sSVGTextData;
}
static const FrameConstructionData sSVGTextData =
FCDATA_DECL(FCDATA_IS_LINE_PARTICIPANT | FCDATA_IS_SVG_TEXT,
NS_NewTextFrame);
if (ancestorFrame->IsSVGText()) {
return &sSVGTextData;
}
}
return nullptr;
@ -4946,19 +4942,17 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
return &sTSpanData;
}
return &sSuppressData;
} else if (NS_SVGTextCSSFramesEnabled()) {
if (aTag == nsGkAtoms::text) {
static const FrameConstructionData sTextData =
FCDATA_WITH_WRAPPING_BLOCK(FCDATA_DISALLOW_OUT_OF_FLOW |
FCDATA_ALLOW_BLOCK_STYLES,
NS_NewSVGTextFrame2,
nsCSSAnonBoxes::mozSVGText);
return &sTextData;
} else if (aTag == nsGkAtoms::tspan ||
aTag == nsGkAtoms::altGlyph ||
aTag == nsGkAtoms::textPath) {
return &sSuppressData;
}
} else if (aTag == nsGkAtoms::text) {
static const FrameConstructionData sTextData =
FCDATA_WITH_WRAPPING_BLOCK(FCDATA_DISALLOW_OUT_OF_FLOW |
FCDATA_ALLOW_BLOCK_STYLES,
NS_NewSVGTextFrame2,
nsCSSAnonBoxes::mozSVGText);
return &sTextData;
} else if (aTag == nsGkAtoms::tspan ||
aTag == nsGkAtoms::altGlyph ||
aTag == nsGkAtoms::textPath) {
return &sSuppressData;
}
static const FrameConstructionDataByTag sSVGData[] = {
@ -4979,8 +4973,6 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
NS_NewSVGForeignObjectFrame,
nsCSSAnonBoxes::mozSVGForeignContent) },
SIMPLE_SVG_CREATE(a, NS_NewSVGAFrame),
SIMPLE_SVG_CREATE(altGlyph, NS_NewSVGTSpanFrame),
SIMPLE_SVG_CREATE(tspan, NS_NewSVGTSpanFrame),
SIMPLE_SVG_CREATE(linearGradient, NS_NewSVGLinearGradientFrame),
SIMPLE_SVG_CREATE(radialGradient, NS_NewSVGRadialGradientFrame),
SIMPLE_SVG_CREATE(stop, NS_NewSVGStopFrame),

View File

@ -154,7 +154,6 @@ FRAME_ID(nsSVGStopFrame)
FRAME_ID(nsSVGSwitchFrame)
FRAME_ID(nsSVGTextContainerFrame)
FRAME_ID(nsSVGTextFrame2)
FRAME_ID(nsSVGTSpanFrame)
FRAME_ID(nsSVGUseFrame)
FRAME_ID(SVGViewFrame)
FRAME_ID(nsTableCaptionFrame)

View File

@ -40,7 +40,6 @@ UNIFIED_SOURCES += [
'nsSVGSwitchFrame.cpp',
'nsSVGTextContainerFrame.cpp',
'nsSVGTextFrame2.cpp',
'nsSVGTSpanFrame.cpp',
'nsSVGUseFrame.cpp',
'nsSVGUtils.cpp',
'SVGFEContainerFrame.cpp',

View File

@ -7,7 +7,7 @@
#include "gfxMatrix.h"
#include "mozilla/dom/SVGAElement.h"
#include "nsSVGIntegrationUtils.h"
#include "nsSVGTSpanFrame.h"
#include "nsSVGTextContainerFrame.h"
#include "nsSVGUtils.h"
#include "SVGLengthList.h"
@ -18,7 +18,7 @@
using namespace mozilla;
typedef nsSVGTSpanFrame nsSVGAFrameBase;
typedef nsSVGTextContainerFrame nsSVGAFrameBase;
class nsSVGAFrame : public nsSVGAFrameBase
{

View File

@ -1,138 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Main header first:
#include "nsSVGTSpanFrame.h"
// Keep others in (case-insensitive) order:
#include "nsSVGEffects.h"
#include "nsSVGIntegrationUtils.h"
#include "nsSVGUtils.h"
//----------------------------------------------------------------------
// Implementation
nsIFrame*
NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsSVGTSpanFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsSVGTSpanFrame)
nsIAtom *
nsSVGTSpanFrame::GetType() const
{
return nsGkAtoms::svgTSpanFrame;
}
//----------------------------------------------------------------------
// nsQueryFrame methods
NS_QUERYFRAME_HEAD(nsSVGTSpanFrame)
NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentNode)
NS_QUERYFRAME_TAIL_INHERITING(nsSVGTSpanFrameBase)
//----------------------------------------------------------------------
// nsIFrame methods
#ifdef DEBUG
void
nsSVGTSpanFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
NS_ASSERTION(aParent, "null parent");
// Some of our subclasses have an aContent that's not a <svg:tspan> or are
// allowed to be constructed even when there is no nsISVGTextContentMetrics
// ancestor. For example, nsSVGAFrame inherits from us but may have nothing
// to do with text.
if (GetType() == nsGkAtoms::svgTSpanFrame) {
nsIFrame* ancestorFrame = nsSVGUtils::GetFirstNonAAncestorFrame(aParent);
NS_ASSERTION(ancestorFrame, "Must have ancestor");
nsSVGTextContainerFrame *metrics = do_QueryFrame(ancestorFrame);
NS_ASSERTION(metrics,
"trying to construct an SVGTSpanFrame for an invalid "
"container");
NS_ASSERTION(aContent->IsSVG() && (aContent->Tag() == nsGkAtoms::altGlyph ||
aContent->Tag() == nsGkAtoms::tspan),
"Content is not an SVG tspan or altGlyph");
}
nsSVGTSpanFrameBase::Init(aContent, aParent, aPrevInFlow);
}
#endif /* DEBUG */
NS_IMETHODIMP
nsSVGTSpanFrame::AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
{
if (aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::dx ||
aAttribute == nsGkAtoms::dy ||
aAttribute == nsGkAtoms::rotate)) {
nsSVGEffects::InvalidateRenderingObservers(this);
nsSVGUtils::ScheduleReflowSVG(this);
NotifyGlyphMetricsChange();
}
return NS_OK;
}
//----------------------------------------------------------------------
// nsSVGContainerFrame methods:
gfxMatrix
nsSVGTSpanFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
{
if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) {
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
}
}
NS_ASSERTION(mParent, "null parent");
return static_cast<nsSVGContainerFrame*>(mParent)->
GetCanvasTM(aFor, aTransformRoot);
}
//----------------------------------------------------------------------
// nsISVGGlyphFragmentNode methods:
uint32_t
nsSVGTSpanFrame::GetNumberOfChars()
{
return nsSVGTSpanFrameBase::GetNumberOfChars();
}
float
nsSVGTSpanFrame::GetComputedTextLength()
{
return nsSVGTSpanFrameBase::GetComputedTextLength();
}
float
nsSVGTSpanFrame::GetSubStringLength(uint32_t charnum, uint32_t nchars)
{
return nsSVGTSpanFrameBase::GetSubStringLength(charnum, nchars);
}
int32_t
nsSVGTSpanFrame::GetCharNumAtPosition(mozilla::nsISVGPoint *point)
{
return nsSVGTSpanFrameBase::GetCharNumAtPosition(point);
}
NS_IMETHODIMP_(void)
nsSVGTSpanFrame::SetWhitespaceCompression(bool)
{
nsSVGTSpanFrameBase::SetWhitespaceCompression();
}

View File

@ -1,78 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NSSVGTSPANFRAME_H
#define NSSVGTSPANFRAME_H
#include "mozilla/Attributes.h"
#include "gfxMatrix.h"
#include "nsFrame.h"
#include "nsISVGGlyphFragmentNode.h"
#include "nsLiteralString.h"
#include "nsQueryFrame.h"
#include "nsSVGTextContainerFrame.h"
class nsIAtom;
class nsIContent;
class nsIFrame;
class nsIPresShell;
class nsStyleContext;
namespace mozilla {
class nsISVGPoint;
}
typedef nsSVGTextContainerFrame nsSVGTSpanFrameBase;
class nsSVGTSpanFrame : public nsSVGTSpanFrameBase,
public nsISVGGlyphFragmentNode
{
friend nsIFrame*
NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
protected:
nsSVGTSpanFrame(nsStyleContext* aContext) :
nsSVGTSpanFrameBase(aContext) {}
public:
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
// nsIFrame:
#ifdef DEBUG
virtual void Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
#endif
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType) MOZ_OVERRIDE;
/**
* Get the "type" of the frame
*
* @see nsGkAtoms::svgTSpanFrame
*/
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
{
return MakeFrameName(NS_LITERAL_STRING("SVGTSpan"), aResult);
}
#endif
// nsSVGContainerFrame methods:
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
// nsISVGGlyphFragmentNode interface:
virtual uint32_t GetNumberOfChars() MOZ_OVERRIDE;
virtual float GetComputedTextLength() MOZ_OVERRIDE;
virtual float GetSubStringLength(uint32_t charnum, uint32_t fragmentChars) MOZ_OVERRIDE;
virtual int32_t GetCharNumAtPosition(mozilla::nsISVGPoint *point) MOZ_OVERRIDE;
NS_IMETHOD_(void) SetWhitespaceCompression(bool aCompressWhitespace) MOZ_OVERRIDE;
};
#endif

View File

@ -148,12 +148,6 @@ NS_SVGDisplayListPaintingEnabled()
return sSVGDisplayListPaintingEnabled;
}
bool
NS_SVGTextCSSFramesEnabled()
{
return true;
}
// we only take the address of this:
static mozilla::gfx::UserDataKey sSVGAutoRenderStateKey;

View File

@ -136,7 +136,6 @@ class Element;
bool NS_SVGDisplayListHitTestingEnabled();
bool NS_SVGDisplayListPaintingEnabled();
bool NS_SVGTextCSSFramesEnabled();
/**
* Sometimes we need to distinguish between an empty box and a box