Bug 410811 - Implement GetNearestViewportElement and GetFarthestViewportElement correct checkin. r=tor,sr=roc,a1.9=beltzner
authorlongsonr@gmail.com
Thu, 10 Jan 2008 03:38:18 -0800
changeset 10139 32683263bdaff6a272046c5659674e3d83622e7e
parent 10138 33bd2bd57c79e4e0f5544cc26d71cd0cacbabab2
child 10140 b210407bbddaf80f15bb09806c57085c73d26c7c
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstor, roc
bugs410811
milestone1.9b3pre
Bug 410811 - Implement GetNearestViewportElement and GetFarthestViewportElement correct checkin. r=tor,sr=roc,a1.9=beltzner
content/svg/content/src/nsSVGGraphicElement.cpp
content/svg/content/src/nsSVGSVGElement.cpp
--- a/content/svg/content/src/nsSVGGraphicElement.cpp
+++ b/content/svg/content/src/nsSVGGraphicElement.cpp
@@ -71,122 +71,23 @@ nsSVGGraphicElement::nsSVGGraphicElement
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGLocatable methods
 
 /* readonly attribute nsIDOMSVGElement nearestViewportElement; */
 NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
 {
-  nsBindingManager *bindingManager = nsnull;
-  // XXXbz I _think_ this is right.  We want to be using the binding manager
-  // that would have attached the bindings that gives us our anonymous
-  // ancestors. That's the binding manager for the document we actually belong
-  // to, which is our owner doc.
-  nsIDocument* ownerDoc = GetOwnerDoc();
-  if (ownerDoc) {
-    bindingManager = ownerDoc->BindingManager();
-  }
-
-  nsCOMPtr<nsIContent> element = this;
-  nsCOMPtr<nsIContent> ancestor;
-  nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox;
-  unsigned short ancestorCount = 0;
-
-  while (1) {
-
-    ancestor = nsnull;
-    if (bindingManager) {
-      // check for an anonymous ancestor first
-      ancestor = bindingManager->GetInsertionParent(element);
-    }
-    if (!ancestor) {
-      // if we didn't find an anonymous ancestor, use the explicit one
-      ancestor = element->GetParent();
-    }
-
-    fitToViewBox = do_QueryInterface(element);
-
-    if (fitToViewBox && (ancestor || ancestorCount)) {
-      // right interface and not the outermost SVG element
-      nsCOMPtr<nsIDOMSVGElement> SVGElement = do_QueryInterface(element);
-      *aNearestViewportElement = SVGElement;
-      NS_ADDREF(*aNearestViewportElement);
-      return NS_OK;
-    }
-
-    if (!ancestor) {
-      // reached the top of our parent chain
-      break;
-    }
-
-    element = ancestor;
-    ancestorCount++;
-  }
-
-  *aNearestViewportElement = nsnull;
-  return NS_OK;
+  return nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
 }
 
 /* readonly attribute nsIDOMSVGElement farthestViewportElement; */
 NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
 {
-  *aFarthestViewportElement = nsnull;
-
-  nsBindingManager *bindingManager = nsnull;
-  // XXXbz I _think_ this is right.  We want to be using the binding manager
-  // that would have attached the bindings that gives us our anonymous
-  // ancestors. That's the binding manager for the document we actually belong
-  // to, which is our owner doc.
-  nsIDocument* ownerDoc = GetOwnerDoc();
-  if (ownerDoc) {
-    bindingManager = ownerDoc->BindingManager();
-  }
-
-  nsCOMPtr<nsIContent> element = this;
-  nsCOMPtr<nsIContent> ancestor;
-  nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox;
-  unsigned short ancestorCount = 0;
-
-  while (1) {
-
-    ancestor = nsnull;
-    if (bindingManager) {
-      // check for an anonymous ancestor first
-      ancestor = bindingManager->GetInsertionParent(element);
-    }
-    if (!ancestor) {
-      // if we didn't find an anonymous ancestor, use the explicit one
-      ancestor = element->GetParent();
-    }
-
-    fitToViewBox = do_QueryInterface(element);
-
-    if (fitToViewBox) {
-      // right interface
-      nsCOMPtr<nsIDOMSVGElement> SVGElement = do_QueryInterface(element);
-      *aFarthestViewportElement = SVGElement;
-    }
-
-    if (!ancestor) {
-      // reached the top of our parent chain
-      break;
-    }
-
-    element = ancestor;
-    ancestorCount++;
-  }
-
-  if (ancestorCount == 0) {
-    // outermost SVG element
-    *aFarthestViewportElement = nsnull;
-  }
-
-  NS_IF_ADDREF(*aFarthestViewportElement);
-  return NS_OK;
+  return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
 }
 
 /* nsIDOMSVGRect getBBox (); */
 NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
 {
   *_retval = nsnull;
 
   nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -652,123 +652,24 @@ nsSVGSVGElement::GetPreserveAspectRatio(
 
 //----------------------------------------------------------------------
 // nsIDOMSVGLocatable methods
 
 /* readonly attribute nsIDOMSVGElement nearestViewportElement; */
 NS_IMETHODIMP
 nsSVGSVGElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
 {
-  nsBindingManager *bindingManager = nsnull;
-  // XXXbz I _think_ this is right.  We want to be using the binding manager
-  // that would have attached the bindings that gives us our anonymous
-  // ancestors. That's the binding manager for the document we actually belong
-  // to, which is our owner doc.
-  nsIDocument* ownerDoc = GetOwnerDoc();
-  if (ownerDoc) {
-    bindingManager = ownerDoc->BindingManager();
-  }
-
-  nsCOMPtr<nsIContent> element = this;
-  nsCOMPtr<nsIContent> ancestor;
-  nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox;
-  unsigned short ancestorCount = 0;
-
-  while (1) {
-
-    ancestor = nsnull;
-    if (bindingManager) {
-      // check for an anonymous ancestor first
-      ancestor = bindingManager->GetInsertionParent(element);
-    }
-    if (!ancestor) {
-      // if we didn't find an anonymous ancestor, use the explicit one
-      ancestor = element->GetParent();
-    }
-
-    fitToViewBox = do_QueryInterface(element);
-
-    if (fitToViewBox && (ancestor || ancestorCount)) {
-      // right interface and not the outermost SVG element
-      nsCOMPtr<nsIDOMSVGElement> SVGElement = do_QueryInterface(element);
-      *aNearestViewportElement = SVGElement;
-      NS_ADDREF(*aNearestViewportElement);
-      return NS_OK;
-    }
-
-    if (!ancestor) {
-      // reached the top of our parent chain
-      break;
-    }
-
-    element = ancestor;
-    ancestorCount++;
-  }
-
-  *aNearestViewportElement = nsnull;
-  return NS_OK;
+  return nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
 }
 
 /* readonly attribute nsIDOMSVGElement farthestViewportElement; */
 NS_IMETHODIMP
 nsSVGSVGElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
 {
-  *aFarthestViewportElement = nsnull;
-
-  nsBindingManager *bindingManager = nsnull;
-  // XXXbz I _think_ this is right.  We want to be using the binding manager
-  // that would have attached the bindings that gives us our anonymous
-  // ancestors. That's the binding manager for the document we actually belong
-  // to, which is our owner doc.
-  nsIDocument* ownerDoc = GetOwnerDoc();
-  if (ownerDoc) {
-    bindingManager = ownerDoc->BindingManager();
-  }
-
-  nsCOMPtr<nsIContent> element = this;
-  nsCOMPtr<nsIContent> ancestor;
-  nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox;
-  unsigned short ancestorCount = 0;
-
-  while (1) {
-
-    ancestor = nsnull;
-    if (bindingManager) {
-      // check for an anonymous ancestor first
-      ancestor = bindingManager->GetInsertionParent(element);
-    }
-    if (!ancestor) {
-      // if we didn't find an anonymous ancestor, use the explicit one
-      ancestor = element->GetParent();
-    }
-
-    fitToViewBox = do_QueryInterface(element);
-
-    if (fitToViewBox) {
-      // right interface
-      nsCOMPtr<nsIDOMSVGElement> SVGElement = do_QueryInterface(element);
-      *aFarthestViewportElement = SVGElement;
-    }
-
-    if (!ancestor) {
-      // reached the top of our parent chain
-      break;
-    }
-
-    element = ancestor;
-    ancestorCount++;
-  }
-
-  if (ancestorCount == 0) {
-    // outermost SVG element
-    *aFarthestViewportElement = nsnull;
-  }
-
-  NS_IF_ADDREF(*aFarthestViewportElement);
-  return NS_OK;
+  return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
 }
 
 /* nsIDOMSVGRect getBBox (); */
 NS_IMETHODIMP
 nsSVGSVGElement::GetBBox(nsIDOMSVGRect **_retval)
 {
   *_retval = nsnull;