IntPoint FrameView::clampOffsetAtScale(const IntPoint& offset, float scale) const { FloatSize scaledSize = unscaledVisibleContentSize(); if (scale) scaledSize.scale(1 / scale); IntPoint clampedOffset = offset; clampedOffset = clampedOffset.shrunkTo( IntPoint(size()) - expandedIntSize(scaledSize)); return clampedOffset; }
void ScrollView::setScrollPosition(const IntPoint& scrollPoint) { if (prohibitsScrolling()) return; if (platformWidget()) { platformSetScrollPosition(scrollPoint); return; } IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); newScrollPosition.clampNegativeToZero(); if (newScrollPosition == scrollPosition()) return; updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y())); }
IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale) { if (!mainFrame() || !mainFrame()->view()) return IntPoint(); FrameView* view = mainFrame()->view(); FloatSize scaledSize(m_size); scaledSize.scale(1 / scale); IntPoint visualViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scaledSize); IntPoint max = view->maximumScrollPosition() + visualViewportMax; IntPoint min = view->minimumScrollPosition(); // VisualViewportMin should be (0, 0) IntPoint clamped = offset; clamped = clamped.shrunkTo(max); clamped = clamped.expandedTo(min); return clamped; }
IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) const { return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumScrollPosition()); }
void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scrollPosition = offset.shrunkTo(m_maximumScrollPosition); }
IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint) const { IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); return newScrollPosition; }