本文整理汇总了C++中FrameView::adjustScrollPositionWithinRange方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameView::adjustScrollPositionWithinRange方法的具体用法?C++ FrameView::adjustScrollPositionWithinRange怎么用?C++ FrameView::adjustScrollPositionWithinRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameView
的用法示例。
在下文中一共展示了FrameView::adjustScrollPositionWithinRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restoreScrollPositionAndViewState
/*
There is a race condition between the layout and load completion that affects restoring the scroll position.
We try to restore the scroll position at both the first layout and upon load completion.
1) If first layout happens before the load completes, we want to restore the scroll position then so that the
first time we draw the page is already scrolled to the right place, instead of starting at the top and later
jumping down. It is possible that the old scroll position is past the part of the doc laid out so far, in
which case the restore silent fails and we will fix it in when we try to restore on doc completion.
2) If the layout happens after the load completes, the attempt to restore at load completion time silently
fails. We then successfully restore it when the layout happens.
*/
void HistoryController::restoreScrollPositionAndViewState()
{
if (!m_frame.loader().stateMachine().committedFirstRealDocumentLoad())
return;
ASSERT(m_currentItem);
// FIXME: As the ASSERT attests, it seems we should always have a currentItem here.
// One counterexample is <rdar://problem/4917290>
// For now, to cover this issue in release builds, there is no technical harm to returning
// early and from a user standpoint - as in the above radar - the previous page load failed
// so there *is* no scroll or view state to restore!
if (!m_currentItem)
return;
FrameView* view = m_frame.view();
// FIXME: There is some scrolling related work that needs to happen whenever a page goes into the
// page cache and similar work that needs to occur when it comes out. This is where we do the work
// that needs to happen when we exit, and the work that needs to happen when we enter is in
// Document::setIsInPageCache(bool). It would be nice if there was more symmetry in these spots.
// https://bugs.webkit.org/show_bug.cgi?id=98698
if (view) {
Page* page = m_frame.page();
if (page && m_frame.isMainFrame()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewRootLayerDidChange(*view);
}
}
// FIXME: It would be great to work out a way to put this code in WebCore instead of calling
// through to the client.
m_frame.loader().client().restoreViewState();
#if !PLATFORM(IOS) && !PLATFORM(EFL)
// Don't restore scroll point on iOS as FrameLoaderClient::restoreViewState() does that.
if (view && !view->wasScrolledByUser()) {
Page* page = m_frame.page();
auto desiredScrollPosition = m_currentItem->scrollPosition();
if (page && m_frame.isMainFrame() && m_currentItem->pageScaleFactor())
page->setPageScaleFactor(m_currentItem->pageScaleFactor() * page->viewScaleFactor(), desiredScrollPosition);
else
view->setScrollPosition(desiredScrollPosition);
// If the scroll position doesn't have to be clamped, consider it successfully restored.
if (m_frame.isMainFrame()) {
auto adjustedDesiredScrollPosition = view->adjustScrollPositionWithinRange(desiredScrollPosition);
if (desiredScrollPosition == adjustedDesiredScrollPosition)
m_frame.loader().client().didRestoreScrollPosition();
}
}
#endif
}
示例2: computeOrigins
void ViewportAnchor::computeOrigins(const FrameView& frameView, const FloatSize& innerSize,
IntPoint& mainFrameOffset, FloatPoint& pinchViewportOffset) const
{
IntSize outerSize = frameView.visibleContentRect().size();
// Compute the viewport origins in CSS pixels relative to the document.
FloatSize absPinchViewportOffset = m_normalizedPinchViewportOffset;
absPinchViewportOffset.scale(outerSize.width(), outerSize.height());
FloatPoint innerOrigin = getInnerOrigin(innerSize);
FloatPoint outerOrigin = innerOrigin - absPinchViewportOffset;
IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize);
FloatRect innerRect = FloatRect(innerOrigin, innerSize);
moveToEncloseRect(outerRect, innerRect);
outerRect.setLocation(frameView.adjustScrollPositionWithinRange(outerRect.location()));
moveIntoRect(innerRect, outerRect);
mainFrameOffset = outerRect.location();
pinchViewportOffset = FloatPoint(innerRect.location() - outerRect.location());
}