Returns the QRectF that represents the visible viewport rect for the
        current view.
        
        :return     <QRectF>
970617
def viewportRect(self):
        
        w = self.width()
        h = self.height()
        
        vbar = self.verticalScrollBar()
        hbar = self.horizontalScrollBar()
        
        if vbar.isVisible():
            w -= vbar.width()
        if hbar.isVisible():
            h -= hbar.height()
        
        top_l = self.mapToScene(QPoint(0, 0))
        bot_r = self.mapToScene(QPoint(w, h))
        
        return QRectF(top_l.x(), 
                      top_l.y(), 
                      bot_r.x() - top_l.x(), 
                      bot_r.y() - top_l.y())
165337
def cursor(self, pos):
        
        index = self.splitAt(pos)

        if len(self._rects[index[0]])-1 < index[1]:
            if index[1] == 0:
                # empty row
                x = 0
            else:
                rect = self._rects[index[0]][index[1]-1]
                x = rect.x() + rect.width()
        else:
            rect = self._rects[index[0]][index[1]]
            x = rect.x()

        y0 = index[0]*(ROW_HEIGHT + ROW_SPACE) + ROW_SPACE
        y1 = y0 + ROW_HEIGHT

        # adjust for scrolled viewport
        x -= self.horizontalScrollBar().value()
        y0 -= self.verticalScrollBar().value()
        y1 -= self.verticalScrollBar().value()
        
        return QtCore.QLine(x,y0,x,y1)
1211680
def rectified(self):
        
        return Rect(np.minimum(self.mins, self.maxes),
                    np.maximum(self.maxes, self.mins))
997466
def get_frame():
    """"""
    ret = QFrame()
    ret.setLineWidth(1)
    ret.setMidLineWidth(0)
    ret.setFrameShadow(QFrame.Sunken)
    ret.setFrameShape(QFrame.Box)
    return ret
203240
function(rect, outRect, useCached) {
            var view = this._viewportRect(useCached),
                scale = view._scale;

            outRect = outRect || {};
            outRect._x = rect._x * scale + Math.round(-view._x * scale);
            outRect._y = rect._y * scale + Math.round(-view._y * scale);
            outRect._w = rect._w * scale;
            outRect._h = rect._h * scale;

            return outRect;
        }
811539
SVG.Box  getCurrentViewPortInUserUnits()
   {
      if (state.viewBox != null)
         return state.viewBox;
      else
         return state.viewPort;
   }
763995
def get_client_rect(self):
        
        cr = win32.GetClientRect( self.get_handle() )
        cr.left, cr.top     = self.client_to_screen(cr.left, cr.top)
        cr.right, cr.bottom = self.client_to_screen(cr.right, cr.bottom)
        return cr
783430
def getBitmapFromRect(self, x, y, w, h):
        
        min_x, min_y, screen_width, screen_height = self._getVirtualScreenRect()
        img = self._getVirtualScreenBitmap() # TODO
        # Limit the coordinates to the virtual screen
        # Then offset so 0,0 is the top left corner of the image
        # (Top left of virtual screen could be negative)
        x1 = min(max(min_x, x), min_x+screen_width) - min_x
        y1 = min(max(min_y, y), min_y+screen_height) - min_y
        x2 = min(max(min_x, x+w), min_x+screen_width) - min_x
        y2 = min(max(min_y, y+h), min_y+screen_height) - min_y
        return numpy.array(img.crop((x1, y1, x2, y2)))
1328483
def viewbox(self):
        
        return self.left, self.top, self.right, self.bottom
663564
def _get_bcpOut(self):
        
        nextSegment = self._nextSegment
        offCurves = nextSegment.offCurve
        if offCurves:
            bcp = offCurves[0]
            x, y = relativeBCPOut(self.anchor, (bcp.x, bcp.y))
        else:
            x = y = 0
        return (x, y)
588247
function isInViewport(element) {
        var rect = element.getBoundingClientRect();
        var html = window.document.documentElement;
        return (
            rect.top >= 0 &&
            rect.left >= 0 &&
            rect.bottom <= (window.innerHeight || html.clientHeight) &&
            rect.right <= (window.innerWidth || html.clientWidth)
        );
    }
816257
def currentPixmapRect(self):
        
        pixmap = self.currentPixmap()
        rect   = self.rect()
        size   = pixmap.size()
        
        x = rect.center().x() - (size.width() / 2.0)
        y = rect.center().y() - (size.height() / 2.0)
        
        return QtCore.QRect(x, y, size.width(), size.height())
386284
def viewport(self) -> Tuple[int, int, int, int]:
        '''
            
        '''

        return self.wnd.viewport
569792
public Rectangle getAbsoluteContainingBlock()
    {
        if (cbox instanceof Viewport) //initial containing block
        {
            Rectangle ab = cbox.getAbsoluteBounds(); //normally positioned at 0,0; other value for nested viewports (e.g. objects)
            Rectangle visible = ((Viewport) cbox).getVisibleRect();
            return new Rectangle(ab.x, ab.y, visible.width, visible.height);
        }
        else //static or relative position
            return cbox.getAbsoluteContentBounds();
    }
427809
function(viewport) {
      var dt = viewport.currentDisplayTransform;
      var containerToTrack = viewport.containerToTrackMap;
      var viewX = dt.xWorldToView(this.xWorld_);

      var viewY = -1;
      for (var index in this.yComponents_) {
        var yComponent = this.yComponents_[index];
        var track = containerToTrack.getTrackByStableId(yComponent.stableId);
        if (track !== undefined) {
          var boundRect = track.getBoundingClientRect();
          viewY = yComponent.yPercentOffset * boundRect.height + boundRect.top;
          break;
        }
      }

      return {
        viewX: viewX,
        viewY: viewY
      };
    }
234913
def boundingRect( self ):
        
        rect = super(XNode, self).boundingRect()
        
        pad = self.highlightPadding()
        x = rect.x() - pad / 2.0
        y = rect.y() - pad / 2.0
        w = rect.width() + pad
        h = rect.height() + pad
        
        return QRectF( x, y, w, h )
842476
private RectF getDisplayRect(Matrix matrix) {
        ImageView imageView = getImageView();

        if (null != imageView) {
            Drawable d = imageView.getDrawable();
            if (null != d) {
                mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
                matrix.mapRect(mDisplayRect);
                return mDisplayRect;
            }
        }
        return null;
    }