diff --git a/dom/public/html/nsIDOMHTMLElement.h b/dom/public/html/nsIDOMHTMLElement.h
index dcae01b38613..cf24a5a57de3 100644
--- a/dom/public/html/nsIDOMHTMLElement.h
+++ b/dom/public/html/nsIDOMHTMLElement.h
@@ -29,6 +29,7 @@
#include "nsIScriptContext.h"
#include "nsIDOMElement.h"
+class nsIDOMElement;
class nsIDOMCSSStyleDeclaration;
#define NS_IDOMHTMLELEMENT_IID \
@@ -55,6 +56,16 @@ public:
NS_IMETHOD SetClassName(const nsString& aClassName)=0;
NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle)=0;
+
+ NS_IMETHOD GetOffsetTop(PRInt32* aOffsetTop)=0;
+
+ NS_IMETHOD GetOffsetLeft(PRInt32* aOffsetLeft)=0;
+
+ NS_IMETHOD GetOffsetWidth(PRInt32* aOffsetWidth)=0;
+
+ NS_IMETHOD GetOffsetHeight(PRInt32* aOffsetHeight)=0;
+
+ NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent)=0;
};
@@ -70,6 +81,11 @@ public:
NS_IMETHOD GetClassName(nsString& aClassName); \
NS_IMETHOD SetClassName(const nsString& aClassName); \
NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle); \
+ NS_IMETHOD GetOffsetTop(PRInt32* aOffsetTop); \
+ NS_IMETHOD GetOffsetLeft(PRInt32* aOffsetLeft); \
+ NS_IMETHOD GetOffsetWidth(PRInt32* aOffsetWidth); \
+ NS_IMETHOD GetOffsetHeight(PRInt32* aOffsetHeight); \
+ NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent); \
@@ -85,6 +101,11 @@ public:
NS_IMETHOD GetClassName(nsString& aClassName) { return _to GetClassName(aClassName); } \
NS_IMETHOD SetClassName(const nsString& aClassName) { return _to SetClassName(aClassName); } \
NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle) { return _to GetStyle(aStyle); } \
+ NS_IMETHOD GetOffsetTop(PRInt32* aOffsetTop) { return _to GetOffsetTop(aOffsetTop); } \
+ NS_IMETHOD GetOffsetLeft(PRInt32* aOffsetLeft) { return _to GetOffsetLeft(aOffsetLeft); } \
+ NS_IMETHOD GetOffsetWidth(PRInt32* aOffsetWidth) { return _to GetOffsetWidth(aOffsetWidth); } \
+ NS_IMETHOD GetOffsetHeight(PRInt32* aOffsetHeight) { return _to GetOffsetHeight(aOffsetHeight); } \
+ NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) { return _to GetOffsetParent(aOffsetParent); } \
extern "C" NS_DOM nsresult NS_InitHTMLElementClass(nsIScriptContext *aContext, void **aPrototype);
diff --git a/dom/public/idl/html/HTMLElement.idl b/dom/public/idl/html/HTMLElement.idl
index 2a9c83c666d1..c60a5072a102 100644
--- a/dom/public/idl/html/HTMLElement.idl
+++ b/dom/public/idl/html/HTMLElement.idl
@@ -8,4 +8,11 @@
attribute DOMString dir;
attribute DOMString className;
readonly attribute CSSStyleDeclaration style;
+
+ /* Temporary till we find a place for them */
+ readonly attribute int offsetTop;
+ readonly attribute int offsetLeft;
+ readonly attribute int offsetWidth;
+ readonly attribute int offsetHeight;
+ readonly attribute Element offsetParent;
};
diff --git a/dom/public/nsDOMPropEnums.h b/dom/public/nsDOMPropEnums.h
index b44ff48411f3..9d22f8754950 100644
--- a/dom/public/nsDOMPropEnums.h
+++ b/dom/public/nsDOMPropEnums.h
@@ -334,6 +334,11 @@ enum nsDOMProp {
NS_DOM_PROP_HTMLELEMENT_DIR,
NS_DOM_PROP_HTMLELEMENT_ID,
NS_DOM_PROP_HTMLELEMENT_LANG,
+ NS_DOM_PROP_HTMLELEMENT_OFFSETHEIGHT,
+ NS_DOM_PROP_HTMLELEMENT_OFFSETLEFT,
+ NS_DOM_PROP_HTMLELEMENT_OFFSETPARENT,
+ NS_DOM_PROP_HTMLELEMENT_OFFSETTOP,
+ NS_DOM_PROP_HTMLELEMENT_OFFSETWIDTH,
NS_DOM_PROP_HTMLELEMENT_STYLE,
NS_DOM_PROP_HTMLELEMENT_TITLE,
NS_DOM_PROP_HTMLEMBEDELEMENT_ALIGN,
diff --git a/dom/public/nsDOMPropNames.h b/dom/public/nsDOMPropNames.h
index 5eda30e4b5aa..8fc76f162754 100644
--- a/dom/public/nsDOMPropNames.h
+++ b/dom/public/nsDOMPropNames.h
@@ -333,6 +333,11 @@
"htmlelement.dir", \
"htmlelement.id", \
"htmlelement.lang", \
+ "htmlelement.offsetheight", \
+ "htmlelement.offsetleft", \
+ "htmlelement.offsetparent", \
+ "htmlelement.offsettop", \
+ "htmlelement.offsetwidth", \
"htmlelement.style", \
"htmlelement.title", \
"htmlembedelement.align", \
diff --git a/dom/src/html/nsJSHTMLElement.cpp b/dom/src/html/nsJSHTMLElement.cpp
index 00b6dacfb338..3c478e9f13d3 100644
--- a/dom/src/html/nsJSHTMLElement.cpp
+++ b/dom/src/html/nsJSHTMLElement.cpp
@@ -34,6 +34,7 @@
#include "nsCOMPtr.h"
#include "nsDOMPropEnums.h"
#include "nsString.h"
+#include "nsIDOMElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMCSSStyleDeclaration.h"
@@ -41,6 +42,7 @@
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
+static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID);
@@ -53,7 +55,12 @@ enum HTMLElement_slots {
HTMLELEMENT_LANG = -3,
HTMLELEMENT_DIR = -4,
HTMLELEMENT_CLASSNAME = -5,
- HTMLELEMENT_STYLE = -6
+ HTMLELEMENT_STYLE = -6,
+ HTMLELEMENT_OFFSETTOP = -7,
+ HTMLELEMENT_OFFSETLEFT = -8,
+ HTMLELEMENT_OFFSETWIDTH = -9,
+ HTMLELEMENT_OFFSETHEIGHT = -10,
+ HTMLELEMENT_OFFSETPARENT = -11
};
/***********************************************************************/
@@ -181,6 +188,92 @@ GetHTMLElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
+ case HTMLELEMENT_OFFSETTOP:
+ {
+ rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLELEMENT_OFFSETTOP, PR_FALSE);
+ if (NS_FAILED(rv)) {
+ return nsJSUtils::nsReportError(cx, obj, rv);
+ }
+ PRInt32 prop;
+ nsresult result = NS_OK;
+ result = a->GetOffsetTop(&prop);
+ if (NS_SUCCEEDED(result)) {
+ *vp = INT_TO_JSVAL(prop);
+ }
+ else {
+ return nsJSUtils::nsReportError(cx, obj, result);
+ }
+ break;
+ }
+ case HTMLELEMENT_OFFSETLEFT:
+ {
+ rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLELEMENT_OFFSETLEFT, PR_FALSE);
+ if (NS_FAILED(rv)) {
+ return nsJSUtils::nsReportError(cx, obj, rv);
+ }
+ PRInt32 prop;
+ nsresult result = NS_OK;
+ result = a->GetOffsetLeft(&prop);
+ if (NS_SUCCEEDED(result)) {
+ *vp = INT_TO_JSVAL(prop);
+ }
+ else {
+ return nsJSUtils::nsReportError(cx, obj, result);
+ }
+ break;
+ }
+ case HTMLELEMENT_OFFSETWIDTH:
+ {
+ rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLELEMENT_OFFSETWIDTH, PR_FALSE);
+ if (NS_FAILED(rv)) {
+ return nsJSUtils::nsReportError(cx, obj, rv);
+ }
+ PRInt32 prop;
+ nsresult result = NS_OK;
+ result = a->GetOffsetWidth(&prop);
+ if (NS_SUCCEEDED(result)) {
+ *vp = INT_TO_JSVAL(prop);
+ }
+ else {
+ return nsJSUtils::nsReportError(cx, obj, result);
+ }
+ break;
+ }
+ case HTMLELEMENT_OFFSETHEIGHT:
+ {
+ rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLELEMENT_OFFSETHEIGHT, PR_FALSE);
+ if (NS_FAILED(rv)) {
+ return nsJSUtils::nsReportError(cx, obj, rv);
+ }
+ PRInt32 prop;
+ nsresult result = NS_OK;
+ result = a->GetOffsetHeight(&prop);
+ if (NS_SUCCEEDED(result)) {
+ *vp = INT_TO_JSVAL(prop);
+ }
+ else {
+ return nsJSUtils::nsReportError(cx, obj, result);
+ }
+ break;
+ }
+ case HTMLELEMENT_OFFSETPARENT:
+ {
+ rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLELEMENT_OFFSETPARENT, PR_FALSE);
+ if (NS_FAILED(rv)) {
+ return nsJSUtils::nsReportError(cx, obj, rv);
+ }
+ nsIDOMElement* prop;
+ nsresult result = NS_OK;
+ result = a->GetOffsetParent(&prop);
+ if (NS_SUCCEEDED(result)) {
+ // get the js object
+ nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
+ }
+ else {
+ return nsJSUtils::nsReportError(cx, obj, result);
+ }
+ break;
+ }
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
}
@@ -352,6 +445,11 @@ static JSPropertySpec HTMLElementProperties[] =
{"dir", HTMLELEMENT_DIR, JSPROP_ENUMERATE},
{"className", HTMLELEMENT_CLASSNAME, JSPROP_ENUMERATE},
{"style", HTMLELEMENT_STYLE, JSPROP_ENUMERATE | JSPROP_READONLY},
+ {"offsetTop", HTMLELEMENT_OFFSETTOP, JSPROP_ENUMERATE | JSPROP_READONLY},
+ {"offsetLeft", HTMLELEMENT_OFFSETLEFT, JSPROP_ENUMERATE | JSPROP_READONLY},
+ {"offsetWidth", HTMLELEMENT_OFFSETWIDTH, JSPROP_ENUMERATE | JSPROP_READONLY},
+ {"offsetHeight", HTMLELEMENT_OFFSETHEIGHT, JSPROP_ENUMERATE | JSPROP_READONLY},
+ {"offsetParent", HTMLELEMENT_OFFSETPARENT, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};