Bug 827197 - Remove some uses of nsIDOMSVGElement subclasses r=longsonr

This commit is contained in:
David Zbarsky 2013-01-07 22:22:41 -05:00
Родитель 314127d662
Коммит f568f12d29
22 изменённых файлов: 80 добавлений и 99 удалений

Просмотреть файл

@ -7,7 +7,6 @@
#include "nsSVGRect.h"
#include "DOMSVGPoint.h"
#include "nsSVGSVGElement.h"
#include "nsIDOMSVGSVGElement.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "mozilla/dom/Element.h"
@ -44,15 +43,14 @@ nsDOMSVGZoomEvent::nsDOMSVGZoomEvent(nsPresContext* aPresContext,
if (doc) {
Element *rootElement = doc->GetRootElement();
if (rootElement) {
// If the root element isn't an SVG 'svg' element this QI will fail
// If the root element isn't an SVG 'svg' element
// (e.g. if this event was created by calling createEvent on a
// non-SVGDocument). In these circumstances the "New" and "Previous"
// non-SVGDocument), then the "New" and "Previous"
// properties will be left null which is probably what we want.
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(rootElement);
if (svgElement) {
if (rootElement->IsSVG(nsGkAtoms::svg)) {
nsSVGSVGElement *SVGSVGElement =
static_cast<nsSVGSVGElement*>(rootElement);
mNewScale = SVGSVGElement->GetCurrentScale();
mPreviousScale = SVGSVGElement->GetPreviousScale();

Просмотреть файл

@ -24,6 +24,7 @@ EXPORTS = \
LOCAL_INCLUDES = \
-I$(srcdir)/../../../content/base/src \
-I$(srcdir)/../../../content/svg/content/src \
$(NULL)
SDK_XPIDLSRCS = \

Просмотреть файл

@ -33,7 +33,7 @@
#include "nsIDOMElement.h"
#include "Link.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMSVGTitleElement.h"
#include "mozilla/dom/SVGTitleElement.h"
#include "nsIDOMEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIFormControl.h"
@ -1028,9 +1028,11 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
{
NS_ENSURE_ARG_POINTER(aNode);
NS_ENSURE_ARG_POINTER(aText);
nsString outText;
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
bool lookingForSVGTitle = true;
bool found = false;
nsCOMPtr<nsIDOMNode> current ( aNode );
@ -1087,16 +1089,12 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
lookingForSVGTitle = UseSVGTitle(currElement);
}
if (lookingForSVGTitle) {
nsCOMPtr<nsIDOMNodeList>childNodes;
aNode->GetChildNodes(getter_AddRefs(childNodes));
uint32_t childNodeCount;
childNodes->GetLength(&childNodeCount);
nsINodeList* childNodes = node->ChildNodes();
uint32_t childNodeCount = childNodes->Length();
for (uint32_t i = 0; i < childNodeCount; i++) {
nsCOMPtr<nsIDOMNode>childNode;
childNodes->Item(i, getter_AddRefs(childNode));
nsCOMPtr<nsIDOMSVGTitleElement> titleElement(do_QueryInterface(childNode));
if (titleElement) {
titleElement->GetTextContent(outText);
nsIContent* child = childNodes->Item(i);
if (child->IsSVG(nsGkAtoms::title)) {
static_cast<dom::SVGTitleElement*>(child)->GetTextContent(outText);
if ( outText.Length() )
found = true;
break;
@ -1108,7 +1106,7 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
}
}
}
// not found here, walk up to the parent and keep trying
if ( !found ) {
nsCOMPtr<nsIDOMNode> temp ( current );

Просмотреть файл

@ -73,8 +73,6 @@
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMSVGImageElement.h"
#include "nsIDOMSVGScriptElement.h"
#ifdef MOZ_MEDIA
#include "nsIDOMHTMLSourceElement.h"
#include "nsIDOMHTMLMediaElement.h"
@ -2700,6 +2698,12 @@ nsresult nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode)
return NS_OK;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (!content)
{
return NS_OK;
}
// Test the node to see if it's an image, frame, iframe, css, js
nsCOMPtr<nsIDOMHTMLImageElement> nodeAsImage = do_QueryInterface(aNode);
if (nodeAsImage)
@ -2708,8 +2712,7 @@ nsresult nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode)
return NS_OK;
}
nsCOMPtr<nsIDOMSVGImageElement> nodeAsSVGImage = do_QueryInterface(aNode);
if (nodeAsSVGImage)
if (content->IsSVG(nsGkAtoms::img))
{
StoreURIAttributeNS(aNode, "http://www.w3.org/1999/xlink", "href");
return NS_OK;
@ -2765,8 +2768,7 @@ nsresult nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode)
return NS_OK;
}
nsCOMPtr<nsIDOMSVGScriptElement> nodeAsSVGScript = do_QueryInterface(aNode);
if (nodeAsSVGScript)
if (content->IsSVG(nsGkAtoms::script))
{
StoreURIAttributeNS(aNode, "http://www.w3.org/1999/xlink", "href");
return NS_OK;
@ -2991,6 +2993,12 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes(
}
}
nsCOMPtr<nsIContent> content = do_QueryInterface(aNodeIn);
if (!content)
{
return NS_OK;
}
// Fix up href and file links in the elements
nsCOMPtr<nsIDOMHTMLAnchorElement> nodeAsAnchor = do_QueryInterface(aNodeIn);
@ -3103,8 +3111,7 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes(
}
#endif // MOZ_MEDIA
nsCOMPtr<nsIDOMSVGImageElement> nodeAsSVGImage = do_QueryInterface(aNodeIn);
if (nodeAsSVGImage)
if (content->IsSVG(nsGkAtoms::img))
{
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut)
@ -3132,8 +3139,7 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes(
return rv;
}
nsCOMPtr<nsIDOMSVGScriptElement> nodeAsSVGScript = do_QueryInterface(aNodeIn);
if (nodeAsSVGScript)
if (content->IsSVG(nsGkAtoms::script))
{
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut)

Просмотреть файл

@ -98,12 +98,9 @@ SVGFEImageFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGFEImageElement> elem = do_QueryInterface(aContent);
NS_ASSERTION(elem,
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::feImage),
"Trying to construct an SVGFEImageFrame for a "
"content element that doesn't support the right interfaces");
#endif /* DEBUG */
SVGFEImageFrameBase::Init(aContent, aParent, aPrevInFlow);
nsCOMPtr<nsIImageLoadingContent> imageLoader =

Просмотреть файл

@ -81,8 +81,8 @@ SVGViewFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGViewElement> elem = do_QueryInterface(aContent);
NS_ASSERTION(elem, "Content is not an SVG view");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::view),
"Content is not an SVG view");
return SVGViewFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -91,8 +91,7 @@ nsSVGAFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGAElement> elem = do_QueryInterface(aContent);
NS_ASSERTION(elem,
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::a),
"Trying to construct an SVGAFrame for a "
"content element that doesn't support the right interfaces");

