Bug 824899 - Don't use nsIDOMSVGElement where possible r=longsonr

This commit is contained in:
David Zbarsky 2013-01-06 01:25:55 -05:00
parent de4ed0fa3d
commit 6defbde7e5
8 changed files with 21 additions and 38 deletions

View File

@ -12,7 +12,6 @@
#include "mozilla/Preferences.h"
#include "nsComputedDOMStyle.h"
#include "nsFontMetrics.h"
#include "nsIDOMSVGElement.h"
#include "nsIFrame.h"
#include "nsIScriptError.h"
#include "nsLayoutUtils.h"
@ -160,7 +159,7 @@ SVGContentUtils::EstablishesViewport(nsIContent *aContent)
aContent->Tag() == nsGkAtoms::symbol);
}
already_AddRefed<nsIDOMSVGElement>
nsSVGElement*
SVGContentUtils::GetNearestViewportElement(nsIContent *aContent)
{
nsIContent *element = aContent->GetFlattenedTreeParent();
@ -170,7 +169,7 @@ SVGContentUtils::GetNearestViewportElement(nsIContent *aContent)
if (element->Tag() == nsGkAtoms::foreignObject) {
return nullptr;
}
return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
return static_cast<nsSVGElement*>(element);
}
element = element->GetFlattenedTreeParent();
}

View File

@ -15,7 +15,6 @@
class nsIContent;
class nsIDocument;
class nsIDOMSVGElement;
class nsIFrame;
class nsStyleContext;
class nsSVGElement;
@ -106,7 +105,7 @@ public:
*/
static bool EstablishesViewport(nsIContent *aContent);
static already_AddRefed<nsIDOMSVGElement>
static nsSVGElement*
GetNearestViewportElement(nsIContent *aContent);
/* enum for specifying coordinate direction for ObjectSpace/UserSpace */

View File

@ -1,4 +1,3 @@
/* -*- 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/. */
@ -33,16 +32,15 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGElement)
NS_IMETHODIMP
SVGLocatableElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
{
*aNearestViewportElement = SVGContentUtils::GetNearestViewportElement(this).get();
nsCOMPtr<nsIDOMSVGElement> domElem = do_QueryInterface(GetNearestViewportElement());
domElem.forget(aNearestViewportElement);
return NS_OK;
}
already_AddRefed<nsSVGElement>
nsSVGElement*
SVGLocatableElement::GetNearestViewportElement()
{
nsCOMPtr<nsIDOMSVGElement> elem = SVGContentUtils::GetNearestViewportElement(this);
nsCOMPtr<nsSVGElement> svgElem = do_QueryInterface(elem);
return svgElem.forget();
return SVGContentUtils::GetNearestViewportElement(this);
}
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
@ -53,12 +51,10 @@ SVGLocatableElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestVie
return NS_OK;
}
already_AddRefed<nsSVGElement>
nsSVGElement*
SVGLocatableElement::GetFarthestViewportElement()
{
nsCOMPtr<nsIDOMSVGElement> elem = SVGContentUtils::GetOuterSVGElement(this);
nsCOMPtr<nsSVGElement> svgElem = do_QueryInterface(elem);
return svgElem.forget();
return SVGContentUtils::GetOuterSVGElement(this);
}
/* nsIDOMSVGRect getBBox (); */

View File

@ -30,8 +30,8 @@ public:
NS_DECL_NSIDOMSVGLOCATABLE
// WebIDL
already_AddRefed<nsSVGElement> GetNearestViewportElement();
already_AddRefed<nsSVGElement> GetFarthestViewportElement();
nsSVGElement* GetNearestViewportElement();
nsSVGElement* GetFarthestViewportElement();
already_AddRefed<nsIDOMSVGRect> GetBBox(ErrorResult& rv);
already_AddRefed<DOMSVGMatrix> GetCTM();
already_AddRefed<DOMSVGMatrix> GetScreenCTM();

View File

@ -1174,19 +1174,16 @@ nsSVGElement::GetOwnerSVGElement(ErrorResult& rv)
NS_IMETHODIMP
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
{
nsCOMPtr<nsSVGElement> elem = GetViewportElement();
nsSVGElement* elem = GetViewportElement();
nsCOMPtr<nsIDOMSVGElement> svgElem = do_QueryInterface(elem);
svgElem.forget(aViewportElement);
return NS_OK;
}
already_AddRefed<nsSVGElement>
nsSVGElement*
nsSVGElement::GetViewportElement()
{
nsCOMPtr<nsIDOMSVGElement> elem =
SVGContentUtils::GetNearestViewportElement(this);
nsCOMPtr<nsSVGElement> svgElem = do_QueryInterface(elem);
return svgElem.forget();
return SVGContentUtils::GetNearestViewportElement(this);
}
already_AddRefed<nsIDOMSVGAnimatedString>

View File

@ -300,7 +300,7 @@ public:
// WebIDL
nsSVGSVGElement* GetOwnerSVGElement(mozilla::ErrorResult& rv);
already_AddRefed<nsSVGElement> GetViewportElement();
nsSVGElement* GetViewportElement();
already_AddRefed<nsIDOMSVGAnimatedString> ClassName();
nsICSSDeclaration* GetStyle(mozilla::ErrorResult& rv);
already_AddRefed<mozilla::dom::CSSValue> GetPresentationAttribute(const nsAString& aName, mozilla::ErrorResult& rv);

View File

@ -606,7 +606,7 @@ DOMInterfaces = {
'nativeType': 'nsSVGElement',
'hasXPConnectImpls': True,
'hasInstanceInterface': 'nsIDOMSVGElement',
'resultNotAddRefed': ['ownerSVGElement', 'style']
'resultNotAddRefed': ['ownerSVGElement', 'viewportElement', 'style']
},
'SVGGraphicsElement': {
@ -615,7 +615,8 @@ DOMInterfaces = {
'SVGLocatableElement': {
'hasXPConnectImpls': True,
'concrete': False
'concrete': False,
'resultNotAddRefed': ['nearestViewportElement', 'farthestViewportElement']
},
'SVGLengthList': {

View File

@ -33,7 +33,6 @@
#include "nsIDOMElement.h"
#include "Link.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMSVGElement.h"
#include "nsIDOMSVGTitleElement.h"
#include "nsIDOMEvent.h"
#include "nsIDOMMouseEvent.h"
@ -1015,19 +1014,11 @@ DefaultTooltipTextProvider::DefaultTooltipTextProvider()
static bool
UseSVGTitle(nsIDOMElement *currElement)
{
nsCOMPtr<nsIDOMSVGElement> svgContent(do_QueryInterface(currElement));
if (!svgContent)
nsCOMPtr<dom::Element> element(do_QueryInterface(currElement));
if (!element || !element->IsSVG() || !element->GetParentNode())
return false;
nsCOMPtr<nsIDOMNode> parent;
currElement->GetParentNode(getter_AddRefs(parent));
if (!parent)
return false;
uint16_t nodeType;
nsresult rv = parent->GetNodeType(&nodeType);
return NS_SUCCEEDED(rv) && nodeType != nsIDOMNode::DOCUMENT_NODE;
return element->GetParentNode()->NodeType() != nsIDOMNode::DOCUMENT_NODE;
}
/* void getNodeText (in nsIDOMNode aNode, out wstring aText); */