Bug 731832 - Backout bug 587021 for breaking a specific web page; r=bz
authorMs2ger <ms2ger@gmail.com>
Tue, 24 Apr 2012 21:04:37 +0200
changeset 92422 75c7378c87b638c1a08c93ed53b6cd7a1e4d021f
parent 92365 f661fb83699babe666e2d5c5b6f94fd315c08ff7
child 92423 83ef3c9a64b50b703f73399152f931413d47a904
push id8674
push usereakhgari@mozilla.com
push dateWed, 25 Apr 2012 14:07:22 +0000
treeherdermozilla-inbound@e420eb1ea2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs731832, 587021
milestone15.0a1
first release with
nightly linux32
75c7378c87b6 / 15.0a1 / 20120425030647 / files
nightly linux64
75c7378c87b6 / 15.0a1 / 20120425030647 / files
nightly mac
75c7378c87b6 / 15.0a1 / 20120425030647 / files
nightly win32
75c7378c87b6 / 15.0a1 / 20120425030647 / files
nightly win64
75c7378c87b6 / 15.0a1 / 20120425030647 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 731832 - Backout bug 587021 for breaking a specific web page; r=bz
content/html/content/src/nsHTMLImageElement.cpp
dom/interfaces/html/nsIDOMHTMLImageElement.idl
--- a/content/html/content/src/nsHTMLImageElement.cpp
+++ b/content/html/content/src/nsHTMLImageElement.cpp
@@ -166,16 +166,17 @@ public:
   virtual nsEventStates IntrinsicState() const;
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   nsresult CopyInnerTo(nsGenericElement* aDest) const;
 
   void MaybeLoadImage();
   virtual nsXPCClassInfo* GetClassInfo();
 protected:
+  nsIntPoint GetXY();
   nsSize GetWidthHeight();
 };
 
 nsGenericHTMLElement*
 NS_NewHTMLImageElement(already_AddRefed<nsINodeInfo> aNodeInfo,
                        FromParser aFromParser)
 {
   /*
@@ -272,16 +273,52 @@ nsHTMLImageElement::GetComplete(bool* aC
   mCurrentRequest->GetImageStatus(&status);
   *aComplete =
     (status &
      (imgIRequest::STATUS_LOAD_COMPLETE | imgIRequest::STATUS_ERROR)) != 0;
 
   return NS_OK;
 }
 
+nsIntPoint
+nsHTMLImageElement::GetXY()
+{
+  nsIntPoint point(0, 0);
+
+  nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
+
+  if (!frame) {
+    return point;
+  }
+
+  nsIFrame* layer = nsLayoutUtils::GetClosestLayer(frame->GetParent());
+  nsPoint origin(frame->GetOffsetTo(layer));
+  // Convert to pixels using that scale
+  point.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
+  point.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
+
+  return point;
+}
+
+NS_IMETHODIMP
+nsHTMLImageElement::GetX(PRInt32* aX)
+{
+  *aX = GetXY().x;
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLImageElement::GetY(PRInt32* aY)
+{
+  *aY = GetXY().y;
+
+  return NS_OK;
+}
+
 nsSize
 nsHTMLImageElement::GetWidthHeight()
 {
   nsSize size(0,0);
 
   nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
 
   if (frame) {
--- a/dom/interfaces/html/nsIDOMHTMLImageElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLImageElement.idl
@@ -45,17 +45,17 @@
  *
  * This interface is trying to follow the DOM Level 2 HTML specification:
  * http://www.w3.org/TR/DOM-Level-2-HTML/
  *
  * with changes from the work-in-progress WHATWG HTML specification:
  * http://www.whatwg.org/specs/web-apps/current-work/
  */
 
-[scriptable, uuid(AACA79C6-FC1D-4AC6-B358-C5CF9595A797)]
+[scriptable, uuid(76cf0381-19fd-442d-bb18-c794fd8b5c25)]
 interface nsIDOMHTMLImageElement : nsIDOMHTMLElement
 {
            attribute DOMString        alt;
            attribute DOMString        src;
            attribute DOMString        crossOrigin;
            attribute DOMString        useMap;
            attribute boolean          isMap;
            attribute unsigned long    width;
@@ -67,9 +67,14 @@ interface nsIDOMHTMLImageElement : nsIDO
 
            attribute DOMString        name;
            attribute DOMString        align;
            attribute DOMString        border;
            attribute long             hspace;       
            attribute DOMString        longDesc;
            attribute long             vspace;
            attribute DOMString        lowsrc;
+
+  // These attributes are offsets from the closest view (to mimic
+  // NS4's "offset-from-layer" behavior).
+  readonly attribute long             x;
+  readonly attribute long             y;
 };