summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/loader/frame_loader.cc
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2020-02-10 15:52:16 +0100
committerTamas Zakor <ztamas@inf.u-szeged.hu>2020-02-11 13:13:34 +0000
commit7c8b94f2916779c7e0eebd1c2dc6b8c713acb3a2 (patch)
tree39b13ee0323a52a2cf4c306a90dea7bf78a45d00 /chromium/third_party/blink/renderer/core/loader/frame_loader.cc
parent1d119e1884d6ee26f1122136867c75fb50091d4f (diff)
downloadqtwebengine-chromium-7c8b94f2916779c7e0eebd1c2dc6b8c713acb3a2.tar.gz
[Backport] Re-land: Only invoke text and element fragment anchors after layout.
This reverts commit f3d96d04734f1e2d1384d558b72f9e8fcfca265b. The original commit was reverted because it caused flakiness in some browser tests (in particular, HostZoomMapBrowserTest.PageScaleIsOneChanged) The flakiness was caused by a real bug in the CL, which is fixed in the latest patchset. The bug was that the base::Optional pending_view_state_ was not being rest after being applied. See https://chromium-review.googlesource.com/c/chromium/src/+/1981806/1..3 for what has changed from the original CL. Bug: 1018632 Fixes: QTBUG-79369 Change-Id: I86fcdb403678a5890a2e9d1abcab3ea1d5a639d9 Reviewed-by: Philip Rogers <pdr@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/master@{#727481} Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/loader/frame_loader.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/loader/frame_loader.cc78
1 files changed, 4 insertions, 74 deletions
diff --git a/chromium/third_party/blink/renderer/core/loader/frame_loader.cc b/chromium/third_party/blink/renderer/core/loader/frame_loader.cc
index e60598f9c8c..da3caa9fa14 100644
--- a/chromium/third_party/blink/renderer/core/loader/frame_loader.cc
+++ b/chromium/third_party/blink/renderer/core/loader/frame_loader.cc
@@ -134,7 +134,7 @@ bool IsReloadLoadType(WebFrameLoadType type) {
type == WebFrameLoadType::kReloadBypassingCache;
}
-static bool NeedsHistoryItemRestore(WebFrameLoadType type) {
+bool FrameLoader::NeedsHistoryItemRestore(WebFrameLoadType type) {
return type == WebFrameLoadType::kBackForward || IsReloadLoadType(type);
}
@@ -1153,79 +1153,9 @@ void FrameLoader::RestoreScrollPositionAndViewState(
if (!NeedsHistoryItemRestore(load_type))
return;
- bool should_restore_scroll =
- scroll_restoration_type != kScrollRestorationManual;
- bool should_restore_scale = view_state.page_scale_factor_;
-
- // This tries to balance:
- // 1. restoring as soon as possible.
- // 2. not overriding user scroll (TODO(majidvp): also respect user scale).
- // 3. detecting clamping to avoid repeatedly popping the scroll position down
- // as the page height increases.
- // 4. forcing a layout if necessary to avoid clamping.
- // 5. ignoring clamp detection if scroll state is not being restored, if load
- // is complete, or if the navigation is same-document (as the new page may
- // be smaller than the previous page).
- bool can_restore_without_clamping =
- view->LayoutViewport()->ClampScrollOffset(view_state.scroll_offset_) ==
- view_state.scroll_offset_;
-
- bool should_force_clamping = !frame_->IsLoading() || is_same_document;
- // Here |can_restore_without_clamping| is false, but layout might be necessary
- // to ensure correct content size.
- if (!can_restore_without_clamping && should_force_clamping)
- frame_->GetDocument()->UpdateStyleAndLayout();
-
- bool can_restore_without_annoying_user =
- !GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user &&
- (can_restore_without_clamping || should_force_clamping ||
- !should_restore_scroll);
- if (!can_restore_without_annoying_user)
- return;
-
- if (should_restore_scroll) {
- // TODO(pnoland): attempt to restore the anchor in more places than this.
- // Anchor-based restore should allow for earlier restoration.
- bool did_restore = view->LayoutViewport()->RestoreScrollAnchor(
- {view_state.scroll_anchor_data_.selector_,
- LayoutPoint(view_state.scroll_anchor_data_.offset_.x,
- view_state.scroll_anchor_data_.offset_.y),
- view_state.scroll_anchor_data_.simhash_});
- if (!did_restore) {
- view->LayoutViewport()->SetScrollOffset(view_state.scroll_offset_,
- kProgrammaticScroll);
- }
- }
-
- // For main frame restore scale and visual viewport position
- if (frame_->IsMainFrame()) {
- ScrollOffset visual_viewport_offset(
- view_state.visual_viewport_scroll_offset_);
-
- // If the visual viewport's offset is (-1, -1) it means the history item
- // is an old version of HistoryItem so distribute the scroll between
- // the main frame and the visual viewport as best as we can.
- if (visual_viewport_offset.Width() == -1 &&
- visual_viewport_offset.Height() == -1) {
- visual_viewport_offset =
- view_state.scroll_offset_ - view->LayoutViewport()->GetScrollOffset();
- }
-
- VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport();
- if (should_restore_scale && should_restore_scroll) {
- visual_viewport.SetScaleAndLocation(
- view_state.page_scale_factor_, visual_viewport.IsPinchGestureActive(),
- FloatPoint(visual_viewport_offset));
- } else if (should_restore_scale) {
- visual_viewport.SetScale(view_state.page_scale_factor_);
- } else if (should_restore_scroll) {
- visual_viewport.SetLocation(FloatPoint(visual_viewport_offset));
- }
-
- if (ScrollingCoordinator* scrolling_coordinator =
- frame_->GetPage()->GetScrollingCoordinator())
- scrolling_coordinator->FrameViewRootLayerDidChange(view);
- }
+ view->GetScrollableArea()->SetPendingHistoryRestoreScrollOffset(
+ view_state, scroll_restoration_type != kScrollRestorationManual);
+ view->ScheduleAnimation();
GetDocumentLoader()->GetInitialScrollState().did_restore_from_history = true;
}