Bug 648094. r=dholbert, a=dveditz.
authorJonathan Watt <jwatt@jwatt.org>
Thu, 16 Jun 2011 10:46:16 +0100
changeset 27426 0efb6d76d4192e2bd657780dea0facaaf98d6cad
parent 27425 df1ac32df5d51eecbb5eeb8bc27de79aa7e9461d
child 27427 920bcf17a9e120114a7b8989ad9be08aa2630909
push id2731
push userjwatt@jwatt.org
push dateThu, 16 Jun 2011 09:51:49 +0000
reviewersdholbert, dveditz
bugs648094
milestone1.9.1.20pre
Bug 648094. r=dholbert, a=dveditz.
content/svg/content/src/nsSVGTSpanElement.cpp
content/svg/content/src/nsSVGTextElement.cpp
content/svg/content/src/nsSVGTextPathElement.cpp
--- a/content/svg/content/src/nsSVGTSpanElement.cpp
+++ b/content/svg/content/src/nsSVGTSpanElement.cpp
@@ -41,16 +41,17 @@
 #include "nsIDOMSVGTSpanElement.h"
 #include "nsCOMPtr.h"
 #include "nsSVGAnimatedLengthList.h"
 #include "nsSVGLengthList.h"
 #include "nsSVGSVGElement.h"
 #include "nsISVGTextContentMetrics.h"
 #include "nsIFrame.h"
 #include "nsDOMError.h"
+#include "nsIDOMSVGPoint.h"
 
 typedef nsSVGStylableElement nsSVGTSpanElementBase;
 
 class nsSVGTSpanElement : public nsSVGTSpanElementBase,
                           public nsIDOMSVGTSpanElement // : nsIDOMSVGTextPositioningElement
                                                        // : nsIDOMSVGTextContentElement
 {
 protected:
@@ -330,19 +331,20 @@ NS_IMETHODIMP nsSVGTSpanElement::GetRota
 
   return metrics->GetRotationOfChar(charnum, _retval);
 }
 
 /* long getCharNumAtPosition (in nsIDOMSVGPoint point); */
 NS_IMETHODIMP nsSVGTSpanElement::GetCharNumAtPosition(nsIDOMSVGPoint *point,
                                                       PRInt32 *_retval)
 {
-  // null check when implementing - this method can be used by scripts!
-  if (!point)
+  nsCOMPtr<nsISVGValue> p = do_QueryInterface(point);
+  if (!p) {
     return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
+  }
 
   nsCOMPtr<nsISVGTextContentMetrics> metrics = GetTextContentMetrics();
 
   if (metrics)
     return metrics->GetCharNumAtPosition(point, _retval);
 
   *_retval = -1;
   return NS_OK;
--- a/content/svg/content/src/nsSVGTextElement.cpp
+++ b/content/svg/content/src/nsSVGTextElement.cpp
@@ -41,16 +41,17 @@
 #include "nsIDOMSVGTextElement.h"
 #include "nsCOMPtr.h"
 #include "nsSVGAnimatedLengthList.h"
 #include "nsSVGLengthList.h"
 #include "nsSVGSVGElement.h"
 #include "nsISVGTextContentMetrics.h"
 #include "nsIFrame.h"
 #include "nsDOMError.h"
+#include "nsIDOMSVGPoint.h"
 
 typedef nsSVGGraphicElement nsSVGTextElementBase;
 
 class nsSVGTextElement : public nsSVGTextElementBase,
                          public nsIDOMSVGTextElement // : nsIDOMSVGTextPositioningElement
                                                      // : nsIDOMSVGTextContentElement
 {
 protected:
@@ -326,19 +327,20 @@ NS_IMETHODIMP nsSVGTextElement::GetRotat
   if (!metrics) return NS_ERROR_FAILURE;
 
   return metrics->GetRotationOfChar(charnum, _retval);
 }
 
 /* long getCharNumAtPosition (in nsIDOMSVGPoint point); */
 NS_IMETHODIMP nsSVGTextElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_retval)
 {
-  // null check when implementing - this method can be used by scripts!
-  if (!point)
+  nsCOMPtr<nsISVGValue> p = do_QueryInterface(point);
+  if (!p) {
     return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
+  }
 
   nsCOMPtr<nsISVGTextContentMetrics> metrics = GetTextContentMetrics();
 
   if (metrics)
     return metrics->GetCharNumAtPosition(point, _retval);
 
   *_retval = -1;
   return NS_OK;
--- a/content/svg/content/src/nsSVGTextPathElement.cpp
+++ b/content/svg/content/src/nsSVGTextPathElement.cpp
@@ -38,16 +38,17 @@
 #include "nsSVGStylableElement.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMSVGTextPathElement.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsISVGTextContentMetrics.h"
 #include "nsIFrame.h"
 #include "nsSVGTextPathElement.h"
 #include "nsDOMError.h"
+#include "nsIDOMSVGPoint.h"
 
 nsSVGElement::LengthInfo nsSVGTextPathElement::sLengthInfo[1] =
 {
   { &nsGkAtoms::startOffset, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::X },
 };
 
 nsSVGEnumMapping nsSVGTextPathElement::sMethodMap[] = {
   {&nsGkAtoms::align, nsIDOMSVGTextPathElement::TEXTPATH_METHODTYPE_ALIGN},
@@ -232,19 +233,20 @@ NS_IMETHODIMP nsSVGTextPathElement::GetR
 
   return metrics->GetRotationOfChar(charnum, _retval);
 }
 
 /* long getCharNumAtPosition (in nsIDOMSVGPoint point); */
 NS_IMETHODIMP nsSVGTextPathElement::GetCharNumAtPosition(nsIDOMSVGPoint *point,
                                                          PRInt32 *_retval)
 {
-  // null check when implementing - this method can be used by scripts!
-  if (!point)
+  nsCOMPtr<nsISVGValue> p = do_QueryInterface(point);
+  if (!p) {
     return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
+  }
 
   nsCOMPtr<nsISVGTextContentMetrics> metrics = GetTextContentMetrics();
 
   if (metrics)
     return metrics->GetCharNumAtPosition(point, _retval);
 
   *_retval = -1;
   return NS_OK;