Figure out the element position relative to the specified window.
764848
function screenPos( element, refWin ) {
				var pos = { x: 0, y: 0 };

				if ( !( element.is( isQuirks ? 'body' : 'html' ) ) ) {
					var box = element.$.getBoundingClientRect();
					pos.x = box.left, pos.y = box.top;
				}

				var win = element.getWindow();
				if ( !win.equals( refWin ) ) {
					var outerPos = screenPos( CKEDITOR.dom.element.get( win.$.frameElement ), refWin );
					pos.x += outerPos.x, pos.y += outerPos.y;
				}

				return pos;
			}
805999
function getWindowScrollPosition() {
  invariant(canUseDOM, 'Cannot get current scroll position without a DOM');

  return {
    x: window.pageXOffset || document.documentElement.scrollLeft,
    y: window.pageYOffset || document.documentElement.scrollTop
  };
}
889711
function getElementBoundingRect(elementSelector) {
    /**
     * @param {Window} win
     * @param {Object} [dims]
     * @returns {Object}
     */
    function computeFrameOffset(win, dims) {
        // initialize our result variable
        dims = dims || {
            left: win.pageXOffset,
            top: win.pageYOffset
        };

        // add the offset & recurse up the frame chain
        var frame = win.frameElement;
        if (frame) {
            var rect = frame.getBoundingClientRect();
            dims.left += rect.left + frame.contentWindow.pageXOffset;
            dims.top += rect.top + frame.contentWindow.pageYOffset;

            if (win !== window.top) {
                computeFrameOffset(win.parent, dims);
            }
        }

        return dims;
    }

    /**
     * @param {HTMLElement} element
     * @param {Object} frameOffset
     * @returns {Object}
     */
    function computeElementRect(element, frameOffset) {
        var rect = element.getBoundingClientRect();

        return {
            left: rect.left + frameOffset.left,
            right: rect.right + frameOffset.left,
            top: rect.top + frameOffset.top,
            bottom: rect.bottom + frameOffset.top,
            width: rect.width,
            height: rect.height
        };
    }

    var element = document.querySelectorAll(elementSelector)[0];
    if (element) {
        var frameOffset = computeFrameOffset(window);
        var elementRect = computeElementRect(element, frameOffset);

        return elementRect;
    }
}
548403
def get_position(self, dt):
        """"""
        return self.sx + self.dx * dt, self.sy + self.dy * dt
73835
function(offset){
            if(arguments.length > 0){
                this.each(function(inx,ele){
                    var node = vQ(ele);
                    var coords = node.offset(),
                        parentOffset = ele.offsetParent.offset(),
                        props = {
                            top: coords.top - parentOffset.top,
                            left: coords.left - parentOffset.left
                        };
                    if (node.css('position') == 'static'){
                        props['position'] = 'relative';
                    }
                    node.css(props);
                });
            }
            if (!this.length) return null;
            if (!vQ.contains(document.documentElement, this[0]))
                return {top: 0, left: 0};
            var obj = this[0].getBoundingClientRect();
            return {
                left: obj.left + window.pageXOffset,
                top: obj.top + window.pageYOffset,
                width: Math.round(obj.width),
                height: Math.round(obj.height)
            };
        }
1010479
def get_mouse_pos(self, window_pos=None):
    """"""
    window_pos = window_pos or pygame.mouse.get_pos()
    # +0.5 to center the point on the middle of the pixel.
    window_pt = point.Point(*window_pos) + 0.5
    for surf in reversed(self._surfaces):
      if (surf.surf_type != SurfType.CHROME and
          surf.surf_rect.contains_point(window_pt)):
        surf_rel_pt = window_pt - surf.surf_rect.tl
        world_pt = surf.world_to_surf.back_pt(surf_rel_pt)
        return MousePos(world_pt, surf)
