Skip to content

Commit c092f72

Browse files
author
Anders Carlsson
committed
Search result page scrolls up before the correct page opens from google search
https://bugs.webkit.org/show_bug.cgi?id=81280 <rdar://problem/10973263> Reviewed by Sam Weinig. Make the requested scroll position part of the ScrollingTreeState so any changes being made are in sync with other important changes such as the scroll layer or contents size. * page/scrolling/ScrollingCoordinator.cpp: (WebCore::ScrollingCoordinator::frameViewRootLayerDidChange): Use coordinatesScrollingForFrameView instead of checking if the frame is the main frame. (WebCore::ScrollingCoordinator::requestScrollPositionUpdate): Call ScrollingTreeState::setRequestedScrollPosition. (WebCore::ScrollingCoordinator::setScrollLayer): Reset the requested scroll position. * page/scrolling/ScrollingTreeState.cpp: (WebCore::ScrollingTreeState::setRequestedScrollPosition): Keep track of the scroll position. * page/scrolling/mac/ScrollingTreeNodeMac.mm: (WebCore::ScrollingTreeNodeMac::update): Update the scroll position if it's changed. Canonical link: https://commits.webkit.org/100444@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@113096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9a9a86e commit c092f72

5 files changed

Lines changed: 53 additions & 2 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
2012-03-15 Anders Carlsson <andersca@apple.com>
2+
3+
Search result page scrolls up before the correct page opens from google search
4+
https://bugs.webkit.org/show_bug.cgi?id=81280
5+
<rdar://problem/10973263>
6+
7+
Reviewed by Sam Weinig.
8+
9+
Make the requested scroll position part of the ScrollingTreeState so any changes being made
10+
are in sync with other important changes such as the scroll layer or contents size.
11+
12+
* page/scrolling/ScrollingCoordinator.cpp:
13+
(WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
14+
Use coordinatesScrollingForFrameView instead of checking if the frame is the main frame.
15+
16+
(WebCore::ScrollingCoordinator::requestScrollPositionUpdate):
17+
Call ScrollingTreeState::setRequestedScrollPosition.
18+
19+
(WebCore::ScrollingCoordinator::setScrollLayer):
20+
Reset the requested scroll position.
21+
22+
* page/scrolling/ScrollingTreeState.cpp:
23+
(WebCore::ScrollingTreeState::setRequestedScrollPosition):
24+
Keep track of the scroll position.
25+
26+
* page/scrolling/mac/ScrollingTreeNodeMac.mm:
27+
(WebCore::ScrollingTreeNodeMac::update):
28+
Update the scroll position if it's changed.
29+
130
2012-04-03 W. James MacLean <wjmaclean@chromium.org>
231

332
[chromium] Switch touchpad fling curve physics to absolute (not scaled) curve.

Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
216216
ASSERT(isMainThread());
217217
ASSERT(m_page);
218218

219-
if (frameView->frame() != m_page->mainFrame())
219+
if (!coordinatesScrollingForFrameView(frameView))
220220
return;
221221

222222
frameViewLayoutUpdated(frameView);
@@ -238,7 +238,14 @@ bool ScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView, con
238238
// since FrameView expects scroll position updates to happen synchronously.
239239
updateMainFrameScrollPosition(scrollPosition);
240240

241-
ScrollingThread::dispatch(bind(&ScrollingTree::setMainFrameScrollPosition, m_scrollingTree.get(), scrollPosition));
241+
if (frameView->frame()->document()->inPageCache()) {
242+
// If this frame view's document is being put into the page cache, we don't want to update our
243+
// main frame scroll position.
244+
return true;
245+
}
246+
247+
m_scrollingTreeState->setRequestedScrollPosition(scrollPosition);
248+
scheduleTreeStateCommit();
242249
return true;
243250
#else
244251
UNUSED_PARAM(scrollPosition);

Source/WebCore/page/scrolling/ScrollingTreeState.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ void ScrollingTreeState::setHasEnabledVerticalScrollbar(bool hasEnabledVerticalS
131131
m_changedProperties |= HasEnabledVerticalScrollbar;
132132
}
133133

134+
void ScrollingTreeState::setRequestedScrollPosition(const IntPoint& requestedScrollPosition)
135+
{
136+
m_requestedScrollPosition = requestedScrollPosition;
137+
m_changedProperties |= RequestedScrollPosition;
138+
}
139+
134140
PassOwnPtr<ScrollingTreeState> ScrollingTreeState::commit()
135141
{
136142
OwnPtr<ScrollingTreeState> treeState = adoptPtr(new ScrollingTreeState(*this));

Source/WebCore/page/scrolling/ScrollingTreeState.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ScrollingTreeState {
6060
HasEnabledHorizontalScrollbar = 1 << 7,
6161
HasEnabledVerticalScrollbar = 1 << 8,
6262
ScrollLayer = 1 << 9,
63+
RequestedScrollPosition = 1 << 10,
6364
};
6465

6566
bool hasChangedProperties() const { return m_changedProperties; }
@@ -95,6 +96,9 @@ class ScrollingTreeState {
9596
PlatformLayer* platformScrollLayer() const;
9697
void setScrollLayer(const GraphicsLayer*);
9798

99+
const IntPoint& requestedScrollPosition() const { return m_requestedScrollPosition; }
100+
void setRequestedScrollPosition(const IntPoint&);
101+
98102
// Copies the current tree state and clears the changed properties mask in the original.
99103
PassOwnPtr<ScrollingTreeState> commit();
100104

@@ -118,6 +122,8 @@ class ScrollingTreeState {
118122
bool m_hasEnabledHorizontalScrollbar;
119123
bool m_hasEnabledVerticalScrollbar;
120124

125+
IntPoint m_requestedScrollPosition;
126+
121127
#if PLATFORM(MAC)
122128
RetainPtr<PlatformLayer> m_platformScrollLayer;
123129
#endif

Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
if (state->changedProperties() & ScrollingTreeState::ScrollLayer)
5959
m_scrollLayer = state->platformScrollLayer();
6060

61+
if (state->changedProperties() & ScrollingTreeState::RequestedScrollPosition)
62+
setScrollPosition(state->requestedScrollPosition());
63+
6164
if (state->changedProperties() & (ScrollingTreeState::ScrollLayer | ScrollingTreeState::ContentsSize | ScrollingTreeState::ViewportRect))
6265
updateMainFramePinState(scrollPosition());
6366

0 commit comments

Comments
 (0)