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

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

Issue 2246803002: Exclude elements with overflow-anchor:none from anchor node selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 4 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/frame/UseCounter.h" 8 #include "core/frame/UseCounter.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // developers to reason about the anchor node. 143 // developers to reason about the anchor node.
144 if (candidate->isAnonymous()) 144 if (candidate->isAnonymous())
145 return ExamineResult(Continue); 145 return ExamineResult(Continue);
146 146
147 if (!candidate->isText() && !candidate->isBox()) 147 if (!candidate->isText() && !candidate->isBox())
148 return ExamineResult(Skip); 148 return ExamineResult(Skip);
149 149
150 if (!candidateMayMoveWithScroller(candidate, m_scroller)) 150 if (!candidateMayMoveWithScroller(candidate, m_scroller))
151 return ExamineResult(Skip); 151 return ExamineResult(Skip);
152 152
153 if (candidate->style()->overflowAnchor() == AnchorNone)
154 return ExamineResult(Skip);
155
153 LayoutRect candidateRect = relativeBounds(candidate, m_scroller); 156 LayoutRect candidateRect = relativeBounds(candidate, m_scroller);
154 LayoutRect visibleRect = scrollerLayoutBoxItem(m_scroller).overflowClipRect( LayoutPoint()); 157 LayoutRect visibleRect = scrollerLayoutBoxItem(m_scroller).overflowClipRect( LayoutPoint());
155 158
156 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0 ; 159 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0 ;
157 if (occupiesSpace && visibleRect.intersects(candidateRect)) { 160 if (occupiesSpace && visibleRect.intersects(candidateRect)) {
158 return ExamineResult( 161 return ExamineResult(
159 visibleRect.contains(candidateRect) ? Return : Constrain, 162 visibleRect.contains(candidateRect) ? Return : Constrain,
160 cornerFromCandidateRect(candidate)); 163 cornerFromCandidateRect(candidate));
161 } else { 164 } else {
162 return ExamineResult(Skip); 165 return ExamineResult(Skip);
(...skipping 29 matching lines...) Expand all
192 } 195 }
193 } 196 }
194 197
195 void ScrollAnchor::save() 198 void ScrollAnchor::save()
196 { 199 {
197 DCHECK(m_scroller); 200 DCHECK(m_scroller);
198 if (m_scroller->scrollPosition() == IntPoint::zero()) { 201 if (m_scroller->scrollPosition() == IntPoint::zero()) {
199 clear(); 202 clear();
200 return; 203 return;
201 } 204 }
205
206 // TODO(ymalik): Just because we have a previously selected anchor doesn't
207 // mean that it's guaranteed to be valid. For e.g. overflow-anchor: none
208 // may have been added after anchor selection. The SANACLAP design poposal
209 // may fix this (see crbug.com/637626).
202 if (m_current) 210 if (m_current)
203 return; 211 return;
204 212
205 findAnchor(); 213 findAnchor();
206 if (!m_current) 214 if (!m_current)
207 return; 215 return;
208 216
209 m_current.m_anchorObject->setIsScrollAnchorObject(); 217 m_current.m_anchorObject->setIsScrollAnchorObject();
210 m_current.m_savedRelativeOffset = computeRelativeOffset( 218 m_current.m_savedRelativeOffset = computeRelativeOffset(
211 m_current.m_anchorObject, m_scroller, m_current.m_corner); 219 m_current.m_anchorObject, m_scroller, m_current.m_corner);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 318
311 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) 319 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject)
312 { 320 {
313 if (m_current.m_anchorObject == layoutObject) 321 if (m_current.m_anchorObject == layoutObject)
314 m_current.clear(); 322 m_current.clear();
315 if (m_lastAdjusted.m_anchorObject == layoutObject) 323 if (m_lastAdjusted.m_anchorObject == layoutObject)
316 m_lastAdjusted.clear(); 324 m_lastAdjusted.clear();
317 } 325 }
318 326
319 } // namespace blink 327 } // 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