Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.624
diff -u -p -r1.624 theme.inc
--- includes/theme.inc	24 Nov 2010 03:30:59 -0000	1.624
+++ includes/theme.inc	26 Nov 2010 15:47:29 -0000
@@ -1623,6 +1623,8 @@ function theme_table($variables) {
 
   // Add sticky headers, if applicable.
   if (count($header) && $sticky) {
+    // Make sure the sticky tableheader won't overlap any focused elements.
+    drupal_add_js('misc/displace.js', array('weight' => JS_LIBRARY + 1));
     drupal_add_js('misc/tableheader.js');
     // Add 'sticky-enabled' class to the table to identify it for JS.
     // This is needed to target tables constructed by this function.
Index: misc/displace.css
===================================================================
RCS file: misc/displace.css
diff -N misc/displace.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/displace.css	26 Nov 2010 15:53:40 -0000
@@ -0,0 +1,30 @@
+/* $Id$ */
+
+/**
+ * @file
+ * Styles to displace absolute and fixed positioned elements.
+ */
+
+.displace-top,
+.displace-bottom {
+  position: relative;
+  width: 100%;
+}
+.displace-processed .displace-top,
+.displace-processed .displace-bottom,
+.displace-processed .displace-absolute.displace-absolute-fixed {
+  position: fixed;
+  width: auto;
+  left: 0;
+  right: 0;
+  z-index: 600;
+}
+.displace-processed .displace-absolute {
+  position: absolute;
+  z-index: 500;
+}
+.displace-unsupported .displace-top,
+.displace-unsupported .displace-bottom {
+  position: absolute;
+  width: 100%;
+}
Index: misc/displace.js
===================================================================
RCS file: misc/displace.js
diff -N misc/displace.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/displace.js	26 Nov 2010 15:56:53 -0000
@@ -0,0 +1,376 @@
+// $Id$
+(function ($) {
+
+/**
+ * Attaches the displace behavior.
+ */
+Drupal.behaviors.displace = {
+  attach: function (context, settings) {
+    $(document.documentElement).once('displace', function () {
+      Drupal.displace.init();
+      Drupal.displaceFocus.init();
+    });
+
+    Drupal.displace.refresh();
+    Drupal.displaceFocus.refresh();
+  },
+
+  detach: function (context, settings, trigger) {
+    if (trigger == 'unload' || trigger == 'move') {
+      Drupal.displace.refresh();
+    }
+  }
+};
+
+/**
+ * Provides a generic method to detect and act on focus movement.
+ *
+ * When a focus movement is being detect a "drupalDisplaceFocus" event is
+ * triggered. Scripts involving elements that are positioned absolute or fixed
+ * can use this event to adjust the window's scroll position so the element
+ * being focused does not hide beneath them.
+ *
+ * The event object passed to the eventhandlers already contains some useful
+ * info about the position of the target element.
+ *
+ * @see Drupal.displaceFocus.createEvent
+ * @see Drupal.displace.eventhandlerDisplaceFocus
+ * @see Drupal.tableHeader
+ */
+Drupal.displaceFocus = Drupal.displaceFocus || {};
+
+/**
+ * Initializes the displaceFocus behavior.
+ */
+Drupal.displaceFocus.init = function () {
+  // Detect when an anchor is being scrolled into view.
+  $(window).bind('scroll.drupal-displace-anchor', Drupal.displaceFocus.eventhandlerDetectAnchorScrolling);
+  // Detect when the focus is being set to an element.
+  $(document).bind('focusin.drupal-displace-focus', Drupal.displaceFocus.eventhandlerDetectFocusMovement);
+};
+
+/**
+ * Refreshes displaceFocus behavior.
+ */
+Drupal.displaceFocus.refresh = function () {
+  $(window).triggerHandler('scroll.drupal-displace-anchor');
+};
+
+/**
+ * Creates an event object containing position data.
+ *
+ * @param type
+ *   Describes the nature of the event.
+ * @param target
+ *   The DOM element that initiated the event.
+ */
+Drupal.displaceFocus.createEvent = function (type, target) {
+  var event = jQuery.Event(type),
+      $target = $(target),
+      targetOffset = $target.offset(),
+      $window = $(window);
+
+  event.target = target;
+  event.$target = $target;
+  // The amount of pixels the entire document has been scrolled.
+  event.pageXOffset = $window.scrollLeft();
+  event.pageYOffset = $window.scrollTop();
+  // The position of the target element relative to the document.
+  event.pageX = Math.round(targetOffset.left);
+  event.pageY = Math.round(targetOffset.top);
+  // The position of the target element relative to the viewport.
+  event.clientX = event.pageX - event.pageXOffset;
+  event.clientY = event.pageY - event.pageYOffset;
+
+  return event;
+};
+
+/**
+ * Event handler: detects when an anchor is being scrolled into view and
+ * triggers the custom event "drupalDisplaceFocus".
+ *
+ * @param event
+ *   Event being triggered, with the following restrictions:
+ *   - event.type: scroll
+ *   - event.currentTarget: window
+ */
+Drupal.displaceFocus.eventhandlerDetectAnchorScrolling = function (event) {
+  if (location.hash && location.hash != '#') {
+    // Delay the timeout as long as events are triggered.
+    clearTimeout(Drupal.displaceFocus.displaceAnchorTimeout);
+    Drupal.displaceFocus.displaceAnchorTimeout = setTimeout(function () {
+      var $anchor = $(location.hash), $window = $(window);
+      if ($anchor.length && Math.round($anchor.offset().top) == $window.scrollTop()) {
+        $window.trigger(Drupal.displaceFocus.createEvent('drupalDisplaceFocus', $anchor[0]));
+      }
+    }, 100);
+  }
+};
+
+/**
+ * Event handler: detects when the focus is being set to an element and
+ * triggers the custom event "drupalDisplaceFocus".
+ *
+ * @param event
+ *   Event being triggered, with the following restrictions:
+ *   - event.type: focusin
+ *   - event.currentTarget: document
+ */
+Drupal.displaceFocus.eventhandlerDetectFocusMovement = function (event) {
+  if (event.target.nodeType === 1) {
+    // Make sure target element is not fixed positioned.
+    var offsetParent = $(event.target).offsetParent();
+    while (offsetParent.length && offsetParent[0] !== document.body) {
+      if (offsetParent.css('position') == 'fixed') {
+        return;
+      }
+      offsetParent = $(offsetParent[0]).offsetParent();
+    }
+
+    $(window).trigger(Drupal.displaceFocus.createEvent('drupalDisplaceFocus', event.target));
+  }
+};
+
+/**
+ * Provides a generic method to position elements fixed to the viewport.
+ *
+ * Fixed positioning (CSS declaration position:fixed) is done relative to the
+ * viewport. This makes it hard to position multiple fixed positioned element
+ * relative to each other (e.g. multiple toolbars should come after each other,
+ * not on top of each other).
+ *
+ * To position an element fixed at the top of the viewport add the class
+ * "displace-top" to that element, and to position it to the bottom of the view-
+ * port add the class "displace-bottom".
+ *
+ * To position an element absolute at the top of the viewport also add the
+ * class "displace-absolute".
+ *
+ * When a displacement region contains both absolute and fixed positioned
+ * elements, the absolute positioned elements will be positioned fixed too, but
+ * will only be visible when they would be visible if they were positioned
+ * absolute. This is done to improve the look & feel.
+ *
+ * When a browser does not support position:fixed (like IE6) the displaced
+ * elements automaticly receive the class "displace-unsupported" and are
+ * positioned absolute.
+ */
+Drupal.displace = Drupal.displace || {};
+
+Drupal.displace._elements = [];
+Drupal.displace._mixedDisplacement = [];
+Drupal.displace._displacement = [];
+
+/**
+ * Initializes the displace behavior.
+ */
+Drupal.displace.init = function () {
+  if (!$.support.positionFixed) {
+    $(document.documentElement).addClass('displace-unsupported');
+  }
+};
+
+/**
+ * Refreshes displace behavior.
+ */
+Drupal.displace.refresh = function () {
+  var $window = $(window);
+
+  Drupal.displace.clearCache(true);
+
+  if (Drupal.displace.forceHandlers || Drupal.displace.getDisplacedElements('top').length || Drupal.displace.getDisplacedElements('bottom').length) {
+    var events = 'resize.drupal-displace';
+    // If there are both absolute and fixed displaced elements also bind the
+    // handler to scroll events.
+    if (Drupal.displace.mixedDisplacement('top') || Drupal.displace.mixedDisplacement('bottom')) {
+      events += ' scroll.drupal-displace';
+    }
+    $window
+      .bind(events, Drupal.displace.eventhandlerDisplaceDocument)
+      .bind('drupalDisplaceFocus.drupal-displace', Drupal.displace.eventhandlerDisplaceFocus);
+  }
+  // Unbind any previously bound event handlers as there are no displaced
+  // elements to be taken into account.
+  else {
+    $window.unbind('.drupal-displace');
+  }
+
+  $window.triggerHandler('resize.drupal-displace');
+};
+
+/**
+ * Get all displaced elements of given region.
+ *
+ * @param region
+ *   (optional) Region name. Either "top" or "bottom". If not provided an object
+ *   containing both will be returned.
+ * @param copy
+ *   (optional) Boolean whether to return a copy of the jQuery object.
+ *   Defaults to FALSE.
+ *
+ * @return
+ *   jQuery object containing all displaced elements of given region.
+ */
+Drupal.displace.getDisplacedElements = function (region, copy) {
+  if (!this._elements.length) {
+    this._elements.top = $('.displace-top');
+    this._elements.bottom = $('.displace-bottom');
+  }
+
+  return region
+    ? copy ? $(this._elements[region]) : this._elements[region]
+    : $(this._elements.top).add(this._elements.bottom);
+};
+
+/**
+ * Checks whether there are both absolute and fixed displaced elements.
+ *
+ * @param region
+ *   Region name. Either "top" or "bottom".
+ *
+ * @return
+ *   TRUE if there are both absolute and fixed displaced elements in given
+ *   region, FALSE otherwise.
+ */
+Drupal.displace.mixedDisplacement = function (region) {
+  if (!this._mixedDisplacement[region]) {
+    this._mixedDisplacement[region] = Drupal.displace.getDisplacedElements(region).is('.displace-absolute') && Drupal.displace.getDisplacedElements(region).is(':not(.displace-absolute)');
+  }
+  return this._mixedDisplacement[region];
+};
+
+/**
+ * Get the total displacement of given region.
+ *
+ * @param region
+ *   Region name. Either "top" or "bottom".
+ *
+ * @return
+ *   The total displacement of given region in pixels.
+ *
+ * @see modules/overlay/overlay-child.js
+ */
+Drupal.displace.getDisplacement = function (region) {
+  if (!this._displacement[region]) {
+    var offset = Drupal.displace.initialOffset || 0;
+    var height = 0;
+    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
+    this.getDisplacedElements(region).each(function () {
+      offset = offset + height;
+      height = $(this).css(region, offset).outerHeight();
+
+      // Make sure absolute and fixed displaced elements work together.
+      if (Drupal.displace.mixedDisplacement(region) && $(this).hasClass('displace-absolute')) {
+        if ((region == 'top' && scrollTop < offset + height) || (region == 'bottom' && scrollTop + $(window).height() > document.body.scrollHeight - offset + height)) {
+          $(this).addClass('displace-absolute-fixed');
+        }
+        // Skip this absolute displaced element as it is outside the viewport.
+        else {
+          $(this).removeClass('displace-absolute-fixed');
+          height = 0;
+        }
+      }
+
+      // In IE, Shadow filter adds some extra height, so we need to remove it
+      // from the returned height.
+      if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) {
+        height -= this.filters.item('DXImageTransform.Microsoft.Shadow').strength;
+        height = Math.max(0, height);
+      }
+    });
+
+    // Use offset of latest displaced element as the total displacement.
+    this._displacement[region] = offset + height;
+  }
+
+  return this._displacement[region];
+};
+
+/**
+ * Clear cache.
+ *
+ * @param selectorCache
+ *   Boolean whether to also clear the selector cache.
+ */
+Drupal.displace.clearCache = function (selectorCache) {
+  if (selectorCache) {
+    this._elements = [];
+    this._mixedDisplacement = [];
+  }
+  this._displacement = [];
+};
+
+/**
+ * Event handler: makes sure there is enough space for displaced elements at the
+ * top and bottom of the document.
+ *
+ * @param event
+ *   Event being triggered, with the following restrictions:
+ *   - event.type: resize, scroll
+ *   - event.currentTarget: window
+ */
+Drupal.displace.eventhandlerDisplaceDocument = function (event) {
+  Drupal.displace.clearCache();
+
+  // Adjust paddingTop and paddingBottom of document root element to make sure
+  // nothing is hidden beneath any displaced elements.
+  var adjustment = {
+    marginTop: Drupal.displace.getDisplacement('top') || null,
+    marginBottom: Drupal.displace.getDisplacement('bottom') || null
+  };
+
+  // Apply adjustments to the document.
+  $(document.body).css(adjustment);
+  //Fake a style change to force an immediate document reflow in IE7.
+  document.body.className = document.body.className;
+};
+
+/**
+ * Event handler: makes sure the element being focused is not hidden beneath any
+ * displaced elements. Adjusts the scrollTop if it does.
+ *
+ * @param event
+ *   Event being triggered, with the following restrictions:
+ *   - event.type: drupalDisplaceFocus
+ *   - event.currentTarget: window
+ *
+ * @see Drupal.displaceFocus
+ */
+Drupal.displace.eventhandlerDisplaceFocus = function (event) {
+  var displacement = Drupal.displace.getDisplacement('top');
+  if (event.clientY < displacement) {
+    window.scrollBy(0, -(displacement - event.clientY));
+  }
+};
+
+// Override jQuery UI so it adjusts positions when beneath a displaced element.
+var _position = $.fn.position;
+$.fn.position = function(options) {
+  var ret = _position.apply(this, arguments);
+  if (ret.each) {
+    ret.each(function() {
+      var elem = $(this), offset = elem.offset();
+
+      if (offset.top < Drupal.displace.getDisplacement('top')) {
+        offset.top = Drupal.displace.getDisplacement('top');
+        elem.offset(offset);
+      }
+    });
+  }
+  return ret;
+};
+
+// Override jQuery UI: If an draggable's containment option is set to document
+// or window, make sure displacement is taken into account.
+if ($.ui && $.ui.draggable) {
+  var _setContainment= $.ui.draggable.prototype._setContainment;
+  $.ui.draggable.prototype._setContainment = function() {
+    _setContainment.apply(this, arguments);
+    if (this.options.containment == 'document' || this.options.containment == 'window') {
+      this.containment[1] += Drupal.displace.getDisplacement('top');
+      this.containment[3] += Drupal.displace.getDisplacement('bottom');
+    }
+  };
+}
+
+})(jQuery);
Index: misc/tableheader.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tableheader.js,v
retrieving revision 1.32
diff -u -p -r1.32 tableheader.js
--- misc/tableheader.js	28 Jul 2010 01:38:28 -0000	1.32
+++ misc/tableheader.js	26 Nov 2010 15:47:52 -0000
@@ -33,9 +33,9 @@ Drupal.tableHeader = function (table) {
   // the table to avoid a flash of the header clone upon page load.
   this.stickyTable = $('<table class="sticky-header"/>')
     .insertBefore(this.originalTable)
-    .css({ position: 'fixed', top: '0px' });
+    .css({ position: 'fixed', top: '0px', zIndex: 1 + (parseInt(this.originalTable.css('zIndex')) || 0) });
   this.stickyHeader = this.originalHeader.clone(true)
-    .hide()
+    .css('visibility', 'hidden')
     .appendTo(this.stickyTable);
   this.stickyHeaderCells = this.stickyHeader.find('> tr > th');
 
@@ -43,11 +43,6 @@ Drupal.tableHeader = function (table) {
   $(window)
     .bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
     .bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
-    // Make sure the anchor being scrolled into view is not hidden beneath the
-    // sticky table header. Adjust the scrollTop if it does.
-    .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
-      window.scrollBy(0, -self.stickyTable.outerHeight());
-    })
     // Make sure the element being focused is not hidden beneath the sticky
     // table header. Adjust the scrollTop if it does.
     .bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
@@ -59,7 +54,7 @@ Drupal.tableHeader = function (table) {
 
   // We hid the header to avoid it showing up erroneously on page load;
   // we need to unhide it now so that it will show up when expected.
-  this.stickyHeader.show();
+  this.stickyHeader.css('visibility', '');
 };
 
 /**
@@ -73,14 +68,14 @@ Drupal.tableHeader.prototype.eventhandle
   var calculateWidth = event.data && event.data.calculateWidth;
 
   // Reset top position of sticky table headers to the current top offset.
-  this.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
+  this.stickyOffsetTop = Drupal.displace ? Drupal.displace.getDisplacement('top') : 0;
   this.stickyTable.css('top', this.stickyOffsetTop + 'px');
 
   // Save positioning data.
   var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
   if (calculateWidth || this.viewHeight !== viewHeight) {
     this.viewHeight = viewHeight;
-    this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
+    this.vPosition = this.originalTable.offset().top - this.stickyOffsetTop;
     this.hPosition = this.originalTable.offset().left;
     this.vLength = this.originalTable[0].clientHeight - 100;
     calculateWidth = true;
@@ -90,22 +85,15 @@ Drupal.tableHeader.prototype.eventhandle
   var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
   var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
   this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
-  this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
+  this.stickyTable.css({ left: parseInt(-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
 
   // Only perform expensive calculations if the sticky header is actually
   // visible or when forced.
   if (this.stickyVisible && (calculateWidth || !this.widthCalculated)) {
     this.widthCalculated = true;
     // Resize header and its cell widths.
-    this.stickyHeaderCells.each(function (index) {
-      var cellWidth = self.originalHeaderCells.eq(index).css('width');
-      // Exception for IE7.
-      if (cellWidth == 'auto') {
-        cellWidth = self.originalHeaderCells.get(index).clientWidth + 'px';
-      }
-      $(this).css('width', cellWidth);
-    });
-    this.stickyTable.css('width', this.originalTable.css('width'));
+    this.stickyHeaderCells.width(function (index) { return self.originalHeaderCells.eq(index).width(); });
+    this.stickyTable.width(this.originalTable.css('width'));
   }
 };
 
Index: modules/overlay/overlay-child.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-child.js,v
retrieving revision 1.11
diff -u -p -r1.11 overlay-child.js
--- modules/overlay/overlay-child.js	6 Nov 2010 00:18:24 -0000	1.11
+++ modules/overlay/overlay-child.js	26 Nov 2010 15:48:21 -0000
@@ -172,22 +172,23 @@ Drupal.overlayChild.behaviors.shortcutAd
 };
 
 /**
- * Use displacement from parent window.
+ * Allow resize event handlers to recalculate sizes/positions when parent window
+ * is being resized.
  */
-Drupal.overlayChild.behaviors.alterTableHeaderOffset = function (context, settings) {
-  if (Drupal.settings.tableHeaderOffset) {
-    Drupal.overlayChild.prevTableHeaderOffset = Drupal.settings.tableHeaderOffset;
-  }
-  Drupal.settings.tableHeaderOffset = 'Drupal.overlayChild.tableHeaderOffset';
+Drupal.overlayChild.behaviors.parentResize = function (context, settings) {
+  $(document).bind('drupalOverlayResize.drupal-overlay', function () {
+    $(window).triggerHandler('resize');
+  });
 };
 
-/**
- * Callback for Drupal.settings.tableHeaderOffset.
- */
-Drupal.overlayChild.tableHeaderOffset = function () {
-  var topOffset = Drupal.overlayChild.prevTableHeaderOffset ? eval(Drupal.overlayChild.prevTableHeaderOffset + '()') : 0;
-
-  return topOffset + parseInt($(document.body).css('marginTop'));
+// Override Drupal.displace so it includes displacement of parent document.
+Drupal.displace.forceHandlers = true;
+var _getDisplacement = Drupal.displace.getDisplacement;
+Drupal.displace.getDisplacement = function (region) {
+  if (parent && parent.Drupal && parent.Drupal.displace) {
+    Drupal.displace.initialOffset = parent.Drupal.displace.getDisplacement(region);
+  }
+  return _getDisplacement.apply(Drupal.displace, arguments);
 };
 
 })(jQuery);
Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.57
diff -u -p -r1.57 overlay-parent.js
--- modules/overlay/overlay-parent.js	6 Nov 2010 00:18:24 -0000	1.57
+++ modules/overlay/overlay-parent.js	26 Nov 2010 15:48:43 -0000
@@ -128,7 +128,7 @@ Drupal.overlay.create = function () {
           ' drupalOverlayBeforeLoad' + eventClass +
           ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'));
 
-  if ($('.overlay-displace-top, .overlay-displace-bottom').length) {
+  if (Drupal.displace) {
     $(document)
       .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements'))
       .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements'));
@@ -400,14 +400,6 @@ Drupal.overlay.eventhandlerAlterDisplace
     return;
   }
 
-  $(this.iframeWindow.document.body).css({
-    marginTop: Drupal.overlay.getDisplacement('top'),
-    marginBottom: Drupal.overlay.getDisplacement('bottom')
-  })
-  // IE7 isn't reflowing the document immediately.
-  // @todo This might be fixed in a cleaner way.
-  .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow');
-
   var documentHeight = this.iframeWindow.document.body.clientHeight;
   var documentWidth = this.iframeWindow.document.body.clientWidth;
   // IE6 doesn't support maxWidth, use width instead.
@@ -415,7 +407,7 @@ Drupal.overlay.eventhandlerAlterDisplace
 
   // Consider any element that should be visible above the overlay (such as
   // a toolbar).
-  $('.overlay-displace-top, .overlay-displace-bottom').each(function () {
+  Drupal.displace.getDisplacedElements().each(function () {
     var data = $(this).data();
     var maxWidth = documentWidth;
     // In IE, Shadow filter makes element to overlap the scrollbar with 1px.
@@ -451,7 +443,7 @@ Drupal.overlay.eventhandlerAlterDisplace
  *   - event.currentTarget: any
  */
 Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) {
-  var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom');
+  var $displacedElements = Drupal.displace.getDisplacedElements();
   try {
     $displacedElements.css({ maxWidth: null, clip: null });
   }
@@ -669,8 +661,13 @@ Drupal.overlay.eventhandlerRefreshPage =
  *   - event.currentTarget: any
  */
 Drupal.overlay.eventhandlerDispatchEvent = function (event) {
+  var self = this;
   if (this.iframeWindow && this.iframeWindow.document) {
-    this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event);
+    window.setTimeout(function() {
+      if (self.iframeWindow && self.iframeWindow.document) {
+        self.iframeWindow.jQuery(self.iframeWindow.document).trigger(event);
+      }
+    }, 1);
   }
 };
 
@@ -738,10 +735,14 @@ Drupal.overlay.refreshRegions = function
  *   Path to match links against.
  */
 Drupal.overlay.resetActiveClass = function(activePath) {
+  if (!Drupal.displace) {
+    return;
+  }
+
   var self = this;
   var windowDomain = window.location.protocol + window.location.hostname;
 
-  $('.overlay-displace-top, .overlay-displace-bottom')
+  Drupal.displace.getDisplacedElements()
   .find('a[href]')
   // Remove active class from all links in displaced elements.
   .removeClass('active')
@@ -794,30 +795,6 @@ Drupal.overlay.getPath = function (link,
 };
 
 /**
- * Get the total displacement of given region.
- *
- * @param region
- *   Region name. Either "top" or "bottom".
- *
- * @return
- *   The total displacement of given region in pixels.
- */
-Drupal.overlay.getDisplacement = function (region) {
-  var displacement = 0;
-  var lastDisplaced = $('.overlay-displace-' + region + ':last');
-  if (lastDisplaced.length) {
-    displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight();
-
-    // Remove height added by IE Shadow filter.
-    if (lastDisplaced[0].filters && lastDisplaced[0].filters.length && lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow')) {
-      displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength;
-      displacement = Math.max(0, displacement);
-    }
-  }
-  return displacement;
-};
-
-/**
  * Makes elements outside the overlay unreachable via the tab key.
  *
  * @param context
@@ -857,7 +834,7 @@ Drupal.overlay.makeDocumentUntabbable = 
   // If another element (like a div) has a tabindex, it's also tabbable.
   $tabbable = $tabbable.add($hasTabindex);
   // Leave links inside the overlay and toolbars alone.
-  $overlay = $('.overlay-element, #overlay-container, .overlay-displace-top, .overlay-displace-bottom').find('*');
+  $overlay = $('.overlay-element, #overlay-container, .displace-top, .displace-bottom').find('*');
   $tabbable = $tabbable.not($overlay);
   // We now have a list of everything in the underlying document that could
   // possibly be reachable via the tab key. Make it all unreachable.
Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.33
diff -u -p -r1.33 overlay.module
--- modules/overlay/overlay.module	20 Nov 2010 04:03:51 -0000	1.33
+++ modules/overlay/overlay.module	26 Nov 2010 15:48:09 -0000
@@ -215,7 +215,10 @@ function overlay_library() {
     'website' => 'http://drupal.org/handbook/modules/overlay',
     'version' => '1.0',
     'js' => array(
-      $module_path . '/overlay-child.js' => array(),
+      // Always include displace.js as any displacement inside the parent window
+      // has to be taken into account.
+      'misc/displace.js' => array('weight' => JS_LIBRARY + 1),
+      $module_path . '/overlay-child.js' => array('weight' => JS_LIBRARY + 2),
     ),
     'css' => array(
       $module_path . '/overlay-child.css' => array(),
Index: modules/toolbar/toolbar.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.css,v
retrieving revision 1.26
diff -u -p -r1.26 toolbar.css
--- modules/toolbar/toolbar.css	11 Sep 2010 14:45:23 -0000	1.26
+++ modules/toolbar/toolbar.css	26 Nov 2010 15:48:59 -0000
@@ -1,13 +1,5 @@
 /* $Id: toolbar.css,v 1.26 2010/09/11 14:45:23 dries Exp $ */
 
-body.toolbar {
-  padding-top: 2.2em;
-}
-
-body.toolbar-drawer {
-  padding-top: 5.3em;
-}
-
 /**
  * Aggressive resets so we can achieve a consistent look in hostile CSS
  * environments.
@@ -35,19 +27,23 @@ body.toolbar-drawer {
   font: normal small "Lucida Grande", Verdana, sans-serif;
   background: #666;
   color: #ccc;
-  position: fixed;
-  top: 0;
-  left: 0;
-  right: 0;
+}
+.displace-processed #toolbar {
   margin: 0 -20px;
   padding: 0 20px;
-  z-index: 600;
   box-shadow: 0 3px 20px #000;
   -moz-box-shadow: 0 3px 20px #000;
   -webkit-box-shadow: 0 3px 20px #000;
   filter: progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10');
   -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10')";
 }
+.displace-unsupported #toolbar {
+  margin: 0;
+  padding-right: 0;
+  left: -20px;
+  right: 0;
+  width: 100%;
+}
 
 #toolbar div.collapsed {
   display: none;
Index: modules/toolbar/toolbar.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.js,v
retrieving revision 1.19
diff -u -p -r1.19 toolbar.js
--- modules/toolbar/toolbar.js	8 Jun 2010 05:16:29 -0000	1.19
+++ modules/toolbar/toolbar.js	26 Nov 2010 15:49:09 -0000
@@ -48,7 +48,6 @@ Drupal.toolbar.collapse = function() {
     .removeClass('toggle-active')
     .attr('title',  toggle_text)
     .html(toggle_text);
-  $('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
   $.cookie(
     'Drupal.toolbar.collapsed',
     1,
@@ -70,7 +69,6 @@ Drupal.toolbar.expand = function() {
     .addClass('toggle-active')
     .attr('title',  toggle_text)
     .html(toggle_text);
-  $('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
   $.cookie(
     'Drupal.toolbar.collapsed',
     0,
@@ -94,14 +92,4 @@ Drupal.toolbar.toggle = function() {
   }
 };
 
-Drupal.toolbar.height = function() {
-  var height = $('#toolbar').outerHeight();
-  // In IE, Shadow filter adds some extra height, so we need to remove it from
-  // the returned height.
-  if ($('#toolbar').css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) {
-    height -= $('#toolbar').get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength;
-  }
-  return height;
-};
-
 })(jQuery);
Index: modules/toolbar/toolbar.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.module,v
retrieving revision 1.46
diff -u -p -r1.46 toolbar.module
--- modules/toolbar/toolbar.module	5 Oct 2010 19:59:10 -0000	1.46
+++ modules/toolbar/toolbar.module	26 Nov 2010 15:50:03 -0000
@@ -155,9 +155,11 @@ function toolbar_preprocess_html(&$vars)
  *
  * Adding the 'overlay-displace-top' class to the toolbar pushes the overlay
  * down, so it appears below the toolbar.
+ *
+ * @see misc/displace.js
  */
 function toolbar_preprocess_toolbar(&$variables) {
-  $variables['classes_array'][] = "overlay-displace-top";
+  $variables['classes_array'][] = "displace-top";
 }
 
 /**
@@ -187,12 +189,9 @@ function toolbar_view() {
     '#theme' => 'toolbar',
     '#attached'=> array(
       'js' => array(
+        array('data' => 'misc/displace.js', 'group' => JS_LIBRARY, 'weight' => 1),
         $module_path . '/toolbar.js',
         array('data' => 'misc/jquery.cookie.js', 'group' => JS_LIBRARY, 'weight' => 2),
-        array(
-          'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
-          'type' => 'setting'
-        ),
       ),
       'css' => array(
         $module_path . '/toolbar.css',
