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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp

Issue 1365853003: LayoutBox::scrollRectToVisible doesn't respect overflow:hidden property. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Worked on review comments Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (scrollBehavior == ScrollBehaviorSmooth) 206 if (scrollBehavior == ScrollBehaviorSmooth)
207 programmaticScrollAnimator()->animateToOffset(toFloatPoint(position)); 207 programmaticScrollAnimator()->animateToOffset(toFloatPoint(position));
208 else 208 else
209 programmaticScrollAnimator()->scrollToOffsetWithoutAnimation(toFloatPoin t(position)); 209 programmaticScrollAnimator()->scrollToOffsetWithoutAnimation(toFloatPoin t(position));
210 } 210 }
211 211
212 void ScrollableArea::userScrollHelper(const DoublePoint& position, ScrollBehavio r scrollBehavior) 212 void ScrollableArea::userScrollHelper(const DoublePoint& position, ScrollBehavio r scrollBehavior)
213 { 213 {
214 cancelProgrammaticScrollAnimation(); 214 cancelProgrammaticScrollAnimation();
215 215
216 double x = userInputScrollable(HorizontalScrollbar) ? position.x() : scrollA nimator()->currentPosition().x();
217 double y = userInputScrollable(VerticalScrollbar) ? position.y() : scrollAni mator()->currentPosition().y();
218
216 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScro ll method. 219 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScro ll method.
217 // TODO(bokan): The userScroll method should probably be modified to call th is method 220 // TODO(bokan): The userScroll method should probably be modified to call th is method
218 // and ScrollAnimator to have a simpler animateToOffset method like the 221 // and ScrollAnimator to have a simpler animateToOffset method like the
219 // ProgrammaticScrollAnimator. 222 // ProgrammaticScrollAnimator.
220 ASSERT(scrollBehavior == ScrollBehaviorInstant); 223 ASSERT(scrollBehavior == ScrollBehaviorInstant);
221 scrollAnimator()->scrollToOffsetWithoutAnimation(toFloatPoint(position)); 224 scrollAnimator()->scrollToOffsetWithoutAnimation(FloatPoint(x, y));
222 } 225 }
223 226
224 void ScrollableArea::scrollIntoRect(const LayoutRect& rectInContent, const Float Rect& targetRectInFrame) 227 void ScrollableArea::scrollIntoRect(const LayoutRect& rectInContent, const Float Rect& targetRectInFrame)
225 { 228 {
226 // Use |pixelSnappedIntRect| for rounding to pixel as opposed to |enclosingI ntRect|. It gives a better 229 // Use |pixelSnappedIntRect| for rounding to pixel as opposed to |enclosingI ntRect|. It gives a better
227 // combined (location and size) rounding error resulting in a more accurate scroll offset. 230 // combined (location and size) rounding error resulting in a more accurate scroll offset.
228 // FIXME: It would probably be best to do the whole calculation in LayoutUni ts but contentsToRootFrame 231 // FIXME: It would probably be best to do the whole calculation in LayoutUni ts but contentsToRootFrame
229 // and friends don't have LayoutRect/Point versions yet. 232 // and friends don't have LayoutRect/Point versions yet.
230 IntRect boundsInContent = pixelSnappedIntRect(rectInContent); 233 IntRect boundsInContent = pixelSnappedIntRect(rectInContent);
231 IntRect boundsInFrame(boundsInContent.location() - toIntSize(scrollPosition( )), boundsInContent.size()); 234 IntRect boundsInFrame(boundsInContent.location() - toIntSize(scrollPosition( )), boundsInContent.size());
232 235
233 int centeringOffsetX = (targetRectInFrame.width() - boundsInFrame.width()) / 2; 236 int centeringOffsetX = (targetRectInFrame.width() - boundsInFrame.width()) / 2;
234 int centeringOffsetY = (targetRectInFrame.height() - boundsInFrame.height()) / 2; 237 int centeringOffsetY = (targetRectInFrame.height() - boundsInFrame.height()) / 2;
235 238
236 IntSize scrollDelta( 239 IntSize scrollDelta(
237 boundsInFrame.x() - centeringOffsetX - targetRectInFrame.x(), 240 boundsInFrame.x() - centeringOffsetX - targetRectInFrame.x(),
238 boundsInFrame.y() - centeringOffsetY - targetRectInFrame.y()); 241 boundsInFrame.y() - centeringOffsetY - targetRectInFrame.y());
239 242
240 DoublePoint targetOffset = DoublePoint(scrollPosition() + scrollDelta); 243 DoublePoint targetOffset = DoublePoint(scrollPosition() + scrollDelta);
241 244
242 setScrollPosition(targetOffset, ProgrammaticScroll); 245 setScrollPosition(targetOffset, ProgrammaticScroll);
243 } 246 }
244 247
245 LayoutRect ScrollableArea::scrollIntoView(const LayoutRect& rectInContent, const ScrollAlignment& alignX, const ScrollAlignment& alignY) 248 LayoutRect ScrollableArea::scrollIntoView(const LayoutRect& rectInContent, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType)
246 { 249 {
247 // TODO(bokan): This should really be implemented here but ScrollAlignment i s in Core which is a dependency violation. 250 // TODO(bokan): This should really be implemented here but ScrollAlignment i s in Core which is a dependency violation.
248 ASSERT_NOT_REACHED(); 251 ASSERT_NOT_REACHED();
249 return LayoutRect(); 252 return LayoutRect();
250 } 253 }
251 254
252 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollTy pe scrollType) 255 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollTy pe scrollType)
253 { 256 {
254 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); 257 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged");
255 258
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; 603 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0;
601 if (Scrollbar* horizontalBar = horizontalScrollbar()) 604 if (Scrollbar* horizontalBar = horizontalScrollbar())
602 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; 605 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0;
603 606
604 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), 607 return IntSize(std::max(0, size.width() - verticalScrollbarWidth),
605 std::max(0, size.height() - horizontalScrollbarHeight)); 608 std::max(0, size.height() - horizontalScrollbarHeight));
606 609
607 } 610 }
608 611
609 } // namespace blink 612 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698