Index: MochiKit/Style.js
===================================================================
--- MochiKit/Style.js	(revision 1256)
+++ MochiKit/Style.js	(working copy)
@@ -66,7 +66,8 @@
     'getViewportDimensions',
     'getViewportPosition',
     'Dimensions',
-    'Coordinates'
+    'Coordinates',
+    'Box'
 ];
 
 
@@ -112,6 +113,73 @@
 };
 
 
+/*
+
+    Box
+
+*/
+/** @id MochiKit.Style.Box */
+MochiKit.Style.Box = function (t, l, w, h) {
+    this.t = t;
+    this.l = l;
+    this.w = w;
+    this.h = h;
+};
+
+MochiKit.Style.Box.prototype.__repr__ = function () {
+    var repr = MochiKit.Base.repr;
+    return '{t: ' + repr(this.t) + ', l: ' + repr(this.l)
+        + ', w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}';
+};
+
+MochiKit.Style.Box.prototype.toString = function () {
+    return this.__repr__();
+};
+
+MochiKit.Style.Box.prototype.getCornerCoordinates = function (corner) {
+    var dim = MochiKit.Style.Dimensions;
+    switch (corner.toLowerCase()) {
+    case 'nw':
+        return new dim(this.l, this.t); 
+    case 'ne':
+        return new dim(this.l+this.w, this.t); 
+    case 'se':
+        return new dim(this.l+this.w, this.t+this.h); 
+    case 'sw':
+        return new dim(this.l, this.t+this.h); 
+    default:
+        throw 'MochiKit.Style.Box.getCornerCoordinates: corner must be nw, ne, se or sw';
+    }
+};
+
+MochiKit.Style.Box.prototype.getRight = function () {
+    return this.l + this.w;
+};
+
+MochiKit.Style.Box.prototype.getBottom = function () {
+    return this.t + this.h;
+};
+
+MochiKit.Style.Box.prototype.getCoordinates = function () {
+    return new MochiKit.Style.Coordinates(this.l, this.t);
+};
+
+MochiKit.Style.Box.prototype.getDimensions = function () {
+    return new MochiKit.Style.Dimensions(this.w, this.h);
+};
+
+MochiKit.Style.Box.prototype.centerWithin = function (otherbox /*optional*/, relative) {
+    if (relative == undefined)
+        relative = true;
+    this.l = Math.floor((otherbox.w - this.w) / 2);
+    this.t = Math.floor((otherbox.h - this.h) / 2);
+    if (!relative) {
+        this.l += otherbox.l;
+        this.t += otherbox.t;
+    }
+};
+
+
 MochiKit.Base.update(MochiKit.Style, {
 
     /** @id MochiKit.Style.getStyle */
@@ -422,7 +490,20 @@
         }
         return c;
     },
+    
+    /** @id MochiKit.Style.getElementBox */
+    getElementBox: function (elem) {
+        var pos = MochiKit.Style.getElementPosition(elem);
+        var dim = MochiKit.Style.getElementDimensions(elem);
+        return new MochiKit.Style.Box(pos.x, pos.y, dim.w, dim.h);
+    },
 
+    /** @id MochiKit.Style.setElementBox */
+    setElementBox: function (elem, newbox) {
+        setElementPosition(newbox.getCoordinates());
+        setElementDimensions(newbox.getDimensions());
+    },
+
     __new__: function () {
         var m = MochiKit.Base;
 
