Permalink
Browse files

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

  • Loading branch information...
1 parent e19ad65 commit 8e07a5f96166ad9b5b4e49f209d60b5c5a2bc982 @dzbarsky dzbarsky committed Jan 8, 2013
@@ -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);
}
Oops, something went wrong.

0 comments on commit 8e07a5f

Please sign in to comment.