Просмотреть файл

@ -9,7 +9,6 @@
// Keep others in (case-insensitive) order:
#include "gfxContext.h"
#include "nsGkAtoms.h"
#include "nsIDOMSVGClipPathElement.h"
#include "nsRenderingContext.h"
#include "nsSVGClipPathElement.h"
#include "nsSVGEffects.h"
@ -298,10 +297,8 @@ nsSVGClipPathFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGClipPathElement> clipPath = do_QueryInterface(aContent);
NS_ASSERTION(clipPath, "Content is not an SVG clipPath!");
#endif
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::clipPath),
"Content is not an SVG clipPath!");
AddStateBits(NS_STATE_SVG_CLIPPATH_CHILD);
return nsSVGClipPathFrameBase::Init(aContent, aParent, aPrevInFlow);

Просмотреть файл

@ -523,15 +523,15 @@ nsSVGFilterFrame::GetPostFilterBounds(nsIFrame *aFilteredFrame,
}
return nsRect();
}
#ifdef DEBUG
NS_IMETHODIMP
nsSVGFilterFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGFilterElement> filter = do_QueryInterface(aContent);
NS_ASSERTION(filter, "Content is not an SVG filter");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::filter),
"Content is not an SVG filter");
return nsSVGFilterFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -10,7 +10,6 @@
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "nsGkAtoms.h"
#include "nsIDOMSVGForeignObjectElem.h"
#include "nsINameSpaceManager.h"
#include "nsLayoutUtils.h"
#include "nsRegion.h"
@ -58,10 +57,8 @@ nsSVGForeignObjectFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGForeignObjectElement> foreignObject = do_QueryInterface(aContent);
NS_ASSERTION(foreignObject, "Content is not an SVG foreignObject!");
#endif
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::foreignObject),
"Content is not an SVG foreignObject!");
nsresult rv = nsSVGForeignObjectFrameBase::Init(aContent, aParent, aPrevInFlow);
AddStateBits(aParent->GetStateBits() &

Просмотреть файл

@ -10,12 +10,13 @@
#include "gfxPattern.h"
#include "nsContentUtils.h"
#include "nsIDOMSVGAnimatedNumber.h"
#include "nsIDOMSVGStopElement.h"
#include "nsSVGEffects.h"
#include "nsSVGGradientElement.h"
#include "SVGAnimatedTransformList.h"
#include "mozilla/dom/SVGStopElement.h"
using mozilla::SVGAnimatedTransformList;
using namespace mozilla;
using namespace mozilla::dom;
//----------------------------------------------------------------------
// Helper classes
@ -103,12 +104,14 @@ nsSVGGradientFrame::GetStopInformation(int32_t aIndex,
nsIFrame *stopFrame = nullptr;
GetStopFrame(aIndex, &stopFrame);
nsCOMPtr<nsIDOMSVGStopElement> stopElement =
do_QueryInterface(stopFrame->GetContent());
if (stopElement) {
nsCOMPtr<nsIDOMSVGAnimatedNumber> aNum;
stopElement->GetOffset(getter_AddRefs(aNum));
nsIContent* stopContent = stopFrame->GetContent();
if (stopContent) {
MOZ_ASSERT(stopContent->IsSVG(nsGkAtoms::stop));
SVGStopElement* stopElement = nullptr;
stopElement = static_cast<SVGStopElement*>(stopContent);
nsCOMPtr<nsIDOMSVGAnimatedNumber> aNum = stopElement->Offset();
aNum->GetAnimVal(aOffset);
if (*aOffset < 0.0f)
@ -419,8 +422,8 @@ nsSVGLinearGradientFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGLinearGradientElement> grad = do_QueryInterface(aContent);
NS_ASSERTION(grad, "Content is not an SVG linearGradient");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::linearGradient),
"Content is not an SVG linearGradient");
return nsSVGLinearGradientFrameBase::Init(aContent, aParent, aPrevInFlow);
}
@ -532,8 +535,8 @@ nsSVGRadialGradientFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGRadialGradientElement> grad = do_QueryInterface(aContent);
NS_ASSERTION(grad, "Content is not an SVG radialGradient");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::radialGradient),
"Content is not an SVG radialGradient");
return nsSVGRadialGradientFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -8,7 +8,6 @@
#include "gfxMatrix.h"
#include "gfxPlatform.h"
#include "imgIContainer.h"
#include "nsIDOMSVGImageElement.h"
#include "nsIImageLoadingContent.h"
#include "nsLayoutUtils.h"
#include "nsRenderingContext.h"
@ -133,14 +132,12 @@ nsSVGImageFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGImageElement> image = do_QueryInterface(aContent);
NS_ASSERTION(image, "Content is not an SVG image!");
#endif
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::image),
"Content is not an SVG image!");
nsresult rv = nsSVGImageFrameBase::Init(aContent, aParent, aPrevInFlow);
if (NS_FAILED(rv)) return rv;
mListener = new nsSVGImageListener(this);
if (!mListener) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);

