Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp

Issue 1831993002: Handle position:absolute candidates correctly in ScrollAnchor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ScrollAnchor.h" 5 #include "core/layout/ScrollAnchor.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/line/InlineTextBox.h" 9 #include "core/layout/line/InlineTextBox.h"
10 #include "core/paint/PaintLayerScrollableArea.h" 10 #include "core/paint/PaintLayerScrollableArea.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (scroller->isFrameView()) 79 if (scroller->isFrameView())
80 relativeBounds.moveBy(-LayoutPoint(scroller->scrollPositionDouble())); 80 relativeBounds.moveBy(-LayoutPoint(scroller->scrollPositionDouble()));
81 return relativeBounds; 81 return relativeBounds;
82 } 82 }
83 83
84 static LayoutPoint computeRelativeOffset(const LayoutObject* layoutObject, const ScrollableArea* scroller, Corner corner) 84 static LayoutPoint computeRelativeOffset(const LayoutObject* layoutObject, const ScrollableArea* scroller, Corner corner)
85 { 85 {
86 return cornerPointOfRect(relativeBounds(layoutObject, scroller), corner); 86 return cornerPointOfRect(relativeBounds(layoutObject, scroller), corner);
87 } 87 }
88 88
89 static bool candidateMovesWithScroller(const LayoutObject* candidate, const Scro llableArea* scroller)
90 {
91 if (candidate->style() && candidate->style()->hasViewportConstrainedPosition ())
92 return false;
93
94 bool skippedByContainerLookup = false;
95 candidate->container(scrollerLayoutBox(scroller), &skippedByContainerLookup) ;
96 return !skippedByContainerLookup;
ymalik 2016/03/25 18:53:19 Sorry, could you briefly explain why if !skippedBy
skobes 2016/03/25 19:36:35 This is looking for cases where the candidate's "c
97 }
98
89 ScrollAnchor::ExamineResult ScrollAnchor::examine(const LayoutObject* candidate) const 99 ScrollAnchor::ExamineResult ScrollAnchor::examine(const LayoutObject* candidate) const
90 { 100 {
91 if (candidate->isLayoutInline()) 101 if (candidate->isLayoutInline())
92 return ExamineResult(Continue); 102 return ExamineResult(Continue);
93 103
94 if (!candidate->isText() && !candidate->isBox()) 104 if (!candidate->isText() && !candidate->isBox())
95 return ExamineResult(Skip); 105 return ExamineResult(Skip);
96 106
97 if (candidate->style() && candidate->style()->hasViewportConstrainedPosition ()) 107 if (!candidateMovesWithScroller(candidate, m_scroller))
98 return ExamineResult(Skip); 108 return ExamineResult(Skip);
99 109
100 LayoutRect candidateRect = relativeBounds(candidate, m_scroller); 110 LayoutRect candidateRect = relativeBounds(candidate, m_scroller);
101 LayoutRect visibleRect = scrollerLayoutBox(m_scroller)->overflowClipRect(Lay outPoint()); 111 LayoutRect visibleRect = scrollerLayoutBox(m_scroller)->overflowClipRect(Lay outPoint());
102 112
103 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0 ; 113 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0 ;
104 if (occupiesSpace && visibleRect.intersects(candidateRect)) { 114 if (occupiesSpace && visibleRect.intersects(candidateRect)) {
105 return ExamineResult( 115 return ExamineResult(
106 visibleRect.contains(candidateRect) ? Return : Constrain, 116 visibleRect.contains(candidateRect) ? Return : Constrain,
107 cornerFromCandidateRect(candidateRect, visibleRect)); 117 cornerFromCandidateRect(candidateRect, visibleRect));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void ScrollAnchor::clear() 179 void ScrollAnchor::clear()
170 { 180 {
171 LayoutObject* anchorObject = m_anchorObject; 181 LayoutObject* anchorObject = m_anchorObject;
172 m_anchorObject = nullptr; 182 m_anchorObject = nullptr;
173 183
174 if (anchorObject) 184 if (anchorObject)
175 anchorObject->maybeClearIsScrollAnchorObject(); 185 anchorObject->maybeClearIsScrollAnchorObject();
176 } 186 }
177 187
178 } // namespace blink 188 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698