218248
function position() {
    
    // Bullets & friends are positioned an absolute distance to the left of
    // the content edge of their parent element
    $cb = $this->_frame->get_containing_block();
    
    // Note: this differs from most frames in that we must position
    // ourselves after determining our width
    $x = $cb["x"] - $this->_frame->get_width();

    $p = $this->_frame->find_block_parent();

    $y = $p->get_current_line_box()->y;

    // This is a bit of a hack...
    $n = $this->_frame->get_next_sibling();
    if ( $n ) {
      $style = $n->get_style();
      $line_height = $style->length_in_pt($style->line_height, $style->get_font_size());
      $offset = $style->length_in_pt($line_height, $n->get_containing_block("h")) - $this->_frame->get_height();             
      $y += $offset / 2;
    }

  // Now the position is the left top of the block which should be marked with the bullet.
  // We tried to find out the y of the start of the first text character within the block.
  // But the top margin/padding does not fit, neither from this nor from the next sibling
  // The "bit of a hack" above does not work also.
  
  // Instead let's position the bullet vertically centered to the block which should be marked.
  // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
  // the get_containing_block is paper width and the entire list as height.
  
    // if ($p) {
    //   //$cb = $n->get_containing_block();
    //   $cb = $p->get_containing_block();
    //   $y += $cb["h"]/2;
    // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':';
    // }   

  // Todo:
  // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing

    /*$style = $p->get_style();
    $font_size = $style->get_font_size();
    $line_height = $style->length_in_pt($style->line_height, $font_size);
    $y += ($line_height - $font_size) / 2;    */
   
    //Position is x-end y-top of character position of the bullet.    
    $this->_frame->set_position($x, $y);
    
  }
245017
function getElementPosition(element) {
  const rect = getElementRect(element);
  return {
    x: rect.left,
    y: rect.top,
    width: rect.right - rect.left,
    height: rect.bottom - rect.top
  };
}
1011391
function (element) {
            var position = ariaUtilsDom.getOffset(element);
            position.width = element.offsetWidth;
            position.height = element.offsetHeight;
            var style = element.style;
            this._elementInitialPosition = position;
            style.position = "absolute";
            style.left = position.left + "px";
            style.top = position.top + "px";
            style.height = position.height + "px";
            style.width = position.width + "px";
        }
540200
private static VerticalDropLocation internalGetVerticalDropLocation(Element element,
        int offsetHeight, int clientY, double topBottomRatio) {

        // Event coordinates are relative to the viewport, element absolute
        // position is relative to the document. Make element position relative
        // to viewport by adjusting for viewport scrolling. See #6021
        int elementTop = element.getAbsoluteTop() - Window.getScrollTop();
        int fromTop = clientY - elementTop;

        float percentageFromTop = (fromTop / (float) offsetHeight);
        if (percentageFromTop < topBottomRatio) {
            return VerticalDropLocation.TOP;
        } else if (percentageFromTop > 1 - topBottomRatio) {
            return VerticalDropLocation.BOTTOM;
        } else {
            return VerticalDropLocation.MIDDLE;
        }
    }
1037120
function calculateOffset(element) {
      var style = window.getComputedStyle(element);
      var getCssProperty = function(prop) {
        return parseInt(style.getPropertyValue(prop).replace('px', '')) || 0;
      };
      return {
        left: element.getBoundingClientRect().left + getCssProperty('padding-left'),
        top: element.getBoundingClientRect().top + getCssProperty('padding-top')
      };
    }