Просмотреть файл

@ -37,8 +37,8 @@ nsSVGInnerSVGFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGSVGElement> svg = do_QueryInterface(aContent);
NS_ASSERTION(svg, "Content is not an SVG 'svg' element!");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::svg),
"Content is not an SVG 'svg' element!");
return nsSVGInnerSVGFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -183,8 +183,8 @@ nsSVGMaskFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGMaskElement> mask = do_QueryInterface(aContent);
NS_ASSERTION(mask, "Content is not an SVG mask");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::mask),
"Content is not an SVG mask");
return nsSVGMaskFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -11,7 +11,6 @@
#include "gfxMatrix.h"
#include "nsDisplayList.h"
#include "nsIDocument.h"
#include "nsIDOMSVGSVGElement.h"
#include "nsIDOMWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIObjectLoadingContent.h"
@ -150,10 +149,8 @@ nsSVGOuterSVGFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(aContent);
NS_ASSERTION(svgElement, "Content is not an SVG 'svg' element!");
#endif
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::svg),
"Content is not an SVG 'svg' element!");
AddStateBits(NS_STATE_IS_OUTER_SVG |
NS_FRAME_FONT_INFLATION_CONTAINER |

Просмотреть файл

@ -105,8 +105,7 @@ nsSVGPatternFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGPatternElement> patternElement = do_QueryInterface(aContent);
NS_ASSERTION(patternElement, "Content is not an SVG pattern");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::pattern), "Content is not an SVG pattern");
return nsSVGPatternFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -6,7 +6,6 @@
// Keep in (case-insensitive) order:
#include "nsFrame.h"
#include "nsGkAtoms.h"
#include "nsIDOMSVGStopElement.h"
#include "nsStyleContext.h"
#include "nsSVGEffects.h"
@ -83,8 +82,8 @@ nsSVGStopFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGStopElement> grad = do_QueryInterface(aContent);
NS_ASSERTION(grad, "Content doesn't support nsIDOMSVGStopElement");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::stop),
"Content doesn't support nsIDOMSVGStopElement");
return nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -79,8 +79,8 @@ nsSVGSwitchFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGSwitchElement> svgSwitch = do_QueryInterface(aContent);
NS_ASSERTION(svgSwitch, "Content is not an SVG switch\n");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::svgSwitch),
"Content is not an SVG switch\n");
return nsSVGSwitchFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -7,8 +7,6 @@
#include "nsSVGTSpanFrame.h"
// Keep others in (case-insensitive) order:
#include "nsIDOMSVGTSpanElement.h"
#include "nsIDOMSVGAltGlyphElement.h"
#include "nsSVGIntegrationUtils.h"
#include "nsSVGUtils.h"
@ -60,9 +58,9 @@ nsSVGTSpanFrame::Init(nsIContent* aContent,
"trying to construct an SVGTSpanFrame for an invalid "
"container");
nsCOMPtr<nsIDOMSVGTSpanElement> tspan = do_QueryInterface(aContent);
nsCOMPtr<nsIDOMSVGAltGlyphElement> altGlyph = do_QueryInterface(aContent);
NS_ASSERTION(tspan || altGlyph, "Content is not an SVG tspan or altGlyph");
NS_ASSERTION(aContent->IsSVG() && (aContent->Tag() == nsGkAtoms::altGlyph ||
aContent->Tag() == nsGkAtoms::tspan),
"Content is not an SVG tspan or altGlyph");
}
return nsSVGTSpanFrameBase::Init(aContent, aParent, aPrevInFlow);