500231
private Box locateBox(Box root, int x, int y)
    {
        if (root.isVisible())
        {
            Box found = null;
            //Rectangle bounds = root.getAbsoluteContentBounds().intersection(root.getClipBlock().getAbsoluteContentBounds());
            Rectangle bounds = root.getAbsoluteBounds();
            if (bounds.contains(x, y))
            {
                found = root;
                System.out.println("Fnd: " + found);
                found.drawExtent(((BrowserCanvas)cssbox).getImageGraphics());
            }
            
            //find if there is something smallest that fits among the child boxes
            if (root instanceof ElementBox)
            {
                ElementBox eb = (ElementBox) root;
                for (int i = eb.getStartChild(); i < eb.getEndChild(); i++)
                {
                    Box inside = locateBox(((ElementBox) root).getSubBox(i), x, y);
                    if (inside != null)
                    {
                        if (found == null)
                            found = inside;
                        else
                        {
                            if (inside.getAbsoluteBounds().width * inside.getAbsoluteBounds().height < found.getAbsoluteBounds().width * found.getAbsoluteBounds().height)
                                found = inside;
                        }
                    }
                }
            }
            return found;
        }
        else
            return null;
    }
581935
function fixPosition ( $elem, cssOffset ) {
            var visualTop = window.visualViewport ? window.visualViewport.pageTop : Math.max( dde.scrollTop, body.scrollTop ),
                visualLeft = window.visualViewport ? window.visualViewport.pageLeft : Math.max( dde.scrollLeft, body.scrollLeft );

            $elem.css( {
                top: visualTop + cssOffset.top,
                left: visualLeft + cssOffset.left
            } );
        }
496155
public static void track(Window window) {
        Preferences prefs = node().node("Windows");

        String bounds = prefs.get(window.getName() + ".bounds", null);
        if (bounds != null) {
            Rectangle rect = (Rectangle) ConverterRegistry.instance().convert(
                    Rectangle.class, bounds);
            window.setBounds(rect);
        }

        window.addComponentListener(WINDOW_DIMENSIONS);
    }
1284325
function fixElementPosition() {
        var style = util.getComputedStyle(element);

        // if the element is not positioned, add position relative so the
        // iframe can be positioned properly
        if (style && style.position === 'static') {
            $(element).css({ position: 'relative' });
        }
    }
282767
def element_screen_center(self, element):
        
        pos = self.element_screen_position(element)
        size = element.size
        pos["top"] += int(size["height"] / 2)
        pos["left"] += int(size["width"] / 2)
        return pos
1271640
function() {
			var cal = calculator, self = this, element = self[0], elementOffset = self.offset();

			// IE has easy way to get caret offset position
			if ($.browser.msie) {
				// must get focus first
				element.focus();
			    var range = document.selection.createRange();  
			    $('#hskeywords').val(element.scrollTop);
			    return {  
			        left: range.boundingLeft - elementOffset.left,
			        top: parseInt(range.boundingTop) - elementOffset.top + element.scrollTop 
						+ document.documentElement.scrollTop + parseInt(self.getComputedStyle("fontSize")) 
			    };  
			}  
			cal.simulator.empty();
			// clone primary styles to imitate textarea
			$.each(cal.primaryStyles, function(index, styleName) {
				self.cloneStyle(cal.simulator, styleName);
			});

			// caculate width and height
			cal.simulator.css($.extend({
				'width': self.width(),
				'height': self.height()
			}, cal.specificStyle));

			var value = self.val(), cursorPosition = self.getCursorPosition();
			var beforeText = value.substring(0, cursorPosition),
				afterText = value.substring(cursorPosition);

			var before = $('<span class="before"/>').html(cal.toHtml(beforeText)),
				focus = $('<span class="focus"/>'),
				after = $('<span class="after"/>').html(cal.toHtml(afterText));

			cal.simulator.append(before).append(focus).append(after);
			var focusOffset = focus.offset(), simulatorOffset = cal.simulator.offset();
			// alert(focusOffset.left  + ',' +  simulatorOffset.left + ',' + element.scrollLeft);
			return { 
				top: focusOffset.top - simulatorOffset.top - element.scrollTop 
					// calculate and add the font height except Firefox
					+ ($.browser.mozilla ? 0 : parseInt(self.getComputedStyle("fontSize"))), 
				left: focus[0].offsetLeft -  cal.simulator[0].offsetLeft - element.scrollLeft
			};
		}