Просмотреть файл

@ -9,7 +9,6 @@
// Keep others in (case-insensitive) order:
#include "nsGkAtoms.h"
#include "nsIDOMSVGRect.h"
#include "nsIDOMSVGTextElement.h"
#include "nsISVGGlyphFragmentNode.h"
#include "nsSVGGlyphFrame.h"
#include "nsSVGIntegrationUtils.h"
@ -40,8 +39,8 @@ nsSVGTextFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGTextElement> text = do_QueryInterface(aContent);
NS_ASSERTION(text, "Content is not an SVG text");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::text),
"Content is not an SVG text");
return nsSVGTextFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -8,7 +8,6 @@
// Keep others in (case-insensitive) order:
#include "nsContentUtils.h"
#include "nsIDOMSVGTextPathElement.h"
#include "nsSVGEffects.h"
#include "nsSVGLength2.h"
#include "nsSVGPathElement.h"
@ -43,9 +42,9 @@ nsSVGTextPathFrame::Init(nsIContent* aContent,
NS_ASSERTION(ancestorFrame->GetType() == nsGkAtoms::svgTextFrame,
"trying to construct an SVGTextPathFrame for an invalid "
"container");
nsCOMPtr<nsIDOMSVGTextPathElement> textPath = do_QueryInterface(aContent);
NS_ASSERTION(textPath, "Content is not an SVG textPath");
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::textPath),
"Content is not an SVG textPath");
return nsSVGTextPathFrameBase::Init(aContent, aParent, aPrevInFlow);
}

Просмотреть файл

@ -5,7 +5,6 @@
// Keep in (case-insensitive) order:
#include "nsIAnonymousContentCreator.h"
#include "nsIDOMSVGUseElement.h"
#include "nsSVGGFrame.h"
#include "nsSVGUseElement.h"
#include "nsContentList.h"
@ -101,10 +100,8 @@ nsSVGUseFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
#ifdef DEBUG
nsCOMPtr<nsIDOMSVGUseElement> use = do_QueryInterface(aContent);
NS_ASSERTION(use, "Content is not an SVG use!");
#endif /* DEBUG */
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::use),
"Content is not an SVG use!");
mHasValidDimensions =
static_cast<nsSVGUseElement*>(aContent)->HasValidDimensions();